From 011f76b05d5a1774194cbfc884ecebd1c8f4ea88 Mon Sep 17 00:00:00 2001 From: Allen Flickinger Date: Sun, 1 Nov 2020 17:59:02 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=8E=20version=202=20-=20ctx?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 20 +- examples/authCodeFlow/main.go | 104 -- examples/simpleClient/main.go | 36 - v2/blizzard.go | 172 +++ v2/d3c.go | 673 +++++++++ v2/d3c/act.go | 18 + v2/d3c/artisanRecipe.go | 84 ++ v2/d3c/characterClassAndSkill.go | 56 + v2/d3c/d3c.go | 2 + v2/d3c/follower.go | 18 + v2/d3c/item.go | 45 + v2/d3c/itemType.go | 17 + v2/d3c/profile.go | 1370 +++++++++++++++++ v2/d3c_test.go | 379 +++++ v2/d3gd.go | 975 ++++++++++++ v2/d3gd/d3.go | 150 ++ v2/d3gd/d3gd.go | 2 + v2/d3gd_test.go | 553 +++++++ v2/hsgd.go | 504 +++++++ v2/hsgd/cardBacks.go | 64 + v2/hsgd/cardSearch.go | 40 + v2/hsgd/decks.go | 76 + v2/hsgd/hsgd.go | 117 ++ v2/hsgd/metadata.go | 77 + v2/hsgd_test.go | 211 +++ v2/init_test.go | 35 + v2/oauth.go | 150 ++ v2/oauth/oauth.go | 12 + v2/oauth/tokenValidation.go | 10 + v2/oauth/userAuthentication.go | 8 + v2/oauth_test.go | 49 + v2/sc2c.go | 308 ++++ v2/sc2c/account.go | 11 + v2/sc2c/ladder.go | 30 + v2/sc2c/legacy.go | 300 ++++ v2/sc2c/profile.go | 188 +++ v2/sc2c/sc2c.go | 2 + v2/sc2c_test.go | 175 +++ v2/sc2gd.go | 30 + v2/sc2gd/league.go | 81 + v2/sc2gd/sc2gd.go | 2 + v2/sc2gd_test.go | 21 + v2/wowcgd.go | 538 +++++++ v2/wowcgd/creature.go | 118 ++ v2/wowcgd/guildCrest.go | 52 + v2/wowcgd/item.go | 107 ++ v2/wowcgd/playableClass.go | 57 + v2/wowcgd/playableRace.go | 38 + v2/wowcgd/powerType.go | 28 + v2/wowcgd/wowcgd.go | 2 + v2/wowcgd_test.go | 307 ++++ v2/wowgd.go | 1674 +++++++++++++++++++++ v2/wowgd/achievement.go | 170 +++ v2/wowgd/azeriteEssence.go | 72 + v2/wowgd/connectedRealm.go | 58 + v2/wowgd/creature.go | 118 ++ v2/wowgd/guildCrest.go | 52 + v2/wowgd/item.go | 107 ++ v2/wowgd/journal.go | 196 +++ v2/wowgd/mount.go | 42 + v2/wowgd/mythicKeystoneAffix.go | 35 + v2/wowgd/mythicKeystoneDungeon.go | 125 ++ v2/wowgd/mythicKeystoneLeaderboard.go | 76 + v2/wowgd/mythicRaidLeaderboard.go | 35 + v2/wowgd/pet.go | 122 ++ v2/wowgd/playableClass.go | 68 + v2/wowgd/playableRace.go | 38 + v2/wowgd/playableSpecialization.go | 85 ++ v2/wowgd/powerType.go | 28 + v2/wowgd/pvpSeason.go | 144 ++ v2/wowgd/pvpTier.go | 53 + v2/wowgd/realm.go | 48 + v2/wowgd/region.go | 25 + v2/wowgd/reputations.go | 81 + v2/wowgd/title.go | 32 + v2/wowgd/wowToken.go | 12 + v2/wowgd/wowgd.go | 12 + v2/wowgd_test.go | 957 ++++++++++++ v2/wowp.go | 656 ++++++++ v2/wowp/accountProfileSummary.go | 64 + v2/wowp/characterAchievements.go | 73 + v2/wowp/characterAppearance.go | 120 ++ v2/wowp/characterCollections.go | 66 + v2/wowp/characterEncounters.go | 150 ++ v2/wowp/characterEquipment.go | 303 ++++ v2/wowp/characterHunterPets.go | 43 + v2/wowp/characterMedia.go | 28 + v2/wowp/characterMythicKeystoneProfile.go | 141 ++ v2/wowp/characterProfile.go | 125 ++ v2/wowp/characterPvP.go | 96 ++ v2/wowp/characterQuests.go | 66 + v2/wowp/characterReputations.go | 46 + v2/wowp/characterSpecializations.go | 95 ++ v2/wowp/characterStatistics.go | 135 ++ v2/wowp/characterTitles.go | 40 + v2/wowp/guild.go | 199 +++ v2/wowp/wowp.go | 12 + v2/wowp_test.go | 341 +++++ 98 files changed, 15536 insertions(+), 150 deletions(-) delete mode 100644 examples/authCodeFlow/main.go delete mode 100644 examples/simpleClient/main.go create mode 100644 v2/blizzard.go create mode 100644 v2/d3c.go create mode 100644 v2/d3c/act.go create mode 100644 v2/d3c/artisanRecipe.go create mode 100644 v2/d3c/characterClassAndSkill.go create mode 100644 v2/d3c/d3c.go create mode 100644 v2/d3c/follower.go create mode 100644 v2/d3c/item.go create mode 100644 v2/d3c/itemType.go create mode 100644 v2/d3c/profile.go create mode 100644 v2/d3c_test.go create mode 100644 v2/d3gd.go create mode 100644 v2/d3gd/d3.go create mode 100644 v2/d3gd/d3gd.go create mode 100644 v2/d3gd_test.go create mode 100644 v2/hsgd.go create mode 100644 v2/hsgd/cardBacks.go create mode 100644 v2/hsgd/cardSearch.go create mode 100644 v2/hsgd/decks.go create mode 100644 v2/hsgd/hsgd.go create mode 100644 v2/hsgd/metadata.go create mode 100644 v2/hsgd_test.go create mode 100644 v2/init_test.go create mode 100644 v2/oauth.go create mode 100644 v2/oauth/oauth.go create mode 100644 v2/oauth/tokenValidation.go create mode 100644 v2/oauth/userAuthentication.go create mode 100644 v2/oauth_test.go create mode 100644 v2/sc2c.go create mode 100644 v2/sc2c/account.go create mode 100644 v2/sc2c/ladder.go create mode 100644 v2/sc2c/legacy.go create mode 100644 v2/sc2c/profile.go create mode 100644 v2/sc2c/sc2c.go create mode 100644 v2/sc2c_test.go create mode 100644 v2/sc2gd.go create mode 100644 v2/sc2gd/league.go create mode 100644 v2/sc2gd/sc2gd.go create mode 100644 v2/sc2gd_test.go create mode 100644 v2/wowcgd.go create mode 100644 v2/wowcgd/creature.go create mode 100644 v2/wowcgd/guildCrest.go create mode 100644 v2/wowcgd/item.go create mode 100644 v2/wowcgd/playableClass.go create mode 100644 v2/wowcgd/playableRace.go create mode 100644 v2/wowcgd/powerType.go create mode 100644 v2/wowcgd/wowcgd.go create mode 100644 v2/wowcgd_test.go create mode 100644 v2/wowgd.go create mode 100644 v2/wowgd/achievement.go create mode 100644 v2/wowgd/azeriteEssence.go create mode 100644 v2/wowgd/connectedRealm.go create mode 100644 v2/wowgd/creature.go create mode 100644 v2/wowgd/guildCrest.go create mode 100644 v2/wowgd/item.go create mode 100644 v2/wowgd/journal.go create mode 100644 v2/wowgd/mount.go create mode 100644 v2/wowgd/mythicKeystoneAffix.go create mode 100644 v2/wowgd/mythicKeystoneDungeon.go create mode 100644 v2/wowgd/mythicKeystoneLeaderboard.go create mode 100644 v2/wowgd/mythicRaidLeaderboard.go create mode 100644 v2/wowgd/pet.go create mode 100644 v2/wowgd/playableClass.go create mode 100644 v2/wowgd/playableRace.go create mode 100644 v2/wowgd/playableSpecialization.go create mode 100644 v2/wowgd/powerType.go create mode 100644 v2/wowgd/pvpSeason.go create mode 100644 v2/wowgd/pvpTier.go create mode 100644 v2/wowgd/realm.go create mode 100644 v2/wowgd/region.go create mode 100644 v2/wowgd/reputations.go create mode 100644 v2/wowgd/title.go create mode 100644 v2/wowgd/wowToken.go create mode 100644 v2/wowgd/wowgd.go create mode 100644 v2/wowgd_test.go create mode 100644 v2/wowp.go create mode 100644 v2/wowp/accountProfileSummary.go create mode 100644 v2/wowp/characterAchievements.go create mode 100644 v2/wowp/characterAppearance.go create mode 100644 v2/wowp/characterCollections.go create mode 100644 v2/wowp/characterEncounters.go create mode 100644 v2/wowp/characterEquipment.go create mode 100644 v2/wowp/characterHunterPets.go create mode 100644 v2/wowp/characterMedia.go create mode 100644 v2/wowp/characterMythicKeystoneProfile.go create mode 100644 v2/wowp/characterProfile.go create mode 100644 v2/wowp/characterPvP.go create mode 100644 v2/wowp/characterQuests.go create mode 100644 v2/wowp/characterReputations.go create mode 100644 v2/wowp/characterSpecializations.go create mode 100644 v2/wowp/characterStatistics.go create mode 100644 v2/wowp/characterTitles.go create mode 100644 v2/wowp/guild.go create mode 100644 v2/wowp/wowp.go create mode 100644 v2/wowp_test.go diff --git a/README.md b/README.md index 97689f9..268fdaf 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ First, download the Blizzard library: ```shell -go get github.com/FuzzyStatic/blizzard/v1 +go get github.com/FuzzyStatic/blizzard/v2 ``` Start using the library by initiating a new Blizzard config structure for your desired region and locale (client_id and client_secret can be acquired through your developer account at [https://develop.battle.net/](https://develop.battle.net/)) and requesting an access token: @@ -32,7 +32,7 @@ Start using the library by initiating a new Blizzard config structure for your d ```go blizz := blizzard.NewClient("client_id", "client_secret", blizzard.US, blizzard.EnUS) -err := blizz.AccessTokenRequest() +err := blizz.AccessTokenRequest(ctx) if err != nil { fmt.Println(err) } @@ -43,7 +43,7 @@ if err != nil { You can use the functions prefixed with "D3" to acquire Diablo 3 information. For example, you can get information about the current D3 hardcore necromancer leaderboards: ```go -dat, _, err := blizz.D3SeasonLeaderboardHardcoreNecromancer(15) +dat, _, err := blizz.D3SeasonLeaderboardHardcoreNecromancer(ctx, 15) if err != nil { fmt.Println(err) } @@ -56,7 +56,7 @@ fmt.Printf("%+v\n", dat) You can use the functions prefixed with "HS" to acquire Hearthstone information. For example, you can get information about all the Hearthstone cards: ```go -dat, _, err := blizz.HSCardsAll() +dat, _, err := blizz.HSCardsAll(ctx) if err != nil { fmt.Println(err) } @@ -69,7 +69,7 @@ fmt.Printf("%+v\n", dat) You can use the functions prefixed with "SC2" to acquire StarCraft 2 information. For example, you can get information about the current SC2 grandmaster ladder: ```go -dat, _, err := blizz.SC2LadderGrandmaster(blizzard.EU) +dat, _, err := blizz.SC2LadderGrandmaster(ctx, blizzard.EU) if err != nil { fmt.Println(err) } @@ -82,7 +82,7 @@ fmt.Printf("%+v\n", dat) You can use the functions prefixed with "WoW" to acquire World of Warcraft information. For example, you can get information about your WoW character profile: ```go -dat, _, err := blizz.WoWCharacterProfileSummary("illidan", "wildz") +dat, _, err := blizz.WoWCharacterProfileSummary(ctx, "illidan", "wildz") if err != nil { fmt.Println(err) } @@ -93,7 +93,7 @@ fmt.Printf("%+v\n", dat) or get information about specific spells: ```go -dat, _, err := blizz.WoWSpell(17086) +dat, _, err := blizz.WoWSpell(ctx, 17086) if err != nil { fmt.Println(err) } @@ -104,7 +104,7 @@ fmt.Printf("%+v\n", dat) or the PvP leaderboards: ```go -dat, _, err := blizz.WoWCharacterPvPBracketStatistics(wowp.Bracket3v3) +dat, _, err := blizz.WoWCharacterPvPBracketStatistics(ctx, wowp.Bracket3v3) if err != nil { fmt.Println(err) } @@ -117,7 +117,7 @@ fmt.Printf("%+v\n", dat) You can use the functions prefixed with "ClassicWoW" to acquire World of Warcraft Classic information. For example, you can get information about WoW Classic creature data: ```go -dat, _, err := blizz.ClassicWoWCreature(30) +dat, _, err := blizz.ClassicWoWCreature(ctx, 30) if err != nil { fmt.Println(err) } @@ -225,7 +225,7 @@ func main() { Now you can validate those tokens with the OAuth API: ```go -dat, _, err := blizz.TokenValidation(token) +dat, _, err := blizz.TokenValidation(ctx, token) if err != nil { fmt.Println(err) } diff --git a/examples/authCodeFlow/main.go b/examples/authCodeFlow/main.go deleted file mode 100644 index 1fea3e7..0000000 --- a/examples/authCodeFlow/main.go +++ /dev/null @@ -1,104 +0,0 @@ -package main - -import ( - "context" - "encoding/json" - "fmt" - "log" - "net/http" - "os" - - "github.com/FuzzyStatic/blizzard/v1" - "github.com/FuzzyStatic/blizzard/v1/oauth" - "golang.org/x/oauth2" -) - -var ( - clientID string - clientSecret string - myDomain string - cfg oauth2.Config - blizz *blizzard.Client -) - -func homepage(w http.ResponseWriter, r *http.Request) { - fmt.Println("Homepage Hit!") - http.Redirect(w, r, cfg.AuthCodeURL("my_random_state"), http.StatusFound) -} - -func authorize(w http.ResponseWriter, r *http.Request) { - err := r.ParseForm() - if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } - - state := r.Form.Get("state") - if state != "my_random_state" { - http.Error(w, "State invalid", http.StatusBadRequest) - return - } - - code := r.Form.Get("code") - if code == "" { - http.Error(w, "Code not found", http.StatusBadRequest) - return - } - - token, err := cfg.Exchange(context.Background(), code) - if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } - - e := json.NewEncoder(w) - e.SetIndent("", " ") - err = e.Encode(*token) - if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } - - validation, _, err := blizz.TokenValidation(token) - if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - } - - fmt.Printf("%+v\n", validation) - - userInfo, _, err := blizz.UserInfoHeader(token) - if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - } - - fmt.Printf("%+v\n", userInfo) -} - -func init() { - clientID = os.Getenv("CLIENT_ID") - if clientID == "" { - log.Fatal("Set the environment variable CLIENT_ID before retrying.") - } - - clientSecret = os.Getenv("CLIENT_SECRET") - if clientSecret == "" { - log.Fatal("Set the environment variable CLIENT_SECRET before retrying.") - } - - myDomain = os.Getenv("MY_DOMAIN") - if clientSecret == "" { - log.Fatal("Set the environment variable MY_DOMAIN before retrying.") - } -} - -func main() { - blizz = blizzard.NewClient(clientID, clientSecret, blizzard.US, blizzard.EnUS) - cfg = blizz.AuthorizeConfig(fmt.Sprintf("http://%s:9094/oauth2", myDomain), oauth.ProfileD3, oauth.ProfileSC2, oauth.ProfileWoW) - - http.HandleFunc("/", homepage) - http.HandleFunc("/oauth2", authorize) - - // We start up our Client on port 9094 - log.Println("Client is running at 9094 port.") - log.Fatal(http.ListenAndServe(":9094", nil)) -} diff --git a/examples/simpleClient/main.go b/examples/simpleClient/main.go deleted file mode 100644 index 5ee4db4..0000000 --- a/examples/simpleClient/main.go +++ /dev/null @@ -1,36 +0,0 @@ -package main - -import ( - "fmt" - "log" - "os" - - "github.com/FuzzyStatic/blizzard/v1" -) - -var ( - clientID string - clientSecret string - blizz *blizzard.Client -) - -func init() { - clientID = os.Getenv("CLIENT_ID") - if clientID == "" { - log.Fatal("Set the environment variable CLIENT_ID before retrying.") - } - - clientSecret = os.Getenv("CLIENT_SECRET") - if clientSecret == "" { - log.Fatal("Set the environment variable CLIENT_SECRET before retrying.") - } -} - -func main() { - blizz = blizzard.NewClient(clientID, clientSecret, blizzard.US, blizzard.EnUS) - - err := blizz.AccessTokenRequest() - if err != nil { - fmt.Println(err) - } -} diff --git a/v2/blizzard.go b/v2/blizzard.go new file mode 100644 index 0000000..26e4fbc --- /dev/null +++ b/v2/blizzard.go @@ -0,0 +1,172 @@ +// Package blizzard is a client library designed to make calling and processing Blizzard Game APIs simple +package blizzard + +import ( + "context" + "errors" + "fmt" + "io/ioutil" + "net/http" + + "golang.org/x/oauth2" + "golang.org/x/oauth2/clientcredentials" +) + +// For testing +var c *Client + +// Client regional API URLs, locale, client ID, client secret +type Client struct { + client *http.Client + cfg clientcredentials.Config + authorizedCfg oauth2.Config + oauth OAuth + oauthURL string + apiURL string + dynamicNamespace string + profileNamespace string + staticNamespace string + staticClassicNamespace string + region Region + locale Locale +} + +// Region type +type Region int + +// Region constants (1=US, 2=EU, 3=KO and TW, 5=CN) DO NOT REARRANGE +const ( + _ Region = iota + US + EU + KR + TW + CN +) + +func (region Region) String() string { + var rr = []string{ + "", + "us", + "eu", + "kr", + "tw", + "cn", + } + + return rr[region] +} + +// Locale generic locale string +// enUS, esMX, ptBR, enGB, esES, frFR, ruRU, deDE, ptPT, itIT, koKR, zhTW, zhCN +type Locale string + +func (locale Locale) String() string { + return string(locale) +} + +// Locale constants +const ( + DeDE = Locale("de_DE") + EnUS = Locale("en_US") + EsES = Locale("es_ES") + EsMX = Locale("es_MX") + FrFR = Locale("fr_FR") + ItIT = Locale("it_IT") + JaJP = Locale("ja_JP") + KoKR = Locale("ko_KR") + PlPL = Locale("pl_PL") + PtBR = Locale("pt_BR") + RuRU = Locale("ru_RU") + ThTH = Locale("th_TH") + ZhCN = Locale("zh_CN") + ZhTW = Locale("zh_TW") +) + +// NewClient create new Blizzard structure. This structure will be used to acquire your access token and make API calls. +func NewClient(clientID, clientSecret string, region Region, locale Locale) *Client { + var c = Client{ + oauth: OAuth{ + ClientID: clientID, + ClientSecret: clientSecret, + }, + locale: locale, + } + + c.cfg = clientcredentials.Config{ + ClientID: c.oauth.ClientID, + ClientSecret: c.oauth.ClientSecret, + } + + c.SetRegion(region) + + return &c +} + +// SetLocale changes the Locale of the client +func (c *Client) SetLocale(locale Locale) { + c.locale = locale +} + +// SetRegion changes the Region of the client +func (c *Client) SetRegion(region Region) { + c.region = region + + switch region { + case CN: + c.oauthURL = "https://www.battlenet.com.cn" + c.apiURL = "https://gateway.battlenet.com.cn" + c.dynamicNamespace = "dynamic-zh" + c.profileNamespace = "profile-zh" + c.staticNamespace = "static-zh" + c.staticClassicNamespace = "static-classic-zh" + default: + c.oauthURL = fmt.Sprintf("https://%s.battle.net", region) + c.apiURL = fmt.Sprintf("https://%s.api.blizzard.com", region) + c.dynamicNamespace = fmt.Sprintf("dynamic-%s", region) + c.profileNamespace = fmt.Sprintf("profile-%s", region) + c.staticNamespace = fmt.Sprintf("static-%s", region) + c.staticClassicNamespace = fmt.Sprintf("static-classic-%s", region) + } + + c.cfg.TokenURL = c.oauthURL + "/oauth/token" + c.client = c.cfg.Client(context.Background()) +} + +// getURLBody processes simple GET request based on URL +func (c *Client) getURLBody(ctx context.Context, url, namespace string) ([]byte, error) { + var ( + req *http.Request + res *http.Response + body []byte + err error + ) + + req, err = http.NewRequestWithContext(ctx, "GET", url, nil) + if err != nil { + return nil, err + } + + req.Header.Set("Accept", "application/json") + + if namespace != "" { + req.Header.Set("Battlenet-Namespace", namespace) + } + + res, err = c.client.Do(req) + if err != nil { + return nil, err + } + defer res.Body.Close() + + body, err = ioutil.ReadAll(res.Body) + if err != nil { + return nil, err + } + + if res.StatusCode != http.StatusOK { + return nil, errors.New(res.Status) + } + + return body, nil +} diff --git a/v2/d3c.go b/v2/d3c.go new file mode 100644 index 0000000..6a1e9cd --- /dev/null +++ b/v2/d3c.go @@ -0,0 +1,673 @@ +package blizzard + +import ( + "context" + "encoding/json" + "fmt" + "strings" + + "github.com/FuzzyStatic/blizzard/v2/d3c" +) + +// D3ActIndex returns an index of acts +func (c *Client) D3ActIndex(ctx context.Context) (*d3c.ActIndex, []byte, error) { + var ( + dat d3c.ActIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/d3/data/act?locale=%s", c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3Act returns information about act based on ID +func (c *Client) D3Act(ctx context.Context, id int) (*d3c.Act, []byte, error) { + var ( + dat d3c.Act + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/d3/data/act/%d?locale=%s", id, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3Blacksmith returns blacksmith data +func (c *Client) D3Blacksmith(ctx context.Context) (*d3c.Artisan, []byte, error) { + var ( + dat d3c.Artisan + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/d3/data/artisan/blacksmith?locale=%s", c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3Jeweler returns jeweler data +func (c *Client) D3Jeweler(ctx context.Context) (*d3c.Artisan, []byte, error) { + var ( + dat d3c.Artisan + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/d3/data/artisan/jeweler?locale=%s", c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3Mystic returns mystic data +func (c *Client) D3Mystic(ctx context.Context) (*d3c.Artisan, []byte, error) { + var ( + dat d3c.Artisan + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/d3/data/artisan/mystic?locale=%s", c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3BlacksmithRecipe returns blacksmith recipe data +func (c *Client) D3BlacksmithRecipe(ctx context.Context, recipeSlug string) (*d3c.Recipe, []byte, error) { + var ( + dat d3c.Recipe + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/d3/data/artisan/blacksmith/recipe/%s?locale=%s", recipeSlug, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3JewelerRecipe returns jeweler recipe data +func (c *Client) D3JewelerRecipe(ctx context.Context, recipeSlug string) (*d3c.Recipe, []byte, error) { + var ( + dat d3c.Recipe + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/d3/data/artisan/jeweler/recipe/%s?locale=%s", recipeSlug, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3Enchantress returns enchantress data +func (c *Client) D3Enchantress(ctx context.Context) (*d3c.Follower, []byte, error) { + var ( + dat d3c.Follower + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/d3/data/follower/enchantress?locale=%s", c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3Scoundrel returns scoundrel data +func (c *Client) D3Scoundrel(ctx context.Context) (*d3c.Follower, []byte, error) { + var ( + dat d3c.Follower + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/d3/data/follower/scoundrel?locale=%s", c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3Templar returns templar data +func (c *Client) D3Templar(ctx context.Context) (*d3c.Follower, []byte, error) { + var ( + dat d3c.Follower + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/d3/data/follower/templar?locale=%s", c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3Barbarian returns barbarian data +func (c *Client) D3Barbarian(ctx context.Context) (*d3c.Hero, []byte, error) { + var ( + dat d3c.Hero + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/d3/data/hero/barbarian?locale=%s", c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3Crusader returns crusader data +func (c *Client) D3Crusader(ctx context.Context) (*d3c.Hero, []byte, error) { + var ( + dat d3c.Hero + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/d3/data/hero/crusader?locale=%s", c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3DemonHunter returns demon hunter data +func (c *Client) D3DemonHunter(ctx context.Context) (*d3c.Hero, []byte, error) { + var ( + dat d3c.Hero + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/d3/data/hero/demon-hunter?locale=%s", c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3Monk returns monk data +func (c *Client) D3Monk(ctx context.Context) (*d3c.Hero, []byte, error) { + var ( + dat d3c.Hero + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/d3/data/hero/monk?locale=%s", c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3Necromancer returns necromancer data +func (c *Client) D3Necromancer(ctx context.Context) (*d3c.Hero, []byte, error) { + var ( + dat d3c.Hero + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/d3/data/hero/necromancer?locale=%s", c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3Wizard returns wizard data +func (c *Client) D3Wizard(ctx context.Context) (*d3c.Hero, []byte, error) { + var ( + dat d3c.Hero + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/d3/data/hero/wizard?locale=%s", c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3WitchDoctor returns witch doctor data +func (c *Client) D3WitchDoctor(ctx context.Context) (*d3c.Hero, []byte, error) { + var ( + dat d3c.Hero + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/d3/data/hero/witch-doctor?locale=%s", c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3BarbarianSkill returns barbarian skill data +func (c *Client) D3BarbarianSkill(ctx context.Context, skillSlug string) (*d3c.Skill, []byte, error) { + var ( + dat d3c.Skill + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/d3/data/hero/barbarian/skill/%s?locale=%s", skillSlug, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3CrusaderSkill returns crusader skill data +func (c *Client) D3CrusaderSkill(ctx context.Context, skillSlug string) (*d3c.Skill, []byte, error) { + var ( + dat d3c.Skill + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/d3/data/hero/crusader/skill/%s?locale=%s", skillSlug, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3DemonHunterSkill returns demon hunter skill data +func (c *Client) D3DemonHunterSkill(ctx context.Context, skillSlug string) (*d3c.Skill, []byte, error) { + var ( + dat d3c.Skill + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/d3/data/hero/demon-hunter/skill/%s?locale=%s", skillSlug, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3MonkSkill returns monk skill data +func (c *Client) D3MonkSkill(ctx context.Context, skillSlug string) (*d3c.Skill, []byte, error) { + var ( + dat d3c.Skill + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/d3/data/hero/monk/skill/%s?locale=%s", skillSlug, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3NecromancerSkill returns necromancer skill data +func (c *Client) D3NecromancerSkill(ctx context.Context, skillSlug string) (*d3c.Skill, []byte, error) { + var ( + dat d3c.Skill + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/d3/data/hero/necromancer/skill/%s?locale=%s", skillSlug, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3WizardSkill returns wizard skill data +func (c *Client) D3WizardSkill(ctx context.Context, skillSlug string) (*d3c.Skill, []byte, error) { + var ( + dat d3c.Skill + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/d3/data/hero/wizard/skill/%s?locale=%s", skillSlug, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3WitchDoctorSkill returns witch doctor skill data +func (c *Client) D3WitchDoctorSkill(ctx context.Context, skillSlug string) (*d3c.Skill, []byte, error) { + var ( + dat d3c.Skill + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/d3/data/hero/witch-doctor/skill/%s?locale=%s", skillSlug, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3ItemTypeIndex returns an index of item types +func (c *Client) D3ItemTypeIndex(ctx context.Context) (*d3c.ItemTypeIndex, []byte, error) { + var ( + dat d3c.ItemTypeIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/d3/data/item-type?locale=%s", c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3ItemType returns item type data +func (c *Client) D3ItemType(ctx context.Context, itemTypeSlug string) (*d3c.ItemType, []byte, error) { + var ( + dat d3c.ItemType + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/d3/data/item-type/%s?locale=%s", itemTypeSlug, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3Item returns item data +func (c *Client) D3Item(ctx context.Context, itemSlug, itemID string) (*d3c.Item, []byte, error) { + var ( + dat d3c.Item + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/d3/data/item/%s-%s?locale=%s", itemSlug, itemID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3Profile returns profile data +// Formats accepted: Player-1234 or Player#1234 +func (c *Client) D3Profile(ctx context.Context, account string) (*d3c.Profile, []byte, error) { + var ( + dat d3c.Profile + b []byte + err error + ) + + account = strings.Replace(account, "#", "-", 1) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/d3/profile/%s/?locale=%s", account, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3ProfileHero returns profile's hero data +// Formats accepted: Player-1234 or Player#1234 +func (c *Client) D3ProfileHero(ctx context.Context, account string, heroID int) (*d3c.ProfileHero, []byte, error) { + var ( + dat d3c.ProfileHero + b []byte + err error + ) + + account = strings.Replace(account, "#", "-", 1) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/d3/profile/%s/hero/%d?locale=%s", account, heroID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3ProfileHeroItems returns profile's hero's item data +// Formats accepted: Player-1234 or Player#1234 +func (c *Client) D3ProfileHeroItems(ctx context.Context, account string, heroID int) (*d3c.ProfileHeroItems, []byte, error) { + var ( + dat d3c.ProfileHeroItems + b []byte + err error + ) + + account = strings.Replace(account, "#", "-", 1) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/d3/profile/%s/hero/%d/items?locale=%s", account, heroID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3ProfileHeroFollowerItems returns profile's hero's follower item data +// Formats accepted: Player-1234 or Player#1234 +func (c *Client) D3ProfileHeroFollowerItems(ctx context.Context, account string, heroID int) (*d3c.ProfileHeroFollowerItems, []byte, error) { + var ( + dat d3c.ProfileHeroFollowerItems + b []byte + err error + ) + + account = strings.Replace(account, "#", "-", 1) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/d3/profile/%s/hero/%d/follower-items?locale=%s", account, heroID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} diff --git a/v2/d3c/act.go b/v2/d3c/act.go new file mode 100644 index 0000000..75e0bed --- /dev/null +++ b/v2/d3c/act.go @@ -0,0 +1,18 @@ +package d3c + +// ActIndex contains slice of Acts +type ActIndex struct { + Acts []Act `json:"acts"` +} + +// Act contains act data +type Act struct { + Slug string `json:"slug"` + Number int `json:"number"` + Name string `json:"name"` + Quests []struct { + ID int `json:"id"` + Name string `json:"name"` + Slug string `json:"slug"` + } `json:"quests"` +} diff --git a/v2/d3c/artisanRecipe.go b/v2/d3c/artisanRecipe.go new file mode 100644 index 0000000..ce4da88 --- /dev/null +++ b/v2/d3c/artisanRecipe.go @@ -0,0 +1,84 @@ +package d3c + +// Artisan structure +type Artisan struct { + Slug string `json:"slug"` + Name string `json:"name"` + Portrait string `json:"portrait"` + Training struct { + Tiers []struct { + Tier int `json:"tier"` + TrainedRecipes []struct { + ID string `json:"id"` + Slug string `json:"slug"` + Name string `json:"name"` + Cost int `json:"cost"` + Reagents []struct { + Quantity int `json:"quantity"` + Item struct { + ID string `json:"id"` + Slug string `json:"slug"` + Name string `json:"name"` + Icon string `json:"icon"` + Path string `json:"path"` + } `json:"item"` + } `json:"reagents"` + ItemProduced struct { + ID string `json:"id"` + Slug string `json:"slug"` + Name string `json:"name"` + Icon string `json:"icon"` + Path string `json:"path"` + } `json:"itemProduced"` + } `json:"trainedRecipes"` + TaughtRecipes []struct { + ID string `json:"id"` + Slug string `json:"slug"` + Name string `json:"name"` + Cost int `json:"cost"` + Reagents []struct { + Quantity int `json:"quantity"` + Item struct { + ID string `json:"id"` + Slug string `json:"slug"` + Name string `json:"name"` + Icon string `json:"icon"` + Path string `json:"path"` + } `json:"item"` + } `json:"reagents"` + ItemProduced struct { + ID string `json:"id"` + Slug string `json:"slug"` + Name string `json:"name"` + Icon string `json:"icon"` + Path string `json:"path"` + } `json:"itemProduced"` + } `json:"taughtRecipes"` + } `json:"tiers"` + } `json:"training"` +} + +// Recipe artisan recipe structure +type Recipe struct { + ID string `json:"id"` + Slug string `json:"slug"` + Name string `json:"name"` + Cost int `json:"cost"` + Reagents []struct { + Quantity int `json:"quantity"` + Item struct { + ID string `json:"id"` + Slug string `json:"slug"` + Name string `json:"name"` + Icon string `json:"icon"` + Path string `json:"path"` + } `json:"item"` + } `json:"reagents"` + ItemProduced struct { + ID string `json:"id"` + Slug string `json:"slug"` + Name string `json:"name"` + Icon string `json:"icon"` + Path string `json:"path"` + } `json:"itemProduced"` +} diff --git a/v2/d3c/characterClassAndSkill.go b/v2/d3c/characterClassAndSkill.go new file mode 100644 index 0000000..fd51b3c --- /dev/null +++ b/v2/d3c/characterClassAndSkill.go @@ -0,0 +1,56 @@ +package d3c + +// Hero structure +type Hero struct { + Slug string `json:"slug"` + Name string `json:"name"` + MaleName string `json:"maleName"` + FemaleName string `json:"femaleName"` + Icon string `json:"icon"` + SkillCategories []struct { + Slug string `json:"slug"` + Name string `json:"name"` + } `json:"skillCategories"` + Skills struct { + Active []struct { + Slug string `json:"slug"` + Name string `json:"name"` + Icon string `json:"icon"` + Level int `json:"level"` + TooltipURL string `json:"tooltipUrl"` + Description string `json:"description"` + DescriptionHTML string `json:"descriptionHtml"` + } `json:"active"` + Passive []struct { + Slug string `json:"slug"` + Name string `json:"name"` + Icon string `json:"icon"` + Level int `json:"level"` + TooltipURL string `json:"tooltipUrl"` + Description string `json:"description"` + DescriptionHTML string `json:"descriptionHtml"` + FlavorText string `json:"flavorText"` + } `json:"passive"` + } `json:"skills"` +} + +// Skill structure +type Skill struct { + Skill struct { + Slug string `json:"slug"` + Name string `json:"name"` + Icon string `json:"icon"` + Level int `json:"level"` + TooltipURL string `json:"tooltipUrl"` + Description string `json:"description"` + DescriptionHTML string `json:"descriptionHtml"` + } `json:"skill"` + Runes []struct { + Slug string `json:"slug"` + Type string `json:"type"` + Name string `json:"name"` + Level int `json:"level"` + Description string `json:"description"` + DescriptionHTML string `json:"descriptionHtml"` + } `json:"runes"` +} diff --git a/v2/d3c/d3c.go b/v2/d3c/d3c.go new file mode 100644 index 0000000..e0a0cbb --- /dev/null +++ b/v2/d3c/d3c.go @@ -0,0 +1,2 @@ +// Package d3c contains types for the Diablo 3 Community APIs +package d3c diff --git a/v2/d3c/follower.go b/v2/d3c/follower.go new file mode 100644 index 0000000..a7f6554 --- /dev/null +++ b/v2/d3c/follower.go @@ -0,0 +1,18 @@ +package d3c + +// Follower structure +type Follower struct { + Slug string `json:"slug"` + Name string `json:"name"` + RealName string `json:"realName"` + Portrait string `json:"portrait"` + Skills []struct { + Slug string `json:"slug"` + Name string `json:"name"` + Icon string `json:"icon"` + Level int `json:"level"` + TooltipURL string `json:"tooltipUrl"` + Description string `json:"description"` + DescriptionHTML string `json:"descriptionHtml"` + } `json:"skills"` +} diff --git a/v2/d3c/item.go b/v2/d3c/item.go new file mode 100644 index 0000000..b3fc5b5 --- /dev/null +++ b/v2/d3c/item.go @@ -0,0 +1,45 @@ +package d3c + +// Item structure +type Item struct { + ID string `json:"id"` + Slug string `json:"slug"` + Name string `json:"name"` + Icon string `json:"icon"` + TooltipParams string `json:"tooltipParams"` + RequiredLevel int `json:"requiredLevel"` + StackSizeMax int `json:"stackSizeMax"` + AccountBound bool `json:"accountBound"` + FlavorText string `json:"flavorText"` + FlavorTextHTML string `json:"flavorTextHtml"` + TypeName string `json:"typeName"` + Type struct { + TwoHanded bool `json:"twoHanded"` + ID string `json:"id"` + } `json:"type"` + Damage string `json:"damage"` + Dps string `json:"dps"` + DamageHTML string `json:"damageHtml"` + Color string `json:"color"` + IsSeasonRequiredToDrop bool `json:"isSeasonRequiredToDrop"` + SeasonRequiredToDrop int `json:"seasonRequiredToDrop"` + Slots []string `json:"slots"` + Attributes struct { + Primary []struct { + TextHTML string `json:"textHtml"` + Text string `json:"text"` + } `json:"primary"` + Secondary []struct { + TextHTML string `json:"textHtml"` + Text string `json:"text"` + } `json:"secondary"` + Other []interface{} `json:"other"` + } `json:"attributes"` + RandomAffixes []struct { + OneOf []struct { + TextHTML string `json:"textHtml"` + Text string `json:"text"` + } `json:"oneOf"` + } `json:"randomAffixes"` + SetItems []string `json:"setItems"` +} diff --git a/v2/d3c/itemType.go b/v2/d3c/itemType.go new file mode 100644 index 0000000..f1346e6 --- /dev/null +++ b/v2/d3c/itemType.go @@ -0,0 +1,17 @@ +package d3c + +// ItemTypeIndex structure +type ItemTypeIndex []struct { + ID string `json:"id"` + Name string `json:"name"` + Path string `json:"path"` +} + +// ItemType structure +type ItemType []struct { + ID string `json:"id"` + Slug string `json:"slug"` + Name string `json:"name"` + Icon string `json:"icon"` + Path string `json:"path"` +} diff --git a/v2/d3c/profile.go b/v2/d3c/profile.go new file mode 100644 index 0000000..04dbfa7 --- /dev/null +++ b/v2/d3c/profile.go @@ -0,0 +1,1370 @@ +package d3c + +// Profile structure +type Profile struct { + BattleTag string `json:"battleTag"` + ParagonLevel int `json:"paragonLevel"` + ParagonLevelHardcore int `json:"paragonLevelHardcore"` + ParagonLevelSeason int `json:"paragonLevelSeason"` + ParagonLevelSeasonHardcore int `json:"paragonLevelSeasonHardcore"` + GuildName string `json:"guildName"` + Heroes []struct { + ID int `json:"id"` + Name string `json:"name"` + Class string `json:"class"` + ClassSlug string `json:"classSlug"` + Gender int `json:"gender"` + Level int `json:"level"` + Kills struct { + Elites int `json:"elites"` + } `json:"kills"` + ParagonLevel int `json:"paragonLevel"` + Hardcore bool `json:"hardcore"` + Seasonal bool `json:"seasonal"` + Dead bool `json:"dead"` + LastUpdated int `json:"last-updated"` + } `json:"heroes"` + LastHeroPlayed int `json:"lastHeroPlayed"` + LastUpdated int `json:"lastUpdated"` + Kills struct { + Monsters int `json:"monsters"` + Elites int `json:"elites"` + HardcoreMonsters int `json:"hardcoreMonsters"` + } `json:"kills"` + HighestHardcoreLevel int `json:"highestHardcoreLevel"` + TimePlayed struct { + DemonHunter float64 `json:"demon-hunter"` + Barbarian float64 `json:"barbarian"` + WitchDoctor float64 `json:"witch-doctor"` + Wizard float64 `json:"wizard"` + Monk float64 `json:"monk"` + Crusader float64 `json:"crusader"` + } `json:"timePlayed"` + Progression struct { + Act1 bool `json:"act1"` + Act3 bool `json:"act3"` + Act2 bool `json:"act2"` + Act5 bool `json:"act5"` + Act4 bool `json:"act4"` + } `json:"progression"` + SeasonalProfiles struct { + Season13 struct { + SeasonID int `json:"seasonId"` + ParagonLevel int `json:"paragonLevel"` + ParagonLevelHardcore int `json:"paragonLevelHardcore"` + Kills struct { + Monsters int `json:"monsters"` + Elites int `json:"elites"` + HardcoreMonsters int `json:"hardcoreMonsters"` + } `json:"kills"` + TimePlayed struct { + DemonHunter float64 `json:"demon-hunter"` + Barbarian float64 `json:"barbarian"` + WitchDoctor float64 `json:"witch-doctor"` + Necromancer float64 `json:"necromancer"` + Wizard float64 `json:"wizard"` + Monk float64 `json:"monk"` + Crusader float64 `json:"crusader"` + } `json:"timePlayed"` + HighestHardcoreLevel int `json:"highestHardcoreLevel"` + } `json:"season13"` + Season0 struct { + SeasonID int `json:"seasonId"` + ParagonLevel int `json:"paragonLevel"` + ParagonLevelHardcore int `json:"paragonLevelHardcore"` + Kills struct { + Monsters int `json:"monsters"` + Elites int `json:"elites"` + HardcoreMonsters int `json:"hardcoreMonsters"` + } `json:"kills"` + TimePlayed struct { + DemonHunter float64 `json:"demon-hunter"` + Barbarian float64 `json:"barbarian"` + WitchDoctor float64 `json:"witch-doctor"` + Necromancer float64 `json:"necromancer"` + Wizard float64 `json:"wizard"` + Monk float64 `json:"monk"` + Crusader float64 `json:"crusader"` + } `json:"timePlayed"` + HighestHardcoreLevel int `json:"highestHardcoreLevel"` + } `json:"season0"` + } `json:"seasonalProfiles"` + JewelerSeasonHardcore struct { + Slug string `json:"slug"` + Level int `json:"level"` + } `json:"jewelerSeasonHardcore"` + MysticSeasonHardcore struct { + Slug string `json:"slug"` + Level int `json:"level"` + } `json:"mysticSeasonHardcore"` + BlacksmithSeason struct { + Slug string `json:"slug"` + Level int `json:"level"` + } `json:"blacksmithSeason"` + JewelerSeason struct { + Slug string `json:"slug"` + Level int `json:"level"` + } `json:"jewelerSeason"` + BlacksmithHardcore struct { + Slug string `json:"slug"` + Level int `json:"level"` + } `json:"blacksmithHardcore"` + JewelerHardcore struct { + Slug string `json:"slug"` + Level int `json:"level"` + } `json:"jewelerHardcore"` + MysticHardcore struct { + Slug string `json:"slug"` + Level int `json:"level"` + } `json:"mysticHardcore"` + BlacksmithSeasonHardcore struct { + Slug string `json:"slug"` + Level int `json:"level"` + } `json:"blacksmithSeasonHardcore"` + MysticSeason struct { + Slug string `json:"slug"` + Level int `json:"level"` + } `json:"mysticSeason"` + Blacksmith struct { + Slug string `json:"slug"` + Level int `json:"level"` + } `json:"blacksmith"` + Jeweler struct { + Slug string `json:"slug"` + Level int `json:"level"` + } `json:"jeweler"` + Mystic struct { + Slug string `json:"slug"` + Level int `json:"level"` + } `json:"mystic"` +} + +// ProfileHero structure +type ProfileHero struct { + ID int `json:"id"` + Name string `json:"name"` + Class string `json:"class"` + Gender int `json:"gender"` + Level int `json:"level"` + ParagonLevel int `json:"paragonLevel"` + Kills struct { + Elites int `json:"elites"` + } `json:"kills"` + Hardcore bool `json:"hardcore"` + Seasonal bool `json:"seasonal"` + SeasonCreated int `json:"seasonCreated"` + Skills struct { + Active []struct { + Skill struct { + Slug string `json:"slug"` + Name string `json:"name"` + Icon string `json:"icon"` + Level int `json:"level"` + TooltipURL string `json:"tooltipUrl"` + Description string `json:"description"` + DescriptionHTML string `json:"descriptionHtml"` + } `json:"skill"` + Rune struct { + Slug string `json:"slug"` + Type string `json:"type"` + Name string `json:"name"` + Level int `json:"level"` + Description string `json:"description"` + DescriptionHTML string `json:"descriptionHtml"` + } `json:"rune"` + } `json:"active"` + Passive []struct { + Skill struct { + Slug string `json:"slug"` + Name string `json:"name"` + Icon string `json:"icon"` + Level int `json:"level"` + TooltipURL string `json:"tooltipUrl"` + Description string `json:"description"` + DescriptionHTML string `json:"descriptionHtml"` + FlavorText string `json:"flavorText"` + } `json:"skill"` + } `json:"passive"` + } `json:"skills"` + Items struct { + Head struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + TransmogItem struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + } `json:"transmogItem"` + } `json:"head"` + Neck struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + } `json:"neck"` + Torso struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + TransmogItem struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + } `json:"transmogItem"` + } `json:"torso"` + Shoulders struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + TransmogItem struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + } `json:"transmogItem"` + } `json:"shoulders"` + Legs struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + TransmogItem struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + } `json:"transmogItem"` + } `json:"legs"` + Waist struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + } `json:"waist"` + Hands struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + TransmogItem struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + } `json:"transmogItem"` + } `json:"hands"` + Bracers struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + } `json:"bracers"` + Feet struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + TransmogItem struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + } `json:"transmogItem"` + } `json:"feet"` + LeftFinger struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + } `json:"leftFinger"` + RightFinger struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + } `json:"rightFinger"` + MainHand struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + } `json:"mainHand"` + OffHand struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + TransmogItem struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + } `json:"transmogItem"` + } `json:"offHand"` + } `json:"items"` + Followers struct { + Templar struct { + Slug string `json:"slug"` + Level int `json:"level"` + Items struct { + Neck struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + } `json:"neck"` + LeftFinger struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + } `json:"leftFinger"` + RightFinger struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + } `json:"rightFinger"` + MainHand struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + } `json:"mainHand"` + OffHand struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + } `json:"offHand"` + } `json:"items"` + Stats struct { + GoldFind float64 `json:"goldFind"` + MagicFind float64 `json:"magicFind"` + ExperienceBonus float64 `json:"experienceBonus"` + } `json:"stats"` + Skills []struct { + Slug string `json:"slug"` + Name string `json:"name"` + Icon string `json:"icon"` + Level int `json:"level"` + TooltipURL string `json:"tooltipUrl"` + Description string `json:"description"` + DescriptionHTML string `json:"descriptionHtml"` + } `json:"skills"` + } `json:"templar"` + Scoundrel struct { + Slug string `json:"slug"` + Level int `json:"level"` + Items struct { + MainHand struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + } `json:"mainHand"` + } `json:"items"` + Stats struct { + GoldFind float64 `json:"goldFind"` + MagicFind float64 `json:"magicFind"` + ExperienceBonus float64 `json:"experienceBonus"` + } `json:"stats"` + Skills []struct { + Slug string `json:"slug"` + Name string `json:"name"` + Icon string `json:"icon"` + Level int `json:"level"` + TooltipURL string `json:"tooltipUrl"` + Description string `json:"description"` + DescriptionHTML string `json:"descriptionHtml"` + } `json:"skills"` + } `json:"scoundrel"` + Enchantress struct { + Slug string `json:"slug"` + Level int `json:"level"` + Items struct { + MainHand struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + } `json:"mainHand"` + } `json:"items"` + Stats struct { + GoldFind float64 `json:"goldFind"` + MagicFind float64 `json:"magicFind"` + ExperienceBonus float64 `json:"experienceBonus"` + } `json:"stats"` + Skills []struct { + Slug string `json:"slug"` + Name string `json:"name"` + Icon string `json:"icon"` + Level int `json:"level"` + TooltipURL string `json:"tooltipUrl"` + Description string `json:"description"` + DescriptionHTML string `json:"descriptionHtml"` + } `json:"skills"` + } `json:"enchantress"` + } `json:"followers"` + LegendaryPowers []struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + } `json:"legendaryPowers"` + Progression struct { + Act1 struct { + Completed bool `json:"completed"` + CompletedQuests []struct { + Slug string `json:"slug"` + Name string `json:"name"` + } `json:"completedQuests"` + } `json:"act1"` + Act2 struct { + Completed bool `json:"completed"` + CompletedQuests []struct { + Slug string `json:"slug"` + Name string `json:"name"` + } `json:"completedQuests"` + } `json:"act2"` + Act3 struct { + Completed bool `json:"completed"` + CompletedQuests []struct { + Slug string `json:"slug"` + Name string `json:"name"` + } `json:"completedQuests"` + } `json:"act3"` + Act4 struct { + Completed bool `json:"completed"` + CompletedQuests []struct { + Slug string `json:"slug"` + Name string `json:"name"` + } `json:"completedQuests"` + } `json:"act4"` + Act5 struct { + Completed bool `json:"completed"` + CompletedQuests []struct { + Slug string `json:"slug"` + Name string `json:"name"` + } `json:"completedQuests"` + } `json:"act5"` + } `json:"progression"` + Alive bool `json:"alive"` + LastUpdated int `json:"lastUpdated"` + HighestSoloRiftCompleted int `json:"highestSoloRiftCompleted"` + Stats struct { + Life float64 `json:"life"` + Damage float64 `json:"damage"` + Toughness float64 `json:"toughness"` + Healing float64 `json:"healing"` + AttackSpeed float64 `json:"attackSpeed"` + Armor float64 `json:"armor"` + Strength float64 `json:"strength"` + Dexterity float64 `json:"dexterity"` + Vitality float64 `json:"vitality"` + Intelligence float64 `json:"intelligence"` + PhysicalResist float64 `json:"physicalResist"` + FireResist float64 `json:"fireResist"` + ColdResist float64 `json:"coldResist"` + LightningResist float64 `json:"lightningResist"` + PoisonResist float64 `json:"poisonResist"` + ArcaneResist float64 `json:"arcaneResist"` + BlockChance float64 `json:"blockChance"` + BlockAmountMin float64 `json:"blockAmountMin"` + BlockAmountMax float64 `json:"blockAmountMax"` + GoldFind float64 `json:"goldFind"` + CritChance float64 `json:"critChance"` + Thorns float64 `json:"thorns"` + LifeSteal float64 `json:"lifeSteal"` + LifePerKill float64 `json:"lifePerKill"` + LifeOnHit float64 `json:"lifeOnHit"` + PrimaryResource float64 `json:"primaryResource"` + SecondaryResource float64 `json:"secondaryResource"` + } `json:"stats"` +} + +// ProfileHeroItems structure +type ProfileHeroItems struct { + Head struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + RequiredLevel int `json:"requiredLevel"` + ItemLevel int `json:"itemLevel"` + StackSizeMax int `json:"stackSizeMax"` + AccountBound bool `json:"accountBound"` + FlavorText string `json:"flavorText"` + TypeName string `json:"typeName"` + Type struct { + TwoHanded bool `json:"twoHanded"` + ID string `json:"id"` + } `json:"type"` + Armor float64 `json:"armor"` + AttacksPerSecond float64 `json:"attacksPerSecond"` + MinDamage float64 `json:"minDamage"` + MaxDamage float64 `json:"maxDamage"` + Slots string `json:"slots"` + Augmentation string `json:"augmentation"` + Attributes struct { + Primary []string `json:"primary"` + Secondary []string `json:"secondary"` + } `json:"attributes"` + AttributesHTML struct { + Primary []string `json:"primary"` + Secondary []string `json:"secondary"` + } `json:"attributesHtml"` + OpenSockets int `json:"openSockets"` + Gems []struct { + Item struct { + ID string `json:"id"` + Slug string `json:"slug"` + Name string `json:"name"` + Icon string `json:"icon"` + Path string `json:"path"` + } `json:"item"` + Attributes []string `json:"attributes"` + IsGem bool `json:"isGem"` + IsJewel bool `json:"isJewel"` + } `json:"gems"` + Set struct { + Name string `json:"name"` + Slug string `json:"slug"` + Description string `json:"description"` + DescriptionHTML string `json:"descriptionHtml"` + } `json:"set"` + SeasonRequiredToDrop int `json:"seasonRequiredToDrop"` + IsSeasonRequiredToDrop bool `json:"isSeasonRequiredToDrop"` + } `json:"head"` + Neck struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + RequiredLevel int `json:"requiredLevel"` + ItemLevel int `json:"itemLevel"` + StackSizeMax int `json:"stackSizeMax"` + AccountBound bool `json:"accountBound"` + FlavorText string `json:"flavorText"` + TypeName string `json:"typeName"` + Type struct { + TwoHanded bool `json:"twoHanded"` + ID string `json:"id"` + } `json:"type"` + Armor float64 `json:"armor"` + AttacksPerSecond float64 `json:"attacksPerSecond"` + MinDamage float64 `json:"minDamage"` + MaxDamage float64 `json:"maxDamage"` + Slots string `json:"slots"` + Augmentation string `json:"augmentation"` + Attributes struct { + Primary []string `json:"primary"` + Secondary []string `json:"secondary"` + } `json:"attributes"` + AttributesHTML struct { + Primary []string `json:"primary"` + Secondary []string `json:"secondary"` + } `json:"attributesHtml"` + OpenSockets int `json:"openSockets"` + Gems []struct { + Item struct { + ID string `json:"id"` + Slug string `json:"slug"` + Name string `json:"name"` + Icon string `json:"icon"` + Path string `json:"path"` + } `json:"item"` + JewelRank int `json:"jewelRank"` + JewelSecondaryUnlockRank int `json:"jewelSecondaryUnlockRank"` + Attributes []string `json:"attributes"` + IsGem bool `json:"isGem"` + IsJewel bool `json:"isJewel"` + } `json:"gems"` + Set struct { + Name string `json:"name"` + Slug string `json:"slug"` + Description string `json:"description"` + DescriptionHTML string `json:"descriptionHtml"` + } `json:"set"` + SeasonRequiredToDrop int `json:"seasonRequiredToDrop"` + IsSeasonRequiredToDrop bool `json:"isSeasonRequiredToDrop"` + } `json:"neck"` + Torso struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + RequiredLevel int `json:"requiredLevel"` + ItemLevel int `json:"itemLevel"` + StackSizeMax int `json:"stackSizeMax"` + AccountBound bool `json:"accountBound"` + FlavorText string `json:"flavorText"` + TypeName string `json:"typeName"` + Type struct { + TwoHanded bool `json:"twoHanded"` + ID string `json:"id"` + } `json:"type"` + Armor float64 `json:"armor"` + AttacksPerSecond float64 `json:"attacksPerSecond"` + MinDamage float64 `json:"minDamage"` + MaxDamage float64 `json:"maxDamage"` + Slots string `json:"slots"` + Attributes struct { + Primary []string `json:"primary"` + Secondary []string `json:"secondary"` + } `json:"attributes"` + AttributesHTML struct { + Primary []string `json:"primary"` + Secondary []string `json:"secondary"` + } `json:"attributesHtml"` + OpenSockets int `json:"openSockets"` + Gems []struct { + Item struct { + ID string `json:"id"` + Slug string `json:"slug"` + Name string `json:"name"` + Icon string `json:"icon"` + Path string `json:"path"` + } `json:"item"` + Attributes []string `json:"attributes"` + IsGem bool `json:"isGem"` + IsJewel bool `json:"isJewel"` + } `json:"gems"` + Set struct { + Name string `json:"name"` + Slug string `json:"slug"` + Description string `json:"description"` + DescriptionHTML string `json:"descriptionHtml"` + } `json:"set"` + SeasonRequiredToDrop int `json:"seasonRequiredToDrop"` + Transmog struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + } `json:"transmog"` + IsSeasonRequiredToDrop bool `json:"isSeasonRequiredToDrop"` + } `json:"torso"` + Shoulders struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + RequiredLevel int `json:"requiredLevel"` + ItemLevel int `json:"itemLevel"` + StackSizeMax int `json:"stackSizeMax"` + AccountBound bool `json:"accountBound"` + FlavorText string `json:"flavorText"` + TypeName string `json:"typeName"` + Type struct { + TwoHanded bool `json:"twoHanded"` + ID string `json:"id"` + } `json:"type"` + Armor float64 `json:"armor"` + AttacksPerSecond float64 `json:"attacksPerSecond"` + MinDamage float64 `json:"minDamage"` + MaxDamage float64 `json:"maxDamage"` + Slots string `json:"slots"` + Augmentation string `json:"augmentation"` + Attributes struct { + Primary []string `json:"primary"` + Secondary []string `json:"secondary"` + } `json:"attributes"` + AttributesHTML struct { + Primary []string `json:"primary"` + Secondary []string `json:"secondary"` + } `json:"attributesHtml"` + OpenSockets int `json:"openSockets"` + Set struct { + Name string `json:"name"` + Slug string `json:"slug"` + Description string `json:"description"` + DescriptionHTML string `json:"descriptionHtml"` + } `json:"set"` + SeasonRequiredToDrop int `json:"seasonRequiredToDrop"` + IsSeasonRequiredToDrop bool `json:"isSeasonRequiredToDrop"` + } `json:"shoulders"` + Legs struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + RequiredLevel int `json:"requiredLevel"` + ItemLevel int `json:"itemLevel"` + StackSizeMax int `json:"stackSizeMax"` + AccountBound bool `json:"accountBound"` + FlavorText string `json:"flavorText"` + TypeName string `json:"typeName"` + Type struct { + TwoHanded bool `json:"twoHanded"` + ID string `json:"id"` + } `json:"type"` + Armor float64 `json:"armor"` + AttacksPerSecond float64 `json:"attacksPerSecond"` + MinDamage float64 `json:"minDamage"` + MaxDamage float64 `json:"maxDamage"` + Slots string `json:"slots"` + Augmentation string `json:"augmentation"` + Attributes struct { + Primary []string `json:"primary"` + Secondary []string `json:"secondary"` + } `json:"attributes"` + AttributesHTML struct { + Primary []string `json:"primary"` + Secondary []string `json:"secondary"` + } `json:"attributesHtml"` + OpenSockets int `json:"openSockets"` + Gems []struct { + Item struct { + ID string `json:"id"` + Slug string `json:"slug"` + Name string `json:"name"` + Icon string `json:"icon"` + Path string `json:"path"` + } `json:"item"` + Attributes []string `json:"attributes"` + IsGem bool `json:"isGem"` + IsJewel bool `json:"isJewel"` + } `json:"gems"` + Set struct { + Name string `json:"name"` + Slug string `json:"slug"` + Description string `json:"description"` + DescriptionHTML string `json:"descriptionHtml"` + } `json:"set"` + SeasonRequiredToDrop int `json:"seasonRequiredToDrop"` + IsSeasonRequiredToDrop bool `json:"isSeasonRequiredToDrop"` + } `json:"legs"` + Waist struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + RequiredLevel int `json:"requiredLevel"` + ItemLevel int `json:"itemLevel"` + StackSizeMax int `json:"stackSizeMax"` + AccountBound bool `json:"accountBound"` + FlavorText string `json:"flavorText"` + TypeName string `json:"typeName"` + Type struct { + TwoHanded bool `json:"twoHanded"` + ID string `json:"id"` + } `json:"type"` + Armor float64 `json:"armor"` + AttacksPerSecond float64 `json:"attacksPerSecond"` + MinDamage float64 `json:"minDamage"` + MaxDamage float64 `json:"maxDamage"` + Slots string `json:"slots"` + Attributes struct { + Primary []string `json:"primary"` + Secondary []string `json:"secondary"` + } `json:"attributes"` + AttributesHTML struct { + Primary []string `json:"primary"` + Secondary []string `json:"secondary"` + } `json:"attributesHtml"` + OpenSockets int `json:"openSockets"` + SeasonRequiredToDrop int `json:"seasonRequiredToDrop"` + IsSeasonRequiredToDrop bool `json:"isSeasonRequiredToDrop"` + } `json:"waist"` + Hands struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + RequiredLevel int `json:"requiredLevel"` + ItemLevel int `json:"itemLevel"` + StackSizeMax int `json:"stackSizeMax"` + AccountBound bool `json:"accountBound"` + FlavorText string `json:"flavorText"` + TypeName string `json:"typeName"` + Type struct { + TwoHanded bool `json:"twoHanded"` + ID string `json:"id"` + } `json:"type"` + Armor float64 `json:"armor"` + AttacksPerSecond float64 `json:"attacksPerSecond"` + MinDamage float64 `json:"minDamage"` + MaxDamage float64 `json:"maxDamage"` + Slots string `json:"slots"` + Augmentation string `json:"augmentation"` + Attributes struct { + Primary []string `json:"primary"` + Secondary []string `json:"secondary"` + } `json:"attributes"` + AttributesHTML struct { + Primary []string `json:"primary"` + Secondary []string `json:"secondary"` + } `json:"attributesHtml"` + OpenSockets int `json:"openSockets"` + Set struct { + Name string `json:"name"` + Slug string `json:"slug"` + Description string `json:"description"` + DescriptionHTML string `json:"descriptionHtml"` + } `json:"set"` + SeasonRequiredToDrop int `json:"seasonRequiredToDrop"` + IsSeasonRequiredToDrop bool `json:"isSeasonRequiredToDrop"` + } `json:"hands"` + Bracers struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + RequiredLevel int `json:"requiredLevel"` + ItemLevel int `json:"itemLevel"` + StackSizeMax int `json:"stackSizeMax"` + AccountBound bool `json:"accountBound"` + FlavorText string `json:"flavorText"` + TypeName string `json:"typeName"` + Type struct { + TwoHanded bool `json:"twoHanded"` + ID string `json:"id"` + } `json:"type"` + Armor float64 `json:"armor"` + AttacksPerSecond float64 `json:"attacksPerSecond"` + MinDamage float64 `json:"minDamage"` + MaxDamage float64 `json:"maxDamage"` + ElementalType string `json:"elementalType"` + Slots string `json:"slots"` + Augmentation string `json:"augmentation"` + Attributes struct { + Primary []string `json:"primary"` + Secondary []string `json:"secondary"` + } `json:"attributes"` + AttributesHTML struct { + Primary []string `json:"primary"` + Secondary []string `json:"secondary"` + } `json:"attributesHtml"` + OpenSockets int `json:"openSockets"` + SeasonRequiredToDrop int `json:"seasonRequiredToDrop"` + IsSeasonRequiredToDrop bool `json:"isSeasonRequiredToDrop"` + } `json:"bracers"` + Feet struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + RequiredLevel int `json:"requiredLevel"` + ItemLevel int `json:"itemLevel"` + StackSizeMax int `json:"stackSizeMax"` + AccountBound bool `json:"accountBound"` + FlavorText string `json:"flavorText"` + TypeName string `json:"typeName"` + Type struct { + TwoHanded bool `json:"twoHanded"` + ID string `json:"id"` + } `json:"type"` + Armor float64 `json:"armor"` + AttacksPerSecond float64 `json:"attacksPerSecond"` + MinDamage float64 `json:"minDamage"` + MaxDamage float64 `json:"maxDamage"` + Slots string `json:"slots"` + Attributes struct { + Primary []string `json:"primary"` + Secondary []string `json:"secondary"` + } `json:"attributes"` + AttributesHTML struct { + Primary []string `json:"primary"` + Secondary []string `json:"secondary"` + } `json:"attributesHtml"` + OpenSockets int `json:"openSockets"` + Set struct { + Name string `json:"name"` + Slug string `json:"slug"` + Description string `json:"description"` + DescriptionHTML string `json:"descriptionHtml"` + } `json:"set"` + SeasonRequiredToDrop int `json:"seasonRequiredToDrop"` + IsSeasonRequiredToDrop bool `json:"isSeasonRequiredToDrop"` + } `json:"feet"` + LeftFinger struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + RequiredLevel int `json:"requiredLevel"` + ItemLevel int `json:"itemLevel"` + StackSizeMax int `json:"stackSizeMax"` + AccountBound bool `json:"accountBound"` + FlavorText string `json:"flavorText"` + TypeName string `json:"typeName"` + Type struct { + TwoHanded bool `json:"twoHanded"` + ID string `json:"id"` + } `json:"type"` + Armor float64 `json:"armor"` + AttacksPerSecond float64 `json:"attacksPerSecond"` + MinDamage float64 `json:"minDamage"` + MaxDamage float64 `json:"maxDamage"` + Slots string `json:"slots"` + Attributes struct { + Primary []string `json:"primary"` + Secondary []string `json:"secondary"` + } `json:"attributes"` + AttributesHTML struct { + Primary []string `json:"primary"` + Secondary []string `json:"secondary"` + } `json:"attributesHtml"` + OpenSockets int `json:"openSockets"` + Gems []struct { + Item struct { + ID string `json:"id"` + Slug string `json:"slug"` + Name string `json:"name"` + Icon string `json:"icon"` + Path string `json:"path"` + } `json:"item"` + JewelRank int `json:"jewelRank"` + JewelSecondaryUnlockRank int `json:"jewelSecondaryUnlockRank"` + Attributes []string `json:"attributes"` + IsGem bool `json:"isGem"` + IsJewel bool `json:"isJewel"` + } `json:"gems"` + SeasonRequiredToDrop int `json:"seasonRequiredToDrop"` + IsSeasonRequiredToDrop bool `json:"isSeasonRequiredToDrop"` + } `json:"leftFinger"` + RightFinger struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + RequiredLevel int `json:"requiredLevel"` + ItemLevel int `json:"itemLevel"` + StackSizeMax int `json:"stackSizeMax"` + AccountBound bool `json:"accountBound"` + FlavorText string `json:"flavorText"` + TypeName string `json:"typeName"` + Type struct { + TwoHanded bool `json:"twoHanded"` + ID string `json:"id"` + } `json:"type"` + Armor float64 `json:"armor"` + AttacksPerSecond float64 `json:"attacksPerSecond"` + MinDamage float64 `json:"minDamage"` + MaxDamage float64 `json:"maxDamage"` + Slots string `json:"slots"` + Augmentation string `json:"augmentation"` + Attributes struct { + Primary []string `json:"primary"` + Secondary []string `json:"secondary"` + } `json:"attributes"` + AttributesHTML struct { + Primary []string `json:"primary"` + Secondary []string `json:"secondary"` + } `json:"attributesHtml"` + OpenSockets int `json:"openSockets"` + Gems []struct { + Item struct { + ID string `json:"id"` + Slug string `json:"slug"` + Name string `json:"name"` + Icon string `json:"icon"` + Path string `json:"path"` + } `json:"item"` + JewelRank int `json:"jewelRank"` + JewelSecondaryUnlockRank int `json:"jewelSecondaryUnlockRank"` + Attributes []string `json:"attributes"` + IsGem bool `json:"isGem"` + IsJewel bool `json:"isJewel"` + } `json:"gems"` + SeasonRequiredToDrop int `json:"seasonRequiredToDrop"` + IsSeasonRequiredToDrop bool `json:"isSeasonRequiredToDrop"` + } `json:"rightFinger"` + MainHand struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + RequiredLevel int `json:"requiredLevel"` + ItemLevel int `json:"itemLevel"` + StackSizeMax int `json:"stackSizeMax"` + AccountBound bool `json:"accountBound"` + FlavorText string `json:"flavorText"` + TypeName string `json:"typeName"` + Type struct { + TwoHanded bool `json:"twoHanded"` + ID string `json:"id"` + } `json:"type"` + Armor float64 `json:"armor"` + Damage string `json:"damage"` + Dps string `json:"dps"` + AttacksPerSecond float64 `json:"attacksPerSecond"` + MinDamage float64 `json:"minDamage"` + MaxDamage float64 `json:"maxDamage"` + ElementalType string `json:"elementalType"` + Slots string `json:"slots"` + Augmentation string `json:"augmentation"` + Attributes struct { + Primary []string `json:"primary"` + Secondary []string `json:"secondary"` + } `json:"attributes"` + AttributesHTML struct { + Primary []string `json:"primary"` + Secondary []string `json:"secondary"` + } `json:"attributesHtml"` + OpenSockets int `json:"openSockets"` + Gems []struct { + Item struct { + ID string `json:"id"` + Slug string `json:"slug"` + Name string `json:"name"` + Icon string `json:"icon"` + Path string `json:"path"` + } `json:"item"` + Attributes []string `json:"attributes"` + IsGem bool `json:"isGem"` + IsJewel bool `json:"isJewel"` + } `json:"gems"` + SeasonRequiredToDrop int `json:"seasonRequiredToDrop"` + IsSeasonRequiredToDrop bool `json:"isSeasonRequiredToDrop"` + } `json:"mainHand"` + OffHand struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + RequiredLevel int `json:"requiredLevel"` + ItemLevel int `json:"itemLevel"` + StackSizeMax int `json:"stackSizeMax"` + AccountBound bool `json:"accountBound"` + FlavorText string `json:"flavorText"` + TypeName string `json:"typeName"` + Type struct { + TwoHanded bool `json:"twoHanded"` + ID string `json:"id"` + } `json:"type"` + Armor float64 `json:"armor"` + AttacksPerSecond float64 `json:"attacksPerSecond"` + MinDamage float64 `json:"minDamage"` + MaxDamage float64 `json:"maxDamage"` + Slots string `json:"slots"` + Augmentation string `json:"augmentation"` + Attributes struct { + Primary []string `json:"primary"` + Secondary []string `json:"secondary"` + } `json:"attributes"` + AttributesHTML struct { + Primary []string `json:"primary"` + Secondary []string `json:"secondary"` + } `json:"attributesHtml"` + OpenSockets int `json:"openSockets"` + Set struct { + Name string `json:"name"` + Slug string `json:"slug"` + Description string `json:"description"` + DescriptionHTML string `json:"descriptionHtml"` + } `json:"set"` + SeasonRequiredToDrop int `json:"seasonRequiredToDrop"` + IsSeasonRequiredToDrop bool `json:"isSeasonRequiredToDrop"` + } `json:"offHand"` +} + +// ProfileHeroFollowerItems structure +type ProfileHeroFollowerItems struct { + Templar struct { + MainHand struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + RequiredLevel int `json:"requiredLevel"` + ItemLevel int `json:"itemLevel"` + StackSizeMax int `json:"stackSizeMax"` + AccountBound bool `json:"accountBound"` + TypeName string `json:"typeName"` + Type struct { + TwoHanded bool `json:"twoHanded"` + ID string `json:"id"` + } `json:"type"` + Armor float64 `json:"armor"` + Damage string `json:"damage"` + Dps string `json:"dps"` + AttacksPerSecond float64 `json:"attacksPerSecond"` + MinDamage float64 `json:"minDamage"` + MaxDamage float64 `json:"maxDamage"` + Slots string `json:"slots"` + OpenSockets int `json:"openSockets"` + SeasonRequiredToDrop int `json:"seasonRequiredToDrop"` + IsSeasonRequiredToDrop bool `json:"isSeasonRequiredToDrop"` + } `json:"mainHand"` + OffHand struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + RequiredLevel int `json:"requiredLevel"` + ItemLevel int `json:"itemLevel"` + StackSizeMax int `json:"stackSizeMax"` + AccountBound bool `json:"accountBound"` + TypeName string `json:"typeName"` + Type struct { + TwoHanded bool `json:"twoHanded"` + ID string `json:"id"` + } `json:"type"` + Armor float64 `json:"armor"` + AttacksPerSecond float64 `json:"attacksPerSecond"` + MinDamage float64 `json:"minDamage"` + MaxDamage float64 `json:"maxDamage"` + Slots string `json:"slots"` + OpenSockets int `json:"openSockets"` + SeasonRequiredToDrop int `json:"seasonRequiredToDrop"` + BlockChance string `json:"blockChance"` + IsSeasonRequiredToDrop bool `json:"isSeasonRequiredToDrop"` + } `json:"offHand"` + } `json:"templar"` + Scoundrel struct { + MainHand struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + RequiredLevel int `json:"requiredLevel"` + ItemLevel int `json:"itemLevel"` + StackSizeMax int `json:"stackSizeMax"` + AccountBound bool `json:"accountBound"` + TypeName string `json:"typeName"` + Type struct { + TwoHanded bool `json:"twoHanded"` + ID string `json:"id"` + } `json:"type"` + Armor float64 `json:"armor"` + Damage string `json:"damage"` + Dps string `json:"dps"` + AttacksPerSecond float64 `json:"attacksPerSecond"` + MinDamage float64 `json:"minDamage"` + MaxDamage float64 `json:"maxDamage"` + Slots string `json:"slots"` + Attributes struct { + Primary []string `json:"primary"` + } `json:"attributes"` + AttributesHTML struct { + Primary []string `json:"primary"` + } `json:"attributesHtml"` + OpenSockets int `json:"openSockets"` + SeasonRequiredToDrop int `json:"seasonRequiredToDrop"` + IsSeasonRequiredToDrop bool `json:"isSeasonRequiredToDrop"` + } `json:"mainHand"` + } `json:"scoundrel"` + Enchantress struct { + Neck struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + RequiredLevel int `json:"requiredLevel"` + ItemLevel int `json:"itemLevel"` + StackSizeMax int `json:"stackSizeMax"` + AccountBound bool `json:"accountBound"` + FlavorText string `json:"flavorText"` + TypeName string `json:"typeName"` + Type struct { + TwoHanded bool `json:"twoHanded"` + ID string `json:"id"` + } `json:"type"` + Armor float64 `json:"armor"` + AttacksPerSecond float64 `json:"attacksPerSecond"` + MinDamage float64 `json:"minDamage"` + MaxDamage float64 `json:"maxDamage"` + Slots string `json:"slots"` + Attributes struct { + Primary []string `json:"primary"` + Secondary []string `json:"secondary"` + } `json:"attributes"` + AttributesHTML struct { + Primary []string `json:"primary"` + Secondary []string `json:"secondary"` + } `json:"attributesHtml"` + OpenSockets int `json:"openSockets"` + SeasonRequiredToDrop int `json:"seasonRequiredToDrop"` + IsSeasonRequiredToDrop bool `json:"isSeasonRequiredToDrop"` + } `json:"neck"` + LeftFinger struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + RequiredLevel int `json:"requiredLevel"` + ItemLevel int `json:"itemLevel"` + StackSizeMax int `json:"stackSizeMax"` + AccountBound bool `json:"accountBound"` + FlavorText string `json:"flavorText"` + TypeName string `json:"typeName"` + Type struct { + TwoHanded bool `json:"twoHanded"` + ID string `json:"id"` + } `json:"type"` + Armor float64 `json:"armor"` + AttacksPerSecond float64 `json:"attacksPerSecond"` + MinDamage float64 `json:"minDamage"` + MaxDamage float64 `json:"maxDamage"` + Slots string `json:"slots"` + Attributes struct { + Primary []string `json:"primary"` + Secondary []string `json:"secondary"` + } `json:"attributes"` + AttributesHTML struct { + Primary []string `json:"primary"` + Secondary []string `json:"secondary"` + } `json:"attributesHtml"` + OpenSockets int `json:"openSockets"` + SeasonRequiredToDrop int `json:"seasonRequiredToDrop"` + IsSeasonRequiredToDrop bool `json:"isSeasonRequiredToDrop"` + } `json:"leftFinger"` + RightFinger struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + RequiredLevel int `json:"requiredLevel"` + ItemLevel int `json:"itemLevel"` + StackSizeMax int `json:"stackSizeMax"` + AccountBound bool `json:"accountBound"` + FlavorText string `json:"flavorText"` + TypeName string `json:"typeName"` + Type struct { + TwoHanded bool `json:"twoHanded"` + ID string `json:"id"` + } `json:"type"` + Armor float64 `json:"armor"` + AttacksPerSecond float64 `json:"attacksPerSecond"` + MinDamage float64 `json:"minDamage"` + MaxDamage float64 `json:"maxDamage"` + Slots string `json:"slots"` + Attributes struct { + Primary []string `json:"primary"` + Secondary []string `json:"secondary"` + } `json:"attributes"` + AttributesHTML struct { + Primary []string `json:"primary"` + Secondary []string `json:"secondary"` + } `json:"attributesHtml"` + OpenSockets int `json:"openSockets"` + SeasonRequiredToDrop int `json:"seasonRequiredToDrop"` + IsSeasonRequiredToDrop bool `json:"isSeasonRequiredToDrop"` + } `json:"rightFinger"` + MainHand struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + RequiredLevel int `json:"requiredLevel"` + ItemLevel int `json:"itemLevel"` + StackSizeMax int `json:"stackSizeMax"` + AccountBound bool `json:"accountBound"` + FlavorText string `json:"flavorText"` + TypeName string `json:"typeName"` + Type struct { + TwoHanded bool `json:"twoHanded"` + ID string `json:"id"` + } `json:"type"` + Armor float64 `json:"armor"` + Damage string `json:"damage"` + Dps string `json:"dps"` + AttacksPerSecond float64 `json:"attacksPerSecond"` + MinDamage float64 `json:"minDamage"` + MaxDamage float64 `json:"maxDamage"` + ElementalType string `json:"elementalType"` + Slots string `json:"slots"` + Attributes struct { + Primary []string `json:"primary"` + Secondary []string `json:"secondary"` + } `json:"attributes"` + AttributesHTML struct { + Primary []string `json:"primary"` + Secondary []string `json:"secondary"` + } `json:"attributesHtml"` + OpenSockets int `json:"openSockets"` + SeasonRequiredToDrop int `json:"seasonRequiredToDrop"` + IsSeasonRequiredToDrop bool `json:"isSeasonRequiredToDrop"` + } `json:"mainHand"` + Special struct { + ID string `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + DisplayColor string `json:"displayColor"` + TooltipParams string `json:"tooltipParams"` + RequiredLevel int `json:"requiredLevel"` + ItemLevel int `json:"itemLevel"` + StackSizeMax int `json:"stackSizeMax"` + AccountBound bool `json:"accountBound"` + FlavorText string `json:"flavorText"` + TypeName string `json:"typeName"` + Type struct { + TwoHanded bool `json:"twoHanded"` + ID string `json:"id"` + } `json:"type"` + Armor float64 `json:"armor"` + AttacksPerSecond float64 `json:"attacksPerSecond"` + MinDamage float64 `json:"minDamage"` + MaxDamage float64 `json:"maxDamage"` + Slots string `json:"slots"` + Attributes struct { + Primary []string `json:"primary"` + Secondary []string `json:"secondary"` + } `json:"attributes"` + AttributesHTML struct { + Primary []string `json:"primary"` + Secondary []string `json:"secondary"` + } `json:"attributesHtml"` + OpenSockets int `json:"openSockets"` + SeasonRequiredToDrop int `json:"seasonRequiredToDrop"` + IsSeasonRequiredToDrop bool `json:"isSeasonRequiredToDrop"` + } `json:"special"` + } `json:"enchantress"` +} diff --git a/v2/d3c_test.go b/v2/d3c_test.go new file mode 100644 index 0000000..94cfa57 --- /dev/null +++ b/v2/d3c_test.go @@ -0,0 +1,379 @@ +package blizzard + +import ( + "context" + "fmt" + "testing" +) + +func TestD3ActIndex(t *testing.T) { + dat, _, err := c.D3ActIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3Act(t *testing.T) { + dat, _, err := c.D3Act(context.Background(), 1) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3Blacksmith(t *testing.T) { + dat, _, err := c.D3Blacksmith(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3Jeweler(t *testing.T) { + dat, _, err := c.D3Jeweler(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3Mystic(t *testing.T) { + dat, _, err := c.D3Mystic(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3BlacksmithRecipe(t *testing.T) { + dat, _, err := c.D3BlacksmithRecipe(context.Background(), "apprentice-flamberge") + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3JewelerRecipe(t *testing.T) { + dat, _, err := c.D3JewelerRecipe(context.Background(), "flawless-amethyst") + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3Enchantress(t *testing.T) { + dat, _, err := c.D3Enchantress(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3Scoundrel(t *testing.T) { + dat, _, err := c.D3Scoundrel(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3Templar(t *testing.T) { + dat, _, err := c.D3Templar(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3Barbarian(t *testing.T) { + dat, _, err := c.D3Barbarian(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3Crusader(t *testing.T) { + dat, _, err := c.D3Crusader(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3DemonHunter(t *testing.T) { + dat, _, err := c.D3DemonHunter(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3Monk(t *testing.T) { + dat, _, err := c.D3Monk(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3Necromancer(t *testing.T) { + dat, _, err := c.D3Necromancer(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3Wizard(t *testing.T) { + dat, _, err := c.D3Wizard(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3WitchDoctor(t *testing.T) { + dat, _, err := c.D3WitchDoctor(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3BarbarianSkill(t *testing.T) { + dat, _, err := c.D3BarbarianSkill(context.Background(), "bash") + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3CrusaderSkill(t *testing.T) { + dat, _, err := c.D3CrusaderSkill(context.Background(), "condemn") + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3DemonHunterSkill(t *testing.T) { + dat, _, err := c.D3DemonHunterSkill(context.Background(), "smoke-screen") + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3MonkSkill(t *testing.T) { + dat, _, err := c.D3MonkSkill(context.Background(), "dashing-strike") + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3NecromancerSkill(t *testing.T) { + dat, _, err := c.D3NecromancerSkill(context.Background(), "grim-scythe") + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3WizardSkill(t *testing.T) { + dat, _, err := c.D3WizardSkill(context.Background(), "energy-twister") + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3WitchDoctorSkill(t *testing.T) { + dat, _, err := c.D3WitchDoctorSkill(context.Background(), "gargantuan") + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3ItemTypeIndex(t *testing.T) { + dat, _, err := c.D3ItemTypeIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3ItemType(t *testing.T) { + dat, _, err := c.D3ItemType(context.Background(), "chestarmorwizard") + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3Item(t *testing.T) { + dat, _, err := c.D3Item(context.Background(), "firebirds-breast", "Unique_Chest_Set_06_x1") + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3Profile(t *testing.T) { + dat, _, err := c.D3Profile(context.Background(), "FuzzyStatic#1384") + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3ProfileHero(t *testing.T) { + dat, _, err := c.D3ProfileHero(context.Background(), "FuzzyStatic#1384", 98663224) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3ProfileHeroItems(t *testing.T) { + dat, _, err := c.D3ProfileHeroItems(context.Background(), "FuzzyStatic#1384", 98663224) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3ProfileHeroFollowerItems(t *testing.T) { + dat, _, err := c.D3ProfileHeroFollowerItems(context.Background(), "FuzzyStatic#1384", 98663224) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} diff --git a/v2/d3gd.go b/v2/d3gd.go new file mode 100644 index 0000000..e730cd3 --- /dev/null +++ b/v2/d3gd.go @@ -0,0 +1,975 @@ +package blizzard + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/FuzzyStatic/blizzard/v2/d3gd" +) + +// D3SeasonIndex returns an index of seasons +func (c *Client) D3SeasonIndex(ctx context.Context) (*d3gd.SeasonIndex, []byte, error) { + var ( + dat d3gd.SeasonIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/season/?locale=%s", c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3Season returns season data +func (c *Client) D3Season(ctx context.Context, seasonID int) (*d3gd.Season, []byte, error) { + var ( + dat d3gd.Season + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/season/%d?locale=%s", seasonID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3SeasonLeaderboard returns leaderboard data for season and leaderboard +func (c *Client) D3SeasonLeaderboard(ctx context.Context, seasonID int, leaderboard string) (*d3gd.Leaderboard, []byte, error) { + var ( + dat d3gd.Leaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/season/%d/leaderboard/%s?locale=%s", seasonID, leaderboard, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3SeasonLeaderboardAchievementPoints returns achievement points leaderboard data for season +func (c *Client) D3SeasonLeaderboardAchievementPoints(ctx context.Context, seasonID int) (*d3gd.Leaderboard, []byte, error) { + var ( + dat d3gd.Leaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/season/%d/leaderboard/achievement-points?locale=%s", seasonID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3SeasonLeaderboardHardcoreBarbarian returns hardcore barbarian leaderboard data for season +func (c *Client) D3SeasonLeaderboardHardcoreBarbarian(ctx context.Context, seasonID int) (*d3gd.Leaderboard, []byte, error) { + var ( + dat d3gd.Leaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/season/%d/leaderboard/rift-hardcore-barbarian?locale=%s", seasonID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3SeasonLeaderboardBarbarian returns barbarian leaderboard data for season +func (c *Client) D3SeasonLeaderboardBarbarian(ctx context.Context, seasonID int) (*d3gd.Leaderboard, []byte, error) { + var ( + dat d3gd.Leaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/season/%d/leaderboard/rift-barbarian?locale=%s", seasonID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3SeasonLeaderboardHardcoreCrusader returns hardcore crusader leaderboard data for season +func (c *Client) D3SeasonLeaderboardHardcoreCrusader(ctx context.Context, seasonID int) (*d3gd.Leaderboard, []byte, error) { + var ( + dat d3gd.Leaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/season/%d/leaderboard/rift-hardcore-crusader?locale=%s", seasonID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3SeasonLeaderboardCrusader returns crusader leaderboard data for season +func (c *Client) D3SeasonLeaderboardCrusader(ctx context.Context, seasonID int) (*d3gd.Leaderboard, []byte, error) { + var ( + dat d3gd.Leaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/season/%d/leaderboard/rift-crusader?locale=%s", seasonID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3SeasonLeaderboardHardcoreDemonHunter returns hardcore demon hunter leaderboard data for season +func (c *Client) D3SeasonLeaderboardHardcoreDemonHunter(ctx context.Context, seasonID int) (*d3gd.Leaderboard, []byte, error) { + var ( + dat d3gd.Leaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/season/%d/leaderboard/rift-hardcore-dh?locale=%s", seasonID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3SeasonLeaderboardDemonHunter returns barbarian leaderboard data for season +func (c *Client) D3SeasonLeaderboardDemonHunter(ctx context.Context, seasonID int) (*d3gd.Leaderboard, []byte, error) { + var ( + dat d3gd.Leaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/season/%d/leaderboard/rift-dh?locale=%s", seasonID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3SeasonLeaderboardHardcoreMonk returns hardcore monk leaderboard data for season +func (c *Client) D3SeasonLeaderboardHardcoreMonk(ctx context.Context, seasonID int) (*d3gd.Leaderboard, []byte, error) { + var ( + dat d3gd.Leaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/season/%d/leaderboard/rift-hardcore-monk?locale=%s", seasonID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3SeasonLeaderboardMonk returns monk leaderboard data for season +func (c *Client) D3SeasonLeaderboardMonk(ctx context.Context, seasonID int) (*d3gd.Leaderboard, []byte, error) { + var ( + dat d3gd.Leaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/season/%d/leaderboard/rift-monk?locale=%s", seasonID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3SeasonLeaderboardHardcoreNecromancer returns hardcore necromancer leaderboard data for season +func (c *Client) D3SeasonLeaderboardHardcoreNecromancer(ctx context.Context, seasonID int) (*d3gd.Leaderboard, []byte, error) { + var ( + dat d3gd.Leaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/season/%d/leaderboard/rift-hardcore-necromancer?locale=%s", seasonID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3SeasonLeaderboardNecromancer returns necromancer leaderboard data for season +func (c *Client) D3SeasonLeaderboardNecromancer(ctx context.Context, seasonID int) (*d3gd.Leaderboard, []byte, error) { + var ( + dat d3gd.Leaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/season/%d/leaderboard/rift-necromancer?locale=%s", seasonID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3SeasonLeaderboardHardcoreWizard returns hardcore wizard leaderboard data for season +func (c *Client) D3SeasonLeaderboardHardcoreWizard(ctx context.Context, seasonID int) (*d3gd.Leaderboard, []byte, error) { + var ( + dat d3gd.Leaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/season/%d/leaderboard/rift-hardcore-wizard?locale=%s", seasonID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3SeasonLeaderboardWizard returns wizard leaderboard data for season +func (c *Client) D3SeasonLeaderboardWizard(ctx context.Context, seasonID int) (*d3gd.Leaderboard, []byte, error) { + var ( + dat d3gd.Leaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/season/%d/leaderboard/rift-wizard?locale=%s", seasonID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3SeasonLeaderboardHardcoreWitchDoctor returns hardcore witch doctor leaderboard data for season +func (c *Client) D3SeasonLeaderboardHardcoreWitchDoctor(ctx context.Context, seasonID int) (*d3gd.Leaderboard, []byte, error) { + var ( + dat d3gd.Leaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/season/%d/leaderboard/rift-hardcore-wd?locale=%s", seasonID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3SeasonLeaderboardWitchDoctor returns witch doctor leaderboard data for season +func (c *Client) D3SeasonLeaderboardWitchDoctor(ctx context.Context, seasonID int) (*d3gd.Leaderboard, []byte, error) { + var ( + dat d3gd.Leaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/season/%d/leaderboard/rift-wd?locale=%s", seasonID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3SeasonLeaderboardHardcoreTeam2 returns hardcore 2 team leaderboard data for season +func (c *Client) D3SeasonLeaderboardHardcoreTeam2(ctx context.Context, seasonID int) (*d3gd.Leaderboard, []byte, error) { + var ( + dat d3gd.Leaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/season/%d/leaderboard/rift-hardcore-team-2?locale=%s", seasonID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3SeasonLeaderboardTeam2 returns 2 team leaderboard data for season +func (c *Client) D3SeasonLeaderboardTeam2(ctx context.Context, seasonID int) (*d3gd.Leaderboard, []byte, error) { + var ( + dat d3gd.Leaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/season/%d/leaderboard/rift-team-2?locale=%s", seasonID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3SeasonLeaderboardHardcoreTeam3 returns hardcore 2 team leaderboard data for season +func (c *Client) D3SeasonLeaderboardHardcoreTeam3(ctx context.Context, seasonID int) (*d3gd.Leaderboard, []byte, error) { + var ( + dat d3gd.Leaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/season/%d/leaderboard/rift-hardcore-team-3?locale=%s", seasonID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3SeasonLeaderboardTeam3 returns 3 team leaderboard data for season +func (c *Client) D3SeasonLeaderboardTeam3(ctx context.Context, seasonID int) (*d3gd.Leaderboard, []byte, error) { + var ( + dat d3gd.Leaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/season/%d/leaderboard/rift-team-3?locale=%s", seasonID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3SeasonLeaderboardHardcoreTeam4 returns hardcore 4 team leaderboard data for season +func (c *Client) D3SeasonLeaderboardHardcoreTeam4(ctx context.Context, seasonID int) (*d3gd.Leaderboard, []byte, error) { + var ( + dat d3gd.Leaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/season/%d/leaderboard/rift-hardcore-team-4?locale=%s", seasonID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3SeasonLeaderboardTeam4 returns 4 team leaderboard data for season +func (c *Client) D3SeasonLeaderboardTeam4(ctx context.Context, seasonID int) (*d3gd.Leaderboard, []byte, error) { + var ( + dat d3gd.Leaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/season/%d/leaderboard/rift-team-4?locale=%s", seasonID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3EraIndex returns an index of seasons +func (c *Client) D3EraIndex(ctx context.Context) (*d3gd.EraIndex, []byte, error) { + var ( + dat d3gd.EraIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/era/?locale=%s", c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3Era returns season data +func (c *Client) D3Era(ctx context.Context, eraID int) (*d3gd.Era, []byte, error) { + var ( + dat d3gd.Era + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/era/%d?locale=%s", eraID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3EraLeaderboardHardcoreBarbarian returns hardcore barbarian leaderboard data for season +func (c *Client) D3EraLeaderboardHardcoreBarbarian(ctx context.Context, eraID int) (*d3gd.Leaderboard, []byte, error) { + var ( + dat d3gd.Leaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/era/%d/leaderboard/rift-hardcore-barbarian?locale=%s", eraID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3EraLeaderboardBarbarian returns barbarian leaderboard data for season +func (c *Client) D3EraLeaderboardBarbarian(ctx context.Context, eraID int) (*d3gd.Leaderboard, []byte, error) { + var ( + dat d3gd.Leaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/era/%d/leaderboard/rift-barbarian?locale=%s", eraID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3EraLeaderboardHardcoreCrusader returns hardcore crusader leaderboard data for season +func (c *Client) D3EraLeaderboardHardcoreCrusader(ctx context.Context, eraID int) (*d3gd.Leaderboard, []byte, error) { + var ( + dat d3gd.Leaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/era/%d/leaderboard/rift-hardcore-crusader?locale=%s", eraID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3EraLeaderboardCrusader returns crusader leaderboard data for season +func (c *Client) D3EraLeaderboardCrusader(ctx context.Context, eraID int) (*d3gd.Leaderboard, []byte, error) { + var ( + dat d3gd.Leaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/era/%d/leaderboard/rift-crusader?locale=%s", eraID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3EraLeaderboardHardcoreDemonHunter returns hardcore demon hunter leaderboard data for season +func (c *Client) D3EraLeaderboardHardcoreDemonHunter(ctx context.Context, eraID int) (*d3gd.Leaderboard, []byte, error) { + var ( + dat d3gd.Leaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/era/%d/leaderboard/rift-hardcore-dh?locale=%s", eraID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3EraLeaderboardDemonHunter returns barbarian leaderboard data for season +func (c *Client) D3EraLeaderboardDemonHunter(ctx context.Context, eraID int) (*d3gd.Leaderboard, []byte, error) { + var ( + dat d3gd.Leaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/era/%d/leaderboard/rift-dh?locale=%s", eraID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3EraLeaderboardHardcoreMonk returns hardcore monk leaderboard data for season +func (c *Client) D3EraLeaderboardHardcoreMonk(ctx context.Context, eraID int) (*d3gd.Leaderboard, []byte, error) { + var ( + dat d3gd.Leaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/era/%d/leaderboard/rift-hardcore-monk?locale=%s", eraID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3EraLeaderboardMonk returns monk leaderboard data for season +func (c *Client) D3EraLeaderboardMonk(ctx context.Context, eraID int) (*d3gd.Leaderboard, []byte, error) { + var ( + dat d3gd.Leaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/era/%d/leaderboard/rift-monk?locale=%s", eraID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3EraLeaderboardHardcoreNecromancer returns hardcore necromancer leaderboard data for season +func (c *Client) D3EraLeaderboardHardcoreNecromancer(ctx context.Context, eraID int) (*d3gd.Leaderboard, []byte, error) { + var ( + dat d3gd.Leaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/era/%d/leaderboard/rift-hardcore-necromancer?locale=%s", eraID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3EraLeaderboardNecromancer returns necromancer leaderboard data for season +func (c *Client) D3EraLeaderboardNecromancer(ctx context.Context, eraID int) (*d3gd.Leaderboard, []byte, error) { + var ( + dat d3gd.Leaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/era/%d/leaderboard/rift-necromancer?locale=%s", eraID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3EraLeaderboardHardcoreWizard returns hardcore wizard leaderboard data for season +func (c *Client) D3EraLeaderboardHardcoreWizard(ctx context.Context, eraID int) (*d3gd.Leaderboard, []byte, error) { + var ( + dat d3gd.Leaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/era/%d/leaderboard/rift-hardcore-wizard?locale=%s", eraID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3EraLeaderboardWizard returns wizard leaderboard data for season +func (c *Client) D3EraLeaderboardWizard(ctx context.Context, eraID int) (*d3gd.Leaderboard, []byte, error) { + var ( + dat d3gd.Leaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/era/%d/leaderboard/rift-wizard?locale=%s", eraID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3EraLeaderboardHardcoreWitchDoctor returns hardcore witch doctor leaderboard data for season +func (c *Client) D3EraLeaderboardHardcoreWitchDoctor(ctx context.Context, eraID int) (*d3gd.Leaderboard, []byte, error) { + var ( + dat d3gd.Leaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/era/%d/leaderboard/rift-hardcore-wd?locale=%s", eraID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3EraLeaderboardWitchDoctor returns witch doctor leaderboard data for season +func (c *Client) D3EraLeaderboardWitchDoctor(ctx context.Context, eraID int) (*d3gd.Leaderboard, []byte, error) { + var ( + dat d3gd.Leaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/era/%d/leaderboard/rift-wd?locale=%s", eraID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3EraLeaderboardHardcoreTeam2 returns hardcore 2 team leaderboard data for season +func (c *Client) D3EraLeaderboardHardcoreTeam2(ctx context.Context, eraID int) (*d3gd.Leaderboard, []byte, error) { + var ( + dat d3gd.Leaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/era/%d/leaderboard/rift-hardcore-team-2?locale=%s", eraID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3EraLeaderboardTeam2 returns 2 team leaderboard data for season +func (c *Client) D3EraLeaderboardTeam2(ctx context.Context, eraID int) (*d3gd.Leaderboard, []byte, error) { + var ( + dat d3gd.Leaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/era/%d/leaderboard/rift-team-2?locale=%s", eraID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3EraLeaderboardHardcoreTeam3 returns hardcore 2 team leaderboard data for season +func (c *Client) D3EraLeaderboardHardcoreTeam3(ctx context.Context, eraID int) (*d3gd.Leaderboard, []byte, error) { + var ( + dat d3gd.Leaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/era/%d/leaderboard/rift-hardcore-team-3?locale=%s", eraID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3EraLeaderboardTeam3 returns 3 team leaderboard data for season +func (c *Client) D3EraLeaderboardTeam3(ctx context.Context, eraID int) (*d3gd.Leaderboard, []byte, error) { + var ( + dat d3gd.Leaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/era/%d/leaderboard/rift-team-3?locale=%s", eraID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3EraLeaderboardHardcoreTeam4 returns hardcore 4 team leaderboard data for season +func (c *Client) D3EraLeaderboardHardcoreTeam4(ctx context.Context, eraID int) (*d3gd.Leaderboard, []byte, error) { + var ( + dat d3gd.Leaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/era/%d/leaderboard/rift-hardcore-team-4?locale=%s", eraID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// D3EraLeaderboardTeam4 returns 4 team leaderboard data for season +func (c *Client) D3EraLeaderboardTeam4(ctx context.Context, eraID int) (*d3gd.Leaderboard, []byte, error) { + var ( + dat d3gd.Leaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/d3/era/%d/leaderboard/rift-team-4?locale=%s", eraID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} diff --git a/v2/d3gd/d3.go b/v2/d3gd/d3.go new file mode 100644 index 0000000..75eb2d7 --- /dev/null +++ b/v2/d3gd/d3.go @@ -0,0 +1,150 @@ +package d3gd + +// SeasonIndex structure +type SeasonIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Season []struct { + Href string `json:"href"` + } `json:"season"` + CurrentSeason int `json:"current_season"` + ServiceCurrentSeason int `json:"service_current_season"` + ServiceSeasonState string `json:"service_season_state"` + LastUpdateTime string `json:"last_update_time"` + GeneratedBy string `json:"generated_by"` +} + +// Season structure +type Season struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Leaderboard []struct { + Ladder struct { + Href string `json:"href"` + } `json:"ladder"` + TeamSize int `json:"team_size,omitempty"` + Hardcore bool `json:"hardcore,omitempty"` + HeroClassString string `json:"hero_class_string,omitempty"` + } `json:"leaderboard"` + SeasonID int `json:"season_id"` + LastUpdateTime string `json:"last_update_time"` + GeneratedBy string `json:"generated_by"` +} + +// Leaderboard structure +type Leaderboard struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Row []struct { + Player []struct { + Key string `json:"key"` + AccountID int `json:"accountId"` + Data []struct { + ID string `json:"id"` + String string `json:"string,omitempty"` + Number int `json:"number,omitempty"` + } `json:"data"` + } `json:"player"` + Order int `json:"order"` + Data []struct { + ID string `json:"id"` + Number int `json:"number,omitempty"` + Timestamp int64 `json:"timestamp,omitempty"` + String string `json:"string,omitempty"` + } `json:"data"` + } `json:"row"` + Key string `json:"key"` + Title string `json:"title"` + Column []struct { + ID string `json:"id"` + Hidden bool `json:"hidden"` + Order int `json:"order,omitempty"` + Label string `json:"label"` + Type string `json:"type"` + } `json:"column"` + LastUpdateTime string `json:"last_update_time"` + GeneratedBy string `json:"generated_by"` + AchievementPoints bool `json:"achievement_points"` + Season int `json:"season"` +} + +// Title structure +type Title struct { + EnUS string `json:"en_US"` + EsMX string `json:"es_MX"` + PtBR string `json:"pt_BR"` + DeDE string `json:"de_DE"` + EnGB string `json:"en_GB"` + EsES string `json:"es_ES"` + FrFR string `json:"fr_FR"` + ItIT string `json:"it_IT"` + PlPL string `json:"pl_PL"` + PtPT string `json:"pt_PT"` + RuRU string `json:"ru_RU"` + KoKR string `json:"ko_KR"` + ZhTW string `json:"zh_TW"` + ZhCN string `json:"zh_CN"` +} + +// Label structure +type Label struct { + EnUS string `json:"en_US"` + EsMX string `json:"es_MX"` + PtBR string `json:"pt_BR"` + DeDE string `json:"de_DE"` + EnGB string `json:"en_GB"` + EsES string `json:"es_ES"` + FrFR string `json:"fr_FR"` + ItIT string `json:"it_IT"` + PlPL string `json:"pl_PL"` + PtPT string `json:"pt_PT"` + RuRU string `json:"ru_RU"` + KoKR string `json:"ko_KR"` + ZhTW string `json:"zh_TW"` + ZhCN string `json:"zh_CN"` +} + +// EraIndex structure +type EraIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Era []struct { + Href string `json:"href"` + } `json:"era"` + CurrentEra int `json:"current_era"` + LastUpdateTime string `json:"last_update_time"` + GeneratedBy string `json:"generated_by"` +} + +// Era structure +type Era struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Leaderboard []struct { + TeamSize int `json:"team_size"` + Ladder struct { + Href string `json:"href"` + } `json:"ladder"` + Hardcore bool `json:"hardcore,omitempty"` + HeroClassString string `json:"hero_class_string,omitempty"` + } `json:"leaderboard"` + EraID int `json:"era_id"` + EraStartDate int `json:"era_start_date"` + LastUpdateTime string `json:"last_update_time"` + GeneratedBy string `json:"generated_by"` +} diff --git a/v2/d3gd/d3gd.go b/v2/d3gd/d3gd.go new file mode 100644 index 0000000..c431c9e --- /dev/null +++ b/v2/d3gd/d3gd.go @@ -0,0 +1,2 @@ +// Package d3gd contains types for the Diablo 3 Game Data APIs +package d3gd diff --git a/v2/d3gd_test.go b/v2/d3gd_test.go new file mode 100644 index 0000000..5b17573 --- /dev/null +++ b/v2/d3gd_test.go @@ -0,0 +1,553 @@ +package blizzard + +import ( + "context" + "fmt" + "testing" +) + +func TestD3SeasonIndex(t *testing.T) { + dat, _, err := c.D3SeasonIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3Season(t *testing.T) { + dat, _, err := c.D3Season(context.Background(), 15) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3SeasonLeaderboard(t *testing.T) { + dat, _, err := c.D3SeasonLeaderboard(context.Background(), 15, "74987248527082") + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3SeasonLeaderboardAchievementPoints(t *testing.T) { + dat, _, err := c.D3SeasonLeaderboardAchievementPoints(context.Background(), 15) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3SeasonLeaderboardHardcoreBarbarian(t *testing.T) { + dat, _, err := c.D3SeasonLeaderboardHardcoreBarbarian(context.Background(), 15) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3SeasonLeaderboardBarbarian(t *testing.T) { + dat, _, err := c.D3SeasonLeaderboardBarbarian(context.Background(), 15) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3SeasonLeaderboardHardcoreCrusader(t *testing.T) { + dat, _, err := c.D3SeasonLeaderboardHardcoreCrusader(context.Background(), 15) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3SeasonLeaderboardCrusader(t *testing.T) { + dat, _, err := c.D3SeasonLeaderboardCrusader(context.Background(), 15) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3SeasonLeaderboardHardcoreDemonHunter(t *testing.T) { + dat, _, err := c.D3SeasonLeaderboardHardcoreDemonHunter(context.Background(), 15) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3SeasonLeaderboardDemonHunter(t *testing.T) { + dat, _, err := c.D3SeasonLeaderboardDemonHunter(context.Background(), 15) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3SeasonLeaderboardHardcoreMonk(t *testing.T) { + dat, _, err := c.D3SeasonLeaderboardHardcoreMonk(context.Background(), 15) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3SeasonLeaderboardMonk(t *testing.T) { + dat, _, err := c.D3SeasonLeaderboardMonk(context.Background(), 15) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3SeasonLeaderboardHardcoreNecromancer(t *testing.T) { + dat, _, err := c.D3SeasonLeaderboardHardcoreNecromancer(context.Background(), 15) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3SeasonLeaderboardNecromancer(t *testing.T) { + dat, _, err := c.D3SeasonLeaderboardNecromancer(context.Background(), 15) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3SeasonLeaderboardHardcoreWizard(t *testing.T) { + dat, _, err := c.D3SeasonLeaderboardHardcoreWizard(context.Background(), 15) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3SeasonLeaderboardWizard(t *testing.T) { + dat, _, err := c.D3SeasonLeaderboardWizard(context.Background(), 15) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} +func TestD3SeasonLeaderboardHardcoreWitchDoctor(t *testing.T) { + dat, _, err := c.D3SeasonLeaderboardHardcoreWitchDoctor(context.Background(), 15) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3SeasonLeaderboardWitchDoctor(t *testing.T) { + dat, _, err := c.D3SeasonLeaderboardWitchDoctor(context.Background(), 15) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3SeasonLeaderboardHardcoreTeam2(t *testing.T) { + dat, _, err := c.D3SeasonLeaderboardHardcoreTeam2(context.Background(), 15) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3SeasonLeaderboardTeam2(t *testing.T) { + dat, _, err := c.D3SeasonLeaderboardTeam2(context.Background(), 15) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} +func TestD3SeasonLeaderboardHardcoreTeam3(t *testing.T) { + dat, _, err := c.D3SeasonLeaderboardHardcoreTeam3(context.Background(), 15) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3SeasonLeaderboardTeam3(t *testing.T) { + dat, _, err := c.D3SeasonLeaderboardTeam3(context.Background(), 15) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} +func TestD3SeasonLeaderboardHardcoreTeam4(t *testing.T) { + dat, _, err := c.D3SeasonLeaderboardHardcoreTeam4(context.Background(), 15) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3SeasonLeaderboardTeam4(t *testing.T) { + dat, _, err := c.D3SeasonLeaderboardTeam4(context.Background(), 15) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3EraIndex(t *testing.T) { + dat, _, err := c.D3EraIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3Era(t *testing.T) { + dat, _, err := c.D3Era(context.Background(), 10) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3EraLeaderboardHardcoreBarbarian(t *testing.T) { + dat, _, err := c.D3EraLeaderboardHardcoreBarbarian(context.Background(), 10) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3EraLeaderboardBarbarian(t *testing.T) { + dat, _, err := c.D3EraLeaderboardBarbarian(context.Background(), 10) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3EraLeaderboardHardcoreCrusader(t *testing.T) { + dat, _, err := c.D3EraLeaderboardHardcoreCrusader(context.Background(), 10) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3EraLeaderboardCrusader(t *testing.T) { + dat, _, err := c.D3EraLeaderboardCrusader(context.Background(), 10) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3EraLeaderboardHardcoreDemonHunter(t *testing.T) { + dat, _, err := c.D3EraLeaderboardHardcoreDemonHunter(context.Background(), 10) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3EraLeaderboardDemonHunter(t *testing.T) { + dat, _, err := c.D3EraLeaderboardDemonHunter(context.Background(), 10) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3EraLeaderboardHardcoreMonk(t *testing.T) { + dat, _, err := c.D3EraLeaderboardHardcoreMonk(context.Background(), 10) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3EraLeaderboardMonk(t *testing.T) { + dat, _, err := c.D3EraLeaderboardMonk(context.Background(), 10) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3EraLeaderboardHardcoreNecromancer(t *testing.T) { + dat, _, err := c.D3EraLeaderboardHardcoreNecromancer(context.Background(), 10) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3EraLeaderboardNecromancer(t *testing.T) { + dat, _, err := c.D3EraLeaderboardNecromancer(context.Background(), 10) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3EraLeaderboardHardcoreWizard(t *testing.T) { + dat, _, err := c.D3EraLeaderboardHardcoreWizard(context.Background(), 10) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3EraLeaderboardWizard(t *testing.T) { + dat, _, err := c.D3EraLeaderboardWizard(context.Background(), 10) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} +func TestD3EraLeaderboardHardcoreWitchDoctor(t *testing.T) { + dat, _, err := c.D3EraLeaderboardHardcoreWitchDoctor(context.Background(), 10) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3EraLeaderboardWitchDoctor(t *testing.T) { + dat, _, err := c.D3EraLeaderboardWitchDoctor(context.Background(), 10) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3EraLeaderboardHardcoreTeam2(t *testing.T) { + dat, _, err := c.D3EraLeaderboardHardcoreTeam2(context.Background(), 10) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3EraLeaderboardTeam2(t *testing.T) { + dat, _, err := c.D3EraLeaderboardTeam2(context.Background(), 10) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} +func TestD3EraLeaderboardHardcoreTeam3(t *testing.T) { + dat, _, err := c.D3EraLeaderboardHardcoreTeam3(context.Background(), 10) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3EraLeaderboardTeam3(t *testing.T) { + dat, _, err := c.D3EraLeaderboardTeam3(context.Background(), 10) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} +func TestD3EraLeaderboardHardcoreTeam4(t *testing.T) { + dat, _, err := c.D3EraLeaderboardHardcoreTeam4(context.Background(), 10) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestD3EraLeaderboardTeam4(t *testing.T) { + dat, _, err := c.D3EraLeaderboardTeam4(context.Background(), 10) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} diff --git a/v2/hsgd.go b/v2/hsgd.go new file mode 100644 index 0000000..c2ffc87 --- /dev/null +++ b/v2/hsgd.go @@ -0,0 +1,504 @@ +package blizzard + +import ( + "context" + "encoding/json" + "fmt" + "strings" + + "github.com/FuzzyStatic/blizzard/v2/hsgd" +) + +// HSCardsSearch returns an up-to-date list of all cards matching the search criteria. +// For more information about the search parameters, see the Card Search Guide (https://develop.battle.net/documentation/hearthstone/guides/card-search). +func (c *Client) HSCardsSearch(ctx context.Context) (*hsgd.CardSearch, []byte, error) { + var ( + dat hsgd.CardSearch + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/hearthstone/cards?locale=%s", c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// HSDetailedCardsSearch returns an up-to-date list of all cards matching the search criteria. +// Input values left blank, 0, or nil will return all values for the type. +// For more information about the search parameters, see the Card Search Guide (https://develop.battle.net/documentation/hearthstone/guides/card-search). +func (c *Client) HSDetailedCardsSearch(ctx context.Context, setSlug, classSlug, raritySlug, typeSlug, minionTypeSlug, keywordSlug, textFilter string, + manaCost, attack, health []int, page, pageSize int, + collectiblility hsgd.Collectibility, sort hsgd.Sort, order hsgd.Order) (*hsgd.CardSearch, []byte, error) { + var ( + dat hsgd.CardSearch + url string + b []byte + err error + ) + + url = c.apiURL + fmt.Sprintf("/hearthstone/cards?locale=%s", c.locale) + + if setSlug != "" { + url = url + fmt.Sprintf("&set=%s", setSlug) + } + + if classSlug != "" { + url = url + fmt.Sprintf("&class=%s", classSlug) + } + + if raritySlug != "" { + url = url + fmt.Sprintf("&rarity=%s", raritySlug) + } + + if typeSlug != "" { + url = url + fmt.Sprintf("&type=%s", typeSlug) + } + + if minionTypeSlug != "" { + url = url + fmt.Sprintf("&minionType=%s", minionTypeSlug) + } + + if keywordSlug != "" { + url = url + fmt.Sprintf("&keyword=%s", keywordSlug) + } + + if textFilter != "" { + url = url + fmt.Sprintf("&textFilter=%s", textFilter) + } + + if manaCost != nil { + url = url + fmt.Sprintf("&manaCost=%s", strings.Trim(strings.Join(strings.Fields(fmt.Sprint(manaCost)), ","), "[]")) + } + + if attack != nil { + url = url + fmt.Sprintf("&attack=%s", strings.Trim(strings.Join(strings.Fields(fmt.Sprint(attack)), ","), "[]")) + } + + if health != nil { + url = url + fmt.Sprintf("&health=%s", strings.Trim(strings.Join(strings.Fields(fmt.Sprint(health)), ","), "[]")) + } + + if page != 0 { + url = url + fmt.Sprintf("&page=%d", page) + } + + if pageSize != 0 { + url = url + fmt.Sprintf("&pageSize=%d", pageSize) + } + + url = url + fmt.Sprintf("&collectible=%s", collectiblility) + url = url + fmt.Sprintf("&sort=%s", sort) + url = url + fmt.Sprintf("&order=%s", order) + + b, err = c.getURLBody(ctx, url, "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// HSBattlegroundsCardsSearch returns an up-to-date list of all cards matching the search criteria for the specified game mode. +// Input values left blank, 0, or nil will return all values for the type. +// For more information about the search parameters, see the Card Search Guide (https://develop.battle.net/documentation/hearthstone/guides/card-search). +func (c *Client) HSBattlegroundsCardsSearch(ctx context.Context, raritySlug, typeSlug, minionTypeSlug, keywordSlug, textFilter string, + manaCost, attack, health []int, page, pageSize int, + tier []hsgd.Tier, collectiblility hsgd.Collectibility, sort hsgd.Sort, order hsgd.Order) (*hsgd.CardSearch, []byte, error) { + var ( + dat hsgd.CardSearch + url string + b []byte + err error + ) + + url = c.apiURL + fmt.Sprintf("/hearthstone/cards?locale=%s&gameMode=%s", c.locale, hsgd.GameModeBattlegrounds) + + if raritySlug != "" { + url = url + fmt.Sprintf("&rarity=%s", raritySlug) + } + + if typeSlug != "" { + url = url + fmt.Sprintf("&type=%s", typeSlug) + } + + if minionTypeSlug != "" { + url = url + fmt.Sprintf("&minionType=%s", minionTypeSlug) + } + + if keywordSlug != "" { + url = url + fmt.Sprintf("&keyword=%s", keywordSlug) + } + + if textFilter != "" { + url = url + fmt.Sprintf("&textFilter=%s", textFilter) + } + + if manaCost != nil { + url = url + fmt.Sprintf("&manaCost=%s", strings.Trim(strings.Join(strings.Fields(fmt.Sprint(manaCost)), ","), "[]")) + } + + if attack != nil { + url = url + fmt.Sprintf("&attack=%s", strings.Trim(strings.Join(strings.Fields(fmt.Sprint(attack)), ","), "[]")) + } + + if health != nil { + url = url + fmt.Sprintf("&health=%s", strings.Trim(strings.Join(strings.Fields(fmt.Sprint(health)), ","), "[]")) + } + + if page != 0 { + url = url + fmt.Sprintf("&page=%d", page) + } + + if pageSize != 0 { + url = url + fmt.Sprintf("&pageSize=%d", pageSize) + } + + if health != nil { + url = url + fmt.Sprintf("&tier=%s", strings.Trim(strings.Join(strings.Fields(fmt.Sprint(tier)), ","), "[]")) + } + + url = url + fmt.Sprintf("&collectible=%s", collectiblility) + url = url + fmt.Sprintf("&sort=%s", sort) + url = url + fmt.Sprintf("&order=%s", order) + + b, err = c.getURLBody(ctx, url, "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// HSCardByIDOrSlug returns card by ID or slug. +// For more information about the search parameters, see the Card Search Guide (https://develop.battle.net/documentation/hearthstone/guides/card-search). +func (c *Client) HSCardByIDOrSlug(ctx context.Context, idOrSlug string, gameMode hsgd.GameMode) (*hsgd.Card, []byte, error) { + var ( + dat hsgd.Card + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/hearthstone/cards/%s?locale=%s&gameMode=%s", idOrSlug, c.locale, gameMode), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// HSCardBackSearchAllLocales returns an up-to-date list of all card backs matching the search criteria for all locales. +// Input values left blank, 0, or nil will return all values for the type. +// For more information about the search parameters, see the Card Search Guide (https://develop.battle.net/documentation/hearthstone/guides/card-search). +func (c *Client) HSCardBackSearchAllLocales(ctx context.Context, cardBackCategory hsgd.CardBackCategory, textFilter string, sort hsgd.Sort, order hsgd.Order) (*hsgd.CardBackSearchAllLocales, []byte, error) { + var ( + dat hsgd.CardBackSearchAllLocales + url string + b []byte + err error + ) + + url = c.apiURL + "/hearthstone/cardbacks" + + if cardBackCategory != "" { + url = url + fmt.Sprintf("?cardBackCategory=%s", cardBackCategory) + } + + if textFilter != "" { + url = url + fmt.Sprintf("&type=%s", textFilter) + } + + url = url + fmt.Sprintf("&sort=%s", sort) + url = url + fmt.Sprintf("&order=%s", order) + + b, err = c.getURLBody(ctx, url, "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// HSCardBackSearch returns an up-to-date list of all card backs matching the search criteria. +// Input values left blank, 0, or nil will return all values for the type. +// For more information about the search parameters, see the Card Search Guide (https://develop.battle.net/documentation/hearthstone/guides/card-search). +func (c *Client) HSCardBackSearch(ctx context.Context, cardBackCategory hsgd.CardBackCategory, textFilter string, sort hsgd.Sort, order hsgd.Order) (*hsgd.CardBackSearch, []byte, error) { + var ( + dat hsgd.CardBackSearch + url string + b []byte + err error + ) + + url = c.apiURL + fmt.Sprintf("/hearthstone/cardbacks?locale=%s", c.locale) + + if cardBackCategory != "" { + url = url + fmt.Sprintf("?cardBackCategory=%s", cardBackCategory) + } + + if textFilter != "" { + url = url + fmt.Sprintf("&type=%s", textFilter) + } + + url = url + fmt.Sprintf("&sort=%s", sort) + url = url + fmt.Sprintf("&order=%s", order) + + b, err = c.getURLBody(ctx, url, "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// HSCardBackByIDOrSlug returns a specific card back by using card back ID or slug. +func (c *Client) HSCardBackByIDOrSlug(ctx context.Context, idOrSlug string) (*hsgd.CardBack, []byte, error) { + var ( + dat hsgd.CardBack + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/hearthstone/cardbacks/%s?locale=%s", idOrSlug, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// HSDeck Finds a deck by its deck code. +// For more information, see the Hearthstone Guide. +func (c *Client) HSDeck(ctx context.Context, deckCode string) (*hsgd.Deck, []byte, error) { + var ( + dat hsgd.Deck + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/hearthstone/deck/%s?locale=%s", deckCode, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// HSMetadata returns information about the categorization of cards. +// Metadata includes the card set, set group (for example, Standard or Year of the Dragon), rarity, class, card type, minion type, and keywords. +// For more information, see the Hearthstone Guide. +func (c *Client) HSMetadata(ctx context.Context) (*hsgd.Metadata, []byte, error) { + var ( + dat hsgd.Metadata + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/hearthstone/metadata?locale=%s", c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// HSMetadataSets returns information about set metadata. +// For more information, see the Hearthstone Guide. +func (c *Client) HSMetadataSets(ctx context.Context) (*[]hsgd.Set, []byte, error) { + var ( + dat []hsgd.Set + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/hearthstone/metadata/%s?locale=%s", hsgd.MetadataTypeSets, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// HSMetadataSetGroups returns information about set group metadata. +// For more information, see the Hearthstone Guide. +func (c *Client) HSMetadataSetGroups(ctx context.Context) (*[]hsgd.SetGroup, []byte, error) { + var ( + dat []hsgd.SetGroup + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/hearthstone/metadata/%s?locale=%s", hsgd.MetadataTypeSetGroups, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// HSMetadataTypes returns information about type metadata. +// For more information, see the Hearthstone Guide. +func (c *Client) HSMetadataTypes(ctx context.Context) (*[]hsgd.Type, []byte, error) { + var ( + dat []hsgd.Type + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/hearthstone/metadata/%s?locale=%s", hsgd.MetadataTypeTypes, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// HSMetadataRarities returns information about rarity metadata. +// For more information, see the Hearthstone Guide. +func (c *Client) HSMetadataRarities(ctx context.Context) (*[]hsgd.Rarity, []byte, error) { + var ( + dat []hsgd.Rarity + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/hearthstone/metadata/%s?locale=%s", hsgd.MetadataTypeRarities, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// HSMetadataClasses returns information about class metadata. +// For more information, see the Hearthstone Guide. +func (c *Client) HSMetadataClasses(ctx context.Context) (*[]hsgd.Class, []byte, error) { + var ( + dat []hsgd.Class + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/hearthstone/metadata/%s?locale=%s", hsgd.MetadataTypeClasses, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// HSMetadataMinionTypes returns information about minion type metadata. +// For more information, see the Hearthstone Guide. +func (c *Client) HSMetadataMinionTypes(ctx context.Context) (*[]hsgd.MinionType, []byte, error) { + var ( + dat []hsgd.MinionType + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/hearthstone/metadata/%s?locale=%s", hsgd.MetadataTypeMinionTypes, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// HSMetadataKeywords returns information about keyword metadata. +// For more information, see the Hearthstone Guide. +func (c *Client) HSMetadataKeywords(ctx context.Context) (*[]hsgd.Keyword, []byte, error) { + var ( + dat []hsgd.Keyword + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/hearthstone/metadata/%s?locale=%s", hsgd.MetadataTypeKeywords, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} diff --git a/v2/hsgd/cardBacks.go b/v2/hsgd/cardBacks.go new file mode 100644 index 0000000..021ff90 --- /dev/null +++ b/v2/hsgd/cardBacks.go @@ -0,0 +1,64 @@ +package hsgd + +// CardBackSearchAllLocales structure +type CardBackSearchAllLocales struct { + CardBacks []struct { + ID int `json:"id"` + SortCategory int `json:"sortCategory"` + Text struct { + DeDE string `json:"de_DE"` + EnUS string `json:"en_US"` + EsES string `json:"es_ES"` + EsMX string `json:"es_MX"` + FrFR string `json:"fr_FR"` + ItIT string `json:"it_IT"` + JaJP string `json:"ja_JP"` + KoKR string `json:"ko_KR"` + PlPL string `json:"pl_PL"` + PtBR string `json:"pt_BR"` + RuRU string `json:"ru_RU"` + ThTH string `json:"th_TH"` + ZhCN string `json:"zh_CN"` + ZhTW string `json:"zh_TW"` + } `json:"text"` + Name struct { + DeDE string `json:"de_DE"` + EnUS string `json:"en_US"` + EsES string `json:"es_ES"` + EsMX string `json:"es_MX"` + FrFR string `json:"fr_FR"` + ItIT string `json:"it_IT"` + JaJP string `json:"ja_JP"` + KoKR string `json:"ko_KR"` + PlPL string `json:"pl_PL"` + PtBR string `json:"pt_BR"` + RuRU string `json:"ru_RU"` + ThTH string `json:"th_TH"` + ZhCN string `json:"zh_CN"` + ZhTW string `json:"zh_TW"` + } `json:"name"` + Image string `json:"image"` + Slug string `json:"slug"` + } `json:"cardBacks"` + CardCount int `json:"cardCount"` + PageCount int `json:"pageCount"` + Page int `json:"page"` +} + +// CardBackSearch structure +type CardBackSearch struct { + CardBacks []CardBack `json:"cardBacks"` + CardCount int `json:"cardCount"` + PageCount int `json:"pageCount"` + Page int `json:"page"` +} + +// CardBack structure +type CardBack struct { + ID int `json:"id"` + SortCategory int `json:"sortCategory"` + Text string `json:"text"` + Name string `json:"name"` + Image string `json:"image"` + Slug string `json:"slug"` +} diff --git a/v2/hsgd/cardSearch.go b/v2/hsgd/cardSearch.go new file mode 100644 index 0000000..49d6f9c --- /dev/null +++ b/v2/hsgd/cardSearch.go @@ -0,0 +1,40 @@ +package hsgd + +// Card structure +type Card struct { + ID int `json:"id"` + Collectible int `json:"collectible"` + Slug string `json:"slug"` + ClassID int `json:"classId"` + MultiClassIds []int `json:"multiClassIds"` + CardTypeID int `json:"cardTypeId"` + CardSetID int `json:"cardSetId"` + RarityID int `json:"rarityId"` + ArtistName string `json:"artistName"` + Health int `json:"health"` + Attack int `json:"attack"` + ManaCost int `json:"manaCost"` + Name string `json:"name"` + Text string `json:"text"` + Image string `json:"image"` + ImageGold string `json:"imageGold"` + FlavorText string `json:"flavorText"` + CropImage string `json:"cropImage"` + ChildIds []int `json:"childIds"` + KeywordIds []int `json:"keywordIds"` + Battlegrounds struct { + Tier int `json:"tier"` + Hero bool `json:"hero"` + UpgradeID int `json:"upgradeId"` + Image string `json:"image"` + ImageGold string `json:"imageGold"` + } `json:"battlegrounds,omitempty"` +} + +// CardSearch structure +type CardSearch struct { + Cards []Card `json:"cards"` + CardCount int `json:"cardCount"` + PageCount int `json:"pageCount"` + Page int `json:"page"` +} diff --git a/v2/hsgd/decks.go b/v2/hsgd/decks.go new file mode 100644 index 0000000..c4fd3d5 --- /dev/null +++ b/v2/hsgd/decks.go @@ -0,0 +1,76 @@ +package hsgd + +// Deck structure +type Deck struct { + Version int `json:"version"` + Format string `json:"format"` + Hero struct { + ID int `json:"id"` + Collectible int `json:"collectible"` + Slug string `json:"slug"` + ClassID int `json:"classId"` + MultiClassIds []int `json:"multiClassIds"` + CardTypeID int `json:"cardTypeId"` + CardSetID int `json:"cardSetId"` + RarityID int `json:"rarityId"` + ArtistName string `json:"artistName"` + Health int `json:"health"` + ManaCost int `json:"manaCost"` + Name string `json:"name"` + Text string `json:"text"` + Image string `json:"image"` + ImageGold string `json:"imageGold"` + FlavorText string `json:"flavorText"` + CropImage string `json:"cropImage"` + ChildIds []int `json:"childIds"` + } `json:"hero"` + HeroPower struct { + ID int `json:"id"` + Collectible int `json:"collectible"` + Slug string `json:"slug"` + ClassID int `json:"classId"` + MultiClassIds []int `json:"multiClassIds"` + CardTypeID int `json:"cardTypeId"` + CardSetID int `json:"cardSetId"` + RarityID int `json:"rarityId"` + ArtistName string `json:"artistName"` + ManaCost int `json:"manaCost"` + Name string `json:"name"` + Text string `json:"text"` + Image string `json:"image"` + ImageGold string `json:"imageGold"` + FlavorText string `json:"flavorText"` + CropImage string `json:"cropImage"` + } `json:"heroPower"` + Class struct { + ID int `json:"id"` + Slug string `json:"slug"` + Name string `json:"name"` + } `json:"class"` + Cards []struct { + ID int `json:"id"` + Collectible int `json:"collectible"` + Slug string `json:"slug"` + ClassID int `json:"classId"` + MultiClassIds []int `json:"multiClassIds"` + CardTypeID int `json:"cardTypeId"` + CardSetID int `json:"cardSetId"` + RarityID int `json:"rarityId"` + ArtistName string `json:"artistName"` + Health int `json:"health,omitempty"` + Attack int `json:"attack,omitempty"` + ManaCost int `json:"manaCost"` + Name string `json:"name"` + Text string `json:"text"` + Image string `json:"image"` + ImageGold string `json:"imageGold"` + FlavorText string `json:"flavorText"` + CropImage string `json:"cropImage"` + KeywordIds []int `json:"keywordIds,omitempty"` + Armor int `json:"armor,omitempty"` + ChildIds []int `json:"childIds,omitempty"` + MinionTypeID int `json:"minionTypeId,omitempty"` + Durability int `json:"durability,omitempty"` + } `json:"cards"` + CardCount int `json:"cardCount"` +} diff --git a/v2/hsgd/hsgd.go b/v2/hsgd/hsgd.go new file mode 100644 index 0000000..282d47b --- /dev/null +++ b/v2/hsgd/hsgd.go @@ -0,0 +1,117 @@ +// Package hsgd contains types for the Hearthstone Game Data APIs +package hsgd + +// Collectibility type +type Collectibility string + +func (collectibility Collectibility) String() string { + return string(collectibility) +} + +// Collectibility constants +const ( + CollectibilityCollectible = Collectibility("1") + CollectibilityUncollectible = Collectibility("0") + CollectibilityBoth = Collectibility("0,1") +) + +// Sort - manaCost, attack, health, or name +type Sort string + +func (sort Sort) String() string { + return string(sort) +} + +// Sort constants +const ( + SortManaCost = Sort("manaCost") + SortAttack = Sort("attack") + SortHealth = Sort("health") + SortName = Sort("name") +) + +// Order - asc or desc +type Order string + +func (order Order) String() string { + return string(order) +} + +// Order constants +const ( + OrderAsc = Order("asc") + OrderDesc = Order("desc") +) + +// MetadataType - sets, setGroups, types, rarities, classes, minionTypes, and keywords +type MetadataType string + +func (metadataType MetadataType) String() string { + return string(metadataType) +} + +// MetadataType constants +const ( + MetadataTypeSets = MetadataType("sets") + MetadataTypeSetGroups = MetadataType("setGroups") + MetadataTypeTypes = MetadataType("types") + MetadataTypeRarities = MetadataType("rarities") + MetadataTypeClasses = MetadataType("classes") + MetadataTypeMinionTypes = MetadataType("minionTypes") + MetadataTypeKeywords = MetadataType("keywords") +) + +// GameMode - constructed or battlegrounds +type GameMode string + +func (gameMode GameMode) String() string { + return string(gameMode) +} + +// GameMode constants +const ( + GameModeConstructed = GameMode("constructed") + GameModeBattlegrounds = GameMode("battlegrounds") +) + +// Tier - hero, 1, 2, 3, 4, 5, or 6 +type Tier string + +func (tier Tier) String() string { + return string(tier) +} + +// Tier constants +const ( + TierHero = Tier("hero") + Tier1 = Tier("1") + Tier2 = Tier("2") + Tier3 = Tier("3") + Tier4 = Tier("4") + Tier5 = Tier("5") + Tier6 = Tier("6") +) + +// CardBackCategory - base, achieve, fireside, heroes, season, legend, esports, game_license, promotion, pre_purchase, blizzard, golden, events +type CardBackCategory string + +func (cardBackCategory CardBackCategory) String() string { + return string(cardBackCategory) +} + +// CardBackCategory constants +const ( + CardBackCategoryBase = CardBackCategory("base") + CardBackCategoryAchieve = CardBackCategory("achieve") + CardBackCategoryFireside = CardBackCategory("fireside") + CardBackCategoryHeroes = CardBackCategory("heroes") + CardBackCategorySeason = CardBackCategory("season") + CardBackCategoryLegend = CardBackCategory("legend") + CardBackCategoryEsports = CardBackCategory("esports") + CardBackCategoryGameLicense = CardBackCategory("game_license") + CardBackCategoryPromotion = CardBackCategory("promotion") + CardBackCategoryPrePurchase = CardBackCategory("pre_purchase") + CardBackCategoryBlizzard = CardBackCategory("blizzard") + CardBackCategoryGolden = CardBackCategory("golden") + CardBackCategoryEvents = CardBackCategory("events") +) diff --git a/v2/hsgd/metadata.go b/v2/hsgd/metadata.go new file mode 100644 index 0000000..0bc48b4 --- /dev/null +++ b/v2/hsgd/metadata.go @@ -0,0 +1,77 @@ +package hsgd + +// Metadata structure +type Metadata struct { + Sets []Set `json:"sets"` + SetGroups []SetGroup `json:"setGroups"` + Types []Type `json:"types"` + Rarities []Rarity `json:"rarities"` + Classes []Class `json:"classes"` + MinionTypes []MinionType `json:"minionTypes"` + Keywords []Keyword `json:"keywords"` + FilterableFields []string `json:"filterableFields"` + NumericFields []string `json:"numericFields"` +} + +// Set structure +type Set struct { + ID int `json:"id"` + Slug string `json:"slug"` + ReleaseDate string `json:"releaseDate,omitempty"` + Name string `json:"name"` + CollectibleCount int `json:"collectibleCount"` + CollectibleRevealedCount int `json:"collectibleRevealedCount"` + NonCollectibleCount int `json:"nonCollectibleCount"` + NonCollectibleRevealedCount int `json:"nonCollectibleRevealedCount"` + Type string `json:"type,omitempty"` +} + +// SetGroup structure +type SetGroup struct { + Slug string `json:"slug"` + Year int `json:"year,omitempty"` + CardSets []string `json:"cardSets"` + Name string `json:"name"` + Standard bool `json:"standard,omitempty"` + Icon string `json:"icon,omitempty"` + YearRange string `json:"yearRange,omitempty"` +} + +// Type structure +type Type struct { + ID int `json:"id"` + Slug string `json:"slug"` + Name string `json:"name"` +} + +// Rarity structure +type Rarity struct { + ID int `json:"id"` + Slug string `json:"slug"` + CraftingCost []int `json:"craftingCost"` + DustValue []int `json:"dustValue"` + Name string `json:"name"` +} + +// Class structure +type Class struct { + ID interface{} `json:"id"` + Slug string `json:"slug"` + Name string `json:"name"` +} + +// MinionType structure +type MinionType struct { + ID int `json:"id"` + Slug string `json:"slug"` + Name string `json:"name"` +} + +// Keyword structure +type Keyword struct { + ID int `json:"id"` + Slug string `json:"slug"` + Name string `json:"name"` + RefText string `json:"refText"` + Text string `json:"text"` +} diff --git a/v2/hsgd_test.go b/v2/hsgd_test.go new file mode 100644 index 0000000..e2d9033 --- /dev/null +++ b/v2/hsgd_test.go @@ -0,0 +1,211 @@ +package blizzard + +import ( + "context" + "fmt" + "testing" + + "github.com/FuzzyStatic/blizzard/v2/hsgd" +) + +func TestHSCardsSearch(t *testing.T) { + dat, _, err := c.HSCardsSearch(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestHSDetailedCardsSearch(t *testing.T) { + dat, _, err := c.HSDetailedCardsSearch( + context.Background(), + "rise-of-shadows", "mage", "legendary", "minion", "dragon", "battlecry", "kalecgos", + []int{10}, []int{4}, []int{10}, 1, 5, + hsgd.CollectibilityCollectible, hsgd.SortName, hsgd.OrderAsc, + ) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestHSBattlegroundsCardsSearch(t *testing.T) { + dat, _, err := c.HSBattlegroundsCardsSearch( + context.Background(), + "", "", "", "", "", + []int{}, []int{}, []int{}, 0, 0, + []hsgd.Tier{hsgd.TierHero, hsgd.Tier3}, "", "", "", + ) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestHSCardByIDOrSlug(t *testing.T) { + dat, _, err := c.HSCardByIDOrSlug(context.Background(), "52119-arch-villain-rafaam", hsgd.GameModeConstructed) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestHSCardBackSearchAllLocales(t *testing.T) { + dat, _, err := c.HSCardBackSearchAllLocales(context.Background(), hsgd.CardBackCategoryBase, "", hsgd.SortName, hsgd.OrderAsc) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestHSCardBackByIDOrSlug(t *testing.T) { + dat, _, err := c.HSCardBackByIDOrSlug(context.Background(), "155-pizza-stone") + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestHSCardBackSearch(t *testing.T) { + dat, _, err := c.HSCardBackSearch(context.Background(), "", "", hsgd.SortName, hsgd.OrderAsc) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestHSDeck(t *testing.T) { + dat, _, err := c.HSDeck(context.Background(), "AAECAQcG+wyd8AKS+AKggAOblAPanQMMS6IE/web8wLR9QKD+wKe+wKz/AL1gAOXlAOalAOSnwMA") + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestHSMetadata(t *testing.T) { + dat, _, err := c.HSMetadata(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestHSMetadataSets(t *testing.T) { + dat, _, err := c.HSMetadataSets(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestHSMetadataSetGroups(t *testing.T) { + dat, _, err := c.HSMetadataSetGroups(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestHSMetadataTypes(t *testing.T) { + dat, _, err := c.HSMetadataTypes(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestHSMetadataRarities(t *testing.T) { + dat, _, err := c.HSMetadataRarities(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestHSMetadataClasses(t *testing.T) { + dat, _, err := c.HSMetadataClasses(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestHSMetadataMinionTypes(t *testing.T) { + dat, _, err := c.HSMetadataMinionTypes(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestHSMetadataKeywords(t *testing.T) { + dat, _, err := c.HSMetadataKeywords(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} diff --git a/v2/init_test.go b/v2/init_test.go new file mode 100644 index 0000000..bdfce14 --- /dev/null +++ b/v2/init_test.go @@ -0,0 +1,35 @@ +package blizzard + +import ( + "context" + "fmt" + "log" + "os" +) + +var printOutput string + +func init() { + clientID := os.Getenv("CLIENT_ID") + if clientID == "" { + log.Fatal("Set the environment variable CLIENT_ID before retrying.") + } + + clientSecret := os.Getenv("CLIENT_SECRET") + if clientSecret == "" { + log.Fatal("Set the environment variable CLIENT_SECRET before retrying.") + } + + printOutput = os.Getenv("PRINT_OUTPUT") + if printOutput == "" { + log.Println("Output will not be printed for tests.") + } + + c = NewClient(clientID, clientSecret, US, EnUS) + + err := c.AccessTokenRequest(context.Background()) + if err != nil { + fmt.Println(err) + return + } +} diff --git a/v2/oauth.go b/v2/oauth.go new file mode 100644 index 0000000..e5cab2d --- /dev/null +++ b/v2/oauth.go @@ -0,0 +1,150 @@ +package blizzard + +import ( + "context" + "encoding/json" + "fmt" + "io/ioutil" + "net/http" + "strings" + + "github.com/FuzzyStatic/blizzard/v2/oauth" + "golang.org/x/oauth2" +) + +// OAuth credentials and access token to access Blizzard API +type OAuth struct { + ClientID string + ClientSecret string + Token *oauth2.Token +} + +// AuthorizeConfig returns OAuth2 config +func (c *Client) AuthorizeConfig(redirectURI string, profiles ...oauth.Profile) oauth2.Config { + var scopes []string + + for _, profile := range profiles { + scopes = append(scopes, string(profile)) + } + + c.authorizedCfg = oauth2.Config{ + ClientID: c.oauth.ClientID, + ClientSecret: c.oauth.ClientSecret, + Scopes: scopes, + RedirectURL: redirectURI, + Endpoint: oauth2.Endpoint{ + AuthURL: c.oauthURL + "/oauth/authorize", + TokenURL: c.oauthURL + "/oauth/token", + }, + } + + return c.authorizedCfg +} + +// AccessTokenRequest retrieves new OAuth2 Token +func (c *Client) AccessTokenRequest(ctx context.Context) error { + var ( + req *http.Request + res *http.Response + b []byte + err error + ) + + req, err = http.NewRequestWithContext(ctx, "POST", c.oauthURL+"/oauth/token", strings.NewReader("grant_type=client_credentials")) + if err != nil { + return err + } + + req.Header.Set("Content-Type", "application/x-www-form-urlencoded") + + res, err = c.client.Do(req) + if err != nil { + return err + } + defer res.Body.Close() + + b, err = ioutil.ReadAll(res.Body) + if err != nil { + return err + } + + err = json.Unmarshal(b, &c.oauth.Token) + if err != nil { + return err + } + + return nil +} + +// UserInfoHeader returns basic information about the user associated with the current bearer token +func (c *Client) UserInfoHeader(token *oauth2.Token) (*oauth.UserInfo, []byte, error) { + var ( + dat oauth.UserInfo + req *http.Request + client *http.Client + res *http.Response + b []byte + err error + ) + + req, err = http.NewRequest("GET", c.oauthURL+"/oauth/userinfo", nil) + if err != nil { + return &dat, b, err + } + + client = c.authorizedCfg.Client(context.Background(), token) + + res, err = client.Do(req) + if err != nil { + return &dat, b, err + } + defer res.Body.Close() + + b, err = ioutil.ReadAll(res.Body) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// TokenValidation verify that a given bearer token is valid and retrieve metadata about the token including the client_id used to create the token, expiration timestamp, and scopes granted to the token +func (c *Client) TokenValidation(ctx context.Context, token *oauth2.Token) (*oauth.TokenValidation, []byte, error) { + var ( + dat oauth.TokenValidation + req *http.Request + res *http.Response + b []byte + err error + ) + + req, err = http.NewRequestWithContext(ctx, "GET", c.oauthURL+fmt.Sprintf("/oauth/check_token?token=%s", token.AccessToken), nil) + if err != nil { + return &dat, b, err + } + + req.Header.Set("Accept", "application/json") + + res, err = c.client.Do(req) + if err != nil { + return &dat, b, err + } + defer res.Body.Close() + + b, err = ioutil.ReadAll(res.Body) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} diff --git a/v2/oauth/oauth.go b/v2/oauth/oauth.go new file mode 100644 index 0000000..72c80a6 --- /dev/null +++ b/v2/oauth/oauth.go @@ -0,0 +1,12 @@ +// Package oauth contains types for the OAuth APIs +package oauth + +// Profile type +type Profile string + +// PRofile field authorize scopes +const ( + ProfileD3 Profile = "d3.profile" + ProfileSC2 Profile = "sc2.profile" + ProfileWoW Profile = "wow.profile" +) diff --git a/v2/oauth/tokenValidation.go b/v2/oauth/tokenValidation.go new file mode 100644 index 0000000..ab7815e --- /dev/null +++ b/v2/oauth/tokenValidation.go @@ -0,0 +1,10 @@ +package oauth + +// TokenValidation contains token validation data +type TokenValidation struct { + Exp int `json:"exp"` + Username string `json:"user_name"` + Authorities []string `json:"authorities"` + ClientID string `json:"client_id"` + Scope []string `json:"scope"` +} diff --git a/v2/oauth/userAuthentication.go b/v2/oauth/userAuthentication.go new file mode 100644 index 0000000..5c1978d --- /dev/null +++ b/v2/oauth/userAuthentication.go @@ -0,0 +1,8 @@ +package oauth + +// UserInfo structure +type UserInfo struct { + Sub string `json:"sub"` + ID int `json:"id"` + Battletag string `json:"battletag"` +} diff --git a/v2/oauth_test.go b/v2/oauth_test.go new file mode 100644 index 0000000..2705f94 --- /dev/null +++ b/v2/oauth_test.go @@ -0,0 +1,49 @@ +package blizzard + +import ( + "context" + "fmt" + "testing" +) + +func TestAccessTokenRequest(t *testing.T) { + err := c.AccessTokenRequest(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", c.oauth) + } +} + +// func TestUserInfoHeader(t *testing.T) { +// err := c.Token() +// if err != nil { +// fmt.Println(err) +// t.Fail() +// } + +// dat, _, err := c.UserInfoHeader(c.oauth.Token) +// if err != nil { +// fmt.Println(err) +// t.Fail() +// } + +// if printOutput != "" { +// fmt.Printf("%+v\n", dat) +// } +// } + +func TestTokenValidation(t *testing.T) { + dat, _, err := c.TokenValidation(context.Background(), c.oauth.Token) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} diff --git a/v2/sc2c.go b/v2/sc2c.go new file mode 100644 index 0000000..b7bbed7 --- /dev/null +++ b/v2/sc2c.go @@ -0,0 +1,308 @@ +package blizzard + +import ( + "context" + "encoding/json" + "errors" + "fmt" + + "github.com/FuzzyStatic/blizzard/v2/sc2c" +) + +// SC2StaticProfile returns all static SC2 profile data (ctx context.Context, achievements, categories, criteria, and rewards) +func (c *Client) SC2StaticProfile(ctx context.Context, region Region) (*sc2c.StaticProfile, []byte, error) { + var ( + dat sc2c.StaticProfile + b []byte + err error + ) + + if c.region == CN { + return &dat, b, errors.New("CN is not a valid region for this call") + } + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/sc2/static/profile/%d?locale=%s", region, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// SC2MetadataProfile returns all SC2 profile metadata +func (c *Client) SC2MetadataProfile(ctx context.Context, region Region, realmID, profileID int) (*sc2c.MetadataProfile, []byte, error) { + var ( + dat sc2c.MetadataProfile + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/sc2/metadata/profile/%d/%d/%d?locale=%s", region, realmID, profileID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// SC2Profile returns all SC2 profile data +func (c *Client) SC2Profile(ctx context.Context, region Region, realmID, profileID int) (*sc2c.Profile, []byte, error) { + var ( + dat sc2c.Profile + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/sc2/profile/%d/%d/%d?locale=%s", region, realmID, profileID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// SC2ProfileLadderSummary returns SC2 profile ladder summary +func (c *Client) SC2ProfileLadderSummary(ctx context.Context, region Region, realmID, profileID int) (*sc2c.LadderSummary, []byte, error) { + var ( + dat sc2c.LadderSummary + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/sc2/profile/%d/%d/%d/ladder/summary?locale=%s", region, realmID, profileID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// SC2ProfileLadder returns SC2 profile ladder data +func (c *Client) SC2ProfileLadder(ctx context.Context, region Region, realmID, profileID, ladderID int) (*sc2c.Ladder, []byte, error) { + var ( + dat sc2c.Ladder + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/sc2/profile/%d/%d/%d/ladder/%d?locale=%s", region, realmID, profileID, ladderID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// SC2LadderGrandmaster returns SC2 ladder grandmaster for current season +func (c *Client) SC2LadderGrandmaster(ctx context.Context, region Region) (*sc2c.LadderGrandmaster, []byte, error) { + var ( + dat sc2c.LadderGrandmaster + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/sc2/ladder/grandmaster/%d?locale=%s", region, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// SC2LadderSeason returns SC2 ladder current season +func (c *Client) SC2LadderSeason(ctx context.Context, region Region) (*sc2c.LadderSeason, []byte, error) { + var ( + dat sc2c.LadderSeason + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/sc2/ladder/season/%d?locale=%s", region, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// SC2Player returns data about player using account ID +func (c *Client) SC2Player(ctx context.Context, accountID int) (*sc2c.Player, []byte, error) { + var ( + dat sc2c.Player + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/sc2/player/%d?locale=%s", accountID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// SC2LegacyProfile returns all SC2 legacy profile data +func (c *Client) SC2LegacyProfile(ctx context.Context, region Region, realmID, profileID int) (*sc2c.LegacyProfile, []byte, error) { + var ( + dat sc2c.LegacyProfile + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/sc2/legacy/profile/%d/%d/%d?locale=%s", region, realmID, profileID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// SC2LegacyProfileLadders returns all SC2 legacy profile ladder data +func (c *Client) SC2LegacyProfileLadders(ctx context.Context, region Region, realmID, profileID int) (*sc2c.LegacyProfileLadders, []byte, error) { + var ( + dat sc2c.LegacyProfileLadders + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/sc2/legacy/profile/%d/%d/%d/ladders?locale=%s", region, realmID, profileID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// SC2LegacyProfileMatches returns all SC2 legacy profile matches data +func (c *Client) SC2LegacyProfileMatches(ctx context.Context, region Region, realmID, profileID int) (*sc2c.LegacyProfileMatches, []byte, error) { + var ( + dat sc2c.LegacyProfileMatches + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/sc2/legacy/profile/%d/%d/%d/matches?locale=%s", region, realmID, profileID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// SC2LegacyLadder returns SC2 legacy ladder data +func (c *Client) SC2LegacyLadder(ctx context.Context, region Region, ladderID int) (*sc2c.LegacyLadder, []byte, error) { + var ( + dat sc2c.LegacyLadder + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/sc2/legacy/ladder/%d/%d?locale=%s", region, ladderID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// SC2LegacyAchievements returns SC2 legacy achievements for region +func (c *Client) SC2LegacyAchievements(ctx context.Context, region Region) (*sc2c.LegacyAchievements, []byte, error) { + var ( + dat sc2c.LegacyAchievements + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/sc2/legacy/data/achievements/%d?locale=%s", region, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// SC2LegacyRewards returns SC2 legacy rewards for region +func (c *Client) SC2LegacyRewards(ctx context.Context, region Region) (*sc2c.LegacyRewards, []byte, error) { + var ( + dat sc2c.LegacyRewards + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/sc2/legacy/data/rewards/%d?locale=%s", region, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} diff --git a/v2/sc2c/account.go b/v2/sc2c/account.go new file mode 100644 index 0000000..3a51a8f --- /dev/null +++ b/v2/sc2c/account.go @@ -0,0 +1,11 @@ +package sc2c + +// Player structure +type Player []struct { + Name string `json:"name"` + ProfileURL string `json:"profileUrl"` + AvatarURL string `json:"avatarUrl"` + ProfileID string `json:"profileId"` + RegionID int `json:"regionId"` + RealmID int `json:"realmId"` +} diff --git a/v2/sc2c/ladder.go b/v2/sc2c/ladder.go new file mode 100644 index 0000000..ded3e03 --- /dev/null +++ b/v2/sc2c/ladder.go @@ -0,0 +1,30 @@ +package sc2c + +// LadderGrandmaster structure +type LadderGrandmaster struct { + LadderTeams []struct { + TeamMembers []struct { + ID string `json:"id"` + Realm int `json:"realm"` + Region int `json:"region"` + DisplayName string `json:"displayName"` + ClanTag string `json:"clanTag"` + FavoriteRace string `json:"favoriteRace"` + } `json:"teamMembers"` + PreviousRank int `json:"previousRank"` + Points int `json:"points"` + Wins int `json:"wins"` + Losses int `json:"losses"` + Mmr int `json:"mmr"` + JoinTimestamp int `json:"joinTimestamp"` + } `json:"ladderTeams"` +} + +// LadderSeason structure +type LadderSeason struct { + SeasonID int `json:"seasonId"` + Number int `json:"number"` + Year int `json:"year"` + StartDate string `json:"startDate"` + EndDate string `json:"endDate"` +} diff --git a/v2/sc2c/legacy.go b/v2/sc2c/legacy.go new file mode 100644 index 0000000..f8aa207 --- /dev/null +++ b/v2/sc2c/legacy.go @@ -0,0 +1,300 @@ +package sc2c + +// LegacyProfile structure +type LegacyProfile struct { + ID string `json:"id"` + Realm int `json:"realm"` + DisplayName string `json:"displayName"` + ClanName string `json:"clanName"` + ClanTag string `json:"clanTag"` + ProfilePath string `json:"profilePath"` + Portrait struct { + X int `json:"x"` + Y int `json:"y"` + W int `json:"w"` + H int `json:"h"` + Offset int `json:"offset"` + URL string `json:"url"` + } `json:"portrait"` + Career struct { + PrimaryRace string `json:"primaryRace"` + TerranWins int `json:"terranWins"` + ProtossWins int `json:"protossWins"` + ZergWins int `json:"zergWins"` + Highest1V1Rank string `json:"highest1v1Rank"` + HighestTeamRank string `json:"highestTeamRank"` + SeasonTotalGames int `json:"seasonTotalGames"` + CareerTotalGames int `json:"careerTotalGames"` + } `json:"career"` + SwarmLevels struct { + Level int `json:"level"` + Terran struct { + Level int `json:"level"` + TotalLevelXP int `json:"totalLevelXP"` + CurrentLevelXP int `json:"currentLevelXP"` + } `json:"terran"` + Zerg struct { + Level int `json:"level"` + TotalLevelXP int `json:"totalLevelXP"` + CurrentLevelXP int `json:"currentLevelXP"` + } `json:"zerg"` + Protoss struct { + Level int `json:"level"` + TotalLevelXP int `json:"totalLevelXP"` + CurrentLevelXP int `json:"currentLevelXP"` + } `json:"protoss"` + } `json:"swarmLevels"` + Campaign struct { + Wol string `json:"wol"` + Hots string `json:"hots"` + } `json:"campaign"` + Season struct { + SeasonID int `json:"seasonId"` + SeasonNumber int `json:"seasonNumber"` + SeasonYear int `json:"seasonYear"` + TotalGamesThisSeason int `json:"totalGamesThisSeason"` + Stats []struct { + Type string `json:"type"` + Wins int `json:"wins"` + Games int `json:"games"` + } `json:"stats"` + } `json:"season"` + Rewards struct { + Selected []string `json:"selected"` + Earned []string `json:"earned"` + } `json:"rewards"` + Achievements struct { + Points struct { + TotalPoints int `json:"totalPoints"` + CategoryPoints struct { + Num4325377 int `json:"4325377"` + Num4325379 int `json:"4325379"` + Num4325382 int `json:"4325382"` + Num4325408 int `json:"4325408"` + Num4325410 int `json:"4325410"` + Num4330138 int `json:"4330138"` + Num4364473 int `json:"4364473"` + Num4386911 int `json:"4386911"` + } `json:"categoryPoints"` + } `json:"points"` + Achievements []struct { + AchievementID string `json:"achievementId"` + CompletionDate int `json:"completionDate"` + } `json:"achievements"` + } `json:"achievements"` +} + +// LegacyProfileLadders structure +type LegacyProfileLadders struct { + CurrentSeason []struct { + Characters []struct { + ClanName string `json:"clanName"` + ClanTag string `json:"clanTag"` + DisplayName string `json:"displayName"` + ID string `json:"id"` + ProfilePath string `json:"profilePath"` + Realm int `json:"realm"` + Region int `json:"region"` + } `json:"characters"` + Ladder []struct { + Division int `json:"division"` + LadderID string `json:"ladderId"` + LadderName string `json:"ladderName"` + League string `json:"league"` + Losses int `json:"losses"` + MatchMakingQueue string `json:"matchMakingQueue"` + Rank int `json:"rank"` + Showcase bool `json:"showcase"` + Wins int `json:"wins"` + } `json:"ladder"` + NonRanked []interface{} `json:"nonRanked"` + } `json:"currentSeason"` + PreviousSeason []struct { + Characters []struct { + ClanName string `json:"clanName"` + ClanTag string `json:"clanTag"` + DisplayName string `json:"displayName"` + ID string `json:"id"` + ProfilePath string `json:"profilePath"` + Realm int `json:"realm"` + Region int `json:"region"` + } `json:"characters"` + Ladder []struct { + Division int `json:"division"` + LadderID string `json:"ladderId"` + LadderName string `json:"ladderName"` + League string `json:"league"` + Losses int `json:"losses"` + MatchMakingQueue string `json:"matchMakingQueue"` + Rank int `json:"rank"` + Showcase bool `json:"showcase"` + Wins int `json:"wins"` + } `json:"ladder"` + NonRanked []struct { + GamesPlayed int `json:"gamesPlayed"` + Mmq string `json:"mmq"` + } `json:"nonRanked"` + } `json:"previousSeason"` + ShowcasePlacement []struct { + Characters []struct { + ClanName string `json:"clanName"` + ClanTag string `json:"clanTag"` + DisplayName string `json:"displayName"` + ID string `json:"id"` + ProfilePath string `json:"profilePath"` + Realm int `json:"realm"` + Region int `json:"region"` + } `json:"characters"` + Ladder []interface{} `json:"ladder"` + NonRanked []struct { + GamesPlayed int `json:"gamesPlayed"` + Mmq string `json:"mmq"` + } `json:"nonRanked"` + } `json:"showcasePlacement"` +} + +// LegacyProfileMatches structure +type LegacyProfileMatches struct { + Matches []struct { + Map string `json:"map"` + Type string `json:"type"` + Decision string `json:"decision"` + Speed string `json:"speed"` + Date int `json:"date"` + } `json:"matches"` +} + +// LegacyLadder structure +type LegacyLadder struct { + LadderMembers []struct { + Character struct { + ID string `json:"id"` + Realm int `json:"realm"` + Region int `json:"region"` + DisplayName string `json:"displayName"` + ClanName string `json:"clanName"` + ClanTag string `json:"clanTag"` + ProfilePath string `json:"profilePath"` + } `json:"character"` + JoinTimestamp int `json:"joinTimestamp"` + Points int `json:"points"` + Wins int `json:"wins"` + Losses int `json:"losses"` + HighestRank int `json:"highestRank"` + PreviousRank int `json:"previousRank"` + FavoriteRaceP1 string `json:"favoriteRaceP1"` + } `json:"ladderMembers"` +} + +// LegacyAchievements structure +type LegacyAchievements struct { + Achievements []struct { + Title string `json:"title"` + Description string `json:"description"` + AchievementID string `json:"achievementId"` + CategoryID string `json:"categoryId"` + Points int `json:"points"` + Icon struct { + X int `json:"x"` + Y int `json:"y"` + W int `json:"w"` + H int `json:"h"` + Offset int `json:"offset"` + URL string `json:"url"` + } `json:"icon"` + } `json:"achievements"` + Categories []struct { + Title string `json:"title"` + CategoryID string `json:"categoryId"` + FeaturedAchievementID string `json:"featuredAchievementId"` + Children []struct { + Title string `json:"title"` + CategoryID string `json:"categoryId"` + FeaturedAchievementID string `json:"featuredAchievementId"` + } `json:"children,omitempty"` + } `json:"categories"` +} + +// LegacyRewards structure +type LegacyRewards struct { + Portraits []struct { + Title string `json:"title"` + ID string `json:"id"` + Icon struct { + X int `json:"x"` + Y int `json:"y"` + W int `json:"w"` + H int `json:"h"` + Offset int `json:"offset"` + URL string `json:"url"` + } `json:"icon"` + AchievementID string `json:"achievementId"` + } `json:"portraits"` + TerranDecals []struct { + Title string `json:"title"` + ID string `json:"id"` + Icon struct { + X int `json:"x"` + Y int `json:"y"` + W int `json:"w"` + H int `json:"h"` + Offset int `json:"offset"` + URL string `json:"url"` + } `json:"icon"` + AchievementID string `json:"achievementId"` + } `json:"terranDecals"` + ZergDecals []struct { + Title string `json:"title"` + ID string `json:"id"` + Icon struct { + X int `json:"x"` + Y int `json:"y"` + W int `json:"w"` + H int `json:"h"` + Offset int `json:"offset"` + URL string `json:"url"` + } `json:"icon"` + AchievementID string `json:"achievementId"` + } `json:"zergDecals"` + ProtossDecals []struct { + Title string `json:"title"` + ID string `json:"id"` + Icon struct { + X int `json:"x"` + Y int `json:"y"` + W int `json:"w"` + H int `json:"h"` + Offset int `json:"offset"` + URL string `json:"url"` + } `json:"icon"` + AchievementID string `json:"achievementId"` + } `json:"protossDecals"` + Skins []struct { + Title string `json:"title"` + ID string `json:"id"` + Icon struct { + X int `json:"x"` + Y int `json:"y"` + W int `json:"w"` + H int `json:"h"` + Offset int `json:"offset"` + URL string `json:"url"` + } `json:"icon"` + Name string `json:"name,omitempty"` + AchievementID string `json:"achievementId"` + } `json:"skins"` + Animations []struct { + Title string `json:"title"` + Command string `json:"command"` + ID string `json:"id"` + Icon struct { + X int `json:"x"` + Y int `json:"y"` + W int `json:"w"` + H int `json:"h"` + Offset int `json:"offset"` + URL string `json:"url"` + } `json:"icon"` + AchievementID string `json:"achievementId"` + } `json:"animations"` +} diff --git a/v2/sc2c/profile.go b/v2/sc2c/profile.go new file mode 100644 index 0000000..f247fe2 --- /dev/null +++ b/v2/sc2c/profile.go @@ -0,0 +1,188 @@ +package sc2c + +// StaticProfile structure +type StaticProfile struct { + Achievements []struct { + CategoryID string `json:"categoryId"` + ChainAchievementIds []string `json:"chainAchievementIds"` + ChainRewardSize int `json:"chainRewardSize"` + CriteriaIds []string `json:"criteriaIds,omitempty"` + Description string `json:"description"` + Flags int `json:"flags"` + ID string `json:"id"` + ImageURL string `json:"imageUrl"` + IsChained bool `json:"isChained"` + Points int `json:"points"` + Title string `json:"title"` + UIOrderHint int `json:"uiOrderHint"` + } `json:"achievements"` + Criteria []struct { + AchievementID string `json:"achievementId"` + Description string `json:"description"` + EvaluationClass string `json:"evaluationClass"` + Flags int `json:"flags"` + ID string `json:"id"` + NecessaryQuantity int `json:"necessaryQuantity"` + UIOrderHint int `json:"uiOrderHint"` + } `json:"criteria"` + Categories []struct { + ChildrenCategoryIds []interface{} `json:"childrenCategoryIds"` + FeaturedAchievementID string `json:"featuredAchievementId"` + ID string `json:"id"` + Name string `json:"name"` + ParentCategoryID string `json:"parentCategoryId"` + Points int `json:"points"` + UIOrderHint int `json:"uiOrderHint"` + MedalTiers []int `json:"medalTiers,omitempty"` + } `json:"categories"` + Rewards []struct { + Flags int `json:"flags"` + ID string `json:"id"` + AchievementID string `json:"achievementId,omitempty"` + Name string `json:"name"` + ImageURL string `json:"imageUrl"` + UnlockableType string `json:"unlockableType"` + IsSkin bool `json:"isSkin"` + UIOrderHint int `json:"uiOrderHint"` + Command string `json:"command,omitempty"` + } `json:"rewards"` +} + +// MetadataProfile structure +type MetadataProfile struct { + Name string `json:"name"` + ProfileURL string `json:"profileUrl"` + AvatarURL string `json:"avatarUrl"` + ProfileID string `json:"profileId"` + RegionID int `json:"regionId"` + RealmID int `json:"realmId"` +} + +// Profile structure +type Profile struct { + Summary struct { + ID string `json:"id"` + Realm int `json:"realm"` + DisplayName string `json:"displayName"` + Portrait string `json:"portrait"` + DecalTerran string `json:"decalTerran"` + DecalProtoss string `json:"decalProtoss"` + DecalZerg string `json:"decalZerg"` + TotalSwarmLevel int `json:"totalSwarmLevel"` + TotalAchievementPoints int `json:"totalAchievementPoints"` + } `json:"summary"` + Snapshot struct { + SeasonSnapshot struct { + OneV1 struct { + Rank int `json:"rank"` + LeagueName interface{} `json:"leagueName"` + TotalGames int `json:"totalGames"` + TotalWins int `json:"totalWins"` + } `json:"1v1"` + TwoV2 struct { + Rank int `json:"rank"` + LeagueName interface{} `json:"leagueName"` + TotalGames int `json:"totalGames"` + TotalWins int `json:"totalWins"` + } `json:"2v2"` + ThreeV3 struct { + Rank int `json:"rank"` + LeagueName interface{} `json:"leagueName"` + TotalGames int `json:"totalGames"` + TotalWins int `json:"totalWins"` + } `json:"3v3"` + FourV4 struct { + Rank int `json:"rank"` + LeagueName interface{} `json:"leagueName"` + TotalGames int `json:"totalGames"` + TotalWins int `json:"totalWins"` + } `json:"4v4"` + Archon struct { + Rank int `json:"rank"` + LeagueName interface{} `json:"leagueName"` + TotalGames int `json:"totalGames"` + TotalWins int `json:"totalWins"` + } `json:"Archon"` + } `json:"seasonSnapshot"` + TotalRankedSeasonGamesPlayed int `json:"totalRankedSeasonGamesPlayed"` + } `json:"snapshot"` + Career struct { + TerranWins int `json:"terranWins"` + ZergWins int `json:"zergWins"` + ProtossWins int `json:"protossWins"` + TotalCareerGames int `json:"totalCareerGames"` + TotalGamesThisSeason int `json:"totalGamesThisSeason"` + Current1V1LeagueName interface{} `json:"current1v1LeagueName"` + CurrentBestTeamLeagueName interface{} `json:"currentBestTeamLeagueName"` + Best1V1Finish struct { + LeagueName string `json:"leagueName"` + TimesAchieved int `json:"timesAchieved"` + } `json:"best1v1Finish"` + BestTeamFinish struct { + LeagueName interface{} `json:"leagueName"` + TimesAchieved int `json:"timesAchieved"` + } `json:"bestTeamFinish"` + } `json:"career"` + SwarmLevels struct { + Level int `json:"level"` + Terran struct { + Level int `json:"level"` + MaxLevelPoints int `json:"maxLevelPoints"` + CurrentLevelPoints int `json:"currentLevelPoints"` + } `json:"terran"` + Zerg struct { + Level int `json:"level"` + MaxLevelPoints int `json:"maxLevelPoints"` + CurrentLevelPoints int `json:"currentLevelPoints"` + } `json:"zerg"` + Protoss struct { + Level int `json:"level"` + MaxLevelPoints int `json:"maxLevelPoints"` + CurrentLevelPoints int `json:"currentLevelPoints"` + } `json:"protoss"` + } `json:"swarmLevels"` + Campaign struct { + DifficultyCompleted struct { + WingsOfLiberty string `json:"wings-of-liberty"` + HeartOfTheSwarm string `json:"heart-of-the-swarm"` + } `json:"difficultyCompleted"` + } `json:"campaign"` + CategoryPointProgress []struct { + CategoryID string `json:"categoryId"` + PointsEarned int `json:"pointsEarned"` + } `json:"categoryPointProgress"` + AchievementShowcase []string `json:"achievementShowcase"` + EarnedRewards []struct { + RewardID string `json:"rewardId"` + Selected bool `json:"selected"` + AchievementID string `json:"achievementId,omitempty"` + Category string `json:"category,omitempty"` + } `json:"earnedRewards"` + EarnedAchievements []struct { + AchievementID string `json:"achievementId"` + CompletionDate float64 `json:"completionDate"` + NumCompletedAchievementsInSeries int `json:"numCompletedAchievementsInSeries"` + TotalAchievementsInSeries int `json:"totalAchievementsInSeries"` + IsComplete bool `json:"isComplete"` + InProgress bool `json:"inProgress"` + Criteria []struct { + CriterionID string `json:"criterionId"` + } `json:"criteria"` + NextProgressEarnedQuantity int `json:"nextProgressEarnedQuantity,omitempty"` + NextProgressRequiredQuantity int `json:"nextProgressRequiredQuantity,omitempty"` + } `json:"earnedAchievements"` +} + +// LadderSummary structure +type LadderSummary struct { + ShowCaseEntries []interface{} `json:"showCaseEntries"` + PlacementMatches []interface{} `json:"placementMatches"` + AllLadderMemberships []interface{} `json:"allLadderMemberships"` +} + +// Ladder structure +type Ladder struct { + LadderTeams []interface{} `json:"ladderTeams"` + AllLadderMemberships []interface{} `json:"allLadderMemberships"` + RanksAndPools []interface{} `json:"ranksAndPools"` +} diff --git a/v2/sc2c/sc2c.go b/v2/sc2c/sc2c.go new file mode 100644 index 0000000..f2498f6 --- /dev/null +++ b/v2/sc2c/sc2c.go @@ -0,0 +1,2 @@ +// Package sc2c contains types for the Starcraft 2 Community APIs +package sc2c diff --git a/v2/sc2c_test.go b/v2/sc2c_test.go new file mode 100644 index 0000000..dcf6332 --- /dev/null +++ b/v2/sc2c_test.go @@ -0,0 +1,175 @@ +package blizzard + +import ( + "context" + "fmt" + "testing" +) + +func TestSC2StaticProfile(t *testing.T) { + dat, _, err := c.SC2StaticProfile(context.Background(), US) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestSC2MetadataProfile(t *testing.T) { + dat, _, err := c.SC2MetadataProfile(context.Background(), US, 1, 305084) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestSC2Profile(t *testing.T) { + dat, _, err := c.SC2Profile(context.Background(), US, 1, 305084) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestSC2ProfileLadderSummary(t *testing.T) { + dat, _, err := c.SC2ProfileLadderSummary(context.Background(), US, 1, 305084) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestSC2ProfileLadder(t *testing.T) { + dat, _, err := c.SC2ProfileLadder(context.Background(), US, 1, 2376042, 194163) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestSC2LadderGrandmaster(t *testing.T) { + dat, _, err := c.SC2LadderGrandmaster(context.Background(), EU) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestSC2LadderSeason(t *testing.T) { + dat, _, err := c.SC2LadderSeason(context.Background(), EU) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestSC2Player(t *testing.T) { + dat, _, err := c.SC2Player(context.Background(), 1312411) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestSC2LegacyProfile(t *testing.T) { + dat, _, err := c.SC2LegacyProfile(context.Background(), US, 1, 1655091) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestSC2LegacyProfileLadders(t *testing.T) { + dat, _, err := c.SC2LegacyProfileLadders(context.Background(), US, 1, 1655091) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestSC2LegacyProfileMatches(t *testing.T) { + dat, _, err := c.SC2LegacyProfileMatches(context.Background(), US, 1, 1655091) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestSC2LegacyLadder(t *testing.T) { + dat, _, err := c.SC2LegacyLadder(context.Background(), US, 194163) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestSC2LegacyAchievements(t *testing.T) { + dat, _, err := c.SC2LegacyAchievements(context.Background(), US) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestSC2LegacyRewards(t *testing.T) { + dat, _, err := c.SC2LegacyRewards(context.Background(), US) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} diff --git a/v2/sc2gd.go b/v2/sc2gd.go new file mode 100644 index 0000000..b9a4582 --- /dev/null +++ b/v2/sc2gd.go @@ -0,0 +1,30 @@ +package blizzard + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/FuzzyStatic/blizzard/v2/sc2gd" +) + +// SC2LeagueData returns all SC2 league data from for seasonID, queue ID, team type, and league ID +func (c *Client) SC2LeagueData(ctx context.Context, seasonID int, queueID sc2gd.QueueID, teamType sc2gd.TeamType, leagueID sc2gd.LeagueID) (*sc2gd.League, []byte, error) { + var ( + dat sc2gd.League + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/sc2/league/%d/%d/%d/%d?locale=%s", seasonID, queueID, teamType, leagueID, c.locale), "") + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} diff --git a/v2/sc2gd/league.go b/v2/sc2gd/league.go new file mode 100644 index 0000000..fcffa0a --- /dev/null +++ b/v2/sc2gd/league.go @@ -0,0 +1,81 @@ +package sc2gd + +// QueueID IDs for different league queues +type QueueID int + +// QueueID constants (1=WoL 1v1, 2=WoL 2v2, 3=WoL 3v3, 4=WoL 4v4) DO NOT REARRANGE +const ( + _ QueueID = iota + WoL1v1 + WoL2v2 + WoL3v3 + WoL4v4 +) + +// QueueID constants (101=HotS 1v1, 102=HotS 2v2, 103=HotS 3v3, 104=HotS 4v4) DO NOT REARRANGE +const ( + _ QueueID = 100 + iota + HotS1v1 + HotS2v2 + HotS3v3 + HotS4v4 +) + +// QueueID constants (201=LotV 1v1, 202=LotV 2v2, 203=LotV 3v3, 204=LotV 4v4, 206=LotV Archon) DO NOT REARRANGE +const ( + _ QueueID = 200 + iota + LotV1v1 + LotV2v2 + LotV3v3 + LotV4v4 + _ + LotVArchon +) + +// TeamType different team types +type TeamType int + +// TeamType constants (0=arranged, 1=random) DO NOT REARRANGE +const ( + Arranged TeamType = iota + Random +) + +// LeagueID available leagues +type LeagueID int + +// LeagueID constants ( 0=Bronze, 1=Silver, 2=Gold, 3=Platinum, 4=Diamond, 5=Master, 6=Grandmaster) DO NOT REARRANGE +const ( + Bronze LeagueID = iota + Silver + Gold + Platinum + Diamond + Master + Grandmaster +) + +// League structure +type League struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Key struct { + LeagueID int `json:"league_id"` + SeasonID int `json:"season_id"` + QueueID int `json:"queue_id"` + TeamType int `json:"team_type"` + } `json:"key"` + Tier []struct { + ID int `json:"id"` + MinRating int `json:"min_rating"` + MaxRating int `json:"max_rating"` + Division []struct { + ID int `json:"id"` + LadderID int `json:"ladder_id"` + MemberCount int `json:"member_count"` + } `json:"division"` + } `json:"tier"` +} diff --git a/v2/sc2gd/sc2gd.go b/v2/sc2gd/sc2gd.go new file mode 100644 index 0000000..ee00f38 --- /dev/null +++ b/v2/sc2gd/sc2gd.go @@ -0,0 +1,2 @@ +// Package sc2gd contains types for the Starcraft 2 Game Data APIs +package sc2gd diff --git a/v2/sc2gd_test.go b/v2/sc2gd_test.go new file mode 100644 index 0000000..1b04050 --- /dev/null +++ b/v2/sc2gd_test.go @@ -0,0 +1,21 @@ +package blizzard + +import ( + "context" + "fmt" + "testing" + + "github.com/FuzzyStatic/blizzard/v2/sc2gd" +) + +func TestSC2LeagueData(t *testing.T) { + dat, _, err := c.SC2LeagueData(context.Background(), 37, sc2gd.LotV1v1, sc2gd.Arranged, sc2gd.Master) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} diff --git a/v2/wowcgd.go b/v2/wowcgd.go new file mode 100644 index 0000000..7f0db45 --- /dev/null +++ b/v2/wowcgd.go @@ -0,0 +1,538 @@ +package blizzard + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/FuzzyStatic/blizzard/v2/wowcgd" + "github.com/FuzzyStatic/blizzard/v2/wowgd" +) + +// ClassicWoWCreatureFamiliesIndex returns an index of creature families. +func (c *Client) ClassicWoWCreatureFamiliesIndex(ctx context.Context) (*wowcgd.CreatureFamiliesIndex, []byte, error) { + var ( + dat wowcgd.CreatureFamiliesIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/creature-family/index?locale=%s", c.locale), c.staticClassicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// ClassicWoWCreatureFamily returns a creature family by ID. +func (c *Client) ClassicWoWCreatureFamily(ctx context.Context, creatureFamilyID int) (*wowcgd.CreatureFamily, []byte, error) { + var ( + dat wowcgd.CreatureFamily + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/creature-family/%d?locale=%s", creatureFamilyID, c.locale), c.staticClassicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// ClassicWoWCreatureTypesIndex returns an index of creature types. +func (c *Client) ClassicWoWCreatureTypesIndex(ctx context.Context) (*wowcgd.CreatureTypesIndex, []byte, error) { + var ( + dat wowcgd.CreatureTypesIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/creature-type/index?locale=%s", c.locale), c.staticClassicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// ClassicWoWCreatureType returns a creature type by ID. +func (c *Client) ClassicWoWCreatureType(ctx context.Context, creatureTypeID int) (*wowcgd.CreatureType, []byte, error) { + var ( + dat wowcgd.CreatureType + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/creature-type/%d?locale=%s", creatureTypeID, c.locale), c.staticClassicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// ClassicWoWCreature returns a creature type by ID. +func (c *Client) ClassicWoWCreature(ctx context.Context, creatureID int) (*wowcgd.Creature, []byte, error) { + var ( + dat wowcgd.Creature + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/creature/%d?locale=%s", creatureID, c.locale), c.staticClassicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// ClassicWoWCreatureDisplayMedia returns media for a creature display by ID. +func (c *Client) ClassicWoWCreatureDisplayMedia(ctx context.Context, creatureDisplayID int) (*wowcgd.CreatureDisplayMedia, []byte, error) { + var ( + dat wowcgd.CreatureDisplayMedia + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/media/creature-display/%d?locale=%s", creatureDisplayID, c.locale), c.staticClassicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// ClassicWoWCreatureFamilyMedia returns media for a creature family by ID. +func (c *Client) ClassicWoWCreatureFamilyMedia(ctx context.Context, creatureFamilyID int) (*wowcgd.CreatureFamilyMedia, []byte, error) { + var ( + dat wowcgd.CreatureFamilyMedia + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/media/creature-family/%d?locale=%s", creatureFamilyID, c.locale), c.staticClassicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// ClassicWoWGuildCrestComponentsIndex returns an index of guild crest media +func (c *Client) ClassicWoWGuildCrestComponentsIndex(ctx context.Context) (*wowcgd.GuildCrestComponentsIndex, []byte, error) { + var ( + dat wowcgd.GuildCrestComponentsIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/guild-crest/index?locale=%s", c.locale), c.staticClassicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// ClassicWoWGuildCrestBorderMedia returns media for a guild crest border by ID +func (c *Client) ClassicWoWGuildCrestBorderMedia(ctx context.Context, borderID int) (*wowcgd.GuildCrestBorderMdedia, []byte, error) { + var ( + dat wowcgd.GuildCrestBorderMdedia + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/media/guild-crest/border/%d?locale=%s", borderID, c.locale), c.staticClassicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// ClassicWoWGuildCrestEmblemMedia returns media for a guild crest emblem by ID +func (c *Client) ClassicWoWGuildCrestEmblemMedia(ctx context.Context, emblemID int) (*wowcgd.GuildCrestEmblemMdedia, []byte, error) { + var ( + dat wowcgd.GuildCrestEmblemMdedia + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/media/guild-crest/emblem/%d?locale=%s", emblemID, c.locale), c.staticClassicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// ClassicWoWItemClassesIndex returns an index of item classes +func (c *Client) ClassicWoWItemClassesIndex(ctx context.Context) (*wowcgd.ItemClassesIndex, []byte, error) { + var ( + dat wowcgd.ItemClassesIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/item-class/index?locale=%s", c.locale), c.staticClassicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// ClassicWoWItemClass returns an item class by ID +func (c *Client) ClassicWoWItemClass(ctx context.Context, itemClassID int) (*wowcgd.ItemClass, []byte, error) { + var ( + dat wowcgd.ItemClass + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/item-class/%d?locale=%s", itemClassID, c.locale), c.staticClassicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// ClassicWoWItemSubclass returns an item subclass by ID +func (c *Client) ClassicWoWItemSubclass(ctx context.Context, itemClassID, itemSubclassID int) (*wowcgd.ItemSubclass, []byte, error) { + var ( + dat wowcgd.ItemSubclass + b []byte + err error + ) + + b, err = c.getURLBody(ctx, + c.apiURL+fmt.Sprintf("/data/wow/item-class/%d/item-subclass/%d?locale=%s", itemClassID, itemSubclassID, c.locale), + c.staticClassicNamespace, + ) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// ClassicWoWItem returns an item by ID +func (c *Client) ClassicWoWItem(ctx context.Context, itemID int) (*wowcgd.Item, []byte, error) { + var ( + dat wowcgd.Item + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/item/%d?locale=%s", itemID, c.locale), c.staticClassicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// ClassicWoWItemMedia returns media for an item by ID +func (c *Client) ClassicWoWItemMedia(ctx context.Context, itemID int) (*wowcgd.ItemMedia, []byte, error) { + var ( + dat wowcgd.ItemMedia + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/media/item/%d?locale=%s", itemID, c.locale), c.staticClassicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// ClassicWoWPlayableClassesIndex returns an index of playable classes +func (c *Client) ClassicWoWPlayableClassesIndex(ctx context.Context) (*wowcgd.PlayableClassesIndex, []byte, error) { + var ( + dat wowcgd.PlayableClassesIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/playable-class/index?locale=%s", c.locale), c.staticClassicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// ClassicWoWPlayableClass returns a playable class by ID +func (c *Client) ClassicWoWPlayableClass(ctx context.Context, classID int) (*wowcgd.PlayableClass, []byte, error) { + var ( + dat wowcgd.PlayableClass + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/playable-class/%d?locale=%s", classID, c.locale), c.staticClassicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// ClassicWoWPlayableClassMedia returns media for a playable class by ID +func (c *Client) ClassicWoWPlayableClassMedia(ctx context.Context, playableClassID int) (*wowcgd.PlayableClassMedia, []byte, error) { + var ( + dat wowcgd.PlayableClassMedia + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/media/playable-class/%d?locale=%s", playableClassID, c.locale), c.staticClassicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// ClassicWoWPlayableRacesIndex returns an index of playable races +func (c *Client) ClassicWoWPlayableRacesIndex(ctx context.Context) (*wowcgd.PlayableRacesIndex, []byte, error) { + var ( + dat wowcgd.PlayableRacesIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/playable-race/index?locale=%s", c.locale), c.staticClassicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// ClassicWoWPlayableRace returns a playable race by ID +func (c *Client) ClassicWoWPlayableRace(ctx context.Context, raceID int) (*wowcgd.PlayableRace, []byte, error) { + var ( + dat wowcgd.PlayableRace + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/playable-race/%d?locale=%s", raceID, c.locale), c.staticClassicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// ClassicWoWPowerTypesIndex returns an index of power types +func (c *Client) ClassicWoWPowerTypesIndex(ctx context.Context) (*wowcgd.PowerTypesIndex, []byte, error) { + var ( + dat wowcgd.PowerTypesIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/power-type/index?locale=%s", c.locale), c.staticClassicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// ClassicWoWPowerType returns a power type by ID +func (c *Client) ClassicWoWPowerType(ctx context.Context, powerTypeID int) (*wowcgd.PowerType, []byte, error) { + var ( + dat wowcgd.PowerType + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/power-type/%d?locale=%s", powerTypeID, c.locale), c.staticClassicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// ClassicWoWRealmIndex returns an index of realms. +func (c *Client) ClassicWoWRealmIndex(ctx context.Context) (*wowgd.RealmIndex, []byte, error) { + var ( + dat wowgd.RealmIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/realm/index?locale=%s", c.locale), c.dynamicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// ClassicWoWRealm returns a single realm by slug or ID. +func (c *Client) ClassicWoWRealm(ctx context.Context, realmSlug string) (*wowgd.Realm, []byte, error) { + var ( + dat wowgd.Realm + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/realm/%s?locale=%s", realmSlug, c.locale), c.dynamicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// ClassicWoWRegionIndex returns an index of regions. +func (c *Client) ClassicWoWRegionIndex(ctx context.Context) (*wowgd.RegionIndex, []byte, error) { + var ( + dat wowgd.RegionIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/region/index?locale=%s", c.locale), c.dynamicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} diff --git a/v2/wowcgd/creature.go b/v2/wowcgd/creature.go new file mode 100644 index 0000000..c9a0f5d --- /dev/null +++ b/v2/wowcgd/creature.go @@ -0,0 +1,118 @@ +package wowcgd + +// CreatureFamiliesIndex structure +type CreatureFamiliesIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + CreatureFamilies []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"creature_families"` +} + +// CreatureFamily structure +type CreatureFamily struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ID int `json:"id"` + Name string `json:"name"` + Media struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + } `json:"media"` +} + +// CreatureTypesIndex structure +type CreatureTypesIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + CreatureTypes []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"creature_types"` +} + +// CreatureType structure +type CreatureType struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ID int `json:"id"` + Name string `json:"name"` +} + +// Creature structure +type Creature struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ID int `json:"id"` + Name string `json:"name"` + Type struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"type"` + Family struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"family"` + CreatureDisplays []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + } `json:"creature_displays"` + IsTameable bool `json:"is_tameable"` +} + +// CreatureDisplayMedia structure +type CreatureDisplayMedia struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Assets []struct { + Key string `json:"key"` + Value string `json:"value"` + } `json:"assets"` +} + +// CreatureFamilyMedia structure +type CreatureFamilyMedia struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Assets []struct { + Key string `json:"key"` + Value string `json:"value"` + } `json:"assets"` +} diff --git a/v2/wowcgd/guildCrest.go b/v2/wowcgd/guildCrest.go new file mode 100644 index 0000000..a40c60f --- /dev/null +++ b/v2/wowcgd/guildCrest.go @@ -0,0 +1,52 @@ +package wowcgd + +// GuildCrestComponentsIndex structure +type GuildCrestComponentsIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Emblems []struct { + ID int `json:"id"` + Media struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + } `json:"media"` + } `json:"emblems"` + Borders []struct { + ID int `json:"id"` + Media struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + } `json:"media"` + } `json:"borders"` +} + +// GuildCrestBorderMdedia structure +type GuildCrestBorderMdedia struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Assets []struct { + Key string `json:"key"` + Value string `json:"value"` + } `json:"assets"` +} + +// GuildCrestEmblemMdedia structure +type GuildCrestEmblemMdedia struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Assets []struct { + Key string `json:"key"` + Value string `json:"value"` + } `json:"assets"` +} diff --git a/v2/wowcgd/item.go b/v2/wowcgd/item.go new file mode 100644 index 0000000..32e7c37 --- /dev/null +++ b/v2/wowcgd/item.go @@ -0,0 +1,107 @@ +package wowcgd + +// ItemClassesIndex structure +type ItemClassesIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ItemClasses []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"item_classes"` +} + +// ItemClass structure +type ItemClass struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ClassID int `json:"class_id"` + Name string `json:"name"` + ItemSubclasses []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"item_subclasses"` +} + +// ItemSubclass structure +type ItemSubclass struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ClassID int `json:"class_id"` + SubclassID int `json:"subclass_id"` + DisplayName string `json:"display_name"` + HideSubclassInTooltips bool `json:"hide_subclass_in_tooltips"` +} + +// Item structure +type Item struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ID int `json:"id"` + Name string `json:"name"` + Quality struct { + Type string `json:"type"` + Name string `json:"name"` + } `json:"quality"` + Level int `json:"level"` + RequiredLevel int `json:"required_level"` + 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"` + PurchasePrice int `json:"purchase_price"` + SellPrice int `json:"sell_price"` + MaxCount int `json:"max_count"` + IsEquippable bool `json:"is_equippable"` + IsStackable bool `json:"is_stackable"` +} + +// ItemMedia structure +type ItemMedia struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Assets []struct { + Key string `json:"key"` + Value string `json:"value"` + } `json:"assets"` +} diff --git a/v2/wowcgd/playableClass.go b/v2/wowcgd/playableClass.go new file mode 100644 index 0000000..94f1078 --- /dev/null +++ b/v2/wowcgd/playableClass.go @@ -0,0 +1,57 @@ +package wowcgd + +// PlayableClassesIndex structure +type PlayableClassesIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Classes []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"classes"` +} + +// PlayableClass structure +type PlayableClass struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ID int `json:"id"` + Name string `json:"name"` + GenderName struct { + Male string `json:"male"` + Female string `json:"female"` + } `json:"gender_name"` + PowerType struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"power_type"` + Media struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + } `json:"media"` + PvpTalentSlots struct { + Href string `json:"href"` + } `json:"pvp_talent_slots"` +} + +// PlayableClassMedia structure +type PlayableClassMedia struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` +} diff --git a/v2/wowcgd/playableRace.go b/v2/wowcgd/playableRace.go new file mode 100644 index 0000000..75c5f06 --- /dev/null +++ b/v2/wowcgd/playableRace.go @@ -0,0 +1,38 @@ +package wowcgd + +// PlayableRacesIndex structure +type PlayableRacesIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Races []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"races"` +} + +// PlayableRace structure +type PlayableRace struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ID int `json:"id"` + Name string `json:"name"` + GenderName struct { + Male string `json:"male"` + Female string `json:"female"` + } `json:"gender_name"` + Faction struct { + Type string `json:"type"` + Name string `json:"name"` + } `json:"faction"` + IsSelectable bool `json:"is_selectable"` + IsAlliedRace bool `json:"is_allied_race"` +} diff --git a/v2/wowcgd/powerType.go b/v2/wowcgd/powerType.go new file mode 100644 index 0000000..2345694 --- /dev/null +++ b/v2/wowcgd/powerType.go @@ -0,0 +1,28 @@ +package wowcgd + +// PowerTypesIndex structure +type PowerTypesIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + PowerTypes []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"power_types"` +} + +// PowerType structure +type PowerType struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ID int `json:"id"` + Name string `json:"name"` +} diff --git a/v2/wowcgd/wowcgd.go b/v2/wowcgd/wowcgd.go new file mode 100644 index 0000000..c6d13a1 --- /dev/null +++ b/v2/wowcgd/wowcgd.go @@ -0,0 +1,2 @@ +// Package wowcgd contains types for the World of Warcraft Classic Game Data APIs +package wowcgd diff --git a/v2/wowcgd_test.go b/v2/wowcgd_test.go new file mode 100644 index 0000000..dc2694b --- /dev/null +++ b/v2/wowcgd_test.go @@ -0,0 +1,307 @@ +package blizzard + +import ( + "context" + "fmt" + "testing" +) + +func TestClassicWoWCreatureFamiliesIndex(t *testing.T) { + dat, _, err := c.ClassicWoWCreatureFamiliesIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestClassicWoWCreatureFamily(t *testing.T) { + dat, _, err := c.ClassicWoWCreatureFamily(context.Background(), 1) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestClassicWoWCreatureTypesIndex(t *testing.T) { + dat, _, err := c.ClassicWoWCreatureTypesIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestClassicWoWCreatureType(t *testing.T) { + dat, _, err := c.ClassicWoWCreatureType(context.Background(), 1) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestClassicWoWCreature(t *testing.T) { + dat, _, err := c.ClassicWoWCreature(context.Background(), 30) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestClassicWoWCreatureDisplayMedia(t *testing.T) { + dat, _, err := c.ClassicWoWCreatureDisplayMedia(context.Background(), 30) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestClassicWoWCreatureFamilyMedia(t *testing.T) { + dat, _, err := c.ClassicWoWCreatureFamilyMedia(context.Background(), 1) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestClassicWoWGuildCrestComponentsIndex(t *testing.T) { + dat, _, err := c.ClassicWoWGuildCrestComponentsIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestClassicWoWGuildCrestBorderMedia(t *testing.T) { + dat, _, err := c.ClassicWoWGuildCrestBorderMedia(context.Background(), 0) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestClassicWoWGuildCrestEmblemMedia(t *testing.T) { + dat, _, err := c.ClassicWoWGuildCrestEmblemMedia(context.Background(), 0) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestClassicWoWItemClassesIndex(t *testing.T) { + dat, _, err := c.ClassicWoWItemClassesIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestClassicWoWItemClass(t *testing.T) { + dat, _, err := c.ClassicWoWItemClass(context.Background(), 0) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestClassicWoWItemSubclass(t *testing.T) { + dat, _, err := c.ClassicWoWItemSubclass(context.Background(), 0, 0) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestClassicWoWItem(t *testing.T) { + dat, _, err := c.ClassicWoWItem(context.Background(), 19019) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestClassicWoWItemMedia(t *testing.T) { + dat, _, err := c.ClassicWoWItemMedia(context.Background(), 19019) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestClassicWoWPlayableClassesIndex(t *testing.T) { + dat, _, err := c.ClassicWoWPlayableClassesIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestClassicWoWPlayableClass(t *testing.T) { + dat, _, err := c.ClassicWoWPlayableClass(context.Background(), 7) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestClassicWoWPlayableClassMedia(t *testing.T) { + dat, _, err := c.ClassicWoWPlayableClassMedia(context.Background(), 7) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestClassicWoWPlayableRacesIndex(t *testing.T) { + dat, _, err := c.ClassicWoWPlayableRacesIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestClassicWoWPlayableRace(t *testing.T) { + dat, _, err := c.ClassicWoWPlayableRace(context.Background(), 2) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestClassicWoWPowerTypesIndex(t *testing.T) { + dat, _, err := c.ClassicWoWPowerTypesIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestClassicWoWPowerType(t *testing.T) { + dat, _, err := c.ClassicWoWPowerType(context.Background(), 0) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestClassicWoWRealmIndex(t *testing.T) { + dat, _, err := c.ClassicWoWRealmIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestClassicWoWRealm(t *testing.T) { + dat, _, err := c.ClassicWoWRealm(context.Background(), "tichondrius") + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestClassicWoWRegionIndex(t *testing.T) { + dat, _, err := c.ClassicWoWRegionIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} diff --git a/v2/wowgd.go b/v2/wowgd.go new file mode 100644 index 0000000..b62e266 --- /dev/null +++ b/v2/wowgd.go @@ -0,0 +1,1674 @@ +package blizzard + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/FuzzyStatic/blizzard/v2/wowgd" +) + +// WoWAchievementCategoriesIndex returns an index of achievement categories. +func (c *Client) WoWAchievementCategoriesIndex(ctx context.Context) (*wowgd.AchievementCategoriesIndex, []byte, error) { + var ( + dat wowgd.AchievementCategoriesIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/achievement-category/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 +} + +// WoWAchievementCategory returns an achievement category by ID. +func (c *Client) WoWAchievementCategory(ctx context.Context, achievementCategoryID int) (*wowgd.AchievementCategory, []byte, error) { + var ( + dat wowgd.AchievementCategory + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/achievement-category/%d?locale=%s", achievementCategoryID, 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 +} + +// WoWAchievementIndex returns an index of achievements. +func (c *Client) WoWAchievementIndex(ctx context.Context) (*wowgd.AchievementIndex, []byte, error) { + var ( + dat wowgd.AchievementIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/achievement/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 +} + +// WoWAchievement returns an achievement category by ID. +func (c *Client) WoWAchievement(ctx context.Context, achievementID int) (*wowgd.Achievement, []byte, error) { + var ( + dat wowgd.Achievement + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/achievement/%d?locale=%s", achievementID, 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 +} + +// WoWAchievementMedia returns media for an achievement by ID. +func (c *Client) WoWAchievementMedia(ctx context.Context, achievementID int) (*wowgd.AchievementMedia, []byte, error) { + var ( + dat wowgd.AchievementMedia + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/media/achievement/%d?locale=%s", achievementID, 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 +} + +// WoWAzeriteEssenceIndex returns an index of azerite essences. +func (c *Client) WoWAzeriteEssenceIndex(ctx context.Context) (*wowgd.AzeriteEssenceIndex, []byte, error) { + var ( + dat wowgd.AzeriteEssenceIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/azerite-essence/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 +} + +// WoWAzeriteEssence returns an azerite essence by ID. +func (c *Client) WoWAzeriteEssence(ctx context.Context, azeriteEssenceID int) (*wowgd.AzeriteEssence, []byte, error) { + var ( + dat wowgd.AzeriteEssence + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/azerite-essence/%d?locale=%s", azeriteEssenceID, 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 +} + +// WoWAzeriteEssenceMedia returns media for an azerite essence by ID. +func (c *Client) WoWAzeriteEssenceMedia(ctx context.Context, azeriteEssenceID int) (*wowgd.AzeriteEssenceMedia, []byte, error) { + var ( + dat wowgd.AzeriteEssenceMedia + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/media/azerite-essence/%d?locale=%s", azeriteEssenceID, 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 +} + +// WoWConnectedRealmIndex returns an index of connected realms +func (c *Client) WoWConnectedRealmIndex(ctx context.Context) (*wowgd.ConnectedRealmIndex, []byte, error) { + var ( + dat wowgd.ConnectedRealmIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/connected-realm/index?locale=%s", c.locale), c.dynamicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWConnectedRealm returns a single connected realm by ID +func (c *Client) WoWConnectedRealm(ctx context.Context, connectedRealmID int) (*wowgd.ConnectedRealm, []byte, error) { + var ( + dat wowgd.ConnectedRealm + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/connected-realm/%d?locale=%s", connectedRealmID, c.locale), c.dynamicNamespace) + 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(ctx context.Context) (*wowgd.CreatureFamiliesIndex, []byte, error) { + var ( + dat wowgd.CreatureFamiliesIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/creature-family/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 +} + +// WoWCreatureFamily returns a creature family by ID. +func (c *Client) WoWCreatureFamily(ctx context.Context, creatureFamilyID int) (*wowgd.CreatureFamily, []byte, error) { + var ( + dat wowgd.CreatureFamily + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/creature-family/%d?locale=%s", creatureFamilyID, 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 +} + +// WoWCreatureTypesIndex returns an index of creature types. +func (c *Client) WoWCreatureTypesIndex(ctx context.Context) (*wowgd.CreatureTypesIndex, []byte, error) { + var ( + dat wowgd.CreatureTypesIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/creature-type/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 +} + +// WoWCreatureType returns a creature type by ID. +func (c *Client) WoWCreatureType(ctx context.Context, creatureTypeID int) (*wowgd.CreatureType, []byte, error) { + var ( + dat wowgd.CreatureType + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/creature-type/%d?locale=%s", creatureTypeID, 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 +} + +// WoWCreature returns a creature type by ID. +func (c *Client) WoWCreature(ctx context.Context, creatureID int) (*wowgd.Creature, []byte, error) { + var ( + dat wowgd.Creature + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/creature/%d?locale=%s", creatureID, 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 +} + +// WoWCreatureDisplayMedia returns media for a creature display by ID. +func (c *Client) WoWCreatureDisplayMedia(ctx context.Context, creatureDisplayID int) (*wowgd.CreatureDisplayMedia, []byte, error) { + var ( + dat wowgd.CreatureDisplayMedia + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/media/creature-display/%d?locale=%s", creatureDisplayID, 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 +} + +// WoWCreatureFamilyMedia returns media for a creature family by ID. +func (c *Client) WoWCreatureFamilyMedia(ctx context.Context, creatureFamilyID int) (*wowgd.CreatureFamilyMedia, []byte, error) { + var ( + dat wowgd.CreatureFamilyMedia + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/media/creature-family/%d?locale=%s", creatureFamilyID, 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 +} + +// WoWGuildCrestComponentsIndex returns an index of guild crest media. +func (c *Client) WoWGuildCrestComponentsIndex(ctx context.Context) (*wowgd.GuildCrestComponentsIndex, []byte, error) { + var ( + dat wowgd.GuildCrestComponentsIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/guild-crest/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 +} + +// WoWGuildCrestBorderMedia returns media for a guild crest border by ID. +func (c *Client) WoWGuildCrestBorderMedia(ctx context.Context, borderID int) (*wowgd.GuildCrestBorderMdedia, []byte, error) { + var ( + dat wowgd.GuildCrestBorderMdedia + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/media/guild-crest/border/%d?locale=%s", borderID, 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 +} + +// WoWGuildCrestEmblemMedia returns media for a guild crest emblem by ID. +func (c *Client) WoWGuildCrestEmblemMedia(ctx context.Context, emblemID int) (*wowgd.GuildCrestEmblemMdedia, []byte, error) { + var ( + dat wowgd.GuildCrestEmblemMdedia + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/media/guild-crest/emblem/%d?locale=%s", emblemID, 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 +} + +// WoWItemClassesIndex returns an index of item classes. +func (c *Client) WoWItemClassesIndex(ctx context.Context) (*wowgd.ItemClassesIndex, []byte, error) { + var ( + dat wowgd.ItemClassesIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/item-class/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 +} + +// WoWItemClass returns an item class by ID. +func (c *Client) WoWItemClass(ctx context.Context, itemClassID int) (*wowgd.ItemClass, []byte, error) { + var ( + dat wowgd.ItemClass + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/item-class/%d?locale=%s", itemClassID, 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 +} + +// WoWItemSubclass returns an item subclass by ID. +func (c *Client) WoWItemSubclass(ctx context.Context, itemClassID, itemSubclassID int) (*wowgd.ItemSubclass, []byte, error) { + var ( + dat wowgd.ItemSubclass + b []byte + err error + ) + + b, err = c.getURLBody(ctx, + c.apiURL+fmt.Sprintf("/data/wow/item-class/%d/item-subclass/%d?locale=%s", itemClassID, itemSubclassID, 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 +} + +// WoWItem returns an item by ID. +func (c *Client) WoWItem(ctx context.Context, itemID int) (*wowgd.Item, []byte, error) { + var ( + dat wowgd.Item + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/item/%d?locale=%s", itemID, 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 +} + +// WoWItemMedia returns media for an item by ID. +func (c *Client) WoWItemMedia(ctx context.Context, itemID int) (*wowgd.ItemMedia, []byte, error) { + var ( + dat wowgd.ItemMedia + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/media/item/%d?locale=%s", itemID, 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 +} + +// WoWJournalExpansionsIndex returns an index of journal expansions. +func (c *Client) WoWJournalExpansionsIndex(ctx context.Context) (*wowgd.JournalExpansionsIndex, []byte, error) { + var ( + dat wowgd.JournalExpansionsIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/journal-expansion/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 +} + +// WoWJournalExpansion returns a journal expansion by ID. +func (c *Client) WoWJournalExpansion(ctx context.Context, journalExpansionID int) (*wowgd.JournalExpansion, []byte, error) { + var ( + dat wowgd.JournalExpansion + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/journal-expansion/%d?locale=%s", + journalExpansionID, 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 +} + +// WoWJournalEncountersIndex returns an index of journal encounters. +func (c *Client) WoWJournalEncountersIndex(ctx context.Context) (*wowgd.JournalEncountersIndex, []byte, error) { + var ( + dat wowgd.JournalEncountersIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/journal-encounter/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 +} + +// WoWJournalEncounter returns a journal expansion by ID. +func (c *Client) WoWJournalEncounter(ctx context.Context, journalEncounterID int) (*wowgd.JournalEncounter, []byte, error) { + var ( + dat wowgd.JournalEncounter + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/journal-encounter/%d?locale=%s", + journalEncounterID, 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 +} + +// WoWJournalInstancesIndex returns an index of journal instances. +func (c *Client) WoWJournalInstancesIndex(ctx context.Context) (*wowgd.JournalInstancesIndex, []byte, error) { + var ( + dat wowgd.JournalInstancesIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/journal-instance/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 +} + +// WoWJournalInstance returns a journal instance. +func (c *Client) WoWJournalInstance(ctx context.Context, journalInstanceID int) (*wowgd.JournalInstance, []byte, error) { + var ( + dat wowgd.JournalInstance + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/journal-instance/%d?locale=%s", + journalInstanceID, 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 +} + +// WoWMountIndex returns an index of mounts. +func (c *Client) WoWMountIndex(ctx context.Context) (*wowgd.MountIndex, []byte, error) { + var ( + dat wowgd.MountIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/mount/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 +} + +// WoWMount returns a mount by ID. +func (c *Client) WoWMount(ctx context.Context, mountID int) (*wowgd.Mount, []byte, error) { + var ( + dat wowgd.Mount + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/mount/%d?locale=%s", mountID, 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 +} + +// WoWMythicKeystoneAffixIndex returns an index of Keystone affixes +func (c *Client) WoWMythicKeystoneAffixIndex(ctx context.Context) (*wowgd.MythicKeystoneAffixIndex, []byte, error) { + var ( + dat wowgd.MythicKeystoneAffixIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/keystone-affix/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 +} + +// WoWMythicKeystoneAffix returns a single connected realm by ID +func (c *Client) WoWMythicKeystoneAffix(ctx context.Context, keystoneAffixID int) (*wowgd.MythicKeystoneAffix, []byte, error) { + var ( + dat wowgd.MythicKeystoneAffix + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/keystone-affix/%d?locale=%s", keystoneAffixID, 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 +} + +// WoWMythicRaidLeaderboard returns the leaderboard for a given raid and faction +func (c *Client) WoWMythicRaidLeaderboard(ctx context.Context, raid, faction string) (*wowgd.MythicRaidLeaderboard, []byte, error) { + var ( + dat wowgd.MythicRaidLeaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/leaderboard/hall-of-fame/%s/%s?locale=%s", raid, faction, c.locale), c.dynamicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWMythicKeystoneDungeonIndex returns an index of Mythic Keystone dungeons +func (c *Client) WoWMythicKeystoneDungeonIndex(ctx context.Context) (*wowgd.MythicKeystoneDungeonIndex, []byte, error) { + var ( + dat wowgd.MythicKeystoneDungeonIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/mythic-keystone/dungeon/index?locale=%s", c.locale), c.dynamicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWMythicKeystoneDungeon returns a Mythic Keystone dungeon by ID +func (c *Client) WoWMythicKeystoneDungeon(ctx context.Context, dungeonID int) (*wowgd.MythicKeystoneDungeon, []byte, error) { + var ( + dat wowgd.MythicKeystoneDungeon + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/mythic-keystone/dungeon/%d?locale=%s", dungeonID, c.locale), c.dynamicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWMythicKeystoneIndex returns n index of links to other documents related to Mythic Keystone dungeons +func (c *Client) WoWMythicKeystoneIndex(ctx context.Context) (*wowgd.MythicKeystoneIndex, []byte, error) { + var ( + dat wowgd.MythicKeystoneIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/mythic-keystone/index?locale=%s", c.locale), c.dynamicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWMythicKeystonePeriodIndex returns an index of Mythic Keystone periods +func (c *Client) WoWMythicKeystonePeriodIndex(ctx context.Context) (*wowgd.MythicKeystonePeriodIndex, []byte, error) { + var ( + dat wowgd.MythicKeystonePeriodIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/mythic-keystone/period/index?locale=%s", c.locale), c.dynamicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWMythicKeystonePeriod returns a Mythic Keystone period by ID +func (c *Client) WoWMythicKeystonePeriod(ctx context.Context, periodID int) (*wowgd.MythicKeystonePeriod, []byte, error) { + var ( + dat wowgd.MythicKeystonePeriod + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/mythic-keystone/period/%d?locale=%s", periodID, c.locale), c.dynamicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWMythicKeystoneSeasonIndex returns an index of Mythic Keystone seasons +func (c *Client) WoWMythicKeystoneSeasonIndex(ctx context.Context) (*wowgd.MythicKeystoneSeasonIndex, []byte, error) { + var ( + dat wowgd.MythicKeystoneSeasonIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/mythic-keystone/season/index?locale=%s", c.locale), c.dynamicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWMythicKeystoneSeason returns a Mythic Keystone season by ID +func (c *Client) WoWMythicKeystoneSeason(ctx context.Context, seasonID int) (*wowgd.MythicKeystoneSeason, []byte, error) { + var ( + dat wowgd.MythicKeystoneSeason + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/mythic-keystone/season/%d?locale=%s", seasonID, c.locale), c.dynamicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWMythicKeystoneLeaderboardIndex returns an index of Mythic Keystone Leaderboard dungeon instances for a connected realm +func (c *Client) WoWMythicKeystoneLeaderboardIndex(ctx context.Context, connectedRealmID int) (*wowgd.MythicKeystoneLeaderboardIndex, []byte, error) { + var ( + dat wowgd.MythicKeystoneLeaderboardIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/connected-realm/%d/mythic-leaderboard/index?locale=%s", connectedRealmID, c.locale), c.dynamicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWMythicKeystoneLeaderboard returns a weekly Mythic Keystone Leaderboard by period +func (c *Client) WoWMythicKeystoneLeaderboard(ctx context.Context, connectedRealmID, dungeonID, period int) (*wowgd.MythicKeystoneLeaderboard, []byte, error) { + var ( + dat wowgd.MythicKeystoneLeaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/connected-realm/%d/mythic-leaderboard/%d/period/%d?locale=%s", connectedRealmID, dungeonID, period, c.locale), c.dynamicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWPetIndex returns an index of pets. +func (c *Client) WoWPetIndex(ctx context.Context) (*wowgd.PetIndex, []byte, error) { + var ( + dat wowgd.PetIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/pet/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 +} + +// WoWPet returns a pet by ID. +func (c *Client) WoWPet(ctx context.Context, petID int) (*wowgd.Pet, []byte, error) { + var ( + dat wowgd.Pet + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/pet/%d?locale=%s", petID, 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 +} + +// WoWPetMedia returns media information for a pet ID. +func (c *Client) WoWPetMedia(ctx context.Context, petID int) (*wowgd.PetMedia, []byte, error) { + var ( + dat wowgd.PetMedia + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/media/pet/%d?locale=%s", petID, 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 +} + +// WoWPetAbilityIndex returns an index of pet abilities. +func (c *Client) WoWPetAbilityIndex(ctx context.Context) (*wowgd.PetAbilityIndex, []byte, error) { + var ( + dat wowgd.PetAbilityIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/pet-ability/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 +} + +// WoWPetAbility returns a pet ability by ID. +func (c *Client) WoWPetAbility(ctx context.Context, petAbilityID int) (*wowgd.PetAbility, []byte, error) { + var ( + dat wowgd.PetAbility + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/pet-ability/%d?locale=%s", petAbilityID, 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 +} + +// WoWPetAbilityMedia returns media information for a pet ID. +func (c *Client) WoWPetAbilityMedia(ctx context.Context, petAbilityID int) (*wowgd.PetMedia, []byte, error) { + var ( + dat wowgd.PetMedia + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/media/pet-ability/%d?locale=%s", petAbilityID, 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 +} + +// WoWPlayableClassesIndex returns an index of playable classes +func (c *Client) WoWPlayableClassesIndex(ctx context.Context) (*wowgd.PlayableClassesIndex, []byte, error) { + var ( + dat wowgd.PlayableClassesIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/playable-class/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 +} + +// WoWPlayableClass returns a playable class by ID +func (c *Client) WoWPlayableClass(ctx context.Context, classID int) (*wowgd.PlayableClass, []byte, error) { + var ( + dat wowgd.PlayableClass + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/playable-class/%d?locale=%s", classID, 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 +} + +// WoWPlayableClassPvPTalentSlots returns the PvP talent slots for a playable class by ID +func (c *Client) WoWPlayableClassPvPTalentSlots(ctx context.Context, classID int) (*wowgd.PlayableClassPvPTalentSlots, []byte, error) { + var ( + dat wowgd.PlayableClassPvPTalentSlots + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/playable-class/%d/pvp-talent-slots?locale=%s", classID, 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 +} + +// WoWPlayableRacesIndex returns an index of races. +func (c *Client) WoWPlayableRacesIndex(ctx context.Context) (*wowgd.PlayableRacesIndex, []byte, error) { + var ( + dat wowgd.PlayableRacesIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/playable-race/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 +} + +// WoWPlayableRace returns a race by ID. +func (c *Client) WoWPlayableRace(ctx context.Context, raceID int) (*wowgd.PlayableRace, []byte, error) { + var ( + dat wowgd.PlayableRace + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/playable-race/%d?locale=%s", raceID, 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 +} + +// WoWPlayableSpecializationIndex returns an index of playable specializations. +func (c *Client) WoWPlayableSpecializationIndex(ctx context.Context) (*wowgd.PlayableSpecializationIndex, []byte, error) { + var ( + dat wowgd.PlayableSpecializationIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/playable-specialization/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 +} + +// WoWPlayableSpecialization returns a playable specialization by ID. +func (c *Client) WoWPlayableSpecialization(ctx context.Context, specID int) (*wowgd.PlayableSpecialization, []byte, error) { + var ( + dat wowgd.PlayableSpecialization + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/playable-specialization/%d?locale=%s", specID, 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 +} + +// WoWPowerTypesIndex returns an index of power types. +func (c *Client) WoWPowerTypesIndex(ctx context.Context) (*wowgd.PowerTypesIndex, []byte, error) { + var ( + dat wowgd.PowerTypesIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/power-type/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 +} + +// WoWPowerType returns a power type by ID. +func (c *Client) WoWPowerType(ctx context.Context, powerTypeID int) (*wowgd.PowerType, []byte, error) { + var ( + dat wowgd.PowerType + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/power-type/%d?locale=%s", powerTypeID, 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 +} + +// WoWPvPSeasonIndex returns an index of PvP seasons. +func (c *Client) WoWPvPSeasonIndex(ctx context.Context) (*wowgd.PvPSeasonIndex, []byte, error) { + var ( + dat wowgd.PvPSeasonIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/pvp-season/index?locale=%s", c.locale), c.dynamicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWPvPSeason returns a PvP season by ID. +func (c *Client) WoWPvPSeason(ctx context.Context, pvpSeasonID int) (*wowgd.PvPSeason, []byte, error) { + var ( + dat wowgd.PvPSeason + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/pvp-season/%d?locale=%s", pvpSeasonID, c.locale), c.dynamicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWPvPLeaderboardsIndex returns an index of PvP leaderboards for a PvP season. +func (c *Client) WoWPvPLeaderboardsIndex(ctx context.Context, pvpSeasonID int) (*wowgd.PvPLeaderboardsIndex, []byte, error) { + var ( + dat wowgd.PvPLeaderboardsIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/pvp-season/%d/pvp-leaderboard/index?locale=%s", pvpSeasonID, c.locale), c.dynamicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWPvPLeaderboard returns the PvP leaderboard of a specific PvP bracket for a PvP season. +func (c *Client) WoWPvPLeaderboard(ctx context.Context, pvpSeasonID int, pvpBracket wowgd.Bracket) (*wowgd.PvPLeaderboard, []byte, error) { + var ( + dat wowgd.PvPLeaderboard + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/pvp-season/%d/pvp-leaderboard/%s?locale=%s", pvpSeasonID, pvpBracket, c.locale), c.dynamicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWPvPRewardsIndex returns an index of PvP rewards for a PvP season. +func (c *Client) WoWPvPRewardsIndex(ctx context.Context, pvpSeasonID int) (*wowgd.PvPRewardsIndex, []byte, error) { + var ( + dat wowgd.PvPRewardsIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/pvp-season/%d/pvp-reward/index?locale=%s", pvpSeasonID, c.locale), c.dynamicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWPvPTierMedia returns media for a PvP tier by ID. +func (c *Client) WoWPvPTierMedia(ctx context.Context, pvpTierID int) (*wowgd.PvPTierMedia, []byte, error) { + var ( + dat wowgd.PvPTierMedia + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/media/pvp-tier/%d?locale=%s", pvpTierID, 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 +} + +// WoWPvPTiersIndex returns an index of PvP tiers. +func (c *Client) WoWPvPTiersIndex(ctx context.Context) (*wowgd.PvPTiersIndex, []byte, error) { + var ( + dat wowgd.PvPTiersIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/pvp-tier/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 +} + +// WoWPvPTier returns a PvP tier by ID. +func (c *Client) WoWPvPTier(ctx context.Context, pvpTierID int) (*wowgd.PvPTier, []byte, error) { + var ( + dat wowgd.PvPTier + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/pvp-tier/%d?locale=%s", pvpTierID, 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 +} + +// WoWRealmIndex returns an index of realms. +func (c *Client) WoWRealmIndex(ctx context.Context) (*wowgd.RealmIndex, []byte, error) { + var ( + dat wowgd.RealmIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/realm/index?locale=%s", c.locale), c.dynamicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWRealm returns a single realm by slug or ID. +func (c *Client) WoWRealm(ctx context.Context, realmSlug string) (*wowgd.Realm, []byte, error) { + var ( + dat wowgd.Realm + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/realm/%s?locale=%s", realmSlug, c.locale), c.dynamicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWRegionIndex returns an index of regions. +func (c *Client) WoWRegionIndex(ctx context.Context) (*wowgd.RegionIndex, []byte, error) { + var ( + dat wowgd.RegionIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/region/index?locale=%s", c.locale), c.dynamicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWRegion returns a single region by ID. +func (c *Client) WoWRegion(ctx context.Context, regionID int) (*wowgd.Region, []byte, error) { + var ( + dat wowgd.Region + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/region/%d?locale=%s", regionID, c.locale), c.dynamicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWReputationFactionsIndex returns an index of reputation factions. +func (c *Client) WoWReputationFactionsIndex(ctx context.Context) (*wowgd.ReputationFactionsIndex, []byte, error) { + var ( + dat wowgd.ReputationFactionsIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/reputation-faction/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 +} + +// WoWReputationFaction returns a single reputation faction by ID. +func (c *Client) WoWReputationFaction(ctx context.Context, reputationFactionID int) (*wowgd.ReputationFaction, []byte, error) { + var ( + dat wowgd.ReputationFaction + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/pvp-tier/%d?locale=%s", reputationFactionID, 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 +} + +// WoWReputationTiersIndex returns an index of reputation tiers. +func (c *Client) WoWReputationTiersIndex(ctx context.Context) (*wowgd.ReputationTiersIndex, []byte, error) { + var ( + dat wowgd.ReputationTiersIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/reputation-tiers/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 +} + +// WoWReputationTiers returns a single set of reputation tiers by ID. +func (c *Client) WoWReputationTiers(ctx context.Context, reputationTiersID int) (*wowgd.ReputationTiers, []byte, error) { + var ( + dat wowgd.ReputationTiers + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/reputation-tiers/%d?locale=%s", reputationTiersID, 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 +} + +// WoWTitlesIndex returns an index of titles. +func (c *Client) WoWTitlesIndex(ctx context.Context) (*wowgd.TitlesIndex, []byte, error) { + var ( + dat wowgd.TitlesIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/title/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 +} + +// WoWTitle returns a title by ID. +func (c *Client) WoWTitle(ctx context.Context, titleID int) (*wowgd.Title, []byte, error) { + var ( + dat wowgd.Title + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/title/%d?locale=%s", titleID, 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 +} + +// WoWToken returns the WoW Token index +func (c *Client) WoWToken(ctx context.Context) (*wowgd.Token, []byte, error) { + var ( + dat wowgd.Token + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+fmt.Sprintf("/data/wow/token/index?locale=%s", c.locale), c.dynamicNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} diff --git a/v2/wowgd/achievement.go b/v2/wowgd/achievement.go new file mode 100644 index 0000000..64e073b --- /dev/null +++ b/v2/wowgd/achievement.go @@ -0,0 +1,170 @@ +package wowgd + +// AchievementCategoriesIndex structure +type AchievementCategoriesIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Categories []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"categories"` + RootCategories []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"root_categories"` + GuildCategories []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"guild_categories"` +} + +// AchievementCategory structure +type AchievementCategory struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ID int `json:"id"` + Name string `json:"name"` + Achievements []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"achievements"` + Subcategories []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"subcategories"` + IsGuildCategory bool `json:"is_guild_category"` + AggregatesByFaction struct { + Alliance struct { + Quantity int `json:"quantity"` + Points int `json:"points"` + } `json:"alliance"` + Horde struct { + Quantity int `json:"quantity"` + Points int `json:"points"` + } `json:"horde"` + } `json:"aggregates_by_faction"` + DisplayOrder int `json:"display_order"` +} + +// AchievementIndex structure +type AchievementIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Achievements []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"achievements"` +} + +// ChildCriteria struct used for representing nested Achievement criteria +type ChildCriteria []struct { + ID int `json:"id"` + Description string `json:"description"` + Amount int `json:"amount"` + Faction struct { + Type string `json:"type"` + Name string `json:"name"` + } `json:"faction,omitempty"` + Achievement struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"achievement,omitempty"` + Operator struct { + Type string `json:"type"` + Name string `json:"name"` + } `json:"operator,omitempty"` + ChildCriteria ChildCriteria `json:"child_criteria,omitempty"` +} + +// Achievement structure +type Achievement struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ID int `json:"id"` + Category struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"category"` + Name string `json:"name"` + Description string `json:"description"` + Points int `json:"points"` + IsAccountWide bool `json:"is_account_wide"` + Criteria struct { + ID int `json:"id"` + Description string `json:"description"` + Amount int `json:"amount"` + Faction struct { + Type string `json:"type"` + Name string `json:"name"` + } `json:"faction,omitempty"` + Operator struct { + Type string `json:"type"` + Name string `json:"name"` + } `json:"operator"` + ChildCriteria ChildCriteria `json:"child_criteria,omitempty"` + } `json:"criteria"` + RewardDescription string `json:"reward_description"` + NextAchievement struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"next_achievement"` + Media struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + } `json:"media"` + DisplayOrder int `json:"display_order"` +} + +// AchievementMedia structure +type AchievementMedia struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Assets []struct { + Key string `json:"key"` + Value string `json:"value"` + } `json:"assets"` +} diff --git a/v2/wowgd/azeriteEssence.go b/v2/wowgd/azeriteEssence.go new file mode 100644 index 0000000..5a12953 --- /dev/null +++ b/v2/wowgd/azeriteEssence.go @@ -0,0 +1,72 @@ +package wowgd + +// AzeriteEssenceIndex structure +type AzeriteEssenceIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + AzeriteEssences []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"azerite_essences"` +} + +// AzeriteEssence structure +type AzeriteEssence struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ID int `json:"id"` + Name string `json:"name"` + AllowedSpecializations []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"allowed_specializations"` + Powers []struct { + ID int `json:"id"` + Rank int `json:"rank"` + MainPowerSpell struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"main_power_spell"` + PassivePowerSpell struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"passive_power_spell"` + } `json:"powers"` + Media struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + } `json:"media"` +} + +// AzeriteEssenceMedia structure +type AzeriteEssenceMedia struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Assets []struct { + Key string `json:"key"` + Value string `json:"value"` + } `json:"assets"` +} diff --git a/v2/wowgd/connectedRealm.go b/v2/wowgd/connectedRealm.go new file mode 100644 index 0000000..214108a --- /dev/null +++ b/v2/wowgd/connectedRealm.go @@ -0,0 +1,58 @@ +package wowgd + +// ConnectedRealmIndex structure +type ConnectedRealmIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ConnectedRealms []struct { + Href string `json:"href"` + } `json:"connected_realms"` +} + +// ConnectedRealm structure +type ConnectedRealm struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ID int `json:"id"` + HasQueue bool `json:"has_queue"` + Status struct { + Type string `json:"type"` + Name string `json:"name"` + } `json:"status"` + Population struct { + Type string `json:"type"` + Name string `json:"name"` + } `json:"population"` + Realms []struct { + ID int `json:"id"` + Region struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"region"` + ConnectedRealm struct { + Href string `json:"href"` + } `json:"connected_realm"` + Name string `json:"name"` + Category string `json:"category"` + Locale string `json:"locale"` + Timezone string `json:"timezone"` + Type struct { + Type string `json:"type"` + Name string `json:"name"` + } `json:"type"` + IsTournament bool `json:"is_tournament"` + Slug string `json:"slug"` + } `json:"realms"` + MythicLeaderboards struct { + Href string `json:"href"` + } `json:"mythic_leaderboards"` +} diff --git a/v2/wowgd/creature.go b/v2/wowgd/creature.go new file mode 100644 index 0000000..a4288e0 --- /dev/null +++ b/v2/wowgd/creature.go @@ -0,0 +1,118 @@ +package wowgd + +// CreatureFamiliesIndex structure +type CreatureFamiliesIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + CreatureFamilies []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"creature_families"` +} + +// CreatureFamily structure +type CreatureFamily struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ID int `json:"id"` + Name string `json:"name"` + Media struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + } `json:"media"` +} + +// CreatureTypesIndex structure +type CreatureTypesIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + CreatureTypes []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"creature_types"` +} + +// CreatureType structure +type CreatureType struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ID int `json:"id"` + Name string `json:"name"` +} + +// Creature structure +type Creature struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ID int `json:"id"` + Name string `json:"name"` + Type struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"type"` + Family struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"family"` + CreatureDisplays []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + } `json:"creature_displays"` + IsTameable bool `json:"is_tameable"` +} + +// CreatureDisplayMedia structure +type CreatureDisplayMedia struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Assets []struct { + Key string `json:"key"` + Value string `json:"value"` + } `json:"assets"` +} + +// CreatureFamilyMedia structure +type CreatureFamilyMedia struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Assets []struct { + Key string `json:"key"` + Value string `json:"value"` + } `json:"assets"` +} diff --git a/v2/wowgd/guildCrest.go b/v2/wowgd/guildCrest.go new file mode 100644 index 0000000..7e6f79d --- /dev/null +++ b/v2/wowgd/guildCrest.go @@ -0,0 +1,52 @@ +package wowgd + +// GuildCrestComponentsIndex structure +type GuildCrestComponentsIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Emblems []struct { + ID int `json:"id"` + Media struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + } `json:"media"` + } `json:"emblems"` + Borders []struct { + ID int `json:"id"` + Media struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + } `json:"media"` + } `json:"borders"` +} + +// GuildCrestBorderMdedia structure +type GuildCrestBorderMdedia struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Assets []struct { + Key string `json:"key"` + Value string `json:"value"` + } `json:"assets"` +} + +// GuildCrestEmblemMdedia structure +type GuildCrestEmblemMdedia struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Assets []struct { + Key string `json:"key"` + Value string `json:"value"` + } `json:"assets"` +} diff --git a/v2/wowgd/item.go b/v2/wowgd/item.go new file mode 100644 index 0000000..7b211e5 --- /dev/null +++ b/v2/wowgd/item.go @@ -0,0 +1,107 @@ +package wowgd + +// ItemClassesIndex structure +type ItemClassesIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ItemClasses []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"item_classes"` +} + +// ItemClass structure +type ItemClass struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ClassID int `json:"class_id"` + Name string `json:"name"` + ItemSubclasses []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"item_subclasses"` +} + +// ItemSubclass structure +type ItemSubclass struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ClassID int `json:"class_id"` + SubclassID int `json:"subclass_id"` + DisplayName string `json:"display_name"` + HideSubclassInTooltips bool `json:"hide_subclass_in_tooltips"` +} + +// Item structure +type Item struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ID int `json:"id"` + Name string `json:"name"` + Quality struct { + Type string `json:"type"` + Name string `json:"name"` + } `json:"quality"` + Level int `json:"level"` + RequiredLevel int `json:"required_level"` + 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"` + PurchasePrice int `json:"purchase_price"` + SellPrice int `json:"sell_price"` + MaxCount int `json:"max_count"` + IsEquippable bool `json:"is_equippable"` + IsStackable bool `json:"is_stackable"` +} + +// ItemMedia structure +type ItemMedia struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Assets []struct { + Key string `json:"key"` + Value string `json:"value"` + } `json:"assets"` +} diff --git a/v2/wowgd/journal.go b/v2/wowgd/journal.go new file mode 100644 index 0000000..068e0c8 --- /dev/null +++ b/v2/wowgd/journal.go @@ -0,0 +1,196 @@ +package wowgd + +// JournalExpansionsIndex structure +type JournalExpansionsIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Tiers []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + Name string `json:"name"` + } `json:"tiers"` +} + +// JournalExpansion structure +type JournalExpansion struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ID int `json:"id"` + Name string `json:"name"` + Dungeons []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + Name string `json:"name"` + } `json:"dungeons"` + Raids []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + Name string `json:"name"` + } `json:"raids"` +} + +// JournalEncountersIndex structure +type JournalEncountersIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Encounters []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + Name string `json:"name"` + } `json:"encounters"` +} + +// JournalEncounter structure +type JournalEncounter struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ID int `json:"id"` + Name string `json:"name"` + Description string `json:"description"` + Creatures []struct { + ID int `json:"id"` + Name string `json:"name"` + CreatureDisplay struct { + ID int `json:"id"` + Key struct { + Href string `json:"href"` + } `json:"key"` + } `json:"creature_display"` + } `json:"creatures"` + Items []struct { + ID int `json:"id"` + Item struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + Name string `json:"name"` + } `json:"item"` + } `json:"items"` + Sections []struct { + ID int `json:"id"` + Title string `json:"title"` + BodyText string `json:"body_text"` + Sections []struct { + ID int `json:"id"` + Title string `json:"title"` + Sections []struct { + ID int `json:"id"` + Title string `json:"title"` + BodyText string `json:"body_text"` + } `json:"sections"` + CreatureDisplay struct { + ID int `json:"id"` + Key struct { + Href string `json:"href"` + } `json:"key"` + } `json:"creature_display"` + } `json:"sections"` + } `json:"sections"` + Instance struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + Name string `json:"name"` + } `json:"instance"` + Category struct { + Type string `json:"type"` + } `json:"category"` + Modes []struct { + Type string `json:"type"` + Name string `json:"name"` + } `json:"modes"` +} + +// JournalInstancesIndex structure +type JournalInstancesIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Instances []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + Name string `json:"name"` + } `json:"instances"` +} + +// JournalInstance structure +type JournalInstance struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ID int `json:"id"` + Name string `json:"name"` + Description string `json:"description"` + MinimumLevel int `json:"minimum_level"` + Map struct { + ID int `json:"id"` + Name string `json:"name"` + } `json:"map"` + Area struct { + ID int `json:"id"` + Name string `json:"name"` + } `json:"area"` + Location struct { + ID int `json:"id"` + Name string `json:"name"` + } `json:"location"` + Encounters []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + Name string `json:"name"` + } `json:"encounters"` + Expansion struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + Name string `json:"name"` + } `json:"expansion"` + Modes []struct { + Mode struct { + Type string `json:"type"` + Name string `json:"name"` + } `json:"mode"` + Players int `json:"players"` + IsTracked bool `json:"is_tracked"` + } `json:"modes"` + Media struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + } `json:"media"` + Category struct { + Type string `json:"type"` + } `json:"category"` +} diff --git a/v2/wowgd/mount.go b/v2/wowgd/mount.go new file mode 100644 index 0000000..ca6e7f0 --- /dev/null +++ b/v2/wowgd/mount.go @@ -0,0 +1,42 @@ +package wowgd + +// MountIndex structure +type MountIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Mounts []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"mounts"` +} + +// Mount structure +type Mount struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ID int `json:"id"` + Name string `json:"name"` + CreatureDisplays []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + } `json:"creature_displays"` + Description string `json:"description"` + Source struct { + Type string `json:"type"` + Name string `json:"name"` + } `json:"source"` + Faction struct { + Type string `json:"type"` + Name string `json:"name"` + } `json:"faction"` +} diff --git a/v2/wowgd/mythicKeystoneAffix.go b/v2/wowgd/mythicKeystoneAffix.go new file mode 100644 index 0000000..f25a779 --- /dev/null +++ b/v2/wowgd/mythicKeystoneAffix.go @@ -0,0 +1,35 @@ +package wowgd + +// MythicKeystoneAffixIndex structure +type MythicKeystoneAffixIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Affixes []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"affixes"` +} + +// MythicKeystoneAffix structure +type MythicKeystoneAffix struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ID int `json:"id"` + Name string `json:"name"` + Description string `json:"description"` + Media struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + } `json:"media"` +} diff --git a/v2/wowgd/mythicKeystoneDungeon.go b/v2/wowgd/mythicKeystoneDungeon.go new file mode 100644 index 0000000..db5f0e0 --- /dev/null +++ b/v2/wowgd/mythicKeystoneDungeon.go @@ -0,0 +1,125 @@ +package wowgd + +// MythicKeystoneDungeonIndex structure +type MythicKeystoneDungeonIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Dungeons []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"dungeons"` +} + +// MythicKeystoneDungeon structure +type MythicKeystoneDungeon struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ID int `json:"id"` + Name string `json:"name"` + Map struct { + Name string `json:"name"` + ID int `json:"id"` + } `json:"map"` + Zone struct { + Slug string `json:"slug"` + } `json:"zone"` + KeystoneUpgrades []struct { + UpgradeLevel int `json:"upgrade_level"` + QualifyingDuration int `json:"qualifying_duration"` + } `json:"keystone_upgrades"` +} + +// MythicKeystoneIndex structure +type MythicKeystoneIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Seasons struct { + Href string `json:"href"` + } `json:"seasons"` + Dungeons struct { + Href string `json:"href"` + } `json:"dungeons"` +} + +// MythicKeystonePeriodIndex structure +type MythicKeystonePeriodIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Periods []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + } `json:"periods"` + CurrentPeriod struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + } `json:"current_period"` +} + +// MythicKeystonePeriod structure +type MythicKeystonePeriod struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ID int `json:"id"` + StartTimestamp int64 `json:"start_timestamp"` + EndTimestamp int64 `json:"end_timestamp"` +} + +// MythicKeystoneSeasonIndex structure +type MythicKeystoneSeasonIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Seasons []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + } `json:"seasons"` + CurrentSeason struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + } `json:"current_season"` +} + +// MythicKeystoneSeason structure +type MythicKeystoneSeason struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ID int `json:"id"` + StartTimestamp int64 `json:"start_timestamp"` + Periods []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + } `json:"periods"` +} diff --git a/v2/wowgd/mythicKeystoneLeaderboard.go b/v2/wowgd/mythicKeystoneLeaderboard.go new file mode 100644 index 0000000..acd3e52 --- /dev/null +++ b/v2/wowgd/mythicKeystoneLeaderboard.go @@ -0,0 +1,76 @@ +package wowgd + +// MythicKeystoneLeaderboardIndex structure +type MythicKeystoneLeaderboardIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + CurrentLeaderboards []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"current_leaderboards"` +} + +// MythicKeystoneLeaderboard structure +type MythicKeystoneLeaderboard struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Map struct { + Name string `json:"name"` + ID int `json:"id"` + } `json:"map"` + Period int `json:"period"` + PeriodStartTimestamp int64 `json:"period_start_timestamp"` + PeriodEndTimestamp int64 `json:"period_end_timestamp"` + ConnectedRealm struct { + Href string `json:"href"` + } `json:"connected_realm"` + LeadingGroups []struct { + Ranking int `json:"ranking"` + Duration int `json:"duration"` + CompletedTimestamp int64 `json:"completed_timestamp"` + KeystoneLevel int `json:"keystone_level"` + Members []struct { + Profile struct { + Name string `json:"name"` + ID int `json:"id"` + Realm struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + Slug string `json:"slug"` + } `json:"realm"` + } `json:"profile"` + Faction struct { + Type string `json:"type"` + } `json:"faction"` + Specialization struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + } `json:"specialization"` + } `json:"members"` + } `json:"leading_groups"` + KeystoneAffixes []struct { + KeystoneAffix struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"keystone_affix"` + StartingLevel int `json:"starting_level"` + } `json:"keystone_affixes"` + MapChallengeModeID int `json:"map_challenge_mode_id"` + Name string `json:"name"` +} diff --git a/v2/wowgd/mythicRaidLeaderboard.go b/v2/wowgd/mythicRaidLeaderboard.go new file mode 100644 index 0000000..e4f5fbf --- /dev/null +++ b/v2/wowgd/mythicRaidLeaderboard.go @@ -0,0 +1,35 @@ +package wowgd + +// MythicRaidLeaderboard structure +type MythicRaidLeaderboard struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Slug string `json:"slug"` + CriteriaType string `json:"criteria_type"` + Zone struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + } `json:"zone"` + Entries []struct { + Guild struct { + Name string `json:"name"` + ID int `json:"id"` + Realm struct { + Name string `json:"name"` + ID int `json:"id"` + Slug string `json:"slug"` + } `json:"realm"` + } `json:"guild"` + Faction struct { + Type string `json:"type"` + } `json:"faction"` + Timestamp int64 `json:"timestamp"` + Region string `json:"region"` + Rank int `json:"rank"` + } `json:"entries"` +} diff --git a/v2/wowgd/pet.go b/v2/wowgd/pet.go new file mode 100644 index 0000000..b57ae50 --- /dev/null +++ b/v2/wowgd/pet.go @@ -0,0 +1,122 @@ +package wowgd + +// PetIndex structure +type PetIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Pets []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"pets"` +} + +// Pet structure +type Pet struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ID int `json:"id"` + Name string `json:"name"` + BattlePetType struct { + Type string `json:"type"` + Name string `json:"name"` + } `json:"battle_pet_type"` + Description string `json:"description"` + IsCapturable bool `json:"is_capturable"` + IsTradable bool `json:"is_tradable"` + IsBattlepet bool `json:"is_battlepet"` + IsAllianceOnly bool `json:"is_alliance_only"` + IsHordeOnly bool `json:"is_horde_only"` + Abilities []struct { + Ability struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"ability"` + Slot int `json:"slot"` + RequiredLevel int `json:"required_level"` + } `json:"abilities"` + Source struct { + Type string `json:"type"` + Name string `json:"name"` + } `json:"source"` + Icon string `json:"icon"` + Creature struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"creature"` + Media struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + } `json:"media"` + IsRandomCreatureDisplay bool `json:"is_random_creature_display"` +} + +// PetAbilityIndex structure +type PetAbilityIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Abilities []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"abilities"` +} + +// PetAbility structure +type PetAbility struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ID int `json:"id"` + Name string `json:"name"` + BattlePetType struct { + ID int `json:"id"` + Type string `json:"type"` + Name string `json:"name"` + } `json:"battle_pet_type"` + Rounds int `json:"rounds"` + Media struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + } `json:"media"` +} + +// PetMedia structure +type PetMedia struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Assets []struct { + Key string `json:"key"` + Value string `json:"value"` + FileDataID int `json:"file_data_id"` + } `json:"assets"` + ID int `json:"id"` +} diff --git a/v2/wowgd/playableClass.go b/v2/wowgd/playableClass.go new file mode 100644 index 0000000..255b5bd --- /dev/null +++ b/v2/wowgd/playableClass.go @@ -0,0 +1,68 @@ +package wowgd + +// PlayableClassesIndex structure +type PlayableClassesIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Classes []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"classes"` +} + +// PlayableClass structure +type PlayableClass struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ID int `json:"id"` + Name string `json:"name"` + GenderName struct { + Male string `json:"male"` + Female string `json:"female"` + } `json:"gender_name"` + PowerType struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"power_type"` + Specializations []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"specializations"` + Media struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + } `json:"media"` + PvpTalentSlots struct { + Href string `json:"href"` + } `json:"pvp_talent_slots"` +} + +// PlayableClassPvPTalentSlots structure +type PlayableClassPvPTalentSlots struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + TalentSlots []struct { + SlotNumber int `json:"slot_number"` + UnlockPlayerLevel int `json:"unlock_player_level"` + } `json:"talent_slots"` +} diff --git a/v2/wowgd/playableRace.go b/v2/wowgd/playableRace.go new file mode 100644 index 0000000..7ed95ee --- /dev/null +++ b/v2/wowgd/playableRace.go @@ -0,0 +1,38 @@ +package wowgd + +// PlayableRacesIndex structure +type PlayableRacesIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Races []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"races"` +} + +// PlayableRace structure +type PlayableRace struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ID int `json:"id"` + Name string `json:"name"` + GenderName struct { + Male string `json:"male"` + Female string `json:"female"` + } `json:"gender_name"` + Faction struct { + Type string `json:"type"` + Name string `json:"name"` + } `json:"faction"` + IsSelectable bool `json:"is_selectable"` + IsAlliedRace bool `json:"is_allied_race"` +} diff --git a/v2/wowgd/playableSpecialization.go b/v2/wowgd/playableSpecialization.go new file mode 100644 index 0000000..31d5c35 --- /dev/null +++ b/v2/wowgd/playableSpecialization.go @@ -0,0 +1,85 @@ +package wowgd + +// PlayableSpecializationIndex structure +type PlayableSpecializationIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + CharacterSpecializations []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"character_specializations"` + PetSpecializations []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"pet_specializations"` +} + +// PlayableSpecialization structure +type PlayableSpecialization struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ID int `json:"id"` + PlayableClass struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"playable_class"` + Name string `json:"name"` + GenderDescription struct { + Male string `json:"male"` + Female string `json:"female"` + } `json:"gender_description"` + Media struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + } `json:"media"` + Role struct { + Type string `json:"type"` + Name string `json:"name"` + } `json:"role"` + TalentTiers []struct { + Level int `json:"level"` + Talents []struct { + Talent struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"talent"` + SpellTooltip struct { + Description string `json:"description"` + CastTime string `json:"cast_time"` + } `json:"spell_tooltip"` + } `json:"talents"` + } `json:"talent_tiers"` + PvpTalents []struct { + Talent struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"talent"` + SpellTooltip struct { + Description string `json:"description"` + CastTime string `json:"cast_time"` + } `json:"spell_tooltip"` + } `json:"pvp_talents"` +} diff --git a/v2/wowgd/powerType.go b/v2/wowgd/powerType.go new file mode 100644 index 0000000..7c0de8b --- /dev/null +++ b/v2/wowgd/powerType.go @@ -0,0 +1,28 @@ +package wowgd + +// PowerTypesIndex structure +type PowerTypesIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + PowerTypes []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"power_types"` +} + +// PowerType structure +type PowerType struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ID int `json:"id"` + Name string `json:"name"` +} diff --git a/v2/wowgd/pvpSeason.go b/v2/wowgd/pvpSeason.go new file mode 100644 index 0000000..322ca61 --- /dev/null +++ b/v2/wowgd/pvpSeason.go @@ -0,0 +1,144 @@ +package wowgd + +// PvPSeasonIndex structure +type PvPSeasonIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Seasons []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + } `json:"seasons"` + CurrentSeason struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + } `json:"current_season"` +} + +// PvPSeason structure +type PvPSeason struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ID int `json:"id"` + Leaderboards struct { + Href string `json:"href"` + } `json:"leaderboards"` + Rewards struct { + Href string `json:"href"` + } `json:"rewards"` + SeasonStartTimestamp int64 `json:"season_start_timestamp"` + SeasonEndTimestamp int64 `json:"season_end_timestamp"` +} + +// PvPLeaderboardsIndex structure +type PvPLeaderboardsIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Season struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + } `json:"season"` + Leaderboards []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"leaderboards"` +} + +// PvPLeaderboard structure +type PvPLeaderboard struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Season struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + } `json:"season"` + Name string `json:"name"` + Bracket struct { + ID int `json:"id"` + Type string `json:"type"` + } `json:"bracket"` + Entries []struct { + Character struct { + Name string `json:"name"` + ID int `json:"id"` + Realm struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + Slug string `json:"slug"` + } `json:"realm"` + } `json:"character"` + Faction struct { + Type string `json:"type"` + } `json:"faction"` + Rank int `json:"rank"` + Rating int `json:"rating"` + SeasonMatchStatistics struct { + Played int `json:"played"` + Won int `json:"won"` + Lost int `json:"lost"` + } `json:"season_match_statistics"` + Tier struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + } `json:"tier"` + } `json:"entries"` +} + +// PvPRewardsIndex structure +type PvPRewardsIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Season struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + } `json:"season"` + Rewards []struct { + Bracket struct { + ID int `json:"id"` + Type string `json:"type"` + } `json:"bracket"` + Achievement struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"achievement"` + RatingCutoff int `json:"rating_cutoff"` + Faction struct { + Type string `json:"type"` + Name string `json:"name"` + } `json:"faction"` + } `json:"rewards"` +} diff --git a/v2/wowgd/pvpTier.go b/v2/wowgd/pvpTier.go new file mode 100644 index 0000000..ac820a6 --- /dev/null +++ b/v2/wowgd/pvpTier.go @@ -0,0 +1,53 @@ +package wowgd + +// PvPTierMedia structure +type PvPTierMedia struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Assets []struct { + Key string `json:"key"` + Value string `json:"value"` + } `json:"assets"` +} + +// PvPTiersIndex structure +type PvPTiersIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Tiers []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"tiers"` +} + +// PvPTier structure +type PvPTier struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ID int `json:"id"` + Name string `json:"name"` + MinRating int `json:"min_rating"` + MaxRating int `json:"max_rating"` + Media struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + } `json:"media"` + Bracket struct { + ID int `json:"id"` + Type string `json:"type"` + } `json:"bracket"` + RatingType int `json:"rating_type"` +} diff --git a/v2/wowgd/realm.go b/v2/wowgd/realm.go new file mode 100644 index 0000000..37053ab --- /dev/null +++ b/v2/wowgd/realm.go @@ -0,0 +1,48 @@ +package wowgd + +// RealmIndex structure +type RealmIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Realms []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + Slug string `json:"slug"` + } `json:"realms"` +} + +// Realm structure +type Realm struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ID int `json:"id"` + Region struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"region"` + ConnectedRealm struct { + Href string `json:"href"` + } `json:"connected_realm"` + Name string `json:"name"` + Category string `json:"category"` + Locale string `json:"locale"` + Timezone string `json:"timezone"` + Type struct { + Type string `json:"type"` + Name string `json:"name"` + } `json:"type"` + IsTournament bool `json:"is_tournament"` + Slug string `json:"slug"` +} diff --git a/v2/wowgd/region.go b/v2/wowgd/region.go new file mode 100644 index 0000000..24e13cb --- /dev/null +++ b/v2/wowgd/region.go @@ -0,0 +1,25 @@ +package wowgd + +// RegionIndex structure +type RegionIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Regions []struct { + Href string `json:"href"` + } `json:"regions"` +} + +// Region structure +type Region struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ID int `json:"id"` + Name string `json:"name"` + Tag string `json:"tag"` +} diff --git a/v2/wowgd/reputations.go b/v2/wowgd/reputations.go new file mode 100644 index 0000000..0500300 --- /dev/null +++ b/v2/wowgd/reputations.go @@ -0,0 +1,81 @@ +package wowgd + +// ReputationFactionsIndex structure +type ReputationFactionsIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Factions []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"factions"` + RootFactions []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"root_factions"` +} + +// ReputationFaction structure +type ReputationFaction struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ID int `json:"id"` + Name string `json:"name"` + Description string `json:"description"` + ReputationTiers struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + } `json:"reputation_tiers"` +} + +// ReputationTiersIndex structure +type ReputationTiersIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ReputationTiers []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + Name string `json:"name,omitempty"` + } `json:"reputation_tiers"` +} + +// ReputationTiers structure +type ReputationTiers struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ID int `json:"id"` + Tiers []struct { + Name string `json:"name"` + MinValue int `json:"min_value"` + MaxValue int `json:"max_value"` + ID int `json:"id"` + } `json:"tiers"` + Faction struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"faction"` +} diff --git a/v2/wowgd/title.go b/v2/wowgd/title.go new file mode 100644 index 0000000..0421451 --- /dev/null +++ b/v2/wowgd/title.go @@ -0,0 +1,32 @@ +package wowgd + +// TitlesIndex structure +type TitlesIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Titles []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"titles"` +} + +// Title structure +type Title struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ID int `json:"id"` + Name string `json:"name"` + GenderName struct { + Male string `json:"male"` + Female string `json:"female"` + } `json:"gender_name"` +} diff --git a/v2/wowgd/wowToken.go b/v2/wowgd/wowToken.go new file mode 100644 index 0000000..2c82730 --- /dev/null +++ b/v2/wowgd/wowToken.go @@ -0,0 +1,12 @@ +package wowgd + +// Token structure +type Token struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + LastUpdatedTimestamp int64 `json:"last_updated_timestamp"` + Price int `json:"price"` +} diff --git a/v2/wowgd/wowgd.go b/v2/wowgd/wowgd.go new file mode 100644 index 0000000..0649454 --- /dev/null +++ b/v2/wowgd/wowgd.go @@ -0,0 +1,12 @@ +// Package wowgd contains types for the World of Warcraft Game Data APIs +package wowgd + +// Bracket type +type Bracket string + +// Bracket field for PVP API calls +const ( + Bracket2v2 Bracket = "2v2" + Bracket3v3 Bracket = "3v3" + BracketRBG Bracket = "rbg" +) diff --git a/v2/wowgd_test.go b/v2/wowgd_test.go new file mode 100644 index 0000000..7d38343 --- /dev/null +++ b/v2/wowgd_test.go @@ -0,0 +1,957 @@ +package blizzard + +import ( + "context" + "fmt" + "testing" + + "github.com/FuzzyStatic/blizzard/v2/wowgd" +) + +func TestWoWAchievementCategoriesIndex(t *testing.T) { + dat, _, err := c.WoWAchievementCategoriesIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWAchievementCategory(t *testing.T) { + dat, _, err := c.WoWAchievementCategory(context.Background(), 81) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWAchievementIndex(t *testing.T) { + dat, _, err := c.WoWAchievementIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWAchievement(t *testing.T) { + dat, _, err := c.WoWAchievement(context.Background(), 6) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWAchievementMedia(t *testing.T) { + dat, _, err := c.WoWAchievementMedia(context.Background(), 6) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWAzeriteEssenceIndex(t *testing.T) { + dat, _, err := c.WoWAzeriteEssenceIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWAzeriteEssence(t *testing.T) { + dat, _, err := c.WoWAzeriteEssence(context.Background(), 6) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWAzeriteEssenceMedia(t *testing.T) { + dat, _, err := c.WoWAzeriteEssenceMedia(context.Background(), 6) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWConnectedRealmIndex(t *testing.T) { + dat, _, err := c.WoWConnectedRealmIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWConnectedRealm(t *testing.T) { + dat, _, err := c.WoWConnectedRealm(context.Background(), 11) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWCreatureFamiliesIndex(t *testing.T) { + dat, _, err := c.WoWCreatureFamiliesIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWCreatureFamily(t *testing.T) { + dat, _, err := c.WoWCreatureFamily(context.Background(), 1) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWCreatureTypesIndex(t *testing.T) { + dat, _, err := c.WoWCreatureTypesIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWCreatureType(t *testing.T) { + dat, _, err := c.WoWCreatureType(context.Background(), 1) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWCreature(t *testing.T) { + dat, _, err := c.WoWCreature(context.Background(), 30) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWCreatureDisplayMedia(t *testing.T) { + dat, _, err := c.WoWCreatureDisplayMedia(context.Background(), 30221) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWCreatureFamilyMedia(t *testing.T) { + dat, _, err := c.WoWCreatureFamilyMedia(context.Background(), 1) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWGuildCrestComponentsIndex(t *testing.T) { + dat, _, err := c.WoWGuildCrestComponentsIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWGuildCrestBorderMedia(t *testing.T) { + dat, _, err := c.WoWGuildCrestBorderMedia(context.Background(), 0) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWGuildCrestEmblemMedia(t *testing.T) { + dat, _, err := c.WoWGuildCrestEmblemMedia(context.Background(), 0) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWItemClassesIndex(t *testing.T) { + dat, _, err := c.WoWItemClassesIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWItemClass(t *testing.T) { + dat, _, err := c.WoWItemClass(context.Background(), 0) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWItemSubclass(t *testing.T) { + dat, _, err := c.WoWItemSubclass(context.Background(), 0, 0) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWItem(t *testing.T) { + dat, _, err := c.WoWItem(context.Background(), 19019) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWItemMedia(t *testing.T) { + dat, _, err := c.WoWItemMedia(context.Background(), 19019) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWJournalExpansionsIndex(t *testing.T) { + dat, _, err := c.WoWJournalExpansionsIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWJournalExpansion(t *testing.T) { + dat, _, err := c.WoWJournalExpansion(context.Background(), 396) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWJournalEncountersIndex(t *testing.T) { + dat, _, err := c.WoWJournalEncountersIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWJournalEncounter(t *testing.T) { + dat, _, err := c.WoWJournalEncounter(context.Background(), 396) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWJournalInstancesIndex(t *testing.T) { + dat, _, err := c.WoWJournalInstancesIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWJournalInstance(t *testing.T) { + dat, _, err := c.WoWJournalInstance(context.Background(), 63) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWMountIndex(t *testing.T) { + dat, _, err := c.WoWMountIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWMount(t *testing.T) { + dat, _, err := c.WoWMount(context.Background(), 6) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWMythicKeystoneAffixIndex(t *testing.T) { + dat, _, err := c.WoWMythicKeystoneAffixIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWMythicKeystoneAffix(t *testing.T) { + dat, _, err := c.WoWMythicKeystoneAffix(context.Background(), 1) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWMythicRaidLeaderboard(t *testing.T) { + dat, _, err := c.WoWMythicRaidLeaderboard(context.Background(), "uldir", "alliance") + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWMythicKeystoneDungeonIndex(t *testing.T) { + dat, _, err := c.WoWMythicKeystoneDungeonIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWMythicKeystoneDungeon(t *testing.T) { + dat, _, err := c.WoWMythicKeystoneDungeon(context.Background(), 353) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWMythicKeystoneIndex(t *testing.T) { + dat, _, err := c.WoWMythicKeystoneIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWMythicKeystonePeriodIndex(t *testing.T) { + dat, _, err := c.WoWMythicKeystonePeriodIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWMythicKeystonePeriod(t *testing.T) { + dat, _, err := c.WoWMythicKeystonePeriod(context.Background(), 641) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWMythicKeystoneSeasonIndex(t *testing.T) { + dat, _, err := c.WoWMythicKeystoneSeasonIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWMythicKeystoneSeason(t *testing.T) { + dat, _, err := c.WoWMythicKeystoneSeason(context.Background(), 1) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWMythicKeystoneLeaderboardIndex(t *testing.T) { + dat, _, err := c.WoWMythicKeystoneLeaderboardIndex(context.Background(), 11) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWMythicKeystoneLeaderboard(t *testing.T) { + dat, _, err := c.WoWMythicKeystoneLeaderboard(context.Background(), 11, 197, 641) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWPetIndex(t *testing.T) { + dat, _, err := c.WoWPetIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWPet(t *testing.T) { + dat, _, err := c.WoWPet(context.Background(), 39) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWPetMedia(t *testing.T) { + dat, _, err := c.WoWPetMedia(context.Background(), 39) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWPetAbilityIndex(t *testing.T) { + dat, _, err := c.WoWPetAbilityIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWPetAbilty(t *testing.T) { + dat, _, err := c.WoWPetAbility(context.Background(), 110) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWPetAbilityMedia(t *testing.T) { + dat, _, err := c.WoWPetAbilityMedia(context.Background(), 110) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWPlayableClassesIndex(t *testing.T) { + dat, _, err := c.WoWPlayableClassesIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWPlayableClass(t *testing.T) { + dat, _, err := c.WoWPlayableClass(context.Background(), 7) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWPlayableClassPvPTalentSlots(t *testing.T) { + dat, _, err := c.WoWPlayableClassPvPTalentSlots(context.Background(), 7) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWPlayableRacesIndex(t *testing.T) { + dat, _, err := c.WoWPlayableRacesIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWPlayableRace(t *testing.T) { + dat, _, err := c.WoWPlayableRace(context.Background(), 2) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWPlayableSpecializationIndex(t *testing.T) { + dat, _, err := c.WoWPlayableSpecializationIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWPlayableSpecialization(t *testing.T) { + dat, _, err := c.WoWPlayableSpecialization(context.Background(), 262) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWPowerTypesIndex(t *testing.T) { + dat, _, err := c.WoWPowerTypesIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWPowerType(t *testing.T) { + dat, _, err := c.WoWPowerType(context.Background(), 0) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWPvPSeasonIndex(t *testing.T) { + dat, _, err := c.WoWPvPSeasonIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWPvPSeason(t *testing.T) { + dat, _, err := c.WoWPvPSeason(context.Background(), 27) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWPvPLeaderboardsIndex(t *testing.T) { + dat, _, err := c.WoWPvPLeaderboardsIndex(context.Background(), 27) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWPvPLeaderboard(t *testing.T) { + dat, _, err := c.WoWPvPLeaderboard(context.Background(), 27, wowgd.BracketRBG) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWPvPRewardsIndex(t *testing.T) { + dat, _, err := c.WoWPvPRewardsIndex(context.Background(), 27) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWPvPTierMedia(t *testing.T) { + dat, _, err := c.WoWPvPTierMedia(context.Background(), 1) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWPvPTiersIndex(t *testing.T) { + dat, _, err := c.WoWPvPTiersIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWPvPTier(t *testing.T) { + dat, _, err := c.WoWPvPTier(context.Background(), 1) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWReputationFactionsIndex(t *testing.T) { + dat, _, err := c.WoWReputationFactionsIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWReputationFaction(t *testing.T) { + dat, _, err := c.WoWReputationFaction(context.Background(), 21) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWReputationTiersIndex(t *testing.T) { + dat, _, err := c.WoWReputationTiersIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWReputationTiers(t *testing.T) { + dat, _, err := c.WoWReputationTiers(context.Background(), 2) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWTitlesIndex(t *testing.T) { + dat, _, err := c.WoWTitlesIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWTitle(t *testing.T) { + dat, _, err := c.WoWTitle(context.Background(), 1) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWRealmIndex(t *testing.T) { + dat, _, err := c.WoWRealmIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWRealm(t *testing.T) { + dat, _, err := c.WoWRealm(context.Background(), "tichondrius") + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWRegionIndex(t *testing.T) { + dat, _, err := c.WoWRegionIndex(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWRegion(t *testing.T) { + dat, _, err := c.WoWRegion(context.Background(), 1) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWToken(t *testing.T) { + dat, _, err := c.WoWToken(context.Background()) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} diff --git a/v2/wowp.go b/v2/wowp.go new file mode 100644 index 0000000..2ce6e3f --- /dev/null +++ b/v2/wowp.go @@ -0,0 +1,656 @@ +package blizzard + +import ( + "context" + "encoding/json" + "fmt" + "io/ioutil" + "net/http" + "strings" + + "github.com/FuzzyStatic/blizzard/v2/wowp" + "golang.org/x/oauth2" +) + +// WoWAccountProfileSummary Returns a profile summary for an account. +func (c *Client) WoWAccountProfileSummary(ctx context.Context, token *oauth2.Token) (*wowp.AccountProfileSummary, []byte, error) { + var ( + dat wowp.AccountProfileSummary + b []byte + err error + ) + + req, err := http.NewRequest("GET", c.apiURL+ + fmt.Sprintf("/profile/user/wow?namespace=%s&locale=%s", c.profileNamespace, c.locale), nil) + if err != nil { + return &dat, b, err + } + + client := c.authorizedCfg.Client(ctx, token) + + res, err := client.Do(req) + if err != nil { + return &dat, b, err + } + defer res.Body.Close() + + b, err = ioutil.ReadAll(res.Body) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWCharacterAchievementsSummary returns a summary of the achievements a character has completed. +func (c *Client) WoWCharacterAchievementsSummary(ctx context.Context, realmSlug, characterName string) (*wowp.CharacterAchievementsSummary, []byte, error) { + var ( + dat wowp.CharacterAchievementsSummary + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+ + fmt.Sprintf("/profile/wow/character/%s/%s/achievements?locale=%s", realmSlug, strings.ToLower(characterName), c.locale), + c.profileNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWCharacterAppearanceSummary returns a summary of a character's appearance settings. +func (c *Client) WoWCharacterAppearanceSummary(ctx context.Context, realmSlug, characterName string) (*wowp.CharacterAppearanceSummary, []byte, error) { + var ( + dat wowp.CharacterAppearanceSummary + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+ + fmt.Sprintf("/profile/wow/character/%s/%s/appearance?locale=%s", realmSlug, strings.ToLower(characterName), c.locale), + c.profileNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWCharacterCollectionsIndex returns an index of collection types for a character. +func (c *Client) WoWCharacterCollectionsIndex(ctx context.Context, realmSlug, characterName string) (*wowp.CharacterCollectionsIndex, []byte, error) { + var ( + dat wowp.CharacterCollectionsIndex + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+ + fmt.Sprintf("/profile/wow/character/%s/%s/collections?locale=%s", realmSlug, strings.ToLower(characterName), c.locale), + c.profileNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWCharacterMountsCollectionSummary returns a summary of the mounts a character has obtained. +func (c *Client) WoWCharacterMountsCollectionSummary(ctx context.Context, realmSlug, characterName string) (*wowp.CharacterMountsCollectionSummary, []byte, error) { + var ( + dat wowp.CharacterMountsCollectionSummary + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+ + fmt.Sprintf("/profile/wow/character/%s/%s/collections/mounts?locale=%s", realmSlug, strings.ToLower(characterName), c.locale), + c.profileNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWCharacterPetsCollectionSummary returns a summary of the mounts a character has obtained. +func (c *Client) WoWCharacterPetsCollectionSummary(ctx context.Context, realmSlug, characterName string) (*wowp.CharacterPetsCollectionSummary, []byte, error) { + var ( + dat wowp.CharacterPetsCollectionSummary + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+ + fmt.Sprintf("/profile/wow/character/%s/%s/collections/pets?locale=%s", realmSlug, strings.ToLower(characterName), c.locale), + c.profileNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWCharacterEncountersSummary returns a summary of a character's encounters. +func (c *Client) WoWCharacterEncountersSummary(ctx context.Context, realmSlug, characterName string) (*wowp.CharacterEncountersSummary, []byte, error) { + var ( + dat wowp.CharacterEncountersSummary + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+ + fmt.Sprintf("/profile/wow/character/%s/%s/encounters?locale=%s", realmSlug, strings.ToLower(characterName), c.locale), + c.profileNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWCharacterDungeons returns a summary of a character's completed dungeons. +func (c *Client) WoWCharacterDungeons(ctx context.Context, realmSlug, characterName string) (*wowp.CharacterDungeons, []byte, error) { + var ( + dat wowp.CharacterDungeons + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+ + fmt.Sprintf("/profile/wow/character/%s/%s/encounters/dungeons?locale=%s", realmSlug, strings.ToLower(characterName), c.locale), + c.profileNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWCharacterRaids returns a summary of a character's completed raids. +func (c *Client) WoWCharacterRaids(ctx context.Context, realmSlug, characterName string) (*wowp.CharacterRaids, []byte, error) { + var ( + dat wowp.CharacterRaids + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+ + fmt.Sprintf("/profile/wow/character/%s/%s/encounters/raids?locale=%s", realmSlug, strings.ToLower(characterName), c.locale), + c.profileNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWCharacterEquipmentSummary returns a summary of the items equipped by a character. +func (c *Client) WoWCharacterEquipmentSummary(ctx context.Context, realmSlug, characterName string) (*wowp.CharacterEquipmentSummary, []byte, error) { + var ( + dat wowp.CharacterEquipmentSummary + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+ + fmt.Sprintf("/profile/wow/character/%s/%s/equipment?locale=%s", realmSlug, strings.ToLower(characterName), c.locale), + c.profileNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWCharacterHunterPetsSummary if the character is a hunter, returns a summary of the character's hunter pets. Otherwise, returns an HTTP 404 Not Found error. +func (c *Client) WoWCharacterHunterPetsSummary(ctx context.Context, realmSlug, characterName string) (*wowp.CharacterHunterPetsSummary, []byte, error) { + var ( + dat wowp.CharacterHunterPetsSummary + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+ + fmt.Sprintf("/profile/wow/character/%s/%s/hunter-pets?locale=%s", realmSlug, strings.ToLower(characterName), c.locale), + c.profileNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWCharacterMediaSummary returns a summary of the media assets available for a character (such as an avatar render). +func (c *Client) WoWCharacterMediaSummary(ctx context.Context, realmSlug, characterName string) (*wowp.CharacterMediaSummary, []byte, error) { + var ( + dat wowp.CharacterMediaSummary + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+ + fmt.Sprintf("/profile/wow/character/%s/%s/character-media?locale=%s", realmSlug, strings.ToLower(characterName), c.locale), + c.profileNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWCharacterProfileSummary returns a profile summary for a character. +func (c *Client) WoWCharacterProfileSummary(ctx context.Context, realmSlug, characterName string) (*wowp.CharacterProfileSummary, []byte, error) { + var ( + dat wowp.CharacterProfileSummary + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+ + fmt.Sprintf("/profile/wow/character/%s/%s?locale=%s", realmSlug, strings.ToLower(characterName), c.locale), + c.profileNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWCharacterProfileStatus returns the status and a unique ID for a character. +// A client should delete information about a character from their application if any of the following conditions occur: +// * an HTTP 404 Not Found error is returned +// * the is_valid value is false +// * the returned character ID doesn't match the previously recorded value for the character +// The following example illustrates how to use this endpoint: +// 1. A client requests and stores information about a character, including its unique character ID and the timestamp of the request. +// 2. After 30 days, the client makes a request to the status endpoint to verify if the character information is still valid. +// 3. If character cannot be found, is not valid, or the characters IDs do not match, the client removes the information from their application. +// 4. If the character is valid and the character IDs match, the client retains the data for another 30 days. +func (c *Client) WoWCharacterProfileStatus(ctx context.Context, realmSlug, characterName string) (*wowp.CharacterProfileStatus, []byte, error) { + var ( + dat wowp.CharacterProfileStatus + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+ + fmt.Sprintf("/profile/wow/character/%s/%s/status?locale=%s", realmSlug, strings.ToLower(characterName), c.locale), + c.profileNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWCharacterMythicKeystoneProfile returns a Mythic Keystone Profile index for a character. +func (c *Client) WoWCharacterMythicKeystoneProfile(ctx context.Context, realmSlug, characterName string) (*wowp.CharacterMythicKeystoneProfile, []byte, error) { + var ( + dat wowp.CharacterMythicKeystoneProfile + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+ + fmt.Sprintf("/profile/wow/character/%s/%s/mythic-keystone-profile?locale=%s", realmSlug, strings.ToLower(characterName), c.locale), + c.profileNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWCharacterMythicKeystoneProfileSeason returns a Mythic Keystone Profile index for a character. +// Note: this request returns a 404 for characters that have not completed a Mythic Keystone dungeon. +func (c *Client) WoWCharacterMythicKeystoneProfileSeason(ctx context.Context, realmSlug, characterName string, seasonID int) (*wowp.CharacterMythicKeystoneProfileSeason, []byte, error) { + var ( + dat wowp.CharacterMythicKeystoneProfileSeason + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+ + fmt.Sprintf("/profile/wow/character/%s/%s/mythic-keystone-profile/season/%d?locale=%s", realmSlug, strings.ToLower(characterName), seasonID, c.locale), + c.profileNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWCharacterPvPBracketStatistics returns the PvP bracket statistics for a character. +func (c *Client) WoWCharacterPvPBracketStatistics(ctx context.Context, realmSlug, characterName string, pvpBracket wowp.Bracket) (*wowp.CharacterPvPBracketStatistics, []byte, error) { + var ( + dat wowp.CharacterPvPBracketStatistics + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+ + fmt.Sprintf("/profile/wow/character/%s/%s/pvp-bracket/%s?locale=%s", realmSlug, strings.ToLower(characterName), pvpBracket, c.locale), + c.profileNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWCharacterPvPSummary returns a PvP summary for a character. +func (c *Client) WoWCharacterPvPSummary(ctx context.Context, realmSlug, characterName string) (*wowp.CharacterPvPSummary, []byte, error) { + var ( + dat wowp.CharacterPvPSummary + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+ + fmt.Sprintf("/profile/wow/character/%s/%s/pvp-summary?locale=%s", realmSlug, strings.ToLower(characterName), c.locale), + c.profileNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWCharacterQuests returns a character's active quests as well as a link to the character's completed quests. +func (c *Client) WoWCharacterQuests(ctx context.Context, realmSlug, characterName string) (*wowp.CharacterQuests, []byte, error) { + var ( + dat wowp.CharacterQuests + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+ + fmt.Sprintf("/profile/wow/character/%s/%s/quests?locale=%s", realmSlug, strings.ToLower(characterName), c.locale), + c.profileNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWCharacterCompletedQuests returns a list of quests that a character has completed. +func (c *Client) WoWCharacterCompletedQuests(ctx context.Context, realmSlug, characterName string) (*wowp.CharacterCompletedQuests, []byte, error) { + var ( + dat wowp.CharacterCompletedQuests + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+ + fmt.Sprintf("/profile/wow/character/%s/%s/quests/completed?locale=%s", realmSlug, strings.ToLower(characterName), c.locale), + c.profileNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWCharacterReputationsSummary returns a summary of a character's reputations. +func (c *Client) WoWCharacterReputationsSummary(ctx context.Context, realmSlug, characterName string) (*wowp.CharacterReputationsSummary, []byte, error) { + var ( + dat wowp.CharacterReputationsSummary + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+ + fmt.Sprintf("/profile/wow/character/%s/%s/reputations?locale=%s", realmSlug, strings.ToLower(characterName), c.locale), + c.profileNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWCharacterSpecializationsSummary returns a summary of a character's specializations. +func (c *Client) WoWCharacterSpecializationsSummary(ctx context.Context, realmSlug, characterName string) (*wowp.CharacterSpecializationsSummary, []byte, error) { + var ( + dat wowp.CharacterSpecializationsSummary + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+ + fmt.Sprintf("/profile/wow/character/%s/%s/specializations?locale=%s", realmSlug, strings.ToLower(characterName), c.locale), + c.profileNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWCharacterStatisticsSummary returns a statistics summary for a character. +func (c *Client) WoWCharacterStatisticsSummary(ctx context.Context, realmSlug, characterName string) (*wowp.CharacterStatisticsSummary, []byte, error) { + var ( + dat wowp.CharacterStatisticsSummary + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+ + fmt.Sprintf("/profile/wow/character/%s/%s/statistics?locale=%s", realmSlug, strings.ToLower(characterName), c.locale), + c.profileNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWCharacterTitlesSummary returns a summary of titles a character has obtained. +func (c *Client) WoWCharacterTitlesSummary(ctx context.Context, realmSlug, characterName string) (*wowp.CharacterTitlesSummary, []byte, error) { + var ( + dat wowp.CharacterTitlesSummary + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+ + fmt.Sprintf("/profile/wow/character/%s/%s/titles?locale=%s", realmSlug, strings.ToLower(characterName), c.locale), + c.profileNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWGuild returns a single guild by its name and realm. +func (c *Client) WoWGuild(ctx context.Context, realmSlug, nameSlug string) (*wowp.Guild, []byte, error) { + var ( + dat wowp.Guild + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+ + fmt.Sprintf("/data/wow/guild/%s/%s?locale=%s", realmSlug, strings.Replace(strings.ToLower(nameSlug), " ", "-", -1), c.locale), + c.profileNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWGuildAchievements returns a single guild's achievements by name and realm. +func (c *Client) WoWGuildAchievements(ctx context.Context, realmSlug, nameSlug string) (*wowp.GuildAchievements, []byte, error) { + var ( + dat wowp.GuildAchievements + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+ + fmt.Sprintf("/data/wow/guild/%s/%s/achievements?locale=%s", realmSlug, strings.Replace(strings.ToLower(nameSlug), " ", "-", -1), c.locale), + c.profileNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} + +// WoWGuildRoster returns a single guild's roster by its name and realm. +func (c *Client) WoWGuildRoster(ctx context.Context, realmSlug, nameSlug string) (*wowp.GuildRoster, []byte, error) { + var ( + dat wowp.GuildRoster + b []byte + err error + ) + + b, err = c.getURLBody(ctx, c.apiURL+ + fmt.Sprintf("/data/wow/guild/%s/%s/roster?locale=%s", realmSlug, strings.Replace(strings.ToLower(nameSlug), " ", "-", -1), c.locale), + c.profileNamespace) + if err != nil { + return &dat, b, err + } + + err = json.Unmarshal(b, &dat) + if err != nil { + return &dat, b, err + } + + return &dat, b, nil +} diff --git a/v2/wowp/accountProfileSummary.go b/v2/wowp/accountProfileSummary.go new file mode 100644 index 0000000..a290531 --- /dev/null +++ b/v2/wowp/accountProfileSummary.go @@ -0,0 +1,64 @@ +package wowp + +// AccountProfileSummary structure +type AccountProfileSummary struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + User struct { + Href string `json:"href"` + } `json:"user"` + Profile struct { + Href string `json:"href"` + } `json:"profile"` + } `json:"_links"` + ID int `json:"id"` + WowAccounts []struct { + ID int `json:"id"` + Characters []struct { + Character struct { + Href string `json:"href"` + } `json:"character"` + ProtectedCharacter struct { + Href string `json:"href"` + } `json:"protected_character"` + Name string `json:"name"` + ID int `json:"id"` + Realm struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + Slug string `json:"slug"` + } `json:"realm"` + PlayableClass struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"playable_class"` + PlayableRace struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"playable_race"` + Gender struct { + Type string `json:"type"` + Name string `json:"name"` + } `json:"gender"` + Faction struct { + Type string `json:"type"` + Name string `json:"name"` + } `json:"faction"` + Level int `json:"level"` + } `json:"characters"` + } `json:"wow_accounts"` + Collections struct { + Href string `json:"href"` + } `json:"collections"` +} diff --git a/v2/wowp/characterAchievements.go b/v2/wowp/characterAchievements.go new file mode 100644 index 0000000..96cece5 --- /dev/null +++ b/v2/wowp/characterAchievements.go @@ -0,0 +1,73 @@ +package wowp + +// ChildCriteria struct used for representing nested Achievement criteria +type ChildCriteria []struct { + ID int `json:"id"` + Amount float64 `json:"amount"` + IsCompleted bool `json:"is_completed"` + ChildCriteria ChildCriteria `json:"child_criteria,omitempty"` +} + +// CharacterAchievementsSummary structure +type CharacterAchievementsSummary struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + TotalQuantity int `json:"total_quantity"` + TotalPoints int `json:"total_points"` + Achievements []struct { + ID int `json:"id,omitempty"` + Achievement struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"achievement"` + Criteria struct { + ID int `json:"id"` + Amount float64 `json:"amount"` + IsCompleted bool `json:"is_completed"` + ChildCriteria ChildCriteria `json:"child_criteria,omitempty"` + } `json:"criteria,omitempty"` + CompleteTimestamp int64 `json:"completed_timestamp"` + } `json:"achievements"` + CategoryProgress []struct { + Category struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"category"` + Quantity int `json:"quantity"` + Points int `json:"points"` + } `json:"category_progress"` + RecentEvents []struct { + Achievement struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"achievement"` + Timestamp int64 `json:"timestamp"` + } `json:"recent_events"` + Character struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + Realm struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + Slug string `json:"slug"` + } `json:"realm"` + } `json:"character"` +} diff --git a/v2/wowp/characterAppearance.go b/v2/wowp/characterAppearance.go new file mode 100644 index 0000000..c5ef10a --- /dev/null +++ b/v2/wowp/characterAppearance.go @@ -0,0 +1,120 @@ +package wowp + +// CharacterAppearanceSummary structure +type CharacterAppearanceSummary struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Character struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + Realm struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + Slug string `json:"slug"` + } `json:"realm"` + } `json:"character"` + PlayableRace struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"playable_race"` + PlayableClass struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"playable_class"` + ActiveSpec struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"active_spec"` + Gender struct { + Type string `json:"type"` + Name string `json:"name"` + } `json:"gender"` + Faction struct { + Type string `json:"type"` + Name string `json:"name"` + } `json:"faction"` + GuildCrest struct { + Emblem struct { + ID int `json:"id"` + Media struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + } `json:"media"` + Color struct { + ID int `json:"id"` + Rgba struct { + R int `json:"r"` + G int `json:"g"` + B int `json:"b"` + A float64 `json:"a"` + } `json:"rgba"` + } `json:"color"` + } `json:"emblem"` + Border struct { + ID int `json:"id"` + Media struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + } `json:"media"` + Color struct { + ID int `json:"id"` + Rgba struct { + R int `json:"r"` + G int `json:"g"` + B int `json:"b"` + A float64 `json:"a"` + } `json:"rgba"` + } `json:"color"` + } `json:"border"` + Background struct { + Color struct { + ID int `json:"id"` + Rgba struct { + R int `json:"r"` + G int `json:"g"` + B int `json:"b"` + A float64 `json:"a"` + } `json:"rgba"` + } `json:"color"` + } `json:"background"` + } `json:"guild_crest"` + Appearance struct { + FaceVariation int `json:"face_variation"` + SkinColor int `json:"skin_color"` + HairVariation int `json:"hair_variation"` + HairColor int `json:"hair_color"` + FeatureVariation int `json:"feature_variation"` + CustomDisplayOptions []int `json:"custom_display_options"` + } `json:"appearance"` + Items []struct { + ID int `json:"id"` + Slot struct { + Type string `json:"type"` + Name string `json:"name"` + } `json:"slot"` + Enchant int `json:"enchant"` + ItemAppearanceModifierID int `json:"item_appearance_modifier_id"` + InternalSlotID int `json:"internal_slot_id"` + Subclass int `json:"subclass"` + } `json:"items"` +} diff --git a/v2/wowp/characterCollections.go b/v2/wowp/characterCollections.go new file mode 100644 index 0000000..44f9c11 --- /dev/null +++ b/v2/wowp/characterCollections.go @@ -0,0 +1,66 @@ +package wowp + +// CharacterCollectionsIndex structure +type CharacterCollectionsIndex struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Pets struct { + Href string `json:"href"` + } `json:"pets"` + Mounts struct { + Href string `json:"href"` + } `json:"mounts"` +} + +// CharacterMountsCollectionSummary structure +type CharacterMountsCollectionSummary struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Mounts []struct { + Mount struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"mount"` + IsFavorite bool `json:"is_favorite,omitempty"` + } `json:"mounts"` +} + +// CharacterPetsCollectionSummary structure +type CharacterPetsCollectionSummary struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Pets []struct { + Species struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"species"` + Level int `json:"level"` + Quality struct { + Type string `json:"type"` + Name string `json:"name"` + } `json:"quality"` + Stats struct { + BreedID int `json:"breed_id"` + Health int `json:"health"` + Power int `json:"power"` + Speed int `json:"speed"` + } `json:"stats"` + IsFavorite bool `json:"is_favorite,omitempty"` + } `json:"pets"` + UnlockedBattlePetSlots int `json:"unlocked_battle_pet_slots"` +} diff --git a/v2/wowp/characterEncounters.go b/v2/wowp/characterEncounters.go new file mode 100644 index 0000000..988182c --- /dev/null +++ b/v2/wowp/characterEncounters.go @@ -0,0 +1,150 @@ +package wowp + +// CharacterEncountersSummary structure +type CharacterEncountersSummary struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Character struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + Realm struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + Slug string `json:"slug"` + } `json:"realm"` + } `json:"character"` + Dungeons struct { + Href string `json:"href"` + } `json:"dungeons"` + Raids struct { + Href string `json:"href"` + } `json:"raids"` +} + +// CharacterDungeons structure +type CharacterDungeons struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Expansions []struct { + Expansion struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"expansion"` + Instances []struct { + Instance struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"instance"` + Modes []struct { + Difficulty struct { + Type string `json:"type"` + Name string `json:"name"` + } `json:"difficulty"` + Status struct { + Type string `json:"type"` + Name string `json:"name"` + } `json:"status"` + Progress struct { + CompletedCount int `json:"completed_count"` + TotalCount int `json:"total_count"` + Encounters []struct { + Encounter struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"encounter"` + CompletedCount int `json:"completed_count"` + LastKillTimestamp int64 `json:"last_kill_timestamp"` + } `json:"encounters"` + } `json:"progress"` + } `json:"modes"` + } `json:"instances"` + } `json:"expansions"` +} + +// CharacterRaids structure +type CharacterRaids struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Character struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + Realm struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + Slug string `json:"slug"` + } `json:"realm"` + } `json:"character"` + Expansions []struct { + Expansion struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"expansion"` + Instances []struct { + Instance struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"instance"` + Modes []struct { + Difficulty struct { + Type string `json:"type"` + Name string `json:"name"` + } `json:"difficulty"` + Status struct { + Type string `json:"type"` + Name string `json:"name"` + } `json:"status"` + Progress struct { + CompletedCount int `json:"completed_count"` + TotalCount int `json:"total_count"` + Encounters []struct { + Encounter struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"encounter"` + CompletedCount int `json:"completed_count"` + LastKillTimestamp int64 `json:"last_kill_timestamp"` + } `json:"encounters"` + } `json:"progress"` + } `json:"modes"` + } `json:"instances"` + } `json:"expansions"` +} diff --git a/v2/wowp/characterEquipment.go b/v2/wowp/characterEquipment.go new file mode 100644 index 0000000..80b6a82 --- /dev/null +++ b/v2/wowp/characterEquipment.go @@ -0,0 +1,303 @@ +package wowp + +// CharacterEquipmentSummary structure +type CharacterEquipmentSummary struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Character struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + Realm struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + Slug string `json:"slug"` + } `json:"realm"` + } `json:"character"` + EquippedItems []struct { + Item struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + } `json:"item"` + Slot struct { + Type string `json:"type"` + Name string `json:"name"` + } `json:"slot"` + Quantity int `json:"quantity"` + Context int `json:"context"` + BonusList []int `json:"bonus_list"` + Quality struct { + Type string `json:"type"` + Name string `json:"name"` + } `json:"quality"` + Name string `json:"name"` + ModifiedAppearanceID int `json:"modified_appearance_id,omitempty"` + AzeriteDetails struct { + SelectedPowers []struct { + ID int `json:"id"` + Tier int `json:"tier"` + SpellTooltip 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"` + CastTime string `json:"cast_time"` + } `json:"spell_tooltip"` + IsDisplayHidden bool `json:"is_display_hidden,omitempty"` + } `json:"selected_powers"` + SelectedPowersString string `json:"selected_powers_string"` + PercentageToNextLevel float64 `json:"percentage_to_next_level"` + SelectedEssences []struct { + Slot int `json:"slot"` + Rank int `json:"rank"` + MainSpellTooltip 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"` + CastTime string `json:"cast_time"` + Range string `json:"range"` + } `json:"main_spell_tooltip,omitempty"` + PassiveSpellTooltip 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"` + CastTime string `json:"cast_time"` + } `json:"passive_spell_tooltip"` + Essence struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"essence"` + Media struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + } `json:"media"` + } `json:"selected_essences"` + Level struct { + Value int `json:"value"` + DisplayString string `json:"display_string"` + } `json:"level"` + } `json:"azerite_details,omitempty"` + 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"` + Armor struct { + Value int `json:"value"` + Display struct { + DisplayString string `json:"display_string"` + Color struct { + R int `json:"r"` + G int `json:"g"` + B int `json:"b"` + A float64 `json:"a"` + } `json:"color"` + } `json:"display"` + } `json:"armor,omitempty"` + Stats []struct { + Type struct { + Type string `json:"type"` + Name string `json:"name"` + } `json:"type"` + Value int `json:"value"` + Display struct { + DisplayString string `json:"display_string"` + Color struct { + R int `json:"r"` + G int `json:"g"` + B int `json:"b"` + A float64 `json:"a"` + } `json:"color"` + } `json:"display"` + IsNegated bool `json:"is_negated,omitempty"` + } `json:"stats"` + Level struct { + Value int `json:"value"` + DisplayString string `json:"display_string"` + } `json:"level"` + Transmog struct { + Item struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"item"` + DisplayString string `json:"display_string"` + ItemModifiedAppearanceID int `json:"item_modified_appearance_id"` + } `json:"transmog,omitempty"` + Durability struct { + Value int `json:"value"` + DisplayString string `json:"display_string"` + } `json:"durability,omitempty"` + NameDescription struct { + DisplayString string `json:"display_string"` + Color struct { + R int `json:"r"` + G int `json:"g"` + B int `json:"b"` + A float64 `json:"a"` + } `json:"color"` + } `json:"name_description,omitempty"` + UniqueEquipped string `json:"unique_equipped,omitempty"` + 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"` + DisplayColor struct { + R int `json:"r"` + G int `json:"g"` + B int `json:"b"` + A float64 `json:"a"` + } `json:"display_color"` + } `json:"spells,omitempty"` + Description string `json:"description,omitempty"` + IsSubclassHidden bool `json:"is_subclass_hidden,omitempty"` + Sockets []struct { + SocketType struct { + Type string `json:"type"` + Name string `json:"name"` + } `json:"socket_type"` + Item struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"item"` + DisplayString string `json:"display_string"` + Media struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + } `json:"media"` + } `json:"sockets,omitempty"` + SellPrice struct { + Value int `json:"value"` + DisplayStrings struct { + Header string `json:"header"` + Gold string `json:"gold"` + Silver string `json:"silver"` + Copper string `json:"copper"` + } `json:"display_strings"` + } `json:"sell_price,omitempty"` + IsCorrupted bool `json:"is_corrupted,omitempty"` + Enchantments []struct { + DisplayString string `json:"display_string"` + SourceItem struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"source_item"` + EnchantmentID int `json:"enchantment_id"` + EnchantmentSlot struct { + ID int `json:"id"` + Type string `json:"type"` + } `json:"enchantment_slot"` + } `json:"enchantments,omitempty"` + LimitCategory string `json:"limit_category,omitempty"` + Requirements struct { + Level struct { + Value int `json:"value"` + DisplayString string `json:"display_string"` + } `json:"level"` + Faction struct { + Value struct { + Type string `json:"type"` + Name string `json:"name"` + } `json:"value"` + DisplayString string `json:"display_string"` + } `json:"faction"` + Skill struct { + Profession struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"profession"` + Level int `json:"level"` + DisplayString string `json:"display_string"` + } `json:"skill"` + } `json:"requirements,omitempty"` + Weapon struct { + Damage struct { + MinValue int `json:"min_value"` + MaxValue int `json:"max_value"` + DisplayString string `json:"display_string"` + DamageClass struct { + Type string `json:"type"` + Name string `json:"name"` + } `json:"damage_class"` + } `json:"damage"` + AttackSpeed struct { + Value int `json:"value"` + DisplayString string `json:"display_string"` + } `json:"attack_speed"` + Dps struct { + Value float64 `json:"value"` + DisplayString string `json:"display_string"` + } `json:"dps"` + } `json:"weapon,omitempty"` + } `json:"equipped_items"` +} diff --git a/v2/wowp/characterHunterPets.go b/v2/wowp/characterHunterPets.go new file mode 100644 index 0000000..23110f9 --- /dev/null +++ b/v2/wowp/characterHunterPets.go @@ -0,0 +1,43 @@ +package wowp + +// CharacterHunterPetsSummary structure +type CharacterHunterPetsSummary struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Character struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + Realm struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + Slug string `json:"slug"` + } `json:"realm"` + } `json:"character"` + HunterPets []struct { + Name string `json:"name"` + Level int `json:"level"` + Creature struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"creature"` + Slot int `json:"slot"` + IsActive bool `json:"is_active"` + CreatureDisplay struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + } `json:"creature_display"` + } `json:"hunter_pets"` +} diff --git a/v2/wowp/characterMedia.go b/v2/wowp/characterMedia.go new file mode 100644 index 0000000..52dd74f --- /dev/null +++ b/v2/wowp/characterMedia.go @@ -0,0 +1,28 @@ +package wowp + +// CharacterMediaSummary structure +type CharacterMediaSummary struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Character struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + Realm struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + Slug string `json:"slug"` + } `json:"realm"` + } `json:"character"` + AvatarURL string `json:"avatar_url"` + BustURL string `json:"bust_url"` + RenderURL string `json:"render_url"` +} diff --git a/v2/wowp/characterMythicKeystoneProfile.go b/v2/wowp/characterMythicKeystoneProfile.go new file mode 100644 index 0000000..c1a00b4 --- /dev/null +++ b/v2/wowp/characterMythicKeystoneProfile.go @@ -0,0 +1,141 @@ +package wowp + +// CharacterMythicKeystoneProfile structure +type CharacterMythicKeystoneProfile struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Character struct { + Href string `json:"href"` + } `json:"character"` + CurrentPeriod struct { + Period struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + } `json:"period"` + BestRuns []struct { + CompletedTimestamp int64 `json:"completed_timestamp"` + Duration int `json:"duration"` + KeystoneLevel int `json:"keystone_level"` + KeystoneAffixes []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"keystone_affixes"` + Members []struct { + Character struct { + Name string `json:"name"` + ID int `json:"id"` + Realm struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + Slug string `json:"slug"` + } `json:"realm"` + } `json:"character"` + Specialization struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"specialization"` + Race struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"race"` + EquippedItemLevel int `json:"equipped_item_level"` + } `json:"members"` + Dungeon struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"dungeon"` + IsCompletedWithinTime bool `json:"is_completed_within_time"` + } `json:"best_runs"` + } `json:"current_period"` + Seasons []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + } `json:"seasons"` +} + +// CharacterMythicKeystoneProfileSeason structure +type CharacterMythicKeystoneProfileSeason struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Season struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + } `json:"season"` + BestRuns []struct { + CompletedTimestamp int64 `json:"completed_timestamp"` + Duration int `json:"duration"` + KeystoneLevel int `json:"keystone_level"` + KeystoneAffixes []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"keystone_affixes"` + Members []struct { + Character struct { + Name string `json:"name"` + ID int `json:"id"` + Realm struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + Slug string `json:"slug"` + } `json:"realm"` + } `json:"character"` + Specialization struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"specialization"` + Race struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"race"` + EquippedItemLevel int `json:"equipped_item_level"` + } `json:"members"` + Dungeon struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"dungeon"` + IsCompletedWithinTime bool `json:"is_completed_within_time"` + } `json:"best_runs"` + Character struct { + Href string `json:"href"` + } `json:"character"` +} diff --git a/v2/wowp/characterProfile.go b/v2/wowp/characterProfile.go new file mode 100644 index 0000000..157c837 --- /dev/null +++ b/v2/wowp/characterProfile.go @@ -0,0 +1,125 @@ +package wowp + +// CharacterProfileSummary structure +type CharacterProfileSummary struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ID int `json:"id"` + Name string `json:"name"` + Gender struct { + Type string `json:"type"` + Name string `json:"name"` + } `json:"gender"` + Faction struct { + Type string `json:"type"` + Name string `json:"name"` + } `json:"faction"` + Race struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"race"` + CharacterClass struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"character_class"` + ActiveSpec struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"active_spec"` + Realm struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + Slug string `json:"slug"` + } `json:"realm"` + Guild struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + Realm struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + Slug string `json:"slug"` + } `json:"realm"` + } `json:"guild"` + Level int `json:"level"` + Experience int `json:"experience"` + AchievementPoints int `json:"achievement_points"` + Achievements struct { + Href string `json:"href"` + } `json:"achievements"` + Titles struct { + Href string `json:"href"` + } `json:"titles"` + PvpSummary struct { + Href string `json:"href"` + } `json:"pvp_summary"` + RaidProgression struct { + Href string `json:"href"` + } `json:"raid_progression"` + Media struct { + Href string `json:"href"` + } `json:"media"` + LastLoginTimestamp int64 `json:"last_login_timestamp"` + AverageItemLevel int `json:"average_item_level"` + EquippedItemLevel int `json:"equipped_item_level"` + Specializations struct { + Href string `json:"href"` + } `json:"specializations"` + Statistics struct { + Href string `json:"href"` + } `json:"statistics"` + MythicKeystoneProfile struct { + Href string `json:"href"` + } `json:"mythic_keystone_profile"` + Equipment struct { + Href string `json:"href"` + } `json:"equipment"` + Appearance struct { + Href string `json:"href"` + } `json:"appearance"` + Collections struct { + Href string `json:"href"` + } `json:"collections"` + ActiveTitle struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + DisplayString string `json:"display_string"` + } `json:"active_title"` + Reputations struct { + Href string `json:"href"` + } `json:"reputations"` +} + +// CharacterProfileStatus structure +type CharacterProfileStatus struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ID int `json:"id"` + IsValid bool `json:"is_valid"` +} diff --git a/v2/wowp/characterPvP.go b/v2/wowp/characterPvP.go new file mode 100644 index 0000000..6931e80 --- /dev/null +++ b/v2/wowp/characterPvP.go @@ -0,0 +1,96 @@ +package wowp + +// CharacterPvPBracketStatistics structure +type CharacterPvPBracketStatistics struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Character struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + Realm struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + Slug string `json:"slug"` + } `json:"realm"` + } `json:"character"` + Faction struct { + Type string `json:"type"` + Name string `json:"name"` + } `json:"faction"` + Bracket struct { + ID int `json:"id"` + Type string `json:"type"` + } `json:"bracket"` + Rating int `json:"rating"` + Season struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + } `json:"season"` + Tier struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + } `json:"tier"` + SeasonMatchStatistics struct { + Played int `json:"played"` + Won int `json:"won"` + Lost int `json:"lost"` + } `json:"season_match_statistics"` + WeeklyMatchStatistics struct { + Played int `json:"played"` + Won int `json:"won"` + Lost int `json:"lost"` + } `json:"weekly_match_statistics"` +} + +// CharacterPvPSummary structure +type CharacterPvPSummary struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Brackets []struct { + Href string `json:"href"` + } `json:"brackets"` + HonorLevel int `json:"honor_level"` + PvpMapStatistics []struct { + WorldMap struct { + Name string `json:"name"` + ID int `json:"id"` + } `json:"world_map"` + MatchStatistics struct { + Played int `json:"played"` + Won int `json:"won"` + Lost int `json:"lost"` + } `json:"match_statistics"` + } `json:"pvp_map_statistics"` + HonorableKills int `json:"honorable_kills"` + Character struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + Realm struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + Slug string `json:"slug"` + } `json:"realm"` + } `json:"character"` +} diff --git a/v2/wowp/characterQuests.go b/v2/wowp/characterQuests.go new file mode 100644 index 0000000..42c878b --- /dev/null +++ b/v2/wowp/characterQuests.go @@ -0,0 +1,66 @@ +package wowp + +// CharacterQuests structure +type CharacterQuests struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Character struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + Realm struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + Slug string `json:"slug"` + } `json:"realm"` + } `json:"character"` + InProgress []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"in_progress"` + Completed struct { + Href string `json:"href"` + } `json:"completed"` +} + +// CharacterCompletedQuests structure +type CharacterCompletedQuests struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Character struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + Realm struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + Slug string `json:"slug"` + } `json:"realm"` + } `json:"character"` + Quests []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"quests"` +} diff --git a/v2/wowp/characterReputations.go b/v2/wowp/characterReputations.go new file mode 100644 index 0000000..4bba0f6 --- /dev/null +++ b/v2/wowp/characterReputations.go @@ -0,0 +1,46 @@ +package wowp + +// CharacterReputationsSummary structure +type CharacterReputationsSummary struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Character struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + Realm struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + Slug string `json:"slug"` + } `json:"realm"` + } `json:"character"` + Reputations []struct { + Faction struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"faction"` + Standing struct { + Raw int `json:"raw"` + Value int `json:"value"` + Max int `json:"max"` + Tier int `json:"tier"` + Name string `json:"name"` + } `json:"standing"` + Paragon struct { + Raw int `json:"raw"` + Value int `json:"value"` + Max int `json:"max"` + } `json:"paragon,omitempty"` + } `json:"reputations"` +} diff --git a/v2/wowp/characterSpecializations.go b/v2/wowp/characterSpecializations.go new file mode 100644 index 0000000..9b60dfc --- /dev/null +++ b/v2/wowp/characterSpecializations.go @@ -0,0 +1,95 @@ +package wowp + +// CharacterSpecializationsSummary structure +type CharacterSpecializationsSummary struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Specializations []struct { + Specialization struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"specialization"` + Talents []struct { + Talent struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"talent"` + SpellTooltip 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"` + CastTime string `json:"cast_time"` + PowerCost interface{} `json:"power_cost"` + Range string `json:"range"` + Cooldown string `json:"cooldown"` + } `json:"spell_tooltip,omitempty"` + } `json:"talents"` + Glyphs []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"glyphs,omitempty"` + PvpTalentSlots []struct { + Selected struct { + Talent struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"talent"` + SpellTooltip 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"` + CastTime string `json:"cast_time"` + Cooldown string `json:"cooldown"` + } `json:"spell_tooltip"` + } `json:"selected"` + SlotNumber int `json:"slot_number"` + } `json:"pvp_talent_slots,omitempty"` + } `json:"specializations"` + ActiveSpecialization struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"active_specialization"` + Character struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + Realm struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + Slug string `json:"slug"` + } `json:"realm"` + } `json:"character"` +} diff --git a/v2/wowp/characterStatistics.go b/v2/wowp/characterStatistics.go new file mode 100644 index 0000000..a937eea --- /dev/null +++ b/v2/wowp/characterStatistics.go @@ -0,0 +1,135 @@ +package wowp + +// CharacterStatisticsSummary structure +type CharacterStatisticsSummary struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Health int `json:"health"` + Power int `json:"power"` + PowerType struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"power_type"` + Speed struct { + Rating int `json:"rating"` + RatingBonus float64 `json:"rating_bonus"` + } `json:"speed"` + Strength struct { + Base int `json:"base"` + Effective int `json:"effective"` + } `json:"strength"` + Agility struct { + Base int `json:"base"` + Effective int `json:"effective"` + } `json:"agility"` + Intellect struct { + Base int `json:"base"` + Effective int `json:"effective"` + } `json:"intellect"` + Stamina struct { + Base int `json:"base"` + Effective int `json:"effective"` + } `json:"stamina"` + MeleeCrit struct { + Rating int `json:"rating"` + RatingBonus float64 `json:"rating_bonus"` + Value float64 `json:"value"` + } `json:"melee_crit"` + MeleeHaste struct { + Rating int `json:"rating"` + RatingBonus float64 `json:"rating_bonus"` + Value float64 `json:"value"` + } `json:"melee_haste"` + Mastery struct { + Rating int `json:"rating"` + RatingBonus float64 `json:"rating_bonus"` + Value float64 `json:"value"` + } `json:"mastery"` + BonusArmor int `json:"bonus_armor"` + Lifesteal struct { + Rating int `json:"rating"` + RatingBonus float64 `json:"rating_bonus"` + Value float64 `json:"value"` + } `json:"lifesteal"` + Versatility float64 `json:"versatility"` + VersatilityDamageDoneBonus float64 `json:"versatility_damage_done_bonus"` + VersatilityHealingDoneBonus float64 `json:"versatility_healing_done_bonus"` + VersatilityDamageTakenBonus float64 `json:"versatility_damage_taken_bonus"` + Avoidance struct { + Rating int `json:"rating"` + RatingBonus float64 `json:"rating_bonus"` + } `json:"avoidance"` + AttackPower int `json:"attack_power"` + MainHandDamageMin float64 `json:"main_hand_damage_min"` + MainHandDamageMax float64 `json:"main_hand_damage_max"` + MainHandSpeed float64 `json:"main_hand_speed"` + MainHandDps float64 `json:"main_hand_dps"` + OffHandDamageMin float64 `json:"off_hand_damage_min"` + OffHandDamageMax float64 `json:"off_hand_damage_max"` + OffHandSpeed float64 `json:"off_hand_speed"` + OffHandDps float64 `json:"off_hand_dps"` + SpellPower int `json:"spell_power"` + SpellPenetration int `json:"spell_penetration"` + SpellCrit struct { + Rating int `json:"rating"` + RatingBonus float64 `json:"rating_bonus"` + Value float64 `json:"value"` + } `json:"spell_crit"` + ManaRegen float64 `json:"mana_regen"` + ManaRegenCombat float64 `json:"mana_regen_combat"` + Armor struct { + Base int `json:"base"` + Effective int `json:"effective"` + } `json:"armor"` + Dodge struct { + Rating int `json:"rating"` + RatingBonus float64 `json:"rating_bonus"` + Value float64 `json:"value"` + } `json:"dodge"` + Parry struct { + Rating int `json:"rating"` + RatingBonus float64 `json:"rating_bonus"` + Value float64 `json:"value"` + } `json:"parry"` + Block struct { + Rating int `json:"rating"` + RatingBonus float64 `json:"rating_bonus"` + Value float64 `json:"value"` + } `json:"block"` + RangedCrit struct { + Rating int `json:"rating"` + RatingBonus float64 `json:"rating_bonus"` + Value float64 `json:"value"` + } `json:"ranged_crit"` + RangedHaste struct { + Rating int `json:"rating"` + RatingBonus float64 `json:"rating_bonus"` + Value float64 `json:"value"` + } `json:"ranged_haste"` + SpellHaste struct { + Rating int `json:"rating"` + RatingBonus float64 `json:"rating_bonus"` + Value float64 `json:"value"` + } `json:"spell_haste"` + Character struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + Realm struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + Slug string `json:"slug"` + } `json:"realm"` + } `json:"character"` +} diff --git a/v2/wowp/characterTitles.go b/v2/wowp/characterTitles.go new file mode 100644 index 0000000..3b11477 --- /dev/null +++ b/v2/wowp/characterTitles.go @@ -0,0 +1,40 @@ +package wowp + +// CharacterTitlesSummary structure +type CharacterTitlesSummary struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Character struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + Realm struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + Slug string `json:"slug"` + } `json:"realm"` + } `json:"character"` + ActiveTitle struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + DisplayString string `json:"display_string"` + } `json:"active_title"` + Titles []struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"titles"` +} diff --git a/v2/wowp/guild.go b/v2/wowp/guild.go new file mode 100644 index 0000000..d08ee72 --- /dev/null +++ b/v2/wowp/guild.go @@ -0,0 +1,199 @@ +package wowp + +// Guild structure +type Guild struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + ID int `json:"id"` + Name string `json:"name"` + Faction struct { + Type string `json:"type"` + Name string `json:"name"` + } `json:"faction"` + AchievementPoints int `json:"achievement_points"` + MemberCount int `json:"member_count"` + Realm struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + Slug string `json:"slug"` + } `json:"realm"` + Crest struct { + Emblem struct { + ID int `json:"id"` + Media struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + } `json:"media"` + Color struct { + ID int `json:"id"` + Rgba struct { + R int `json:"r"` + G int `json:"g"` + B int `json:"b"` + A float64 `json:"a"` + } `json:"rgba"` + } `json:"color"` + } `json:"emblem"` + Border struct { + ID int `json:"id"` + Media struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + } `json:"media"` + Color struct { + ID int `json:"id"` + Rgba struct { + R int `json:"r"` + G int `json:"g"` + B int `json:"b"` + A float64 `json:"a"` + } `json:"rgba"` + } `json:"color"` + } `json:"border"` + Background struct { + Color struct { + ID int `json:"id"` + Rgba struct { + R int `json:"r"` + G int `json:"g"` + B int `json:"b"` + A float64 `json:"a"` + } `json:"rgba"` + } `json:"color"` + } `json:"background"` + } `json:"crest"` + Roster struct { + Href string `json:"href"` + } `json:"roster"` + Achievements struct { + Href string `json:"href"` + } `json:"achievements"` + CreatedTimestamp int64 `json:"created_timestamp"` +} + +// GuildAchievements structure +type GuildAchievements struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Guild struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + Realm struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + Slug string `json:"slug"` + } `json:"realm"` + } `json:"guild"` + TotalQuantity int `json:"total_quantity"` + TotalPoints int `json:"total_points"` + Achievements []struct { + ID int `json:"id"` + Achievement struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"achievement"` + Criteria struct { + ID int `json:"id"` + Amount float64 `json:"amount"` + IsCompleted bool `json:"is_completed"` + ChildCriteria []struct { + ID int `json:"id"` + Amount float64 `json:"amount"` + IsCompleted bool `json:"is_completed"` + } `json:"child_criteria"` + } `json:"criteria,omitempty"` + CompletedTimestamp int64 `json:"completed_timestamp,omitempty"` + } `json:"achievements"` + CategoryProgress []struct { + Category struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"category"` + Quantity int `json:"quantity"` + Points int `json:"points"` + } `json:"category_progress"` + RecentEvents []struct { + Achievement struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + } `json:"achievement"` + Timestamp int64 `json:"timestamp"` + } `json:"recent_events"` +} + +// GuildRoster structure +type GuildRoster struct { + Links struct { + Self struct { + Href string `json:"href"` + } `json:"self"` + } `json:"_links"` + Guild struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + Realm struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + Name string `json:"name"` + ID int `json:"id"` + Slug string `json:"slug"` + } `json:"realm"` + } `json:"guild"` + Members []struct { + Character struct { + Name string `json:"name"` + ID int `json:"id"` + Realm struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + Slug string `json:"slug"` + } `json:"realm"` + Level int `json:"level"` + PlayableClass struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + } `json:"playable_class"` + PlayableRace struct { + Key struct { + Href string `json:"href"` + } `json:"key"` + ID int `json:"id"` + } `json:"playable_race"` + } `json:"character"` + Rank int `json:"rank"` + } `json:"members"` +} diff --git a/v2/wowp/wowp.go b/v2/wowp/wowp.go new file mode 100644 index 0000000..659cd0a --- /dev/null +++ b/v2/wowp/wowp.go @@ -0,0 +1,12 @@ +// Package wowp contains types for the World of Warcraft Profile APIs +package wowp + +// Bracket type +type Bracket string + +// Bracket field for PVP API calls +const ( + Bracket2v2 Bracket = "2v2" + Bracket3v3 Bracket = "3v3" + BracketRBG Bracket = "rbg" +) diff --git a/v2/wowp_test.go b/v2/wowp_test.go new file mode 100644 index 0000000..71514ad --- /dev/null +++ b/v2/wowp_test.go @@ -0,0 +1,341 @@ +package blizzard + +import ( + "context" + "fmt" + "testing" + + "github.com/FuzzyStatic/blizzard/v2/wowp" +) + +func TestWoWCharacterAchievementsSummary(t *testing.T) { + dat, _, err := c.WoWCharacterAchievementsSummary(context.Background(), "illidan", "Darkee") + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWCharacterAppearanceSummary(t *testing.T) { + dat, _, err := c.WoWCharacterAppearanceSummary(context.Background(), "illidan", "Darkee") + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWCharacterCollectionsIndex(t *testing.T) { + dat, _, err := c.WoWCharacterCollectionsIndex(context.Background(), "illidan", "Darkee") + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWCharacterMountsCollectionSummary(t *testing.T) { + dat, _, err := c.WoWCharacterMountsCollectionSummary(context.Background(), "illidan", "Darkee") + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWCharacterPetsCollectionSummary(t *testing.T) { + dat, _, err := c.WoWCharacterPetsCollectionSummary(context.Background(), "illidan", "Darkee") + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWCharacterEncountersSummary(t *testing.T) { + dat, _, err := c.WoWCharacterEncountersSummary(context.Background(), "illidan", "Darkee") + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWCharacterDungeons(t *testing.T) { + dat, _, err := c.WoWCharacterDungeons(context.Background(), "illidan", "Darkee") + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWCharacterRaids(t *testing.T) { + dat, _, err := c.WoWCharacterRaids(context.Background(), "illidan", "Darkee") + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWCharacterEquipmentSummary(t *testing.T) { + dat, _, err := c.WoWCharacterEquipmentSummary(context.Background(), "illidan", "Darkee") + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWCharacterHunterPetsSummary(t *testing.T) { + dat, _, err := c.WoWCharacterHunterPetsSummary(context.Background(), "illidan", "Defraudedguy") + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWCharacterMediaSummary(t *testing.T) { + dat, _, err := c.WoWCharacterMediaSummary(context.Background(), "illidan", "Darkee") + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWCharacterProfileSummary(t *testing.T) { + dat, _, err := c.WoWCharacterProfileSummary(context.Background(), "illidan", "Darkee") + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWCharacterProfileStatus(t *testing.T) { + dat, _, err := c.WoWCharacterProfileStatus(context.Background(), "illidan", "Darkee") + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWCharacterMythicKeystoneProfile(t *testing.T) { + dat, _, err := c.WoWCharacterMythicKeystoneProfile(context.Background(), "illidan", "Darkee") + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWCharacterMythicKeystoneProfileSeason(t *testing.T) { + dat, _, err := c.WoWCharacterMythicKeystoneProfileSeason(context.Background(), "illidan", "Darkee", 1) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWCharacterPvPBracketStatistics(t *testing.T) { + dat, _, err := c.WoWCharacterPvPBracketStatistics(context.Background(), "tichondrius", "tmpikaboo", wowp.Bracket2v2) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } + + dat, _, err = c.WoWCharacterPvPBracketStatistics(context.Background(), "tichondrius", "tmpikaboo", wowp.Bracket3v3) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } + + dat, _, err = c.WoWCharacterPvPBracketStatistics(context.Background(), "icecrown", "soballer", wowp.BracketRBG) + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWCharacterPvPSummary(t *testing.T) { + dat, _, err := c.WoWCharacterPvPSummary(context.Background(), "tichondrius", "tmpikaboo") + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWCharacterQuests(t *testing.T) { + dat, _, err := c.WoWCharacterQuests(context.Background(), "illidan", "Darkee") + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWCharacterCompletedQuests(t *testing.T) { + dat, _, err := c.WoWCharacterCompletedQuests(context.Background(), "illidan", "Darkee") + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWCharacterReputationsSummary(t *testing.T) { + dat, _, err := c.WoWCharacterReputationsSummary(context.Background(), "illidan", "Darkee") + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWCharacterSpecializationsSummary(t *testing.T) { + dat, _, err := c.WoWCharacterSpecializationsSummary(context.Background(), "illidan", "Darkee") + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWCharacterStatisticsSummary(t *testing.T) { + dat, _, err := c.WoWCharacterStatisticsSummary(context.Background(), "illidan", "Darkee") + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWCharacterTitlesSummary(t *testing.T) { + dat, _, err := c.WoWCharacterTitlesSummary(context.Background(), "illidan", "Darkee") + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWGuild(t *testing.T) { + dat, _, err := c.WoWGuild(context.Background(), "illidan", "Complexity Limit") + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWGuildAchievements(t *testing.T) { + dat, _, err := c.WoWGuildAchievements(context.Background(), "illidan", "Complexity Limit") + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +} + +func TestWoWGuildRoster(t *testing.T) { + dat, _, err := c.WoWGuildRoster(context.Background(), "illidan", "Complexity Limit") + if err != nil { + fmt.Println(err) + t.Fail() + } + + if printOutput != "" { + fmt.Printf("%+v\n", dat) + } +}