Documentation
¶
Index ¶
- Constants
- Variables
- type Actor
- type ActorListResponse
- type ActorResponse
- type BaseResponse
- type Character
- type CharacterListResponse
- type CharacterResponse
- type Client
- func (c *Client) CacheSize() int
- func (c *Client) ClearCache() int
- func (c *Client) CreateActor(s CreateActor) (Actor, error)
- func (c *Client) CreateCharacter(s CreateCharacter) (Character, error)
- func (c *Client) CreateEpisode(s CreateEpisode) (Episode, error)
- func (c *Client) CreateGame(s CreateGame) (Game, error)
- func (c *Client) CreateLocation(s CreateLocation) (Location, error)
- func (c *Client) CreateSeason(s CreateSeason) (Season, error)
- func (c *Client) CreateSoundtrack(s CreateSoundtrack) (Soundtrack, error)
- func (c *Client) DeleteActor(id uuid.UUID) error
- func (c *Client) DeleteCharacter(id uuid.UUID) error
- func (c *Client) DeleteEpisode(id uuid.UUID) error
- func (c *Client) DeleteGame(id uuid.UUID) error
- func (c *Client) DeleteLocation(id uuid.UUID) error
- func (c *Client) DeleteSeason(id uuid.UUID) error
- func (c *Client) DeleteSoundtrack(id uuid.UUID) error
- func (c *Client) FindActor(id uuid.UUID) (ActorResponse, error)
- func (c *Client) FindCharacter(id uuid.UUID) (CharacterResponse, error)
- func (c *Client) FindEpisode(id uuid.UUID) (EpisodeResponse, error)
- func (c *Client) FindGame(id uuid.UUID) (GameResponse, error)
- func (c *Client) FindLocation(id uuid.UUID) (LocationResponse, error)
- func (c *Client) FindSeason(id uuid.UUID) (SeasonResponse, error)
- func (c *Client) FindSoundtrack(id uuid.UUID) (SoundtrackResponse, error)
- func (c *Client) Info() (Info, error)
- func (c *Client) ListActors(options ...QueryOptions) (ActorListResponse, error)
- func (c *Client) ListCharacters(options ...QueryOptions) (CharacterListResponse, error)
- func (c *Client) ListEpisodes(options ...QueryOptions) (EpisodeListResponse, error)
- func (c *Client) ListGames(options ...QueryOptions) (GameListResponse, error)
- func (c *Client) ListLocations(options ...QueryOptions) (LocationListResponse, error)
- func (c *Client) ListSeasons(options ...QueryOptions) (SeasonListResponse, error)
- func (c *Client) ListSoundtracks(options ...QueryOptions) (SoundtrackListResponse, error)
- func (c *Client) Overview(options ...QueryOptions) (Overview, error)
- func (c *Client) PatchActor(id uuid.UUID, p PatchActor) (Actor, error)
- func (c *Client) PatchCharacter(id uuid.UUID, p PatchCharacter) (Character, error)
- func (c *Client) PatchEpisode(id uuid.UUID, p PatchEpisode) (Episode, error)
- func (c *Client) PatchGame(id uuid.UUID, p PatchGame) (Game, error)
- func (c *Client) PatchLocation(id uuid.UUID, p PatchLocation) (Location, error)
- func (c *Client) PatchSeason(id uuid.UUID, p PatchSeason) (Season, error)
- func (c *Client) PatchSoundtrack(id uuid.UUID, p PatchSoundtrack) (Soundtrack, error)
- func (c *Client) RandomActor() (ActorResponse, error)
- func (c *Client) RandomCharacter() (CharacterResponse, error)
- func (c *Client) RandomEpisode() (EpisodeResponse, error)
- func (c *Client) RandomGame() (GameResponse, error)
- func (c *Client) RandomLocation() (LocationResponse, error)
- func (c *Client) RandomSeason() (SeasonResponse, error)
- func (c *Client) RandomSoundtrack() (SoundtrackResponse, error)
- func (c *Client) WithOpts(options Options)
- type CreateActor
- type CreateCharacter
- type CreateEpisode
- type CreateGame
- type CreateLocation
- type CreateSeason
- type CreateSoundtrack
- type DataCount
- type Episode
- type EpisodeListResponse
- type EpisodeResponse
- type ErrorResponse
- type Filters
- type FormatterHandler
- type Game
- type GameListResponse
- type GameResponse
- type HeaderResponse
- type Info
- type Location
- type LocationListResponse
- type LocationResponse
- type Options
- type Overview
- type Pageable
- type PatchActor
- type PatchCharacter
- type PatchEpisode
- type PatchGame
- type PatchLocation
- type PatchSeason
- type PatchSoundtrack
- type QueryOptions
- func NewQueryOptions(pageable Pageable, filters Filters) QueryOptions
- func WithFilter(key string, value string) QueryOptions
- func WithFilters(filters Filters) QueryOptions
- func WithLanguage(language string) QueryOptions
- func WithOrder(order string) QueryOptions
- func WithPage(page int) QueryOptions
- func WithPageable(pageable Pageable) QueryOptions
- func WithSize(size int) QueryOptions
- func WithSort(sort string) QueryOptions
- type Quota
- type Season
- type SeasonListResponse
- type SeasonResponse
- type Social
- type Soundtrack
- type SoundtrackListResponse
- type SoundtrackResponse
Constants ¶
const ( DefaultLogLevel = slog.LevelInfo DefaultEndpoint = "https://hawapi.theproject.id/api" DefaultVersion = "v1" DefaultLanguage = "en-US" DefaultSize = 10 DefaultTimeout = 10 DefaultUseInMemoryCache = true )
Variables ¶
var DefaultOptions = Options{ Endpoint: DefaultEndpoint, Version: DefaultVersion, Language: DefaultLanguage, Size: DefaultSize, Timeout: DefaultTimeout, UseInMemoryCache: DefaultUseInMemoryCache, LogLevel: DefaultLogLevel, LogHandler: nil, }
DefaultOptions for Go HawAPI SDK
var DefaultPageable = Pageable{ Page: 1, Size: DefaultSize, Sort: "", Order: "ASC", }
Functions ¶
This section is empty.
Types ¶
type Actor ¶
type Actor struct { UUID uuid.UUID `json:"uuid"` Href string `json:"href"` FirstName string `json:"first_name"` LastName string `json:"last_name"` Nicknames []string `json:"nicknames,omitempty"` Socials []Social `json:"socials,omitempty"` Nationality string `json:"nationality,omitempty"` BirthDate string `json:"birth_date,omitempty"` DeathDate string `json:"death_date,omitempty"` Gender int `json:"gender,omitempty"` Seasons []string `json:"seasons,omitempty"` Awards []string `json:"awards,omitempty"` Character string `json:"character"` Thumbnail string `json:"thumbnail,omitempty"` Images []string `json:"images,omitempty"` Sources []string `json:"sources,omitempty"` CreatedAt string `json:"created_at"` UpdatedAt string `json:"updated_at"` }
type ActorListResponse ¶
type ActorListResponse struct { BaseResponse Data []Actor `json:"data"` }
type ActorResponse ¶
type ActorResponse struct { BaseResponse Data Actor `json:"data"` }
type BaseResponse ¶
type BaseResponse struct { HeaderResponse Cached bool `json:"cached,omitempty"` Status int `json:"status"` }
BaseResponse represents all required response fields
type Character ¶
type Character struct { Uuid uuid.UUID `json:"uuid"` Href string `json:"href"` FirstName string `json:"first_name"` LastName string `json:"last_name"` Nicknames []string `json:"nicknames,omitempty"` Gender int `json:"gender"` Actor string `json:"actor"` BirthDate string `json:"birth_date,omitempty"` DeathDate string `json:"death_date,omitempty"` Thumbnail string `json:"thumbnail"` Images []string `json:"images,omitempty"` Sources []string `json:"sources,omitempty"` CreatedAt string `json:"created_at"` UpdatedAt string `json:"updated_at"` }
type CharacterListResponse ¶
type CharacterListResponse struct { BaseResponse Data []Character `json:"data"` }
type CharacterResponse ¶
type CharacterResponse struct { BaseResponse Data Character `json:"data"` }
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the HawAPI golang client.
func NewClient ¶
func NewClient() Client
NewClient creates a new HawAPI client using the default options.
func NewClientWithOpts ¶
NewClientWithOpts creates a new HawAPI client using custom options.
func (*Client) ClearCache ¶
ClearCache deletes all values from the cache and returns the count of deleted items
func (*Client) CreateActor ¶
func (c *Client) CreateActor(s CreateActor) (Actor, error)
func (*Client) CreateCharacter ¶
func (c *Client) CreateCharacter(s CreateCharacter) (Character, error)
func (*Client) CreateEpisode ¶
func (c *Client) CreateEpisode(s CreateEpisode) (Episode, error)
func (*Client) CreateGame ¶
func (c *Client) CreateGame(s CreateGame) (Game, error)
func (*Client) CreateLocation ¶
func (c *Client) CreateLocation(s CreateLocation) (Location, error)
func (*Client) CreateSeason ¶
func (c *Client) CreateSeason(s CreateSeason) (Season, error)
func (*Client) CreateSoundtrack ¶
func (c *Client) CreateSoundtrack(s CreateSoundtrack) (Soundtrack, error)
func (*Client) FindActor ¶
func (c *Client) FindActor(id uuid.UUID) (ActorResponse, error)
FindActor will get a single item by uuid
func (*Client) FindCharacter ¶
func (c *Client) FindCharacter(id uuid.UUID) (CharacterResponse, error)
FindCharacter will get a single item by uuid
func (*Client) FindEpisode ¶
func (c *Client) FindEpisode(id uuid.UUID) (EpisodeResponse, error)
FindEpisode will get a single item by uuid
func (*Client) FindGame ¶
func (c *Client) FindGame(id uuid.UUID) (GameResponse, error)
FindGame will get a single item by uuid
func (*Client) FindLocation ¶
func (c *Client) FindLocation(id uuid.UUID) (LocationResponse, error)
FindLocation will get a single item by uuid
func (*Client) FindSeason ¶
func (c *Client) FindSeason(id uuid.UUID) (SeasonResponse, error)
FindSeason will get a single item by uuid
func (*Client) FindSoundtrack ¶
func (c *Client) FindSoundtrack(id uuid.UUID) (SoundtrackResponse, error)
FindSoundtrack will get a single item by uuid
func (*Client) ListActors ¶
func (c *Client) ListActors(options ...QueryOptions) (ActorListResponse, error)
ListActors will get all actors
func (*Client) ListCharacters ¶
func (c *Client) ListCharacters(options ...QueryOptions) (CharacterListResponse, error)
ListCharacters will get all characters
func (*Client) ListEpisodes ¶
func (c *Client) ListEpisodes(options ...QueryOptions) (EpisodeListResponse, error)
ListEpisodes will get all episodes
func (*Client) ListGames ¶
func (c *Client) ListGames(options ...QueryOptions) (GameListResponse, error)
ListGames will get all games
func (*Client) ListLocations ¶
func (c *Client) ListLocations(options ...QueryOptions) (LocationListResponse, error)
ListLocations will get all locations
func (*Client) ListSeasons ¶
func (c *Client) ListSeasons(options ...QueryOptions) (SeasonListResponse, error)
ListSeasons will get all seasons
func (*Client) ListSoundtracks ¶
func (c *Client) ListSoundtracks(options ...QueryOptions) (SoundtrackListResponse, error)
ListSoundtracks will get all soundtracks
func (*Client) PatchActor ¶
func (*Client) PatchCharacter ¶
func (*Client) PatchEpisode ¶
func (*Client) PatchLocation ¶
func (*Client) PatchSeason ¶
func (*Client) PatchSoundtrack ¶
func (c *Client) PatchSoundtrack(id uuid.UUID, p PatchSoundtrack) (Soundtrack, error)
func (*Client) RandomActor ¶
func (c *Client) RandomActor() (ActorResponse, error)
func (*Client) RandomCharacter ¶
func (c *Client) RandomCharacter() (CharacterResponse, error)
func (*Client) RandomEpisode ¶
func (c *Client) RandomEpisode() (EpisodeResponse, error)
func (*Client) RandomGame ¶
func (c *Client) RandomGame() (GameResponse, error)
func (*Client) RandomLocation ¶
func (c *Client) RandomLocation() (LocationResponse, error)
func (*Client) RandomSeason ¶
func (c *Client) RandomSeason() (SeasonResponse, error)
func (*Client) RandomSoundtrack ¶
func (c *Client) RandomSoundtrack() (SoundtrackResponse, error)
type CreateActor ¶
type CreateActor struct { FirstName string `json:"first_name,omitempty"` LastName string `json:"last_name,omitempty"` Nicknames []string `json:"nicknames,omitempty"` Socials []Social `json:"socials,omitempty"` Nationality string `json:"nationality,omitempty"` BirthDate string `json:"birth_date,omitempty"` DeathDate string `json:"death_date,omitempty"` Gender int `json:"gender,omitempty"` Seasons []string `json:"seasons,omitempty"` Awards []string `json:"awards,omitempty"` Character string `json:"character,omitempty"` Thumbnail string `json:"thumbnail,omitempty"` Images []string `json:"images,omitempty"` Sources []string `json:"sources,omitempty"` }
type CreateCharacter ¶
type CreateCharacter struct { FirstName string `json:"first_name,omitempty"` LastName string `json:"last_name,omitempty"` Nicknames []string `json:"nicknames,omitempty"` Gender int `json:"gender,omitempty"` Actor string `json:"actor,omitempty"` BirthDate string `json:"birth_date,omitempty"` DeathDate string `json:"death_date,omitempty"` Thumbnail string `json:"thumbnail,omitempty"` Images []string `json:"images,omitempty"` Sources []string `json:"sources,omitempty"` }
type CreateEpisode ¶
type CreateEpisode struct { Title string `json:"title"` Description string `json:"description"` Language string `json:"language"` Duration int64 `json:"duration"` Season string `json:"season"` EpisodeNum byte `json:"episode_num"` NextEpisode string `json:"next_episode,omitempty"` PrevEpisode string `json:"prev_episode,omitempty"` Thumbnail string `json:"thumbnail"` Images []string `json:"images,omitempty"` Sources []string `json:"sources,omitempty"` }
type CreateGame ¶
type CreateGame struct { Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` Playtime int64 `json:"playtime,omitempty"` Language string `json:"language,omitempty"` Platforms []string `json:"platforms,omitempty,omitempty"` Stores []string `json:"stores,omitempty,omitempty"` Modes []string `json:"modes,omitempty,omitempty"` Genres []string `json:"genres,omitempty,omitempty"` Publishers []string `json:"publishers,omitempty,omitempty"` Developers []string `json:"developers,omitempty,omitempty"` Website string `json:"website,omitempty"` Tags []string `json:"tags,omitempty,omitempty"` Trailer string `json:"trailer,omitempty"` AgeRating string `json:"age_rating,omitempty"` ReleaseDate string `json:"release_date,omitempty"` Thumbnail string `json:"thumbnail,omitempty"` Images []string `json:"images,omitempty"` Sources []string `json:"sources,omitempty"` }
type CreateLocation ¶
type CreateSeason ¶
type CreateSeason struct { Title string `json:"title,omitempty"` Description string `json:"description,omitempty"` Language string `json:"language,omitempty"` Genres []string `json:"genres,omitempty"` Episodes []string `json:"episodes,omitempty"` Trailers []string `json:"trailers,omitempty"` Budget int `json:"budget,omitempty"` DurationTotal int64 `json:"duration_total,omitempty"` SeasonNum byte `json:"season_num,omitempty"` ReleaseDate string `json:"release_date,omitempty"` NextSeason string `json:"next_season,omitempty"` PrevSeason string `json:"prev_season,omitempty"` Thumbnail string `json:"thumbnail,omitempty"` Images []string `json:"images,omitempty"` Sources []string `json:"sources,omitempty"` }
type CreateSoundtrack ¶
type CreateSoundtrack struct { Name string `json:"name,omitempty"` Duration int64 `json:"duration,omitempty"` Artist string `json:"artist,omitempty"` Album string `json:"album,omitempty"` ReleaseDate string `json:"release_date"` Urls []string `json:"urls,omitempty"` Thumbnail string `json:"thumbnail,omitempty"` Images []string `json:"images,omitempty"` Sources []string `json:"sources,omitempty"` }
type Episode ¶
type Episode struct { Uuid uuid.UUID `json:"uuid"` Href string `json:"href"` Title string `json:"title"` Description string `json:"description"` Language string `json:"language"` Duration int64 `json:"duration"` Season string `json:"season"` EpisodeNum byte `json:"episode_num"` NextEpisode string `json:"next_episode,omitempty"` PrevEpisode string `json:"prev_episode,omitempty"` Thumbnail string `json:"thumbnail"` Images []string `json:"images,omitempty"` Sources []string `json:"sources,omitempty"` CreatedAt string `json:"created_at"` UpdatedAt string `json:"updated_at"` }
type EpisodeListResponse ¶
type EpisodeListResponse struct { BaseResponse Data []Episode `json:"data"` }
type EpisodeResponse ¶
type EpisodeResponse struct { BaseResponse Data Episode `json:"data"` }
type ErrorResponse ¶
type ErrorResponse struct { Code int `json:"code"` Status string `json:"status"` Method string `json:"method"` Cause string `json:"cause"` Url string `json:"url"` Message string `json:"message,omitempty"` }
func (ErrorResponse) Error ¶
func (e ErrorResponse) Error() string
type FormatterHandler ¶
func NewFormattedHandler ¶
func NewFormattedHandler(out io.Writer, opts *slog.HandlerOptions) *FormatterHandler
type Game ¶
type Game struct { Uuid string `json:"uuid"` Href string `json:"href"` Name string `json:"name"` Description string `json:"description"` Playtime int64 `json:"playtime"` Language string `json:"language"` Platforms []string `json:"platforms,omitempty"` Stores []string `json:"stores,omitempty"` Modes []string `json:"modes,omitempty"` Genres []string `json:"genres,omitempty"` Publishers []string `json:"publishers,omitempty"` Developers []string `json:"developers,omitempty"` Website string `json:"website"` Tags []string `json:"tags,omitempty"` Trailer string `json:"trailer"` AgeRating string `json:"age_rating"` ReleaseDate string `json:"release_date"` Thumbnail string `json:"thumbnail"` Images []string `json:"images,omitempty"` Sources []string `json:"sources,omitempty"` CreatedAt string `json:"created_at"` UpdatedAt string `json:"updated_at"` }
type GameListResponse ¶
type GameListResponse struct { BaseResponse Data []Game `json:"data"` }
type GameResponse ¶
type GameResponse struct { BaseResponse Data Game `json:"data"` }
type HeaderResponse ¶
type HeaderResponse struct { Page int `json:"page,omitempty"` PageSize int `json:"page_size,omitempty"` PageTotal int `json:"page_total,omitempty"` ItemSize int `json:"item_size,omitempty"` NextPage int `json:"next_page,omitempty"` PrevPage int `json:"prev_page,omitempty"` Language string `json:"language,omitempty"` Quota Quota `json:"quota"` Etag string `json:"etag"` Length int `json:"length"` }
HeaderResponse represents the formatted header response from a request
type Info ¶
type Info struct { Title string `json:"title"` Description string `json:"description"` Version string `json:"version"` Url string `json:"url"` Docs string `json:"docs"` Github string `json:"github"` License string `json:"license"` GithubHome string `json:"github_home"` ApiUrl string `json:"api_url"` ApiVersion string `json:"api_version"` ApiPath string `json:"api_path"` ApiBaseUrl string `json:"api_base_url"` LicenseUrl string `json:"license_url"` }
type Location ¶
type Location struct { Uuid uuid.UUID `json:"uuid"` Href string `json:"href"` Name string `json:"name"` Description string `json:"description"` Language string `json:"language"` Thumbnail string `json:"thumbnail,omitempty"` Images []string `json:"images,omitempty"` Sources []string `json:"sources,omitempty"` CreatedAt string `json:"created_at"` UpdatedAt string `json:"updated_at"` }
type LocationListResponse ¶
type LocationListResponse struct { BaseResponse Data []Location `json:"data"` }
type LocationResponse ¶
type LocationResponse struct { BaseResponse Data Location `json:"data"` }
type Options ¶
type Options struct { // The endpoint of the HawAPI instance // // Default value: DefaultEndpoint Endpoint string // The version of the API Version string // The language of items for all requests // // Note: This value can be overwritten later Language string // The size of items for all requests // // Note: This value can be overwritten later Size int // The timeout of a response in milliseconds Timeout int // The HawAPI token (JWT) // // By default, all requests are made with 'ANONYMOUS' tier Token string // Define if the package should save (in-memory) all request results UseInMemoryCache bool // Define the level of SDK logging // // NOTE: If you are using a custom LogHandler, use slog.HandlerOptions to define a new log level or the SDK will panic LogLevel slog.Level // Defines the log handler. // // If set to nil, it defaults to NewFormattedHandler LogHandler slog.Handler }
type Overview ¶
type Overview struct { Uuid string `json:"uuid"` Href string `json:"href"` Sources []string `json:"sources"` Thumbnail string `json:"thumbnail"` Title string `json:"title"` Description string `json:"description"` Language string `json:"language"` Languages []string `json:"languages"` Creators []string `json:"creators"` CreatedAt string `json:"created_at"` UpdatedAt string `json:"updated_at"` DataCount DataCount `json:"data_count"` }
type PatchActor ¶
type PatchActor = CreateActor
type PatchCharacter ¶
type PatchCharacter = CreateCharacter
type PatchEpisode ¶
type PatchEpisode = CreateEpisode
type PatchGame ¶
type PatchGame = CreateGame
type PatchLocation ¶
type PatchLocation = CreateLocation
type PatchSeason ¶
type PatchSeason = CreateSeason
type PatchSoundtrack ¶
type PatchSoundtrack = CreateSoundtrack
type QueryOptions ¶
type QueryOptions func(*queryOptions)
func NewQueryOptions ¶
func NewQueryOptions(pageable Pageable, filters Filters) QueryOptions
func WithFilter ¶
func WithFilter(key string, value string) QueryOptions
func WithFilters ¶
func WithFilters(filters Filters) QueryOptions
func WithLanguage ¶
func WithLanguage(language string) QueryOptions
func WithOrder ¶
func WithOrder(order string) QueryOptions
func WithPage ¶
func WithPage(page int) QueryOptions
func WithPageable ¶
func WithPageable(pageable Pageable) QueryOptions
func WithSize ¶
func WithSize(size int) QueryOptions
func WithSort ¶
func WithSort(sort string) QueryOptions
type Quota ¶
type Quota struct {
Remaining int `json:"remaining,omitempty"`
}
Quota represents the quota status
type Season ¶
type Season struct { Uuid uuid.UUID `json:"uuid"` Href string `json:"href"` Title string `json:"title"` Description string `json:"description"` Language string `json:"language"` Genres []string `json:"genres,omitempty"` Episodes []string `json:"episodes,omitempty"` Trailers []string `json:"trailers,omitempty"` Budget int `json:"budget"` DurationTotal int64 `json:"duration_total"` SeasonNum byte `json:"season_num"` ReleaseDate string `json:"release_date"` NextSeason string `json:"next_season,omitempty"` PrevSeason string `json:"prev_season,omitempty"` Thumbnail string `json:"thumbnail,omitempty"` Images []string `json:"images,omitempty"` Sources []string `json:"sources,omitempty"` CreatedAt string `json:"created_at"` UpdatedAt string `json:"updated_at"` }
type SeasonListResponse ¶
type SeasonListResponse struct { BaseResponse Data []Season `json:"data"` }
type SeasonResponse ¶
type SeasonResponse struct { BaseResponse Data Season `json:"data"` }
type Soundtrack ¶
type Soundtrack struct { UUID uuid.UUID `json:"uuid"` Href string `json:"href"` Name string `json:"name"` Duration int64 `json:"duration"` Artist string `json:"artist"` Album string `json:"album,omitempty"` ReleaseDate string `json:"release_date"` Urls []string `json:"urls"` Thumbnail string `json:"thumbnail,omitempty"` Images []string `json:"images,omitempty"` Sources []string `json:"sources,omitempty"` CreatedAt string `json:"created_at"` UpdatedAt string `json:"updated_at"` }
type SoundtrackListResponse ¶
type SoundtrackListResponse struct { BaseResponse Data []Soundtrack `json:"data"` }
type SoundtrackResponse ¶
type SoundtrackResponse struct { BaseResponse Data Soundtrack `json:"data"` }