Skip to content

Commit

Permalink
classic wow auction house api (#61)
Browse files Browse the repository at this point in the history
* auctionHouseIndex struct & function to call the api

* added function for retrieving auctions data

* added comments to auction related types
  • Loading branch information
jriegner authored Jul 20, 2023
1 parent 58db808 commit 354c66a
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
20 changes: 20 additions & 0 deletions wowcgd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
44 changes: 44 additions & 0 deletions wowcgd/auctionHouse.go
Original file line number Diff line number Diff line change
@@ -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"`
}

0 comments on commit 354c66a

Please sign in to comment.