summaryrefslogtreecommitdiff
path: root/src/cardmarket/game.go
blob: 995162df569b0281f1ede6ad0d3d90ac1ba36206 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package cardmarket

import (
	"context"
)

type Game struct {
	GameID       uint32 `json:"idGame"`
	Name         string `json:"name"`
	Abbreviation string `json:"abbreviation"`
	Links        Links  `json:"links"`
}

func (c *ApiClient) GetGames(ctx context.Context) ([]Game, error) {
	type responseBody struct {
		Game  []Game `json:"game"`
		Links Links  `json:"links"`
	}
	respBody := &responseBody{}
	if err := c.get(ctx, "/games", respBody); err != nil {
		return nil, err
	}
	return respBody.Game, nil
}