Skip to content

Commit

Permalink
Add Auction House Commodities API (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanskidmore authored Nov 17, 2024
1 parent 6f79bb1 commit 26f959e
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
14 changes: 13 additions & 1 deletion wowgd.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ func (c *Client) WoWAuctions(ctx context.Context, connectedRealmID int) (*wowgd.
return dat.(*wowgd.AuctionHouse), header, err
}

// WoWAuctionCommodities returns all active auctions for commodity items for the entire game region.
// Auction house data updates at a set interval. The value was initially set at 1 hour; however, it might change over time without notice.
// Depending on the number of active auctions on the specified connected realm, the response from this endpoint may be rather large, sometimes exceeding 10 MB.
func (c *Client) WoWAuctionCommodities(ctx context.Context) (*wowgd.AuctionHouseCommodities, *Header, error) {
dat, header, err := c.getStructData(ctx,
"/data/wow/auctions/commodities",
c.GetDynamicNamespace(),
&wowgd.AuctionHouseCommodities{},
)
return dat.(*wowgd.AuctionHouseCommodities), header, err
}

// WoWAzeriteEssenceIndex returns an index of azerite essences.
func (c *Client) WoWAzeriteEssenceIndex(ctx context.Context) (*wowgd.AzeriteEssenceIndex, *Header, error) {
dat, header, err := c.getStructData(ctx,
Expand Down Expand Up @@ -436,7 +448,7 @@ func (c *Client) WoWItemAppearanceSlotIndex(ctx context.Context) (*wowgd.ItemApp
// WoWItemAppearanceSlot returns an item appearance slot by slot type.
func (c *Client) WoWItemAppearanceSlot(ctx context.Context, itemAppearanceSlot string) (*wowgd.ItemAppearanceSlot, *Header, error) {
dat, header, err := c.getStructData(ctx,
fmt.Sprintf("/data/wow/item-appearance/slot/%d", itemAppearanceSlot),
fmt.Sprintf("/data/wow/item-appearance/slot/%s", itemAppearanceSlot),
c.GetStaticNamespace(),
&wowgd.ItemAppearanceSlot{},
)
Expand Down
19 changes: 19 additions & 0 deletions wowgd/auctionHouseCommodities.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package wowgd

// AuctionHouseCommodities structure
type AuctionHouseCommodities struct {
Links struct {
Self struct {
Href string `json:"href"`
} `json:"self"`
} `json:"_links"`
Auctions []struct {
ID int `json:"id"`
Item struct {
ID int `json:"id"`
} `json:"item"`
Quantity int `json:"quantity"`
UnitPrice int `json:"unit_price"`
TimeLeft TimeLeft `json:"time_left"`
} `json:"auctions"`
}
12 changes: 12 additions & 0 deletions wowgd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,18 @@ func TestWoWAuctions(t *testing.T) {
}
}

func TestWoWAuctionCommodities(t *testing.T) {
dat, _, err := usClient.WoWAuctionCommodities(context.Background())
if err != nil {
fmt.Println(err)
t.Fail()
}

if printOutput != "" {
fmt.Printf("%+v\n", dat)
}
}

func TestWoWAzeriteEssenceIndex(t *testing.T) {
dat, _, err := usClient.WoWAzeriteEssenceIndex(context.Background())
if err != nil {
Expand Down

0 comments on commit 26f959e

Please sign in to comment.