From 2f61b07aea82fa0f5b98686bdfeba2e297c7b21b Mon Sep 17 00:00:00 2001 From: DJ O'Leary Date: Mon, 7 Sep 2026 03:13:01 +0200 Subject: refactor(cardmarket): move handlers to own directory --- src/cardmarket/handlers/game.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/cardmarket/handlers/game.go (limited to 'src/cardmarket/handlers/game.go') diff --git a/src/cardmarket/handlers/game.go b/src/cardmarket/handlers/game.go new file mode 100644 index 0000000..99b9046 --- /dev/null +++ b/src/cardmarket/handlers/game.go @@ -0,0 +1,26 @@ +package handlers + +import ( + "context" + + "codeberg.org/dijitol/trading_post/src/cardmarket" +) + +type Game struct { + GameID uint32 `json:"idGame"` + Name string `json:"name"` + Abbreviation string `json:"abbreviation"` + Links cardmarket.Links `json:"links"` +} + +func GetGames(ctx context.Context, c *cardmarket.ApiClient) ([]Game, error) { + type responseBody struct { + Game []Game `json:"game"` + Links cardmarket.Links `json:"links"` + } + respBody := &responseBody{} + if err := c.Get(ctx, "/games", nil, respBody); err != nil { + return nil, err + } + return respBody.Game, nil +} -- cgit v1.2.3