Skip to content

Commit

Permalink
✨ add wow shadowlands covenant API calls
Browse files Browse the repository at this point in the history
  • Loading branch information
FuzzyStatic committed Feb 2, 2021
1 parent 4e224b8 commit a98d72b
Show file tree
Hide file tree
Showing 9 changed files with 932 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ env:
# You don't need to test on very old version of the Go compiler. It's the user's
# responsibility to keep their compilers up to date.
go:
- 1.16.x
- 1.15.x

# Only clone the most recent commit.
git:
Expand Down
46 changes: 46 additions & 0 deletions v1/sc2gd/ladder.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package sc2gd

// Ladder structure
type Ladder struct {
Team []struct {
ID uint64 `json:"id"`
Rating int `json:"rating"`
Wins int `json:"wins"`
Losses int `json:"losses"`
Ties int `json:"ties"`
Points int `json:"points"`
LongestWinStreak int `json:"longest_win_streak"`
CurrentWinStreak int `json:"current_win_streak"`
CurrentRank int `json:"current_rank"`
HighestRank int `json:"highest_rank"`
PreviousRank int `json:"previous_rank"`
JoinTimeStamp int `json:"join_time_stamp"`
LastPlayedTimeStamp int `json:"last_played_time_stamp"`
Member []struct {
LegacyLink struct {
ID int `json:"id"`
Realm int `json:"realm"`
Name string `json:"name"`
Path string `json:"path"`
} `json:"legacy_link"`
PlayedRaceCount []struct {
Race string `json:"race"`
Count int `json:"count"`
} `json:"played_race_count"`
CharacterLink struct {
ID int `json:"id"`
BattleTag string `json:"battle_tag"`
Key struct {
Href string `json:"href"`
} `json:"key"`
} `json:"character_link"`
ClanLink struct {
ID int `json:"id"`
ClanTag string `json:"clan_tag"`
ClanName string `json:"clan_name"`
IconURL string `json:"icon_url"`
DecalURL string `json:"decal_url"`
} `json:"clan_link"`
} `json:"member"`
} `json:"team"`
}
148 changes: 148 additions & 0 deletions v1/wowgd.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package blizzard

import (
"context"
"encoding/json"
"fmt"

Expand Down Expand Up @@ -217,6 +218,153 @@ func (c *Client) WoWConnectedRealm(connectedRealmID int) (*wowgd.ConnectedRealm,
return &dat, b, nil
}

// WoWCovenantsIndex returns an index of covenants.
func (c *Client) WoWCovenantsIndex(ctx context.Context) (*wowgd.CovenantsIndex, []byte, error) {
var (
dat wowgd.CovenantsIndex
b []byte
err error
)

b, err = c.getURLBody(c.apiURL+fmt.Sprintf("/data/wow/covenant/index?locale=%s", c.locale), c.staticNamespace)
if err != nil {
return &dat, b, err
}

err = json.Unmarshal(b, &dat)
if err != nil {
return &dat, b, err
}

return &dat, b, nil
}

// WoWCovenant returns a covenant by ID.
func (c *Client) WoWCovenant(covenantID int) (*wowgd.Covenant, []byte, error) {
var (
dat wowgd.Covenant
b []byte
err error
)

b, err = c.getURLBody(c.apiURL+fmt.Sprintf("/data/wow/covenant/%d?locale=%s", covenantID, c.locale), c.staticNamespace)
if err != nil {
return &dat, b, err
}

err = json.Unmarshal(b, &dat)
if err != nil {
return &dat, b, err
}

return &dat, b, nil
}

// WoWCovenantMedia returns media for a covenant by ID.
func (c *Client) WoWCovenantMedia(covenantID int) (*wowgd.CovenantMedia, []byte, error) {
var (
dat wowgd.CovenantMedia
b []byte
err error
)

b, err = c.getURLBody(c.apiURL+fmt.Sprintf("/data/wow/media/covenant/%d?locale=%s", covenantID, c.locale), c.staticNamespace)
if err != nil {
return &dat, b, err
}

err = json.Unmarshal(b, &dat)
if err != nil {
return &dat, b, err
}

return &dat, b, nil
}

// WoWCovenantSoulbindsIndex returns an index of soulbinds.
func (c *Client) WoWCovenantSoulbindsIndex(ctx context.Context) (*wowgd.CovenantSoulbindsIndex, []byte, error) {
var (
dat wowgd.CovenantSoulbindsIndex
b []byte
err error
)

b, err = c.getURLBody(c.apiURL+fmt.Sprintf("/data/wow/covenant/soulbind/index?locale=%s", c.locale), c.staticNamespace)
if err != nil {
return &dat, b, err
}

err = json.Unmarshal(b, &dat)
if err != nil {
return &dat, b, err
}

return &dat, b, nil
}

// WoWCovenantSoulbind returns a soulbind by ID.
func (c *Client) WoWCovenantSoulbind(soulbindID int) (*wowgd.CovenantSoulbind, []byte, error) {
var (
dat wowgd.CovenantSoulbind
b []byte
err error
)

b, err = c.getURLBody(c.apiURL+fmt.Sprintf("/data/wow/covenant/soulbind/%d?locale=%s", soulbindID, c.locale), c.staticNamespace)
if err != nil {
return &dat, b, err
}

err = json.Unmarshal(b, &dat)
if err != nil {
return &dat, b, err
}

return &dat, b, nil
}

// WoWCovenantConduitsIndex returns an index of conduits.
func (c *Client) WoWCovenantConduitsIndex(ctx context.Context) (*wowgd.CovenantConduitsIndex, []byte, error) {
var (
dat wowgd.CovenantConduitsIndex
b []byte
err error
)

b, err = c.getURLBody(c.apiURL+fmt.Sprintf("/data/wow/covenant/conduit/index?locale=%s", c.locale), c.staticNamespace)
if err != nil {
return &dat, b, err
}

err = json.Unmarshal(b, &dat)
if err != nil {
return &dat, b, err
}

return &dat, b, nil
}

// WoWCovenantConduit returns a conduit by ID.
func (c *Client) WoWCovenantConduit(conduitID int) (*wowgd.CovenantConduit, []byte, error) {
var (
dat wowgd.CovenantConduit
b []byte
err error
)

b, err = c.getURLBody(c.apiURL+fmt.Sprintf("/data/wow/covenant/conduit/%d?locale=%s", conduitID, c.locale), c.staticNamespace)
if err != nil {
return &dat, b, err
}

err = json.Unmarshal(b, &dat)
if err != nil {
return &dat, b, err
}

return &dat, b, nil
}

// WoWCreatureFamiliesIndex returns an index of creature families.
func (c *Client) WoWCreatureFamiliesIndex() (*wowgd.CreatureFamiliesIndex, []byte, error) {
var (
Expand Down
Loading

0 comments on commit a98d72b

Please sign in to comment.