client

package
v0.0.0-...-6698619 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2022 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BaseUrl = "https://api.clashroyale.com/v1"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPSessionManager

type HTTPSessionManager struct {
	Credentials   []LoginCredential
	Client        *resty.Client
	KeyNames      string
	KeyCount      int
	CacheMaxSize  int
	LoginResponse LoginResponse
	KeysList      KeysList
	RawKeysList   []Key
	KeyIndex      int
	IP            string
	WG            sync.WaitGroup
	Mutex         sync.RWMutex
	IsValidKeys   bool
	// contains filtered or unexported fields
}

func Initialize

func Initialize(credentials ...map[string]string) *HTTPSessionManager

func (*HTTPSessionManager) APILopin

func (h *HTTPSessionManager) APILopin(credential LoginCredential) error

func (*HTTPSessionManager) AddKey

func (h *HTTPSessionManager) AddKey() error

func (*HTTPSessionManager) AddOrDeleteKeysAsNecessary

func (h *HTTPSessionManager) AddOrDeleteKeysAsNecessary(developerID string) error

func (*HTTPSessionManager) DeleteKey

func (h *HTTPSessionManager) DeleteKey(key Key) error

func (*HTTPSessionManager) GetClan

func (h *HTTPSessionManager) GetClan(ClanTag string) (*clan.Clan, error)

func (*HTTPSessionManager) GetClanCurrentRiverRace

func (h *HTTPSessionManager) GetClanCurrentRiverRace(ClanTag string) (*clan.CurrentWar, error)

func (*HTTPSessionManager) GetClanCurrentWar

func (h *HTTPSessionManager) GetClanCurrentWar(ClanTag string) (*clan.CurrentWar, error)

func (*HTTPSessionManager) GetClanLabels

func (h *HTTPSessionManager) GetClanLabels(args ...map[string]string) (*labels.LabelsData, error)

func (*HTTPSessionManager) GetClanMembers

func (h *HTTPSessionManager) GetClanMembers(ClanTag string) (*clan.MemberList, error)

func (*HTTPSessionManager) GetClanRiverRaceLog

func (h *HTTPSessionManager) GetClanRiverRaceLog(ClanTag string) (*clan.CurrentWar, error)

func (*HTTPSessionManager) GetClanWarLog

func (h *HTTPSessionManager) GetClanWarLog(ClanTag string) (*clan.WarLog, error)

func (*HTTPSessionManager) GetIP

func (h *HTTPSessionManager) GetIP() error

func (*HTTPSessionManager) GetKeys

func (h *HTTPSessionManager) GetKeys() error

func (*HTTPSessionManager) GetLeague

func (h *HTTPSessionManager) GetLeague(LeagueID string) (*league.League, error)

func (*HTTPSessionManager) GetLeagueSeasonInfo

func (h *HTTPSessionManager) GetLeagueSeasonInfo(LeagueID string, SeasonID string, args ...map[string]string) (*league.SeasonInfo, error)

be cautious when using this. the data returned is massive. recommended to add args of {"limit": limit} and use the cursors for more data

func (*HTTPSessionManager) GetLeagueSeasons

func (h *HTTPSessionManager) GetLeagueSeasons(LeagueID string, args ...map[string]string) (*league.SeasonData, error)

func (*HTTPSessionManager) GetLocation

func (h *HTTPSessionManager) GetLocation(LocationID string) (*location.Location, error)

func (*HTTPSessionManager) GetLocationClans

func (h *HTTPSessionManager) GetLocationClans(LocationID string, args ...map[string]string) (*location.ClanData, error)

func (*HTTPSessionManager) GetLocationClansVersus

func (h *HTTPSessionManager) GetLocationClansVersus(LocationID string, args ...map[string]string) (*location.ClanVersusData, error)

func (*HTTPSessionManager) GetLocationPlayers

func (h *HTTPSessionManager) GetLocationPlayers(LocationID string, args ...map[string]string) (*location.PlayerData, error)

func (*HTTPSessionManager) GetLocationPlayersVersus

func (h *HTTPSessionManager) GetLocationPlayersVersus(LocationID string, args ...map[string]string) (*location.PlayerVersusData, error)

func (*HTTPSessionManager) GetPlayer

func (h *HTTPSessionManager) GetPlayer(PlayerTag string) (*player.Player, error)

func (*HTTPSessionManager) GetPlayerLabels

func (h *HTTPSessionManager) GetPlayerLabels(args ...map[string]string) (*labels.LabelsData, error)

func (*HTTPSessionManager) Post

func (h *HTTPSessionManager) Post(route string, body string, nested bool) ([]byte, error)

func (*HTTPSessionManager) Request

func (h *HTTPSessionManager) Request(route string, nested bool) ([]byte, error)

func (*HTTPSessionManager) SearchClans

func (h *HTTPSessionManager) SearchClans(args ...map[string]string) (*clan.ClanList, error)

func (*HTTPSessionManager) SearchLeagues

func (h *HTTPSessionManager) SearchLeagues(args ...map[string]string) (*league.LeagueData, error)

func (*HTTPSessionManager) SearchLocations

func (h *HTTPSessionManager) SearchLocations(args ...map[string]string) (*location.LocationData, error)

This should be passed ideally with nothing, kwargs aren't necessary here but only for the sake of completeness.

func (*HTTPSessionManager) VerifyPlayerToken

func (h *HTTPSessionManager) VerifyPlayerToken(PlayerTag string, Token string) (bool, error)

Only POST method for the API so far

func (*HTTPSessionManager) ViewKeys

func (h *HTTPSessionManager) ViewKeys()

type Key

type Key struct {
	ID          string      `json:"id"`
	Developerid string      `json:"developerId"`
	Tier        string      `json:"tier"`
	Name        string      `json:"name"`
	Description string      `json:"description"`
	Origins     interface{} `json:"origins"`
	Scopes      []string    `json:"scopes"`
	Cidrranges  []string    `json:"cidrRanges"`
	ValidUntil  interface{} `json:"validUntil"`
	Key         string      `json:"key"`
}

func RemoveKey

func RemoveKey(keylist []Key, deleteKey Key) []Key

type KeyCreationResponse

type KeyCreationResponse struct {
	Status                  Status `json:"status,omitempty"`
	SessionExpiresInSeconds int64  `json:"sessionExpiresInSeconds,omitempty"`
	Key                     Key    `json:"key,omitempty"`
}

type KeyDeletionResponse

type KeyDeletionResponse struct {
	Status                  Status `json:"status,omitempty"`
	SessionExpiresInSeconds int64  `json:"sessionExpiresInSeconds,omitempty"`
}

type KeysList

type KeysList struct {
	Status        Status `json:"status"`
	SessionExpire int    `json:"sessionExpiresInSeconds"`
	Keys          []Key  `json:"keys"`
}

type LoginCredential

type LoginCredential struct {
	Email    string
	Password string
}

type LoginResponse

type LoginResponse struct {
	Status                  Status `json:"status,omitempty"`
	SessionExpiresInSeconds *int64 `json:"sessionExpiresInSeconds,omitempty"`
	Auth                    struct {
		Uid   *string     `json:"uid,omitempty"`
		Token *string     `json:"token,omitempty"`
		Ua    interface{} `json:"ua"`
		IP    interface{} `json:"ip"`
	} `json:"auth,omitempty"`
	Developer struct {
		ID            *string     `json:"id,omitempty"`
		Name          *string     `json:"name,omitempty"`
		Game          *string     `json:"game,omitempty"`
		Email         *string     `json:"email,omitempty"`
		Tier          *string     `json:"tier,omitempty"`
		AllowedScopes interface{} `json:"allowedScopes"`
		MaxCidrs      interface{} `json:"maxCidrs"`
		PrevLoginTs   *string     `json:"prevLoginTs,omitempty"`
		PrevLoginIP   *string     `json:"prevLoginIp,omitempty"`
		PrevLoginUa   *string     `json:"prevLoginUa,omitempty"`
	} `json:"developer,omitempty"`
	TemporaryAPIToken string `json:"temporaryAPIToken,omitempty"`
	SwaggerURL        string `json:"swaggerUrl,omitempty"`
}

type Status

type Status struct {
	Code    int64       `json:"code,omitempty"`
	Message string      `json:"message,omitempty"`
	Detail  interface{} `json:"detail"`
}

Jump to

Keyboard shortcuts

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