Skip to content

Commit

Permalink
Add item appearance (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
BellionBastien authored Aug 12, 2024
1 parent a28f43d commit 877698e
Show file tree
Hide file tree
Showing 4 changed files with 345 additions and 13 deletions.
62 changes: 62 additions & 0 deletions wowgd.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,68 @@ func (c *Client) WoWItemMedia(ctx context.Context, itemID int) (*wowgd.ItemMedia
return dat.(*wowgd.ItemMedia), header, err
}

// WoWItemAppearance returns an item appearance by ID.
func (c *Client) WoWItemAppearance(ctx context.Context, appearanceID int) (*wowgd.ItemAppearance, *Header, error) {
dat, header, err := c.getStructData(ctx,
fmt.Sprintf("/data/wow/item-appearance/%d", appearanceID),
c.GetStaticNamespace(),
&wowgd.ItemAppearance{},
)
return dat.(*wowgd.ItemAppearance), header, err
}

// WoWItemAppearanceSearch item appearance search data.
func (c *Client) WoWItemAppearanceSearch(ctx context.Context, opts ...wowsearch.Opt) (*wowgd.ItemAppearanceSearch, *Header, error) {
dat, header, err := c.getStructData(
ctx,
fmt.Sprintf("/data/wow/search/item-appearance%s", buildSearchParams(opts...)),
c.GetStaticNamespace(),
&wowgd.ItemAppearanceSearch{},
)

return dat.(*wowgd.ItemAppearanceSearch), header, err
}

// WoWItemAppearanceSetsIndex returns an index of item appearance sets.
func (c *Client) WoWItemAppearanceSetsIndex(ctx context.Context) (*wowgd.ItemAppearanceSetsIndex, *Header, error) {
dat, header, err := c.getStructData(ctx,
"/data/wow/item-appearance/set/index",
c.GetStaticNamespace(),
&wowgd.ItemAppearanceSetsIndex{},
)
return dat.(*wowgd.ItemAppearanceSetsIndex), header, err
}

// WoWItemAppearanceSet returns an item appearance set by ID.
func (c *Client) WoWItemAppearanceSet(ctx context.Context, itemAppearanceSetID int) (*wowgd.ItemAppearanceSet, *Header, error) {
dat, header, err := c.getStructData(ctx,
fmt.Sprintf("/data/wow/item-appearance/set/%d", itemAppearanceSetID),
c.GetStaticNamespace(),
&wowgd.ItemAppearanceSet{},
)
return dat.(*wowgd.ItemAppearanceSet), header, err
}

// WoWItemAppearanceSlotIndex returns an index of item appearance slot.
func (c *Client) WoWItemAppearanceSlotIndex(ctx context.Context) (*wowgd.ItemAppearanceSlotIndex, *Header, error) {
dat, header, err := c.getStructData(ctx,
"/data/wow/item-appearance/slot/index",
c.GetStaticNamespace(),
&wowgd.ItemAppearanceSlotIndex{},
)
return dat.(*wowgd.ItemAppearanceSlotIndex), header, err
}

// 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),
c.GetStaticNamespace(),
&wowgd.ItemAppearanceSlot{},
)
return dat.(*wowgd.ItemAppearanceSlot), header, err
}

// WoWJournalExpansionsIndex returns an index of journal expansions.
func (c *Client) WoWJournalExpansionsIndex(ctx context.Context) (*wowgd.JournalExpansionsIndex, *Header, error) {
dat, header, err := c.getStructData(ctx,
Expand Down
190 changes: 190 additions & 0 deletions wowgd/item.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,63 @@ type Item struct {
MaxCount int `json:"max_count"`
IsEquippable bool `json:"is_equippable"`
IsStackable bool `json:"is_stackable"`
PreviewItem struct {
Item struct {
Key struct {
Href string `json:"href"`
} `json:"key"`
ID int `json:"id"`
} `json:"item"`
Quality struct {
Type string `json:"type"`
Name string `json:"name"`
} `json:"quality"`
Name string `json:"name"`
Media struct {
Key struct {
Href string `json:"href"`
} `json:"key"`
ID int `json:"id"`
} `json:"media"`
ItemClass struct {
Key struct {
Href string `json:"href"`
} `json:"key"`
Name string `json:"name"`
ID int `json:"id"`
} `json:"item_class"`
ItemSubclass struct {
Key struct {
Href string `json:"href"`
} `json:"key"`
Name string `json:"name"`
ID int `json:"id"`
} `json:"item_subclass"`
InventoryType struct {
Type string `json:"type"`
Name string `json:"name"`
} `json:"inventory_type"`
Binding struct {
Type string `json:"type"`
Name string `json:"name"`
} `json:"binding"`
UniqueEquipped string `json:"unique_equipped"`
Spells []struct {
Spell struct {
Key struct {
Href string `json:"href"`
} `json:"key"`
Name string `json:"name"`
ID int `json:"id"`
} `json:"spell"`
Description string `json:"description"`
} `json:"spells"`
IsSubclassHidden bool `json:"is_subclass_hidden"`
NameDescription *struct {
DisplayString string `json:"display_string"`
} `json:"name_description"`
} `json:"preview_item"`
PurchaseQuantity int `json:"purchase_quantity"`
}

// ItemMedia structure
Expand Down Expand Up @@ -249,3 +306,136 @@ type ItemSearch struct {
} `json:"data"`
} `json:"results"`
}

type ItemAppearance struct {
Links struct {
Self struct {
Href string `json:"href"`
} `json:"self"`
} `json:"_links"`
ID int `json:"id"`
Slot struct {
Type string `json:"type"`
Name string `json:"name"`
} `json:"slot"`
ItemClass struct {
Key struct {
Href string `json:"href"`
} `json:"key"`
Name string `json:"name"`
ID int `json:"id"`
} `json:"item_class"`
ItemSubclass struct {
Key struct {
Href string `json:"href"`
} `json:"key"`
Name string `json:"name"`
ID int `json:"id"`
} `json:"item_subclass"`
ItemDisplayInfoID int `json:"item_display_info_id"`
Items []struct {
Key struct {
Href string `json:"href"`
} `json:"key"`
Name string `json:"name"`
ID int `json:"id"`
} `json:"items"`
Media struct {
Key struct {
Href string `json:"href"`
} `json:"key"`
ID int `json:"id"`
} `json:"media"`
}

type ItemAppearanceSearch struct {
Page int `json:"page"`
PageSize int `json:"pageSize"`
MaxPageSize int `json:"maxPageSize"`
PageCount int `json:"pageCount"`
ResultCountCapped bool `json:"resultCountCapped"`
Results []struct {
Key struct {
Href string `json:"href"`
} `json:"key"`
Data struct {
ItemDisplayInfoID int `json:"item_display_info_id"`
ID int `json:"id"`
Slot struct {
Name struct {
ItIT string `json:"it_IT"`
RuRU string `json:"ru_RU"`
EnGB string `json:"en_GB"`
ZhTW string `json:"zh_TW"`
KoKR string `json:"ko_KR"`
EnUS string `json:"en_US"`
EsMX string `json:"es_MX"`
PtBR string `json:"pt_BR"`
EsES string `json:"es_ES"`
ZhCN string `json:"zh_CN"`
FrFR string `json:"fr_FR"`
DeDE string `json:"de_DE"`
} `json:"name"`
Type string `json:"type"`
} `json:"slot"`
} `json:"data"`
} `json:"results"`
}

type ItemAppearanceSetsIndex struct {
Links struct {
Self struct {
Href string `json:"href"`
} `json:"self"`
} `json:"_links"`
AppearanceSets []struct {
Key struct {
Href string `json:"href"`
} `json:"key"`
Name string `json:"name"`
ID int `json:"id"`
} `json:"appearance_sets"`
}

type ItemAppearanceSet struct {
Links struct {
Self struct {
Href string `json:"href"`
} `json:"self"`
} `json:"_links"`
ID int `json:"id"`
SetName string `json:"set_name"`
Appearances []struct {
Key struct {
Href string `json:"href"`
} `json:"key"`
ID int `json:"id"`
} `json:"appearances"`
}

type ItemAppearanceSlotIndex struct {
Links struct {
Self struct {
Href string `json:"href"`
} `json:"self"`
} `json:"_links"`
Slots []struct {
Key struct {
Href string `json:"href"`
} `json:"key"`
} `json:"slots"`
}

type ItemAppearanceSlot struct {
Links struct {
Self struct {
Href string `json:"href"`
} `json:"self"`
} `json:"_links"`
Appearances []struct {
Key struct {
Href string `json:"href"`
} `json:"key"`
ID int `json:"id"`
} `json:"appearances"`
}
77 changes: 77 additions & 0 deletions wowgd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,83 @@ func TestWoWJournalExpansionsIndex(t *testing.T) {
}
}

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

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

func TestWoWItemAppearanceSearch(t *testing.T) {
dat, _, err := usClient.WoWItemAppearanceSearch(context.Background(),
wowsearch.Page(1),
wowsearch.PageSize(5),
wowsearch.Field().
AND("slot.type", "HEAD"))

if err != nil {
fmt.Println(err)
t.Fail()
}

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

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

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

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

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

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

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

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

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

func TestWoWJournalExpansion(t *testing.T) {
dat, _, err := usClient.WoWJournalExpansion(context.Background(), 396)
if err != nil {
Expand Down
29 changes: 16 additions & 13 deletions wowp/characterCollections.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,24 +119,27 @@ type CharacterTransmogsCollectionSummary struct {
Key struct {
Href string `json:"href"`
} `json:"key"`
Id string `json:"id"`
Id int `json:"id"`
Name string `json:"name"`
} `json:"appearance_sets"`
Links struct {
Self struct {
Href string `json:"href"`
} `json:"self"`
} `json:"_links"`
Slots []struct {
Slot struct {
Name string `json:"name"`
Type string `json:"type"`
} `json:"slot"`
Appearances []struct {
Key struct {
Href string `json:"href"`
} `json:"key"`
ID int `json:"id"`
} `json:"appearances"`
} `json:"slots"`
Slots []CharacterTransmogsCollectionSummarySlots `json:"slots"`
}

type CharacterTransmogsCollectionSummarySlots struct {
Slot struct {
Name string `json:"name"`
Type string `json:"type"`
} `json:"slot"`
Appearances []struct {
Key struct {
Href string `json:"href"`
} `json:"key"`
ID int `json:"id"`
} `json:"appearances"`

}

0 comments on commit 877698e

Please sign in to comment.