From 354c66a9a23c79ffe0e4f27ff76c2e6685ec79fa Mon Sep 17 00:00:00 2001 From: Johannes Riegner Date: Thu, 20 Jul 2023 15:10:19 +0200 Subject: [PATCH] classic wow auction house api (#61) * auctionHouseIndex struct & function to call the api * added function for retrieving auctions data * added comments to auction related types --- wowcgd.go | 20 +++++++++++++++++++ wowcgd/auctionHouse.go | 44 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 wowcgd/auctionHouse.go diff --git a/wowcgd.go b/wowcgd.go index f800289..4be92d3 100644 --- a/wowcgd.go +++ b/wowcgd.go @@ -9,6 +9,26 @@ import ( "github.com/FuzzyStatic/blizzard/v3/wowsearch" ) +// ClassicWoWAuctionHouseIndex returns an index of auction houses for a given realmID +func (c *Client) ClassicWoWAuctionHouseIndex(ctx context.Context, connectedRealmID int) (*wowcgd.AuctionHouseIndex, *Header, error) { + dat, header, err := c.getStructData(ctx, + fmt.Sprintf("/data/wow/connected-realm/%d/auctions/index", connectedRealmID), + c.GetDynamicClassicNamespace(), + &wowcgd.AuctionHouseIndex{}, + ) + return dat.(*wowcgd.AuctionHouseIndex), header, err +} + +// ClassicWoWAuctions returns all auctions by realmID and auctionHouseID +func (c *Client) ClassicWoWAuctions(ctx context.Context, connectedRealmID, auctionHouseID int) (*wowcgd.Auctions, *Header, error) { + dat, header, err := c.getStructData(ctx, + fmt.Sprintf("/data/wow/connected-realm/%d/auctions/%d", connectedRealmID, auctionHouseID), + c.GetDynamicClassicNamespace(), + &wowcgd.Auctions{}, + ) + return dat.(*wowcgd.Auctions), header, err +} + // ClassicWoWConnectedRealmsIndex returns an index of connected realms. func (c *Client) ClassicWoWConnectedRealmsIndex(ctx context.Context) (*wowcgd.ConnectedRealmsIndex, *Header, error) { dat, header, err := c.getStructData(ctx, diff --git a/wowcgd/auctionHouse.go b/wowcgd/auctionHouse.go new file mode 100644 index 0000000..1e495c3 --- /dev/null +++ b/wowcgd/auctionHouse.go @@ -0,0 +1,44 @@ +package wowcgd + +// AuctionHouseIndex structure +type AuctionHouseIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Auctions []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"auctions"` +} + +// Auctions structure +type Auctions struct { + Linkds struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ConnectedRealm struct { + Href string `json:"href"` + } `json:"connected_realm"` + Auctions []Auction `json:"auctions"` + ID int `json:"id"` + Name string `json:"name"` +} + +// Auction structure +type Auction struct { + ID int `json:"id"` + Item struct { + ID int `json:"id"` + } `json:"item"` + Bid int `json:"bid"` + Buyout int `json:"buyout"` + Quantity int `json:"quantity"` + TimeLeft string `json:"time_left"` +}