Initial
This commit is contained in:
parent
1c05e995ad
commit
b0e4215b17
1
app/api/api.go
Normal file
1
app/api/api.go
Normal file
@ -0,0 +1 @@
|
|||||||
|
package api
|
||||||
13
app/types/types.go
Normal file
13
app/types/types.go
Normal 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
33
main.go
Normal 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
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user