summaryrefslogtreecommitdiff
path: root/src/cardmarket/handlers/game.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/cardmarket/handlers/game.go')
-rw-r--r--src/cardmarket/handlers/game.go26
1 files changed, 26 insertions, 0 deletions
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
+}