From b0e4215b17f9782e09970ec5b8e09a852bdbcc2f Mon Sep 17 00:00:00 2001 From: Ryan Ward Date: Sun, 3 Mar 2024 11:02:35 -0500 Subject: [PATCH] Initial --- app/api/api.go | 1 + app/types/types.go | 13 +++++++++++++ main.go | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 app/api/api.go create mode 100644 app/types/types.go create mode 100644 main.go diff --git a/app/api/api.go b/app/api/api.go new file mode 100644 index 0000000..778f64e --- /dev/null +++ b/app/api/api.go @@ -0,0 +1 @@ +package api diff --git a/app/types/types.go b/app/types/types.go new file mode 100644 index 0000000..8804e4e --- /dev/null +++ b/app/types/types.go @@ -0,0 +1,13 @@ +package types + +// {"name":"Lightstone of Flora: Haggler","id":764021,"currentStock":5,"totalTrades":66994,"basePrice":5300000,"mainCategory":85,"subCategory":4} +type MarketItem struct { + Name string `json:"name"` + Id int `json:"id"` + CurrentStock int `json:"currentStock"` + TotalTrades int `json:"totalTrades"` + BasePrice int `json:"basePrice"` + MainCategory int `json:"mainCategory"` + SubCategory int `json:"subCategory"` + MarketCategory int `json:"marketCategory"` +} diff --git a/main.go b/main.go new file mode 100644 index 0000000..ad94284 --- /dev/null +++ b/main.go @@ -0,0 +1,33 @@ +package main + +import ( + "app/types" + "fmt" + "json" + "net/http" +) + +func main() { + +} + +func GetMarketItems() []types.MarketItem { + var marketdata []types.MarketItem + url := "https://api.arsha.io/v2/na/market" + + client := &http.Client{} + req, err := http.NewRequest("GET", url, nil) + + if err != nil { + fmt.Println(err) + return + } + res, err := client.Do(req) + if err != nil { + fmt.Println(err) + return + } + defer res.Body.Close() + json.UnMarshal(res.Body, &marketdata) + return marketdata +}