Documentation
¶
Overview ¶
Consume the PandaScore API in Go.
TODO look at errors and how they're returned; we should probably be using Wrap() and stuff but I don't fully understand how that works
Index ¶
- Constants
- type Client
- func (c *Client) AccessToken(accessToken string) *Client
- func (c *Client) GetAllLeagues(game Game) ([]League, error)
- func (c *Client) GetAllRunningMatches(game Game) ([]Match, error)
- func (c *Client) GetAllRunningSeries(game Game) ([]Series, error)
- func (c *Client) GetAllUpcomingMatches(game Game) ([]Match, error)
- func (c *Client) GetAllUpcomingMatchesBetween(game Game, beginning time.Time, until time.Time) ([]Match, error)
- func (c *Client) GetAllUpcomingMatchesForSeries(game Game, seriesID int) ([]Match, error)
- func (c *Client) Request(game Game, path string) *Request
- type Game
- type League
- type Match
- type MatchOpponent
- type Opponent
- type PandaScoreError
- type Request
- func (r *Request) Filter(field string, value ...string) *Request
- func (r *Request) Get(value interface{}) (Response, error)
- func (r *Request) GetAll(value interface{}) (Response, error)
- func (r *Request) Page(page int) *Request
- func (r *Request) PageSize(size int) *Request
- func (r *Request) Range(field string, lowerBound string, upperBound string) *Request
- func (r *Request) Search(field string, value string) *Request
- func (r *Request) Sort(field string, order Sorting) *Request
- type Response
- type Series
- type Sorting
- type Videogame
Constants ¶
const ( // PandaScore API base URL BaseURL string = "api.pandascore.co" // Name of the environment variable that contains the PandaScore access token AccessTokenEnvironmentVariable string = "PANDASCORE_ACCESS_TOKEN" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
PandaScore client which is the primary entity.
func New ¶
func New() *Client
Construct a new PandaScore client with the default URL.
By default, the PandaScore access token will be read from the environment variable defined in the AccessTokenEnvironmentVariable constant. You can set it afterwards, for example if there is not environment variable.
func (*Client) AccessToken ¶
Sets this client's PandaScore access token to the given value.
func (*Client) GetAllLeagues ¶ added in v0.3.0
Returns all known leagues for the given game.
func (*Client) GetAllRunningMatches ¶ added in v0.6.0
Returns all running matches for the given game.
func (*Client) GetAllRunningSeries ¶ added in v0.3.0
Returns all currently ongoing series for the given game.
func (*Client) GetAllUpcomingMatches ¶ added in v0.3.0
Returns all upcoming matches for the given game.
func (*Client) GetAllUpcomingMatchesBetween ¶ added in v0.6.0
func (c *Client) GetAllUpcomingMatchesBetween(game Game, beginning time.Time, until time.Time) ([]Match, error)
Returns all upcoming matches for the given game starting from the given time up until the given time.
Careful: the given times are always set to UTC (Zulu) so timezones are not take into account.
func (*Client) GetAllUpcomingMatchesForSeries ¶ added in v0.4.0
Returns all upcoming matches for the given game & series ID.
type Game ¶
type Game string
Game represents a single game in the PandaScore API (eg. csgo, dota2, ...)
type League ¶
type League struct {
ID int `json:"id"`
Name string `json:"name"`
Modified time.Time `json:"modified_at"`
URL string `json:"url"`
}
League represents a logical group of series, which are events that belong to a league.
More information: https://developers.pandascore.co/doc/#section/Introduction/Events-hierarchy
type Match ¶ added in v0.3.0
type Match struct {
ID int `json:"id"`
Name string `json:"name"`
BeginsAt time.Time `json:"begin_at"`
Modified time.Time `json:"modified_at"`
LiveURL string `json:"live_url"`
Videogame Videogame `json:"videogame"`
Opponents []MatchOpponent `json:"opponents"`
Series Series `json:"serie"`
League League `json:"league"`
}
Match represents an instance of a single match between 2 opponents (teams or players).
More information: https://developers.pandascore.co/doc/#section/Introduction/Events-hierarchy
type MatchOpponent ¶ added in v0.3.0
MatchOpponent represents an opponent as defined for a specific match. Whether the opponent is a team is defined on this level, which I find really weird.
type Opponent ¶ added in v0.3.0
type Opponent struct {
Name string `json:"name"`
Location string `json:"location"`
LogoURL string `json:"image_url"`
}
Opponent represents a single opponent that partakes in a match.
type PandaScoreError ¶
type PandaScoreError struct {
Message string `json:"error"`
}
Represents an error coming directly from the PandaScore API (eg. no or invalid access token).
func (*PandaScoreError) Error ¶
func (pse *PandaScoreError) Error() string
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
PandaScore API request with it's attributes
func (*Request) Filter ¶
Adds a filter parameter to the request, where the given field must match the given value.
More information: https://developers.pandascore.co/doc/index.htm#section/Introduction/Filtering
func (*Request) Get ¶ added in v0.3.0
Execute a single request against the PandaScore API to fetch the first page of results and marshal the response body in the struct pointed to by value. Typically value will be an array of some struct, eg. []Series
In case there was an error executing the request, an empty response struct is returned.
func (*Request) GetAll ¶ added in v0.3.0
Execute multiple requests against the PandaScore API to fetch all results from all pages and marshal the response body in the struct pointed to by value. Typically value will be an array of some struct, eg. []League
In case there was an error executing the request, an empty response struct is returned.
func (*Request) Page ¶ added in v0.3.0
Adds the given page number to the request. Input cannot be <= 0, if it is then the page is set to 1.
More information: https://developers.pandascore.co/doc/index_dota2.htm#section/Introduction/Pagination
func (*Request) PageSize ¶ added in v0.4.0
Set the given page size for the request. Page size must be larger than 0 and less than, or equal to, 100. The default page size is 50 if the given size is invalid.
func (*Request) Range ¶ added in v0.6.0
Adds a range parameter to the request, typically dates, where the given field must have a value between the given bounds.
More information: https://developers.pandascore.co/doc/#section/Introduction/Range
func (*Request) Search ¶
Adds a search parameter to the request, where the given field must contain the given value.
More information: https://developers.pandascore.co/doc/index.htm#section/Introduction/Search
type Response ¶ added in v0.3.0
Response as parsed from a PandaScore API. Important: this is not the actual response body but rather any other information (headers, etc.) that might be useful for a caller to get.
type Series ¶
type Series struct {
ID int `json:"id"`
FullName string `json:"full_name"`
Modified time.Time `json:"modified_at"`
}
Series represents an instance of a league event.
More information: https://developers.pandascore.co/doc/#section/Introduction/Events-hierarchy