Skip to content

Commit

Permalink
Add support for fetching wvw team from account endpoint (#7)
Browse files Browse the repository at this point in the history
* Use 2024-07-20 schema for Account endpoint which add wvw team and last_modified fields

* Refactor struct WvW to AccountWvWInfo

* Deprecated Account.WvWRank
  • Loading branch information
vennekilde authored Jan 8, 2025
1 parent e7ab1ee commit 21a2583
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions account.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,19 @@ type Account struct {
FractalLevel int `json:"fractal_level"`
DailyAP int `json:"daily_ap"`
MonthlyAP int `json:"monthly_ap"`
WvWRank int `json:"wvw_rank"`
// Deprecated: Use WvW.Rank instead
WvWRank int `json:"wvw_rank"`
LastModified time.Time `json:"last_modified"`
WvW AccountWvWInfo `json:"wvw"`
}

// Account returns general account information
func (s *Session) Account() (account Account, err error) {
err = s.getWithAuth("/v2/account", &account)
err = s.getWithAuth("/v2/account?v=2024-07-20T01:00:00.000Z", &account)
// Backwards compatibility for Account.WvWRank, as that information is now in Account.WvW.Rank
if account.WvW.Rank > 0 {
account.WvWRank = account.WvW.Rank
}
return
}

Expand Down Expand Up @@ -291,3 +298,9 @@ func (s *Session) AccountLegendaryArmory() (res []*AccountLegendaryArmoryItem, e
err = s.getWithAuth("/v2/account/legendaryarmory", &res)
return
}

// AccountWvWInfo is the accounts WvW information
type AccountWvWInfo struct {
TeamID int `json:"team_id"`
Rank int `json:"rank"`
}

0 comments on commit 21a2583

Please sign in to comment.