internal

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package internal used for client and services

Package internal used for client and services

Package internal used for client and services

Package internal used for client and services

Package internal used for client and services

Package internal used for client and services

Package internal used for client and services

Package internal used for client and services

Index

Constants

View Source
const (
	Version = "2"

	HeaderRateLimit           = "X-RateLimit"
	HeaderRetryAfter          = "Retry-After"
	HeaderPaginationPageCount = "X-Pagination-Page-Count"
)

basic consts for client

Variables

This section is empty.

Functions

This section is empty.

Types

type AbuseRateLimitError

type AbuseRateLimitError struct {
	Response   *http.Response
	RetryAfter *time.Duration
	Message    string `json:"message"`
}

AbuseRateLimitError occurs when trakt.tv returns 429 too many requests header

func (*AbuseRateLimitError) Error

func (r *AbuseRateLimitError) Error() string

type CalendarsService

type CalendarsService Service

CalendarsService handles communication with the calendars related methods of the Trakt API.

func (*CalendarsService) GetDVDReleases

func (c *CalendarsService) GetDVDReleases(ctx context.Context, actionType *string, startDate *string, days *int, opts *uri.ListOptions) ([]*str.CalendarList, *str.Response, error)

GetDVDReleases Returns all movies with a DVD release date during the time period specified.

API docs: https://trakt.docs.apiary.io/#reference/calendars/my-dvd/get-dvd-releases API docs: https://trakt.docs.apiary.io/#reference/calendars/all-dvd/get-dvd-releases

func (*CalendarsService) GetFinales

func (c *CalendarsService) GetFinales(ctx context.Context, actionType *string, startDate *string, days *int, opts *uri.ListOptions) ([]*str.CalendarList, *str.Response, error)

GetFinales Returns all show finales (mid_season_finale, season_finale, series_finale) airing during the time period specified.

API docs: https://trakt.docs.apiary.io/#reference/calendars/my-finales/get-finales API docs: https://trakt.docs.apiary.io/#reference/calendars/all-finales/get-finales

func (*CalendarsService) GetMovies

func (c *CalendarsService) GetMovies(ctx context.Context, actionType *string, startDate *string, days *int, opts *uri.ListOptions) ([]*str.CalendarList, *str.Response, error)

GetMovies Returns all movies with a release date during the time period specified.

API docs: https://trakt.docs.apiary.io/#reference/calendars/my-movies/get-movies API docs: https://trakt.docs.apiary.io/#reference/calendars/all-movies/get-movies

func (*CalendarsService) GetNewShows

func (c *CalendarsService) GetNewShows(ctx context.Context, actionType *string, startDate *string, days *int, opts *uri.ListOptions) ([]*str.CalendarList, *str.Response, error)

GetNewShows Returns all new show premieres airing during the time period specified.

API docs: https://trakt.docs.apiary.io/#reference/calendars/my-new-shows/get-new-shows API docs: https://trakt.docs.apiary.io/#reference/calendars/all-new-shows/get-new-shows

func (*CalendarsService) GetSeasonPremieres

func (c *CalendarsService) GetSeasonPremieres(ctx context.Context, actionType *string, startDate *string, days *int, opts *uri.ListOptions) ([]*str.CalendarList, *str.Response, error)

GetSeasonPremieres Returns all show premieres (mid_season_premiere, season_premiere, series_premiere) airing during the time period specified.

API docs: https://trakt.docs.apiary.io/#reference/calendars/my-season-premieres/get-season-premieres API docs: https://trakt.docs.apiary.io/#reference/calendars/all-season-premieres/get-season-premieres

func (*CalendarsService) GetShows

func (c *CalendarsService) GetShows(ctx context.Context, actionType *string, startDate *string, days *int, opts *uri.ListOptions) ([]*str.CalendarList, *str.Response, error)

GetShows Returns all shows airing during the time period specified.

API docs: https://trakt.docs.apiary.io/#reference/calendars/my-shows/get-shows API docs: https://trakt.docs.apiary.io/#reference/calendars/all-shows/get-shows

type Client

type Client struct {
	RateLimitReset time.Time

	BaseURL *url.URL

	Oauth     *OauthService
	Users     *UsersService
	Sync      *SyncService
	People    *PeopleService
	Calendars *CalendarsService
	Search    *SearchService
	// contains filtered or unexported fields
}

A Client manages communication with the trakt.tv API.

func NewClient

func NewClient(httpClient *http.Client) *Client

NewClient returns a new API client. If a nil httpClient is provided, a new http.Client will be used.

func (*Client) BareDo

func (c *Client) BareDo(ctx context.Context, req *http.Request) (*str.Response, error)

BareDo sends an API request and lets you handle the api response.

func (*Client) CheckResponse

func (c *Client) CheckResponse(r *http.Response) error

CheckResponse checks if api response have errors.

func (*Client) CheckRetryAfter

func (c *Client) CheckRetryAfter(req *http.Request) *AbuseRateLimitError

CheckRetryAfter check Retry After header.

func (*Client) Do

func (c *Client) Do(ctx context.Context, req *http.Request, v any) (*str.Response, error)

Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred

func (*Client) HavePages added in v1.0.3

func (*Client) HavePages(page int, pages int) bool

HavePages checks if we have available pages to fetch

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlStr string, body any, opts ...RequestOption) (*http.Request, error)

NewRequest creates an API request.

func (*Client) NewResponse

func (c *Client) NewResponse(r *http.Response) *str.Response

NewResponse creates a new Response for the provided http.Response. r must not be nil.

func (*Client) ParseRate

func (*Client) ParseRate(r *http.Response) str.Rate

ParseRate parses the rate related headers.

func (*Client) ParseRateLimit

func (*Client) ParseRateLimit(r *http.Response) *time.Duration

ParseRateLimit parses related headers, and returns the time to retry after.

func (*Client) UpdateHeaders

func (c *Client) UpdateHeaders(headers map[string]any)

UpdateHeaders is for update client headers map

func (*Client) WithContext

func (*Client) WithContext(ctx context.Context, req *http.Request) *http.Request

WithContext pass context to request

type OauthService

type OauthService Service

OauthService handles communication with the oauth related methods of the Trakt API.

API docs: https://trakt.docs.apiary.io/#reference/authentication-oauth

func (*OauthService) ExchangeRefreshTokenForAccessToken

func (o *OauthService) ExchangeRefreshTokenForAccessToken(ctx context.Context, deviceToken *str.CurrentDeviceToken) (*str.DeviceToken, *str.Response, error)

ExchangeRefreshTokenForAccessToken Use the refresh_token to get a new access_token without asking the user to re-authenticate. The access_token is valid for 3 months before it needs to be refreshed again.

API docs: https://trakt.docs.apiary.io/#reference/authentication-oauth/get-token/exchange-refresh_token-for-access_token

func (*OauthService) GenerateNewDeviceCodes

func (o *OauthService) GenerateNewDeviceCodes(ctx context.Context, code *str.NewDeviceCode) (*str.DeviceCode, *str.Response, error)

GenerateNewDeviceCodes Generate new codes to start the device authentication process.

API docs: https://trakt.docs.apiary.io/#reference/authentication-devices/device-code/generate-new-device-codes

func (*OauthService) PoolForTheAccessToken

func (o *OauthService) PoolForTheAccessToken(ctx context.Context, deviceToken *str.NewDeviceToken) (*str.DeviceToken, *str.Response, error)

PoolForTheAccessToken Use the device_code and poll at the interval (in seconds) to check if the user has authorized you app.

API docs: https://trakt.docs.apiary.io/#reference/authentication-devices/get-token/poll-for-the-access_token

type PeopleService

type PeopleService Service

PeopleService handles communication with the people related methods of the Trakt API.

func (*PeopleService) GetListsContainingThisPerson

func (p *PeopleService) GetListsContainingThisPerson(ctx context.Context, id *string, typeString *string, sort *string, opts *uri.ListOptions) ([]*str.PersonalList, *str.Response, error)

GetListsContainingThisPerson Returns all lists that contain this person.

API docs: https://trakt.docs.apiary.io/#reference/people/lists/get-lists-containing-this-person

func (*PeopleService) GetMovieCredits

func (p *PeopleService) GetMovieCredits(ctx context.Context, id *string, opts *uri.ListOptions) (*str.PersonMovies, *str.Response, error)

GetMovieCredits Returns all movies where this person is in the cast or crew.

API docs: https://trakt.docs.apiary.io/#reference/people/movies/get-movie-credits

func (*PeopleService) GetRecentlyUpdatedPeople

func (p *PeopleService) GetRecentlyUpdatedPeople(ctx context.Context, startDate *string, opts *uri.ListOptions) ([]*str.PersonItem, *str.Response, error)

GetRecentlyUpdatedPeople Returns all people updated since the specified UTC date and time.

API docs: https://trakt.docs.apiary.io/#reference/people/updates/get-recently-updated-people

func (*PeopleService) GetRecentlyUpdatedPeopleTraktIDs

func (p *PeopleService) GetRecentlyUpdatedPeopleTraktIDs(ctx context.Context, startDate *string, opts *uri.ListOptions) ([]*int, *str.Response, error)

GetRecentlyUpdatedPeopleTraktIDs Returns all people Trakt IDs updated since the specified UTC date and time.

API docs: https://trakt.docs.apiary.io/#reference/people/updated-ids

func (*PeopleService) GetShowCredits

func (p *PeopleService) GetShowCredits(ctx context.Context, id *string, opts *uri.ListOptions) (*str.PersonShows, *str.Response, error)

GetShowCredits Returns all shows where this person is in the cast or crew, including the episode_count for which they appear.

API docs: https://trakt.docs.apiary.io/#reference/people/shows/get-show-credits

func (*PeopleService) GetSinglePerson

func (p *PeopleService) GetSinglePerson(ctx context.Context, id *string, opts *uri.ListOptions) (*str.Person, *str.Response, error)

GetSinglePerson Returns a single person's details.

API docs: https://trakt.docs.apiary.io/#reference/people/summary/get-a-single-person

type RequestOption

type RequestOption func(req *http.Request)

RequestOption represents an option that can modify an http.Request.

type SearchService

type SearchService Service

SearchService handles communication with the search related methods of the Trakt API.

func (*SearchService) GetIDLookupResults

func (s *SearchService) GetIDLookupResults(ctx context.Context, formatType *string, id *string, opts *uri.ListOptions) ([]*str.SearchListItem, *str.Response, error)

GetIDLookupResults Lookup items by their Trakt, IMDB, TMDB, or TVDB ID. If you use the search url without a type it might return multiple items if the id_type is not globally unique. Specify the type of results by sending a single value or a comma delimited string for multiple types.

API docs: https://trakt.docs.apiary.io/#reference/search/id-lookup/get-id-lookup-results

func (*SearchService) GetTextQueryResults

func (s *SearchService) GetTextQueryResults(ctx context.Context, searchType *string, opts *uri.ListOptions) ([]*str.SearchListItem, *str.Response, error)

GetTextQueryResults Search all text fields that a media object contains (i.e. title, overview, etc). Results are ordered by the most relevant score. Specify the type of results by sending a single value or a comma delimited string for multiple types.

API docs: https://trakt.docs.apiary.io/#reference/search/text-query/get-text-query-results

type Service

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

Service structure for other services

type SyncService

type SyncService Service

SyncService handles communication with the sync related methods of the Trakt API.

func (*SyncService) GetCollection

func (s *SyncService) GetCollection(ctx context.Context, types *string, opts *uri.ListOptions) ([]*str.ExportlistItem, *str.Response, error)

GetCollection Get all collected items in a user's collection.

API docs: https://trakt.docs.apiary.io/#reference/sync/get-collection/get-collection

func (*SyncService) GetWatchedHistory

func (s *SyncService) GetWatchedHistory(ctx context.Context, types *string, opts *uri.ListOptions) ([]*str.ExportlistItem, *str.Response, error)

GetWatchedHistory Returns movies and episodes that a user has watched, sorted by most recent.

API docs: https://trakt.docs.apiary.io/#reference/sync/get-watched/get-watched-history

func (*SyncService) GetWatchlist

func (s *SyncService) GetWatchlist(ctx context.Context, types *string, sort *string, opts *uri.ListOptions) ([]*str.ExportlistItem, *str.Response, error)

GetWatchlist Returns all items in a user's watchlist filtered by type.

API docs: https://trakt.docs.apiary.io/#reference/sync/get-watchlist/get-watchlist

type UsersService

type UsersService Service

UsersService handles communication with the users related methods of the Trakt API.

func (*UsersService) GetItemstOnAPersonalList

func (u *UsersService) GetItemstOnAPersonalList(ctx context.Context, id *string, listID *string, t *string) ([]*str.UserListItem, *str.Response, error)

GetItemstOnAPersonalList Get all items on a personal list.

API docs: https://trakt.docs.apiary.io/#reference/users/list-items/get-items-on-a-personal-list

func (*UsersService) GetUserProfile

func (u *UsersService) GetUserProfile(ctx context.Context, id *string) (*str.UserProfile, *str.Response, error)

GetUserProfile Get a user's profile information.

API docs:https://trakt.docs.apiary.io/#reference/users/profile/get-user-profile

func (*UsersService) GetUsersPersonalLists

func (u *UsersService) GetUsersPersonalLists(ctx context.Context, id *string) ([]*str.PersonalList, *str.Response, error)

GetUsersPersonalLists Returns all personal lists for a user.

API docs: https://trakt.docs.apiary.io/#reference/users/lists/get-a-user's-personal-lists

Jump to

Keyboard shortcuts

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