sc2replaystats

package
v0.0.0-...-c1607c5 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Hostname represents the root domain sc2replaystats is hosted at
	Hostname = "sc2replaystats.com"

	// Protocol represents the HTTP protocol we use when communicating with sc2replaystats
	Protocol = "https"

	// APIRoot represents the base URL for requests to the sc2replaystats JSON-ish API
	APIRoot = fmt.Sprintf("%s://api.%s", Protocol, Hostname)

	// WebRoot represents the base URL for requests to the sc2replaystats Website
	WebRoot = fmt.Sprintf("%s://%s", Protocol, Hostname)

	// ClientIdentifier represents the "upload_method" shown to sc2replaystats
	ClientIdentifier = fmt.Sprintf("sc2-rsu-api-%s", runtime.GOOS)
)
View Source
var (
	// ErrBadKey is the base message shown in all errors returned by ValidAPIKey
	ErrBadKey = errors.New("invalid sc2replaystats API key")

	// ErrBadKeyDate means the API key's timestamp was invalid or too old to use
	ErrBadKeyDate = fmt.Errorf("%s: bad timestamp", ErrBadKey.Error())

	// ErrBadKeyLen means the API key's format or length was incorrect
	ErrBadKeyLen = fmt.Errorf("%s: bad length", ErrBadKey.Error())
)

Functions

func ValidAPIKey

func ValidAPIKey(key string) bool

ValidAPIKey checks that the given string matches sc2replaystats API key format

Types

type AccountPlayer

type AccountPlayer struct {
	ID      uint   `json:"players_id"`
	Default uint   `json:"default"`
	Player  Player `json:"player"`
}

AccountPlayer represents the JSON format of a Player owned by a server Account

type Client

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

Client allows you to communicate with the sc2ReplayStats API

func New

func New(apikey string) *Client

New returns an sc2ReplayStats API Client

func (*Client) GetAccountPlayers

func (client *Client) GetAccountPlayers() (players []AccountPlayer, err error)

GetAccountPlayers returns an slice of AccountPlayers from the server, showing all those Accounts/Toons associated with the given API key

func (*Client) GetReplayStatus

func (client *Client) GetReplayStatus(replayQueueID string) (replayID string, err error)

GetReplayStatus tries to retrieve the replayID associated with a given replayQueueID -- returning an empty string if it's still processing

func (*Client) UploadReplay

func (client *Client) UploadReplay(filename string) (replayQueueID string, err error)

UploadReplay sends the specified replay to sc2replaystats queue for processing

type Player

type Player struct {
	ID                  uint      `json:"players_id"`
	Name                string    `json:"players_name"`
	BattleNetURL        string    `json:"battle_net_url"`
	BattleTagName       string    `json:"battle_tag_name"`
	BattleTagID         uint      `json:"battle_tag_id"`
	CharacterID         uint      `json:"character_link_id"`
	LegacyBattleTagName string    `json:"legacy_battle_tag_name"`
	LegacyLinkID        uint      `json:"legacy_link_id"`
	LegacyLinkRealm     uint      `json:"legacy_link_realm"`
	ReplaysURL          string    `json:"players_replays_url"`
	Updated             time.Time `json:"updated_at"`
}

Player represents the JSON format that the server stores Toon/Characters in

func (Player) BattleTag

func (p Player) BattleTag() string

BattleTag returns the assembled friends tag of a given Toon/Character

Jump to

Keyboard shortcuts

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