Documentation
¶
Index ¶
- Variables
- func NormaliseTag(tag string) string
- type APIError
- type Achievement
- type Arena
- type Badge
- type Battle
- type BattleOutcome
- type BattlePlayer
- type Battles
- type Card
- type Clan
- type ClanMember
- type ClanPager
- type ClanQuery
- type ClanRanking
- type ClanService
- type ClansService
- type Client
- func (c *Client) Clan(tag string) *ClanService
- func (c *Client) Clans() *ClansService
- func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error)
- func (c *Client) Location(id string) *LocationService
- func (c *Client) Locations() *LocationsService
- func (c *Client) NewRequest(method, path string, body interface{}) (*http.Request, error)
- func (c *Client) Player(tag string) *PlayerService
- func (c *Client) Replay(tag string) *ReplayService
- func (c *Client) SetTimeout(duration time.Duration)
- func (c *Client) Tournament(tag string) *TournamentService
- func (c *Client) Tournaments() *TournamentsService
- type CurrentWar
- type ErrorBody
- type FavouriteCard
- type GameMode
- type IconUrls
- type LeagueStats
- type Location
- type LocationClanRankingPager
- type LocationPager
- type LocationPlayerRankingPager
- type LocationService
- func (i *LocationService) ClanRankings(query *PagedQuery) (LocationClanRankingPager, error)
- func (i *LocationService) ClanWarRankings(query *PagedQuery) (LocationClanRankingPager, error)
- func (i *LocationService) Get() (Location, error)
- func (i *LocationService) PlayerRankings(query *PagedQuery) (LocationPlayerRankingPager, error)
- type LocationsService
- type MemberPager
- type PagedQuery
- type Paging
- type Player
- type PlayerClan
- type PlayerRanking
- type PlayerService
- type Replay
- type ReplayService
- type Season
- type Tournament
- type TournamentMember
- type TournamentPager
- type TournamentQuery
- type TournamentService
- type TournamentsService
- type UpcomingChest
- type UpcomingChests
- type VerificationResult
- type War
- type WarClanDetails
- type WarLogPager
- type WarParticipant
- type WarStanding
Constants ¶
This section is empty.
Variables ¶
var TimeLayout = "20060102T150405.000Z"
This is the time format used by time fields -- we'll be using it to provide cleaner APIs.
Functions ¶
func NormaliseTag ¶
make sure the tag is prefixed with a # if it doesn't have one
Types ¶
type Achievement ¶
type Battle ¶
type Battle struct {
Type string `json:"type"`
RawBattleTime string `json:"battleTime"`
Arena Arena `json:"arena"`
GameMode GameMode `json:"gameMode"`
DeckSelection string `json:"deckSelection"`
Team []BattlePlayer `json:"team"`
Opponent []BattlePlayer `json:"opponent"`
TournamentTag string `json:"tournamentTag"`
ChallengeId int `json:"challengeId"`
ChallengeWinCountBefore int `json:"challengeWinCountBefore"`
ReplayTag string `json:"replayTag,omitempty"`
}
func (*Battle) Outcome ¶
func (b *Battle) Outcome() BattleOutcome
Get a struct describing the outcome of the battle.
func (*Battle) PlayerByTag ¶
func (b *Battle) PlayerByTag(tag string) (BattlePlayer, error)
Find a player in the battle by tag. Return an error if the tag could not be found.
type BattleOutcome ¶
type BattleOutcome struct {
IsDraw bool
Winners []BattlePlayer
Losers []BattlePlayer
}
type BattlePlayer ¶
type BattlePlayer struct {
Tag string `json:"tag"`
Name string `json:"name"`
StartingTrophies int `json:"startingTrophies"`
TrophyChange int `json:"trophyChange"`
Crowns int `json:"crowns"`
// king tower hit points is missing from the response if it is zero.
KingTowerHitPoints int `json:"kingTowerHitPoints,omitempty"`
// ditto. princess tower hit points are an array of values.
PrincessTowersHitPoints []int `json:"princessTowersHitPoints,omitempty"`
Clan struct {
Tag string `json:"tag"`
Name string `json:"name"`
BadgeId int `json:"badgeId"`
} `json:"clan"`
Cards []Card `json:"cards"`
}
type Card ¶
type Card struct {
Name string `json:"name"`
Level int `json:"level"`
MaxLevel int `json:"maxLevel"`
Count int `json:"count"`
IconUrls IconUrls `json:"iconUrls"`
StarLevel int `json:"starLevel"`
}
func (*Card) ClientLevel ¶
Return the internal client level for the card, as these are zero-indexed
type Clan ¶
type Clan struct {
Tag string `json:"tag"`
Name string `json:"name"`
Type string `json:"type"`
Description string `json:"description"`
BadgeId int `json:"badgeId"`
ClanScore int `json:"clanScore"`
ClanWarTrophies int `json:"clanWarTrophies"`
Location Location `json:"location"`
RequiredTrophies int `json:"requiredTrophies"`
DonationsPerWeek int `json:"donationsPerWeek"`
ClanChestStatus string `json:"clanChestStatus"`
ClanChestPoints int `json:"clanChestPoints"`
ClanChestLevel int `json:"clanChestLevel"`
ClanChestMaxLevel int `json:"clanChestMaxLevel"`
Members int `json:"members"`
MemberList []ClanMember `json:"memberList"`
}
type ClanMember ¶
type ClanMember struct {
Tag string `json:"tag"`
Name string `json:"name"`
Role string `json:"role"`
ExpLevel int `json:"expLevel"`
Trophies int `json:"trophies"`
Arena Arena `json:"arena"`
ClanRank int `json:"clanRank"`
PreviousClanRank int `json:"previousClanRank"`
Donations int `json:"donations"`
DonationsReceived int `json:"donationsReceived"`
ClanChestPoints int `json:"clanChestPoints"`
RawLastSeen string `json:"lastSeen"`
}
func (*ClanMember) LastSeen ¶
func (c *ClanMember) LastSeen() time.Time
type ClanRanking ¶
type ClanService ¶
type ClanService struct {
// contains filtered or unexported fields
}
func (*ClanService) CurrentWar ¶
func (i *ClanService) CurrentWar() (CurrentWar, error)
Retrieve information about clan's current clan war
func (*ClanService) Get ¶
func (i *ClanService) Get() (Clan, error)
Get information about a single clan by clan tag. Clan tags can be found using clan search operation.
func (*ClanService) Members ¶
func (i *ClanService) Members() (MemberPager, error)
List clan members
func (*ClanService) WarLog ¶
func (i *ClanService) WarLog() (WarLogPager, error)
Retrieve clan's clan war log
type ClansService ¶
type ClansService struct {
// contains filtered or unexported fields
}
func (*ClansService) Search ¶
func (i *ClansService) Search(query *ClanQuery) (ClanPager, error)
Search all clans by name and/or filtering the results using various criteria. At least one filtering criteria must be defined and if name is used as part of search, it is required to be at least three characters long.
type Client ¶
type Client struct {
BaseURL *url.URL
UserAgent string
Bearer string
// contains filtered or unexported fields
}
func (*Client) Clan ¶
func (c *Client) Clan(tag string) *ClanService
func (*Client) Clans ¶
func (c *Client) Clans() *ClansService
func (*Client) Location ¶
func (c *Client) Location(id string) *LocationService
NB: Location ID is a string. This is because 'global' is a valid location ID.
func (*Client) Locations ¶
func (c *Client) Locations() *LocationsService
func (*Client) NewRequest ¶
make a new request object.
func (*Client) Player ¶
func (c *Client) Player(tag string) *PlayerService
func (*Client) Replay ¶
func (c *Client) Replay(tag string) *ReplayService
func (*Client) SetTimeout ¶
func (*Client) Tournament ¶
func (c *Client) Tournament(tag string) *TournamentService
func (*Client) Tournaments ¶
func (c *Client) Tournaments() *TournamentsService
type CurrentWar ¶
type CurrentWar struct {
State string `json:"state"`
RawCollectionEndTime string `json:"collectionEndTime"`
Clan WarClanDetails `json:"clan"`
Clans []WarClanDetails `json:"clans"`
Participants []WarParticipant `json:"participants"`
RawWarEndTime string `json:"warEndTime"`
}
func (*CurrentWar) CollectionEndTime ¶
func (w *CurrentWar) CollectionEndTime() time.Time
func (*CurrentWar) WarEndTime ¶
func (w *CurrentWar) WarEndTime() time.Time
type FavouriteCard ¶
type LeagueStats ¶
type LocationClanRankingPager ¶
type LocationClanRankingPager struct {
Items []ClanRanking `json:"items"`
Paging Paging `json:"paging"`
}
type LocationPager ¶
type LocationPlayerRankingPager ¶
type LocationPlayerRankingPager struct {
Items []PlayerRanking `json:"items"`
Paging Paging `json:"paging"`
}
type LocationService ¶
type LocationService struct {
// contains filtered or unexported fields
}
func (*LocationService) ClanRankings ¶
func (i *LocationService) ClanRankings(query *PagedQuery) (LocationClanRankingPager, error)
Get clan rankings for a specific location
func (*LocationService) ClanWarRankings ¶
func (i *LocationService) ClanWarRankings(query *PagedQuery) (LocationClanRankingPager, error)
Get clan war rankings for a specific location
func (*LocationService) Get ¶
func (i *LocationService) Get() (Location, error)
Get information about specific location
func (*LocationService) PlayerRankings ¶
func (i *LocationService) PlayerRankings(query *PagedQuery) (LocationPlayerRankingPager, error)
Get player rankings for a specific location
type LocationsService ¶
type LocationsService struct {
// contains filtered or unexported fields
}
func (*LocationsService) All ¶
func (i *LocationsService) All() (LocationPager, error)
List all available locations
type MemberPager ¶
type MemberPager struct {
Items []ClanMember `json:"items"`
Paging Paging `json:"paging"`
}
type PagedQuery ¶ added in v1.1.0
Base struct for paged queries.
type Paging ¶ added in v1.1.0
type Paging struct {
Cursors struct {
Before string `json:"before"`
After string `json:"after"`
} `json:"cursors"`
}
Paging for pager responses. 'before' and 'after' may be empty if there are no more results to return.
type Player ¶
type Player struct {
Tag string `json:"tag"`
Name string `json:"name"`
ExpLevel int `json:"expLevel"`
Trophies int `json:"trophies"`
BestTrophies int `json:"bestTrophies"`
Wins int `json:"wins"`
Losses int `json:"losses"`
BattleCount int `json:"battleCount"`
ThreeCrownWins int `json:"threeCrownWins"`
ChallengeCardsWon int `json:"challengeCardsWon"`
ChallengeMaxWins int `json:"challengeMaxWins"`
TournamentCardsWon int `json:"tournamentCardsWon"`
TournamentBattleCount int `json:"tournamentBattleCount"`
Role string `json:"role"`
Donations int `json:"donations"`
DonationsReceived int `json:"donationsReceived"`
TotalDonations int `json:"totalDonations"`
WarDayWins int `json:"warDayWins"`
ClanCardsCollected int `json:"clanCardsCollected"`
Clan PlayerClan `json:"clan"`
Arena Arena `json:"arena"`
Achievements []Achievement `json:"achievements"`
Badges []Badge `json:"badges"`
Cards []Card `json:"cards"`
CurrentDeck []Card `json:"currentDeck"`
CurrentFavouriteCard FavouriteCard `json:"currentFavouriteCard"`
LeagueStatistics LeagueStats `json:"leagueStatistics"`
StarPoints int `json:"starPoints"`
}
type PlayerClan ¶
type PlayerRanking ¶
type PlayerService ¶
type PlayerService struct {
// contains filtered or unexported fields
}
func (*PlayerService) BattleLog ¶
func (i *PlayerService) BattleLog() (Battles, error)
Get list of recent battle results for a player.
func (*PlayerService) Get ¶
func (i *PlayerService) Get() (Player, error)
Get information about a single player by player tag. Player tags can be found either in game or by from clan member lists.
func (*PlayerService) UpcomingChests ¶
func (i *PlayerService) UpcomingChests() (UpcomingChests, error)
Get list of reward chests that the player will receive next in the game.
func (*PlayerService) VerifyToken ¶
func (i *PlayerService) VerifyToken(token string) (VerificationResult, error)
Verifies a player token and returns whether or not the token was associated with the given player.
This API call can be used by a player to prove that they own a particular game account as the token can only be retrieved inside the game from settings view.
type ReplayService ¶
type ReplayService struct {
// contains filtered or unexported fields
}
func (*ReplayService) Get ¶
func (i *ReplayService) Get() (Replay, error)
Get information about a single replay by a replay tag.
type Tournament ¶
type Tournament struct {
Tag string `json:"tag"`
Type string `json:"type"`
Status string `json:"status"`
CreatorTag string `json:"creatorTag"`
Name string `json:"name"`
Description string `json:"description"`
Capacity int `json:"capacity"`
MaxCapacity int `json:"maxCapacity"`
PreparationDuration int `json:"preparationDuration"`
Duration int `json:"duration"`
RawCreatedTime string `json:"createdTime"`
RawStartedTime string `json:"startedTime"`
MembersList []TournamentMember `json:"membersList"`
FirstPlaceCardPrize int `json:"firstPlaceCardPrize"`
GameMode GameMode `json:"gameMode"`
LevelCap int `json:"levelCap"`
}
func (*Tournament) CreatedTime ¶
func (t *Tournament) CreatedTime() time.Time
func (*Tournament) StartedTime ¶
func (t *Tournament) StartedTime() time.Time
type TournamentMember ¶
type TournamentMember struct {
Tag string `json:"tag"`
Name string `json:"name"`
Score int `json:"score"`
Rank int `json:"rank"`
Clan PlayerClan `json:"clan"`
}
type TournamentPager ¶
type TournamentPager struct {
Items []Tournament `json:"items"`
Paging Paging `json:"paging"`
}
type TournamentQuery ¶
type TournamentQuery struct {
PagedQuery
Name string
}
type TournamentService ¶
type TournamentService struct {
// contains filtered or unexported fields
}
func (*TournamentService) Get ¶
func (i *TournamentService) Get() (Tournament, error)
Get information about a single tournament by a tournament tag.
type TournamentsService ¶
type TournamentsService struct {
// contains filtered or unexported fields
}
func (*TournamentsService) Search ¶
func (i *TournamentsService) Search(query *TournamentQuery) (TournamentPager, error)
Search all tournaments by name.
It is not possible to specify ordering for results so clients should not rely on any specific ordering as that may change in the future releases of the API.
type UpcomingChest ¶
type UpcomingChests ¶
type UpcomingChests struct {
Items []UpcomingChest `json:"items"`
}
type VerificationResult ¶
type VerificationResult struct {
Tag string `json:"tag"`
Token string `json:"token"`
Status string `json:"status"`
}
func (*VerificationResult) IsValid ¶
func (v *VerificationResult) IsValid() bool
type War ¶
type War struct {
SeasonId int `json:"seasonId"`
RawCreatedDate string `json:"createdDate"`
Participants []WarParticipant `json:"participants"`
Standings []WarStanding `json:"standings"`
}
func (*War) CreatedDate ¶
type WarClanDetails ¶
type WarLogPager ¶
type WarParticipant ¶
type WarStanding ¶
type WarStanding struct {
Clan WarClanDetails `json:"clan"`
TrophyChange int `json:"trophyChange"`
}