twitch

package
v0.0.0-...-c62bbba Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthResponse

type AuthResponse struct {
	AccessToken string `json:"access_token"`
	ExpiresIn   int    `json:"expires_in"`
	TokenType   string `json:"token_type"`
}

AuthResponse contains the response for the authentication endpoint.

func ParseAuthenticateResponse

func ParseAuthenticateResponse(data []byte) (*AuthResponse, error)

ParseAuthenticateResponse parses the Authenticate response into AuthResponse.

type Cache

type Cache interface {
	Get(ctx context.Context, key string) (string, error)
	Set(ctx context.Context, key string, value any, expiration time.Duration) error
}

Cache interface for caching.

type Client

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

Client communicates with the Twitch api.

func NewClient

func NewClient(config Config) *Client

NewClient creates a new Client. Any number of Options can be provided.

func (*Client) Authenticate

func (c *Client) Authenticate(ctx context.Context) (string, error)

Authenticate returns an access token for the Twitch API.

func (*Client) ClientID

func (c *Client) ClientID() string

ClientID returns the client id.

func (*Client) Do

func (c *Client) Do(req *http.Request) (*http.Response, error)

Do executes c.doFunc(), which in turn allows wrapping c.client.Do() and manipulating the request behavior of the api client.

type Config

type Config struct {
	BaseURL      string
	Cache        Cache
	CacheKey     string
	ClientID     string
	ClientSecret string
	Logger       *slog.Logger
}

Config contains celcoin client configurations.

type Twitch

type Twitch interface {
	Authenticate(context.Context) (string, error)
}

Twitch is the interface for the Twitch client.

Jump to

Keyboard shortcuts

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