Documentation
¶
Index ¶
- type AiredInfo
- type Anime
- type AnimeEndpoints
- func (s *AnimeEndpoints) GetById(ctx context.Context, id string) (*Anime, *Response, error)
- func (s *AnimeEndpoints) GetFullById(ctx context.Context, id string) (*AnimeFull, *Response, error)
- func (s *AnimeEndpoints) GetSearch(ctx context.Context, query string, values *url.Values) (*PaginatedResponseBody[Anime], *Response, error)
- type AnimeFull
- type BroadcastInfo
- type Cache
- type Client
- type ClientOption
- type Entity
- type Image
- type Images
- type Link
- type PaginatedResponseBody
- type Pagination
- type PaginationItems
- type RedisCache
- func (c *RedisCache) BulkSet(ctx context.Context, keyValues map[string]any, ttl time.Duration) error
- func (c *RedisCache) DeferBulkSet(ctx context.Context, keyValues map[string]any, ttl time.Duration)
- func (c *RedisCache) DeferSet(ctx context.Context, key string, v any, ttl time.Duration)
- func (c *RedisCache) Delete(ctx context.Context, key string) error
- func (c *RedisCache) Get(ctx context.Context, key string, v any) error
- func (c *RedisCache) Set(ctx context.Context, key string, v any, ttl time.Duration) error
- type Relation
- type Response
- type ResponseBody
- type SeasonsEndpoints
- type Theme
- type Title
- type TopEndpoints
- type Trailer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Anime ¶
type Anime struct {
MalID int `json:"mal_id"`
URL string `json:"url"`
Images Images `json:"images"`
Trailer Trailer `json:"trailer"`
Approved bool `json:"approved"`
Titles []Title `json:"titles"`
Title string `json:"title"`
TitleEN string `json:"title_english"`
TitleJP string `json:"title_japanese"`
TitleSynonyms []string `json:"title_synonyms"`
Type *string `json:"type"`
Source *string `json:"source"`
Episodes *int `json:"episodes"`
Status *string `json:"status"`
Airing bool `json:"airing"`
Aired AiredInfo `json:"aired"`
Duration *string `json:"duration"`
Rating *string `json:"rating"`
Score *float64 `json:"score"`
ScoredBy *int `json:"scored_by"`
Rank *int `json:"rank"`
Popularity *int `json:"popularity"`
Members *int `json:"members"`
Favorites *int `json:"favorites"`
Synopsis *string `json:"synopsis"`
Background *string `json:"background"`
Season *string `json:"season"`
Year *int `json:"year"`
Broadcast BroadcastInfo `json:"broadcast"`
Producers []Entity `json:"producers"`
Licensors []Entity `json:"licensors"`
Studios []Entity `json:"studios"`
Genres []Entity `json:"genres"`
ExplicityGenres []Entity `json:"explicit_genres"`
Themes []Entity `json:"themes"`
Demographics []Entity `json:"demographics"`
}
func (*Anime) IsExplicit ¶
IsExplicit will check the rating to determine if the anime is considered explicit.
type AnimeEndpoints ¶
type AnimeEndpoints service
func (*AnimeEndpoints) GetFullById ¶
GetFullById returns a complete anime resource.
type BroadcastInfo ¶
type Cache ¶
type Cache interface {
// Get will get a value from the cache.
Get(ctx context.Context, key string, value any) error
// Set will set a value in the cache.
Set(ctx context.Context, key string, value any, ttl time.Duration) error
// DeferSet will set a value in the cache, but will not wait for the operation to complete.
DeferSet(ctx context.Context, key string, value any, ttl time.Duration)
// BulkSet will set multiple values in the cache.
BulkSet(ctx context.Context, keyValues map[string]any, ttl time.Duration) error
// DeferBulkSet will set multiple values in the cache, but will not wait for the operation to complete.
DeferBulkSet(ctx context.Context, keyValues map[string]any, ttl time.Duration)
// Delete will delete a value from the cache.
Delete(ctx context.Context, key string) error
}
func NewRedisCache ¶
NewRedisCache will create a new cache manager for Redis that implements the Cache interface.
This will only use JSON commands, so your Redis server must have the JSON module loaded.
type Client ¶
type Client struct {
Anime *AnimeEndpoints
Seasons *SeasonsEndpoints
Top *TopEndpoints
// contains filtered or unexported fields
}
func NewJikanClient ¶
func NewJikanClient(options ...ClientOption) *Client
NewJikanClient will create a new, default client.
func (*Client) NewGETRequest ¶
NewGETRequest will create a new GET request only.
Jikan only supports GET requests, refer to documentation. https://docs.api.jikan.moe/#/section/information/allowed-http(s)-requests
type ClientOption ¶
type ClientOption func(*Client)
func WithCache ¶
func WithCache(cache Cache) ClientOption
WithCache will enable caching with a custom cache manager.
func WithRedisCache ¶
func WithRedisCache(client *redis.Client) ClientOption
WithRedisCache will enable redis caching.
type PaginatedResponseBody ¶
type PaginatedResponseBody[T any] struct { Data []T `json:"data"` }
type Pagination ¶
type Pagination struct {
LastVisiblePage int `json:"last_visible_page"`
HasNextPage bool `json:"has_next_page"`
CurrentPage int `json:"current_page"`
Items PaginationItems `json:"items"`
}
type PaginationItems ¶
type RedisCache ¶
type RedisCache struct {
// contains filtered or unexported fields
}
func (*RedisCache) DeferBulkSet ¶
type ResponseBody ¶
type ResponseBody[T any] struct { Data T `json:"data"` }
type SeasonsEndpoints ¶
type SeasonsEndpoints service
func (*SeasonsEndpoints) Now ¶
func (s *SeasonsEndpoints) Now(ctx context.Context, query *url.Values) (*PaginatedResponseBody[Anime], *Response, error)
Now will return the list of anime airing in the current season To filter results, pass in query parameters. Refer to documentation for accepted parameters.
type TopEndpoints ¶
type TopEndpoints service
func (*TopEndpoints) GetTopAnime ¶
func (s *TopEndpoints) GetTopAnime(ctx context.Context, query *url.Values) (*PaginatedResponseBody[Anime], *Response, error)
GetTopAnime will return the top anime. To filter results, pass in query parameters. Refer to documentation for accepted parameters.