This commit is contained in:
Ryan Ward 2024-03-03 11:02:35 -05:00
parent 1c05e995ad
commit b0e4215b17
3 changed files with 47 additions and 0 deletions

1
app/api/api.go Normal file
View File

@ -0,0 +1 @@
package api

13
app/types/types.go Normal file
View File

@ -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"`
}

33
main.go Normal file
View File

@ -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
}