Skip to content

Commit

Permalink
Add Heirlooms, Toys, Transmog collection capability (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
BellionBastien authored Aug 6, 2024
1 parent a51f4a8 commit a28f43d
Show file tree
Hide file tree
Showing 3 changed files with 148 additions and 3 deletions.
35 changes: 34 additions & 1 deletion wowp.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ func (c *Client) WoWCharacterCollectionsIndex(ctx context.Context,
return dat.(*wowp.CharacterCollectionsIndex), header, err
}

// WoWCharacterHeirloomsCollectionSummary returns a summary of the heirlooms a character has obtained.
func (c *Client) WoWCharacterHeirloomsCollectionSummary(ctx context.Context,
realmSlug, characterName string) (*wowp.CharacterHeirloomsCollectionSummary, *Header, error) {
dat, header, err := c.getStructData(ctx,
fmt.Sprintf("/profile/wow/character/%s/%s/collections/heirlooms", realmSlug, strings.ToLower(characterName)),
c.GetProfileNamespace(),
&wowp.CharacterHeirloomsCollectionSummary{},
)
return dat.(*wowp.CharacterHeirloomsCollectionSummary), header, err
}

// WoWCharacterMountsCollectionSummary returns a summary of the mounts a character has obtained.
func (c *Client) WoWCharacterMountsCollectionSummary(ctx context.Context,
realmSlug, characterName string) (*wowp.CharacterMountsCollectionSummary, *Header, error) {
Expand All @@ -76,7 +87,7 @@ func (c *Client) WoWCharacterMountsCollectionSummary(ctx context.Context,
return dat.(*wowp.CharacterMountsCollectionSummary), header, err
}

// WoWCharacterPetsCollectionSummary returns a summary of the mounts a character has obtained.
// WoWCharacterPetsCollectionSummary returns a summary of the pets a character has obtained.
func (c *Client) WoWCharacterPetsCollectionSummary(ctx context.Context,
realmSlug, characterName string) (*wowp.CharacterPetsCollectionSummary, *Header, error) {
dat, header, err := c.getStructData(ctx,
Expand All @@ -87,6 +98,28 @@ func (c *Client) WoWCharacterPetsCollectionSummary(ctx context.Context,
return dat.(*wowp.CharacterPetsCollectionSummary), header, err
}

// WoWCharacterToysCollectionSummary returns a summary of the toys a character has obtained.
func (c *Client) WoWCharacterToysCollectionSummary(ctx context.Context,
realmSlug, characterName string) (*wowp.CharacterToysCollectionSummary, *Header, error) {
dat, header, err := c.getStructData(ctx,
fmt.Sprintf("/profile/wow/character/%s/%s/collections/toys", realmSlug, strings.ToLower(characterName)),
c.GetProfileNamespace(),
&wowp.CharacterToysCollectionSummary{},
)
return dat.(*wowp.CharacterToysCollectionSummary), header, err
}

// WoWCharacterTransmogsCollectionSummary returns a summary of the transmogs a character has obtained.
func (c *Client) WoWCharacterTransmogsCollectionSummary(ctx context.Context,
realmSlug, characterName string) (*wowp.CharacterTransmogsCollectionSummary, *Header, error) {
dat, header, err := c.getStructData(ctx,
fmt.Sprintf("/profile/wow/character/%s/%s/collections/transmogs", realmSlug, strings.ToLower(characterName)),
c.GetProfileNamespace(),
&wowp.CharacterTransmogsCollectionSummary{},
)
return dat.(*wowp.CharacterTransmogsCollectionSummary), header, err
}

// WoWCharacterEncountersSummary returns a summary of a character's encounters.
func (c *Client) WoWCharacterEncountersSummary(ctx context.Context,
realmSlug, characterName string) (*wowp.CharacterEncountersSummary, *Header, error) {
Expand Down
80 changes: 78 additions & 2 deletions wowp/characterCollections.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,42 @@ type CharacterCollectionsIndex struct {
Href string `json:"href"`
} `json:"self"`
} `json:"_links"`
Pets struct {
Heirlooms struct {
Href string `json:"href"`
} `json:"pets"`
} `json:"heirlooms"`
Mounts struct {
Href string `json:"href"`
} `json:"mounts"`
Pets struct {
Href string `json:"href"`
} `json:"pets"`
Toys struct {
Href string `json:"href"`
} `json:"toys"`
Transmog struct {
Href string `json:"href"`
} `json:"transmog"`
}

// CharacterHeirloomsCollectionSummary structure
type CharacterHeirloomsCollectionSummary struct {
Links struct {
Self struct {
Href string `json:"href"`
} `json:"self"`
} `json:"_links"`
Heirlooms []struct {
Heirloom struct {
Key struct {
Href string `json:"href"`
} `json:"key"`
Name string `json:"name"`
ID int `json:"id"`
} `json:"heirloom"`
Upgrade struct {
Level int `json:"level"`
} `json:"upgrade"`
} `json:"Heirlooms"`
}

// CharacterMountsCollectionSummary structure
Expand Down Expand Up @@ -64,3 +94,49 @@ type CharacterPetsCollectionSummary struct {
} `json:"pets"`
UnlockedBattlePetSlots int `json:"unlocked_battle_pet_slots"`
}

// CharacterToysCollectionSummary structure
type CharacterToysCollectionSummary struct {
Links struct {
Self struct {
Href string `json:"href"`
} `json:"self"`
} `json:"_links"`
Toys []struct {
Toy struct {
Key struct {
Href string `json:"href"`
} `json:"key"`
Name string `json:"name"`
ID int `json:"id"`
} `json:"toy"`
} `json:"toys"`
}

// CharacterTransmogCollectionSummary structure
type CharacterTransmogsCollectionSummary struct {
AppearanceSets []struct {
Key struct {
Href string `json:"href"`
} `json:"key"`
Id string `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"`
}
36 changes: 36 additions & 0 deletions wowp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ func TestWoWCharacterCollectionsIndex(t *testing.T) {
}
}

func TestWoWCharacterHeirloomsCollectionSummary(t *testing.T) {
dat, _, err := usClient.WoWCharacterHeirloomsCollectionSummary(context.Background(), "illidan", "covlol")
if err != nil {
fmt.Println(err)
t.Fail()
}

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

func TestWoWCharacterMountsCollectionSummary(t *testing.T) {
dat, _, err := usClient.WoWCharacterMountsCollectionSummary(context.Background(), "illidan", "covlol")
if err != nil {
Expand All @@ -80,6 +92,30 @@ func TestWoWCharacterPetsCollectionSummary(t *testing.T) {
}
}

func TestWoWCharacterToysCollectionSummary(t *testing.T) {
dat, _, err := usClient.WoWCharacterToysCollectionSummary(context.Background(), "illidan", "covlol")
if err != nil {
fmt.Println(err)
t.Fail()
}

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

func TestWoWCharacterTransmogCollectionSummary(t *testing.T) {
dat, _, err := usClient.WoWCharacterTransmogsCollectionSummary(context.Background(), "illidan", "covlol")
if err != nil {
fmt.Println(err)
t.Fail()
}

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

func TestWoWCharacterEncountersSummary(t *testing.T) {
dat, _, err := usClient.WoWCharacterEncountersSummary(context.Background(), "illidan", "covlol")
if err != nil {
Expand Down

0 comments on commit a28f43d

Please sign in to comment.