jerkcity

package
v0.0.0-...-3f13264 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEmptyQuery is returned when a search query is empty.
	ErrEmptyQuery = errors.New("jerkcity: empty search query")
)

Functions

This section is empty.

Types

type Client

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

Client is an HTTP Client responsible for pulling data from Jerkcity's API.

func New

func New(opts ...Option) *Client

New creates a new Client.

func (*Client) FetchEpisode

func (c *Client) FetchEpisode(ctx context.Context, number int) (*Episode, error)

FetchEpisode fetches an episode from Jerkcity's API.

func (*Client) FetchMeta

func (c *Client) FetchMeta(ctx context.Context) (int, error)

func (*Client) FetchQuote

func (c *Client) FetchQuote(ctx context.Context) (*Episode, error)

func (*Client) FetchSearch

func (c *Client) FetchSearch(ctx context.Context, query string) (*Search, error)

type Episode

type Episode struct {
	Day     int      `json:"day"`
	Month   int      `json:"month"`
	Year    int      `json:"year"`
	Title   string   `json:"title"`
	Episode int      `json:"episode"`
	Image   string   `json:"image"`
	Players []string `json:"players"`

	// Only present when calling /quote/random
	Quote string `json:"quote,omitempty"`

	// Only present when calling /search
	Search *EpisodeSearch `json:"search"`
}

Episode is an episode of Jerkcity.

func (*Episode) Time

func (e *Episode) Time() time.Time

Time returns an Episode's release, localized in Pacific Time.

type EpisodeSearch

type EpisodeSearch struct {
	Query   string             `json:"query"`
	Runtime float64            `json:"runtime"`
	Sums    *EpisodeSearchSums `json:"sums"`
	Version int                `json:"version"`
}

type EpisodeSearchSums

type EpisodeSearchSums struct {
	Dates    int `json:"dates"`
	Episodes int `json:"episodes"`
	Tags     int `json:"tags"`
	Titles   int `json:"titles"`
	Words    int `json:"words"`
}

type Meta

type Meta struct {
	High int `json:"high"`
}

type Option

type Option func(*Client)

Option configures a Client.

func WithHTTPClient

func WithHTTPClient(cli *http.Client) Option

WithHTTPClient sets a Client's underlying HTTP client.

type Search struct {
	Episodes []*Episode     `json:"episodes"`
	Search   *EpisodeSearch `json:"search"`
}

Search represents a request to the /search endpoint.

Jump to

Keyboard shortcuts

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