client

package
v0.0.0-...-d7d6a54 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package client implements a REST API client for retrieving information on shows.

Index

Constants

View Source
const (
	BaseURL    = "https://api.themoviedb.org/3"
	DateFormat = "2006-01-02"
)

TMDb api constants.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	SearchMovie(name string) ([]*Movie, error)
	SearchTvShow(name string) ([]*TvShow, error)
	GetMovie(id int) (*Movie, error)
	GetTvShow(id int) (*TvShow, error)
}

Client allows to retrieve info about shows.

type Movie

type Movie struct {
	ID          int     `json:"id"`
	Title       string  `json:"title"`
	ReleaseDate string  `json:"release_date"`
	Popularity  float32 `json:"popularity"`
	VoteAverage float32 `json:"vote_average"`
}

Movie represents a movie as returned by the TMDb API.

type TMDbClient

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

TMDbClient allows to communicate with the TMDb API.

func Custom

func Custom(k string, baseURL string, c *http.Client) *TMDbClient

Custom creates a new custom TMDb API client.

func New

func New(k string) *TMDbClient

New creates a new TMDb API client with the default base URL and http client. This is the recommended way to create a TMDb client.

func (*TMDbClient) GetMovie

func (c *TMDbClient) GetMovie(id int) (*Movie, error)

GetMovie gets info about a movie with the given id.

func (*TMDbClient) GetTvShow

func (c *TMDbClient) GetTvShow(id int) (*TvShow, error)

GetTvShow gets info about a tv show with the given id.

func (*TMDbClient) SearchMovie

func (c *TMDbClient) SearchMovie(name string) ([]*Movie, error)

SearchMovie searches for the given movie name in the API and returns a list of matching movies.

func (*TMDbClient) SearchTvShow

func (c *TMDbClient) SearchTvShow(name string) ([]*TvShow, error)

SearchTvShow searches for the given tv show name in the API and returns a list of matching tv shows.

type TvShow

type TvShow struct {
	ID           int     `json:"id"`
	Name         string  `json:"name"`
	FirstAirDate string  `json:"first_air_date"`
	Popularity   float32 `json:"popularity"`
	VoteAverage  float32 `json:"vote_average"`
}

TvShow represents a tv show as returned by the TMDb API.

Jump to

Keyboard shortcuts

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