pandascore

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2020 License: MIT Imports: 8 Imported by: 0

README

pandascore-go master Coverage Status GoDoc

PandaScore client for Go.

Getting started

Installation

TODO

Basic usage

TODO

Basic examples

TODO

Usage

TODO

Contributing

TODO

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

View Source
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

func (c *Client) AccessToken(accessToken string) *Client

Sets this client's PandaScore access token to the given value.

func (*Client) GetLeagues

func (c *Client) GetLeagues(game Game) ([]League, error)

Returns all known leagues for the given game.

func (*Client) GetRunningSeries

func (c *Client) GetRunningSeries(game Game) ([]Series, error)

Returns the currently ongoing series for the given game.

func (*Client) Request

func (c *Client) Request(game Game, path string, value interface{}) *Request

Construct a new request for the given game with the given path and with a pointer to the value for the result.

type Game

type Game string

Game represents a single game in the PandaScore API (eg. csgo, dota2, ...)

const (
	CSGO  Game = "csgo"
	Dota2 Game = "dota2"
)

func (Game) IsValid

func (g Game) IsValid() bool

Validates that the access token is valid.

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 Order

type Order byte

Order used for specifying sorting parameters.

const (
	// Sort in ascending order
	Ascending Order = 0
	// Sort in descending order
	Descending Order = 1
)

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

TODO add support for range

func (*Request) Execute

func (r *Request) Execute() error

Execute the request against the PandaScore API and marshal the response body in the value pointed to by value.

func (*Request) Filter

func (r *Request) Filter(field string, value ...string) *Request

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) Search

func (r *Request) Search(field string, value string) *Request

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

func (*Request) Sort

func (r *Request) Sort(field string, order Order) *Request

Adds a sort parameter to the request.

More information: https://developers.pandascore.co/doc/index.htm#section/Introduction/Sorting

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

Jump to

Keyboard shortcuts

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