Skip to content

Commit

Permalink
Add PvP Season APIs for Classic WoW (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
FuzzyStatic authored Oct 9, 2022
1 parent 44291cf commit c54e3f6
Show file tree
Hide file tree
Showing 200 changed files with 24,967 additions and 1,579 deletions.
16 changes: 9 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@ module github.com/FuzzyStatic/blizzard
go 1.18

require (
github.com/go-playground/validator v9.31.0+incompatible
golang.org/x/oauth2 v0.0.0-20220622183110-fd043fe589d2
github.com/go-playground/validator/v10 v10.11.1
golang.org/x/oauth2 v0.0.0-20221006150949-b44042a4b9c1
)

require (
github.com/go-playground/locales v0.14.0 // indirect
github.com/go-playground/universal-translator v0.18.0 // indirect
github.com/golang/protobuf v1.4.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect
google.golang.org/appengine v1.6.6 // indirect
google.golang.org/protobuf v1.25.0 // indirect
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 // indirect
golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e // indirect
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.28.0 // indirect
)
52 changes: 45 additions & 7 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion v3/blizzard.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

"github.com/FuzzyStatic/blizzard/wowp"
"github.com/FuzzyStatic/blizzard/wowsearch"
"github.com/go-playground/validator"
"github.com/go-playground/validator/v10"
"golang.org/x/oauth2"
"golang.org/x/oauth2/clientcredentials"
)
Expand Down
81 changes: 81 additions & 0 deletions v3/wowcgd.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"

"github.com/FuzzyStatic/blizzard/wow"
"github.com/FuzzyStatic/blizzard/wowcgd"
"github.com/FuzzyStatic/blizzard/wowsearch"
)
Expand Down Expand Up @@ -258,6 +259,86 @@ func (c *Client) ClassicWoWPowerType(ctx context.Context, powerTypeID int) (*wow
return dat.(*wowcgd.PowerType), header, err
}

// ClassicWoWPvPSeasonsIndex returns an index of PvP seasons.
func (c *Client) ClassicWoWPvPSeasonsIndex(ctx context.Context) (*wowcgd.PvPSeasonIndex, *Header, error) {
dat, header, err := c.getStructData(ctx,
"/data/wow/pvp-season/index",
c.GetDynamicClassicNamespace(),
&wowcgd.PvPSeasonIndex{},
)
return dat.(*wowcgd.PvPSeasonIndex), header, err
}

// ClassicWoWPvPSeason returns a PvP season by ID.
func (c *Client) ClassicWoWPvPSeason(ctx context.Context, pvpSeasonID int) (*wowcgd.PvPSeason, *Header, error) {
dat, header, err := c.getStructData(ctx,
fmt.Sprintf("/data/wow/pvp-season/%d", pvpSeasonID),
c.GetDynamicClassicNamespace(),
&wowcgd.PvPSeason{},
)
return dat.(*wowcgd.PvPSeason), header, err
}

// ClassicWoWPvPRegionIndex returns an index of PvP Regions.
func (c *Client) ClassicWoWPvPRegionIndex(ctx context.Context) (*wowcgd.PvPRegionIndex, *Header, error) {
dat, header, err := c.getStructData(ctx,
"/data/wow/pvp-region/index",
c.GetDynamicClassicNamespace(),
&wowcgd.PvPRegionIndex{},
)
return dat.(*wowcgd.PvPRegionIndex), header, err
}

// ClassicWoWPvPRegionalSeasonIndex returns an index of PvP Seasons in a PvP region.
func (c *Client) ClassicWoWPvPRegionalSeasonIndex(ctx context.Context, pvpRegionID int) (*wowcgd.PvPRegionalSeasonIndex, *Header, error) {
dat, header, err := c.getStructData(ctx,
fmt.Sprintf("/data/wow/pvp-region/%d/pvp-season/index", pvpRegionID),
c.GetDynamicClassicNamespace(),
&wowcgd.PvPRegionalSeasonIndex{},
)
return dat.(*wowcgd.PvPRegionalSeasonIndex), header, err
}

// ClassicWoWPvPRegionalSeason returns a PvP season by region ID and season ID.
func (c *Client) ClassicWoWPvPRegionalSeason(ctx context.Context, pvpRegionID, pvpSeasonID int) (*wowcgd.PvPRegionSeason, *Header, error) {
dat, header, err := c.getStructData(ctx,
fmt.Sprintf("/data/wow/pvp-region/%d/pvp-season/%d", pvpRegionID, pvpSeasonID),
c.GetDynamicClassicNamespace(),
&wowcgd.PvPRegionSeason{},
)
return dat.(*wowcgd.PvPRegionSeason), header, err
}

// ClassicWoWPvPLeaderboardsIndex returns an index of PvP leaderboards for a PvP season in a given PvP region.
func (c *Client) ClassicWoWPvPLeaderboardsIndex(ctx context.Context, pvpRegionID, pvpSeasonID int) (*wowcgd.PvPLeaderboardsIndex, *Header, error) {
dat, header, err := c.getStructData(ctx,
fmt.Sprintf("/data/wow/pvp-region/%d/pvp-season/%d/pvp-leaderboard/index", pvpRegionID, pvpSeasonID),
c.GetDynamicClassicNamespace(),
&wowcgd.PvPLeaderboardsIndex{},
)
return dat.(*wowcgd.PvPLeaderboardsIndex), header, err
}

// ClassicWoWPvPLeaderboards returns the PvP leaderboard of a specific PvP bracket for a PvP season in a given PvP region.
func (c *Client) ClassicWoWPvPLeaderboards(ctx context.Context, pvpRegionID, pvpSeasonID int, pvpBracket wow.Bracket) (*wowcgd.PvPLeaderboards, *Header, error) {
dat, header, err := c.getStructData(ctx,
fmt.Sprintf("/data/wow/pvp-region/%d/pvp-season/%d/pvp-leaderboard/%s", pvpRegionID, pvpSeasonID, pvpBracket),
c.GetDynamicClassicNamespace(),
&wowcgd.PvPLeaderboards{},
)
return dat.(*wowcgd.PvPLeaderboards), header, err
}

// ClassicWoWPvPRewardsIndex returns an index of PvP rewards for a PvP season in a given PvP region.
func (c *Client) ClassicWoWPvPRewardsIndex(ctx context.Context, pvpRegionID, pvpSeasonID int) (*wowcgd.PvPRewardsIndex, *Header, error) {
dat, header, err := c.getStructData(ctx,
fmt.Sprintf("/data/wow/pvp-region/%d/pvp-season/%d/pvp-reward/index", pvpRegionID, pvpSeasonID),
c.GetDynamicClassicNamespace(),
&wowcgd.PvPRewardsIndex{},
)
return dat.(*wowcgd.PvPRewardsIndex), header, err
}

// ClassicWoWRealmIndex returns an index of realms.
func (c *Client) ClassicWoWRealmIndex(ctx context.Context) (*wowcgd.RealmIndex, *Header, error) {
dat, header, err := c.getStructData(ctx,
Expand Down
108 changes: 108 additions & 0 deletions v3/wowcgd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"context"
"fmt"
"testing"

"github.com/FuzzyStatic/blizzard/wow"
)

func TestClassicWoWConnectedRealmsIndex(t *testing.T) {
Expand Down Expand Up @@ -294,6 +296,112 @@ func TestClassicWoWPowerType(t *testing.T) {
}
}

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

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

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

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

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

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

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

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

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

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

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

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

func TestClassicWoWPvPLeaderboards(t *testing.T) {
dat, _, err := usClient.ClassicWoWPvPLeaderboards(context.Background(), 1, 4, wow.Bracket2v2)
if err != nil {
fmt.Println(err)
t.Fail()
}

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

dat, _, err = usClient.ClassicWoWPvPLeaderboards(context.Background(), 1, 4, wow.Bracket3v3)
if err != nil {
fmt.Println(err)
t.Fail()
}

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

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

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

func TestClassicWoWRealmIndex(t *testing.T) {
dat, _, err := usClient.ClassicWoWRealmIndex(context.Background())
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion v3/wowp.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"strings"

"github.com/FuzzyStatic/blizzard/wow"
"github.com/FuzzyStatic/blizzard/wowp"
"golang.org/x/oauth2"
)
Expand Down Expand Up @@ -244,7 +245,7 @@ func (c *Client) WoWCharacterMythicKeystoneProfileSeason(ctx context.Context, re

// WoWCharacterPvPBracketStatistics returns the PvP bracket statistics for a character.
func (c *Client) WoWCharacterPvPBracketStatistics(ctx context.Context,
realmSlug, characterName string, pvpBracket wowp.Bracket) (*wowp.CharacterPvPBracketStatistics, *Header, error) {
realmSlug, characterName string, pvpBracket wow.Bracket) (*wowp.CharacterPvPBracketStatistics, *Header, error) {
dat, header, err := c.getStructData(ctx,
fmt.Sprintf("/profile/wow/character/%s/%s/pvp-bracket/%s", realmSlug, strings.ToLower(characterName), pvpBracket),
c.GetProfileNamespace(),
Expand Down
8 changes: 4 additions & 4 deletions v3/wowp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"testing"

"github.com/FuzzyStatic/blizzard/wowp"
"github.com/FuzzyStatic/blizzard/wow"
)

func TestWoWCharacterAchievementsSummary(t *testing.T) {
Expand Down Expand Up @@ -225,7 +225,7 @@ func TestWoWCharacterMythicKeystoneProfileSeason(t *testing.T) {
}

func TestWoWCharacterPvPBracketStatistics(t *testing.T) {
dat, _, err := usClient.WoWCharacterPvPBracketStatistics(context.Background(), "tichondrius", "tmpikaboo", wowp.Bracket2v2)
dat, _, err := usClient.WoWCharacterPvPBracketStatistics(context.Background(), "tichondrius", "tmpikaboo", wow.Bracket2v2)
if err != nil {
fmt.Println(err)
t.Fail()
Expand All @@ -235,7 +235,7 @@ func TestWoWCharacterPvPBracketStatistics(t *testing.T) {
fmt.Printf("%+v\n", dat)
}

dat, _, err = usClient.WoWCharacterPvPBracketStatistics(context.Background(), "tichondrius", "tmpikaboo", wowp.Bracket3v3)
dat, _, err = usClient.WoWCharacterPvPBracketStatistics(context.Background(), "tichondrius", "tmpikaboo", wow.Bracket3v3)
if err != nil {
fmt.Println(err)
t.Fail()
Expand All @@ -245,7 +245,7 @@ func TestWoWCharacterPvPBracketStatistics(t *testing.T) {
fmt.Printf("%+v\n", dat)
}

dat, _, err = usClient.WoWCharacterPvPBracketStatistics(context.Background(), "icecrown", "soballer", wowp.BracketRBG)
dat, _, err = usClient.WoWCharacterPvPBracketStatistics(context.Background(), "icecrown", "soballer", wow.BracketRBG)
if err != nil {
fmt.Println(err)
t.Fail()
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions vendor/github.com/go-playground/validator/v10/MAINTAINERS.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c54e3f6

Please sign in to comment.