Documentation ¶
Index ¶
- func CheckError(r *http.Response) error
- func Endpoint(region string) oauth2.Endpoint
- type AccountService
- type Achievement
- type Achievements
- type Career
- type CharacterImage
- type Client
- type ErrorResponse
- type Level
- type Points
- type ProfileService
- type Response
- type Rewards
- type SC2Character
- type SC2Profile
- type SC2Service
- type Season
- type SwarmLevels
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckError ¶
CheckError checks for an error in the given response.
Types ¶
type AccountService ¶
type AccountService struct {
// contains filtered or unexported fields
}
AccountService has account-related APIs. See Client.
type Achievement ¶
type Achievement struct { ID int `json:"achievementId"` CompletionDate int `json:"completionDate"` }
Achievement represents a single Starcraft 2 achievement.
type Achievements ¶
type Achievements struct { Points Points `json:"points"` Achievements []Achievement `json:"achievements"` }
Achievements represents achievement information for a Starcraft 2 profile.
type Career ¶
type Career struct { PrimaryRace string `json:"primaryRace"` TerranWins int `json:"terranWins"` ProtossWins int `json:"protossWins"` ZergWins int `json:"zergWins"` Highest1v1Rank string `json:"highest1v1Rank"` SeasonTotalGames int `json:"seasonTotalGames"` CareerTotalGames int `json:"careerTotalGames"` }
Career represents game statistics for a character's Battle.net career.
type CharacterImage ¶
type CharacterImage 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"` }
CharacterImage is a character's portrait or avatar.
type Client ¶
type Client struct { // Client is the HTTP client to use for communication. Client *http.Client // BaseURL is the base URL for API requests. This should match // the region with the auth region used for Client. BaseURL *url.URL // UserAgent is the user agent to set on API requests. UserAgent string }
Client is the API client for Battle.net. Create this using NewClient. This can also be constructed manually but it isn't recommended.
func NewClient ¶
NewClient creates a new Battle.net client.
region must be a valid Battle.net region. This will not validate it is valid.
The http.Client argument should usually be retrieved via the oauth2 Go library NewClient function. It must be a client that automatically injects authentication details into requests.
func (*Client) Account ¶
func (c *Client) Account() *AccountService
func (*Client) Do ¶
Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response body will be written to v, without attempting to first decode it.
func (*Client) NewRequest ¶
NewRequest creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the BaseURL of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.
func (*Client) Profile ¶
func (c *Client) Profile() *ProfileService
type ErrorResponse ¶
type ErrorResponse struct { Response *http.Response Code string `json:"error"` Description string `json:"error_description"` Scope string `json:"scope"` }
ErrorResponse is the error response structure from the Battle.net API
func (*ErrorResponse) Error ¶
func (r *ErrorResponse) Error() string
type Level ¶
type Level struct { Level int `json:"level"` TotalLevelXP int `json:"totalLevelXP"` CurrentLevelXP int `json:"currentLevelXP"` }
Level is the current level and XP a character has earned.
type Points ¶
type Points struct {
Total int `json:"totalPoints"`
}
Points holds a character's total achievement points.
type ProfileService ¶
type ProfileService struct {
// contains filtered or unexported fields
}
ProfileService has OAuth Profile APIs. See Client.
func (*ProfileService) SC2 ¶
func (s *ProfileService) SC2() (*SC2Profile, *Response, error)
SC2() calls the /sc2/profile/user endpoint. This endpoint uses OAuth2 to retrieve a user's Starcraft 2 profile. See Battle.net docs.
type Response ¶
type Response struct { *http.Response QPSCurrent int QPSAllotted int QuotaCurrent int QuotaAllotted int QuotaReset time.Time }
Reponse is a Battle.net API response. This wraps the standard http.Response and provides convenient access to some of the metadata returned.
type SC2Character ¶
type SC2Character struct { ID int `json:"id"` Realm int `json:"realm"` Name string `json:"name"` DisplayName string `json:"displayName"` ClanName string `json:"clanName"` ClanTag string `json:"clanTag"` ProfilePath string `json:"profilePath"` Portrait CharacterImage `json:"portrait"` Avatar CharacterImage `json:"avatar"` Career Career `json:"career"` SwarmLevels SwarmLevels `json:"swarmLevels"` Season Season `json:"season"` Rewards Rewards `json:"rewards"` Achievements Achievements `json:"achievements"` }
SC2Character represents a character in a user's Starcraft 2 profile.
type SC2Profile ¶
type SC2Profile struct {
Characters []SC2Character `json:"characters"`
}
SC2Profile represents the profile information for a user's Starcraft 2 profile.
type SC2Service ¶
type SC2Service struct {
// contains filtered or unexported fields
}
SC2Service has Starcraft2-related APIs. See Client.
type Season ¶
type Season struct { ID int `json:"seasonId"` Number int `json:"seasonNumber"` Year int `json:"seasonYear"` TotalGames int `json:"totalGamesThisSeason"` }
Season is the current Starcraft 2 online multiplayer season.