Documentation
¶
Index ¶
- Variables
- type Client
- func (c *Client) GetCollections() (CollectionResponse, error)
- func (c *Client) GetSettings() (SettingsResponse, error)
- func (c *Client) GetTagDetails(tagID int) (TagResponse, error)
- func (c *Client) GetWallpaperDetails(wallID string) (WallpaperResponse, error)
- func (c *Client) NextPage(result SearchResponse, sp *SearchParams) (SearchResponse, error)
- func (c *Client) PrevPage(result SearchResponse, sp *SearchParams) (SearchResponse, error)
- func (c *Client) Search(sp SearchParams) (SearchResponse, error)
- func (c *Client) SetPage(result SearchResponse, sp *SearchParams, page int) (SearchResponse, error)
- type CollectionResponse
- type Collections
- type Meta
- type SearchParams
- type SearchResponse
- type Settings
- type SettingsResponse
- type TagResponse
- type Tags
- type Thumbs
- type Uploader
- type Wallpaper
- func (w Wallpaper) ImageURL() string
- func (w Wallpaper) IsAnime() bool
- func (w Wallpaper) IsGeneral() bool
- func (w Wallpaper) IsNSFW() bool
- func (w Wallpaper) IsPeople() bool
- func (w Wallpaper) IsSFW() bool
- func (w Wallpaper) IsSketchy() bool
- func (w Wallpaper) SizeByte() int
- func (w Wallpaper) SizeKiB() float64
- func (w Wallpaper) SizeMiB() float64
- func (w Wallpaper) TagNames() []string
- func (w Wallpaper) ThumbLarge() string
- func (w Wallpaper) ThumbOrig() string
- func (w Wallpaper) ThumbSmall() string
- func (w Wallpaper) WallFileType() string
- func (w Wallpaper) WallShortURL() string
- func (w Wallpaper) WallURL() string
- func (w Wallpaper) WallXAxis() int
- func (w Wallpaper) WallYAxis() int
- type WallpaperResponse
Constants ¶
This section is empty.
Variables ¶
var ErrAPICollections = errors.New("API required for retreiving collections")
var ErrAPISettings = errors.New("API required for reading settings")
var ErrFirstPage = errors.New("already on first page")
var ErrInvalidPage = errors.New("not a valid page")
var ErrLastPage = errors.New("already on the last page")
Functions ¶
This section is empty.
Types ¶
type Client ¶
func NewClientWithKey ¶
NewClientWithKey creates a new authorized client
func (*Client) GetCollections ¶
func (c *Client) GetCollections() (CollectionResponse, error)
func (*Client) GetSettings ¶
func (c *Client) GetSettings() (SettingsResponse, error)
func (*Client) GetTagDetails ¶
func (c *Client) GetTagDetails(tagID int) (TagResponse, error)
func (*Client) GetWallpaperDetails ¶
func (c *Client) GetWallpaperDetails(wallID string) (WallpaperResponse, error)
GetWallpaperDetails retrieves metadata of a wallpaper provided with the ID
func (*Client) NextPage ¶
func (c *Client) NextPage(result SearchResponse, sp *SearchParams) (SearchResponse, error)
NextPage retrieves new results of the next page
func (*Client) PrevPage ¶
func (c *Client) PrevPage(result SearchResponse, sp *SearchParams) (SearchResponse, error)
PrevPage retrieves results of the previous page
func (*Client) Search ¶
func (c *Client) Search(sp SearchParams) (SearchResponse, error)
Search performs the search based on provided search parameters
func (*Client) SetPage ¶
func (c *Client) SetPage(result SearchResponse, sp *SearchParams, page int) (SearchResponse, error)
SetPage retrieves results based on the provided page
type CollectionResponse ¶
type CollectionResponse struct {
UserCollections []Collections `json:"data"`
}
CollectionResponse holds wallpaper collections
type Collections ¶
type Collections struct {
ID int `json:"id"`
Label string `json:"label"`
Views int `json:"views"`
Public int `json:"public"`
Count int `json:"count"`
}
Collections holds per collection data
type Meta ¶
type Meta struct {
CurrentPage int `json:"current_page"`
LastPage int `json:"last_page"`
PerPage int `json:"per_page"`
Total int `json:"total"`
Seed string `json:"seed"`
}
Meta holds pagindation data
func (*Meta) UnmarshalJSON ¶
type SearchParams ¶
type SearchParams struct {
// KeySearch holds the query of what will be searched
KeySearch string
// Categories filters the search to "general", "anime", and "people" as indicated by: "100", "010", "001"
Categories string
// Purity filters the search to "sfw", "sketchy", and "nsfw" as indicated by: "100", "010", "001"
Purity string
// Sorting: "date_added", "relevance", "random", "views", "favorites", "toplist"
Sorting string
// Order sorts by "desc" or "asc"
Order string
// AtLeast defines the minimum resolution allowed for the search: "1920x1080"
AtLeast string
// Resolution defines a list of allowed resolutions: "1920x1080,2400x1080"
Resolution string
// Ratios defines a list of allowed ratios: "16x9,16x10"
Ratios string
// Page specifies which page to obtain wallpapers
Page int
// Seed specifies the randomness if Sorting is set to "random"
Seed string
}
SearchParams holds the seacrh configuration
type SearchResponse ¶
SearchResponse holds Meta and Wallpaper slices
type Settings ¶
type Settings struct {
ThumbSize string `json:"thumb_size"`
PerPage string `json:"per_page"`
Purity []string `json:"purity"`
Categories []string `json:"categories"`
Resolutions []string `json:"resolutions"`
Ratios []string `json:"aspect_ratios"`
ToplistRange string `json:"toplist_range"`
TagBlacklist []string `json:"tag_blacklist"`
UserBlacklist []string `json:"user_blacklist"`
}
Settings holds field data
type SettingsResponse ¶
type SettingsResponse struct {
UserSettings Settings `json:"data"`
}
SettingsResponse holds user settings data
type TagResponse ¶
type TagResponse struct {
Tagdata Tags `json:"data"`
}
TagResponse holds data when looking up tag IDs
type Tags ¶
type Tags struct {
ID int `json:"id"`
Name string `json:"name"`
Alias string `json:"alias"`
CategoryID int `json:"category_id"`
Category string `json:"category"`
Purity string `json:"purity"`
Date string `json:"created_at"`
}
Tags holds the tags assigned to the wallpaper
type Thumbs ¶
type Thumbs struct {
Large string `json:"large"`
Orig string `json:"original"`
Small string `json:"small"`
}
Thumbs holds the thumbnail paths of the wallpaper
type Wallpaper ¶
type Wallpaper struct {
Thumbnails Thumbs `json:"thumbs"`
ID string `json:"id"`
URL string `json:"url"`
ShortURL string `json:"short_url"`
Views int `json:"views"`
Favorites int `json:"favorites"`
// Purity indicates content rating: "sfw", "sketchy", "nsfw"
Purity string `json:"purity"`
// Category indiacates content: "general", "anime", "people"
Category string `json:"category"`
AxisX int `json:"dimension_x"`
AxisY int `json:"dimension_y"`
Resolution string `json:"resolution"`
Date string `json:"created_at"`
Ratio string `json:"ratio"`
FileSize int `json:"file_size"`
FileType string `json:"file_type"`
// Path holds the direct image path
Path string `json:"path"`
WallpaperUploader Uploader `json:"uploader"`
WallpaperTags []Tags `json:"tags"`
}
Wallpaper holds the data of a wallpaper
func (Wallpaper) ThumbLarge ¶
Returns the large thumbnail path
func (Wallpaper) ThumbSmall ¶
Return the small thumbnail path
func (Wallpaper) WallShortURL ¶
Returns shortened wallhaven link
type WallpaperResponse ¶
type WallpaperResponse struct {
Wall Wallpaper `json:"data"`
}
WallpaperResponse holds data of a singular wallpaper