bsapi

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 26, 2023 License: MIT Imports: 7 Imported by: 0

README

Api wrapper for brawlstars

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Battle

type Battle struct {
	Mode   string       `json:"mode"`
	Type   string       `json:"type"`
	Result BattleResult `json:"result"`
	//  in seconds
	Duration     int            `json:"duration"`
	TrophyChange int            `json:"trophyChange"`
	Teams        [][]TeamMember `json:"teams"`
}

type BattleBrawler

type BattleBrawler struct {
	Id   int    `json:"id"`
	Name string `json:"name"`
	// power lvl of brawler
	Power    int `json:"power"`
	Trophies int `json:"trophies"`
}

type BattleItem

type BattleItem struct {
	// 	battle time in supercell's format: yyyymmddThhmmss.000Z
	// 	use BattleItem.ParseTime to get time
	BattleTime string `json:"battleTime"`
	Battle     Battle `json:"battle"`
	Event      Event  `json:"event"`
}

func (BattleItem) ParseTime

func (bi BattleItem) ParseTime() (time.Time, error)

type BattleList

type BattleList struct {
	Items []BattleItem `json:"items"`
}

type BattleResult

type BattleResult string
const (
	BattleVictory BattleResult = "victory"
	BattleDefeat  BattleResult = "defeat"
	BattleDraw    BattleResult = "draw"
)

type BsApi

type BsApi struct {
	// contains filtered or unexported fields
}

func NewApi

func NewApi(token string) BsApi

func (BsApi) GetBattleList

func (api BsApi) GetBattleList(ctx context.Context, playerTag string) (BattleList, error)

func (BsApi) GetClubStats

func (api BsApi) GetClubStats(ctx context.Context, tag string) (Club, error)

func (BsApi) GetPlayerStats

func (api BsApi) GetPlayerStats(ctx context.Context, tag string) (Player, error)

type ClientError

type ClientError struct {
	Reason  string `json:"reason"`
	Message string `json:"message"`
	Type    string `json:"type"`
}

func (ClientError) Error

func (ce ClientError) Error() string

type Club

type Club struct {
	Tag              string       `json:"tag"`
	Name             string       `json:"name"`
	Description      string       `json:"description"`
	Trophies         int          `json:"trophies"`
	RequiredTrophies int          `json:"requiredTrophies"`
	Members          []ClubMember `json:"members"`
	Type             string       `json:"type"`
	BadgeId          int          `json:"badgeId"`
}

type ClubMember

type ClubMember struct {
	Icon      PlayerIcon `json:"icon"`
	Tag       string     `json:"tag"`
	Name      string     `json:"name"`
	Trophies  int        `json:"trophies"`
	Role      ClubRole   `json:"role"`
	NameColor string     `json:"nameColor"`
}

type ClubRole

type ClubRole string
const (
	ClubRolePresident     ClubRole = "president"
	ClubRoleVicePresident ClubRole = "vicePresident"
	ClubRoleSenior        ClubRole = "senior"
	ClubRoleMember        ClubRole = "member"
)

type Event

type Event struct {
	Id   int    `json:"id"`
	Mode string `json:"mode"`
	Map  string `json:"map"`
}

type Player

type Player struct {
	Club            PlayerClub `json:"club"`
	TrioVictories   int        `json:"3vs3Victories"`
	SoloVictories   int        `json:"soloVictories"`
	DuoVictories    int        `json:"duoVictories"`
	Icon            PlayerIcon `json:"icon"`
	ExpLevel        int        `json:"expLevel"`
	ExpPoints       int        `json:"expPoints"`
	Tag             string     `json:"tag"`
	Name            string     `json:"name"`
	Trophies        int        `json:"trophies"`
	HighestTrophies int        `json:"highestTrophies"`
	NameColor       string     `json:"nameColor"`
}

type PlayerClub

type PlayerClub struct {
	Tag  string `json:"tag"`
	Name string `json:"name"`
}

type PlayerIcon

type PlayerIcon struct {
	Id int `json:"id"`
}

type TeamMember

type TeamMember struct {
	Tag     string        `json:"tag"`
	Name    string        `json:"name"`
	Brawler BattleBrawler `json:"brawler"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL