igdb

package
v0.0.0-...-61270f2 Latest Latest
Warning

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

Go to latest
Published: May 14, 2025 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client communicates with the igdb api.

func NewClient

func NewClient(config Config) *Client

NewClient creates a new igdb Client.

func (*Client) Do

func (c *Client) Do(ctx context.Context, 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.

func (*Client) Games

func (c *Client) Games(ctx context.Context, criteria string) ([]Game, error)

Games returns a list of games that match the given criteria.

func (*Client) Genres

func (c *Client) Genres(ctx context.Context, ids []int) ([]Genre, error)

Genres returns a list of genres that match the given criteria.

func (*Client) Platforms

func (c *Client) Platforms(ctx context.Context, ids []int) ([]Platform, error)

Platforms returns a list of platforms that match the given criteria.

type Config

type Config struct {
	BaseURL      string
	Logger       *slog.Logger
	TwitchClient TwitchClient
}

Config contains igdb client configurations.

type Game

type Game struct {
	ID               int    `json:"id"`
	FirstReleaseDate int64  `json:"first_release_date"`
	Genres           []int  `json:"genres"`
	Name             string `json:"name"`
	Platforms        []int  `json:"platforms"`
	Slug             string `json:"slug"`
	Summary          string `json:"summary"`
}

Game represents a IGDB game.

func ParseGamesResponse

func ParseGamesResponse(data []byte) ([]Game, error)

ParseGamesResponse parses the given data and returns a list of games.

type Genre

type Genre struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
}

Genre represents a IGDB game genre.

func ParseGenresResponse

func ParseGenresResponse(data []byte) ([]Genre, error)

ParseGenresResponse parses the given data and returns a list of genres.

type Platform

type Platform struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
}

Platform represents a IGDB game platform.

func ParsePlatformsResponse

func ParsePlatformsResponse(data []byte) ([]Platform, error)

ParsePlatformsResponse parses the given data and returns a list of platforms.

type TwitchClient

type TwitchClient interface {
	Authenticate(ctx context.Context) (string, error)
	ClientID() string
}

TwitchClient 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