helix

package
v0.0.0-...-1cc4fbe Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2017 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package helix exposes a client for interacting with the upcomming version of the Twitch.tv API. Helix is considered the "new" and "current" API, though at this time it is incomlete. Kraken is v5 and complete, but considered deprecated and will be turned of ~Dec. 2018. When possible, you should use helix.

Index

Constants

View Source
const AccessTokenEnvVar = "TWITCH_ACCESS_TOKEN"

AccessTokenEnvVar is the name of the environment variable where the Twitch API key should be read from. ClientIdEnvVar is the name of the environment variable the client id should be read from.

View Source
const AccessTokenHeader = "Authorization"

AccessTokenHeader is the name of the header that contains the Twitch API key.

View Source
const ClientIdEnvVar = "TWITCH_CLIENT_ID"

Probably not needed, but offered

View Source
const ClientIdHeader = "Client-ID"
View Source
const ClientSecretEnvVar = "TWITCH_CLIENT_SECRET"

Not used yet

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Config *twitch.Config
	// contains filtered or unexported fields
}

func DefaultClient

func DefaultClient(config *twitch.Config) (*Client, error)

DefaultClient instantiates a new Twitch API client. This function requires the environment variables `TWITCH_ACCESS_TOKEN` and `TWITCH_CLIENT_ID` to be set and contain valid access token and client id, respectively, to authenticate with Twitch.

func NewClient

func NewClient(config *twitch.Config) (*Client, error)

NewClient creates a new API client with the given key and the default API endpoint. Twitch requires both an access token and a client id for requests, so we error if either is empty.

Creating an access token is not yet supported by this libary TODO: Support creating an access token

func (*Client) Delete

func (c *Client) Delete(p string, ro *twitch.RequestOptions) (*http.Response, error)

Delete issues an HTTP DELETE request.

func (*Client) Get

func (c *Client) Get(p string, ro *twitch.RequestOptions) (*http.Response, error)

func (*Client) GetGames

func (k *Client) GetGames(i *GetGamesInput) (*GetGamesOutput, error)

Gets details specific games. Can be list of games, ids See:

func (*Client) Head

func (c *Client) Head(p string, ro *twitch.RequestOptions) (*http.Response, error)

Head issues an HTTP HEAD request.

func (*Client) Post

func (c *Client) Post(p string, ro *twitch.RequestOptions) (*http.Response, error)

Post issues an HTTP POST request.

func (*Client) PostForm

func (c *Client) PostForm(p string, i interface{}, ro *twitch.RequestOptions) (*http.Response, error)

PostForm issues an HTTP POST request with the given interface form-encoded.

func (*Client) Put

func (c *Client) Put(p string, ro *twitch.RequestOptions) (*http.Response, error)

Put issues an HTTP PUT request.

func (*Client) PutForm

func (c *Client) PutForm(p string, i interface{}, ro *twitch.RequestOptions) (*http.Response, error)

PutForm issues an HTTP PUT request with the given interface form-encoded.

func (*Client) RawRequest

func (c *Client) RawRequest(verb, p string, ro *twitch.RequestOptions) (*http.Request, error)

RawRequest accepts a verb, URL, and twitch.RequestOptions struct and returns the constructed http.Request and any errors that occurred

func (*Client) Request

func (c *Client) Request(verb, p string, ro *twitch.RequestOptions) (*http.Response, error)

Request makes an HTTP request against the HTTPClient using the given verb, Path, and request options.

func (*Client) RequestForm

func (c *Client) RequestForm(verb, p string, i interface{}, ro *twitch.RequestOptions) (*http.Response, error)

RequestForm makes an HTTP request with the given interface being encoded as form data.

type Game

type Game struct {
	Id   string `mapstructure:"id"`
	Name string `mapstructure:"name"`
}

Version represents a distinct configuration version.

type GetGamesInput

type GetGamesInput struct {
	// Games are referenced by a globally unique string called a slug
	Names []string `mapstructure:"name"`
	Ids   []int    `mapstructure:"id"`
}

GetGamesInput is the input to the GetGames function.

type GetGamesOutput

type GetGamesOutput struct {
	Games []*Game `mapstructure:"data"`
}

GetGamesOutput is the output of the GetGames function.

Jump to

Keyboard shortcuts

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