Documentation ¶
Index ¶
- Variables
- func Env(key, fallback string) string
- func EnvBool(key string, fallback bool) bool
- func EnvInt(key string, fallback int) int
- type ActionURL
- type Analytics
- type Client
- func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error)
- func (c *Client) GIF(id string) (GIF, error)
- func (c *Client) NewRequest(s string) (*http.Request, error)
- func (c *Client) Random(args []string) (Random, error)
- func (c *Client) Search(args []string) (Search, error)
- func (c *Client) Translate(args []string) (Translate, error)
- func (c *Client) Trending(args ...[]string) (Trending, error)
- type Data
- type GIF
- type Image
- type Images
- type Meta
- type Option
- type Pagination
- type Random
- type RandomData
- type Search
- type Translate
- type Trending
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoImageFound is the error returned when no image was found ErrNoImageFound = errors.New("no image found") // ErrUnknown is used for unknown errors from the Giphy API ErrUnknown = errors.New("unknown error") // ErrNoTrendingImagesFound is returned when no trending images were found ErrNoTrendingImagesFound = errors.New("no trending images found") // ErrNoRawData is returned if there was no data property in response ErrNoRawData = errors.New("no raw data") )
var DefaultClient = NewClient()
DefaultClient is the default Giphy API client
Functions ¶
Types ¶
type ActionURL ¶ added in v0.0.2
type ActionURL struct {
URL string `json:"url"`
}
ActionURL contains a pingback URL for an action such as SEEN, CLICK or SENT
type Analytics ¶ added in v0.0.2
type Analytics struct { Onload ActionURL `json:"onload"` Onclick ActionURL `json:"onclick"` Onsent ActionURL `json:"onsent"` }
Analytics represents the analytics section in a Giphy API response
type Client ¶
type Client struct { // APIKey is the key used for requests to the Giphy API APIKey string // Limit is the limit used for requests to the Giphy API Limit int // Rating is the rating used for requests to the Giphy API Rating string // BaseURL is the base url for Giphy API. BaseURL *url.URL // BasePath is the base path for the gifs endpoints BasePath string // User agent used for HTTP requests to Giphy API. UserAgent string // contains filtered or unexported fields }
A Client communicates with the Giphy API.
func NewClient ¶
NewClient returns a new Giphy API client. If HTTPClient were not provided then http.DefaultClient is used.
func (*Client) Do ¶
Do sends an API request and returns the API response. The API response is decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred.
func (*Client) NewRequest ¶
NewRequest creates an API request.
type Data ¶
type Data struct { Type string `json:"type"` ID string `json:"id"` URL string `json:"url"` BitlyGifURL string `json:"bitly_gif_url"` BitlyURL string `json:"bitly_url"` EmbedURL string `json:"embed_url"` Username string `json:"username"` Source string `json:"source"` Rating string `json:"rating"` Caption string `json:"caption"` ContentURL string `json:"content_url"` ImportDatetime string `json:"import_datetime"` TrendingDatetime string `json:"trending_datetime"` Images Images `json:"images"` Analytics Analytics `json:"analytics"` }
Data contains all the fields in a data response from the Giphy API
type GIF ¶
type GIF struct { Data Data RawData json.RawMessage `json:"data"` Meta Meta `json:"meta"` }
GIF represents a ID response from the Giphy API
type Image ¶
type Image struct { Height string `json:"height"` Width string `json:"width"` Size string `json:"size"` URL string `json:"url"` Mp4Size string `json:"mp4_size"` Mp4 string `json:"mp4"` WebpSize string `json:"webp_size"` Webp string `json:"webp"` }
Image represents an image
type Images ¶
type Images struct { FixedHeight Image `json:"fixed_height"` FixedHeightStill Image `json:"fixed_height_still"` FixedHeightDownsampled Image `json:"fixed_height_downsampled"` FixedWidth Image `json:"fixed_width"` FixedWidthStill Image `json:"fixed_width_still"` FixedWidthDownsampled Image `json:"fixed_width_downsampled"` Downsized Image `json:"downsized"` DownsizedStill Image `json:"downsized_still"` Original Image `json:"original"` OriginalStill Image `json:"original_still"` }
Images represents all the different types of images
type Option ¶
type Option func(*Client)
Option function used by the Giphy client
func HTTPClient ¶
HTTPClient option used by the Giphy client
type Pagination ¶
type Pagination struct { TotalCount int `json:"total_count"` Count int `json:"count"` Offset int `json:"offset"` }
Pagination represents the pagination section in a Giphy API response
type Random ¶
type Random struct { Data RandomData RawData json.RawMessage `json:"data"` Meta Meta `json:"meta"` }
Random represents a random response from the Giphy API
type RandomData ¶
type RandomData struct { Type string `json:"type"` ID string `json:"id"` URL string `json:"url"` ImageOriginalURL string `json:"image_original_url"` ImageURL string `json:"image_url"` ImageMp4URL string `json:"image_mp4_url"` ImageFrames string `json:"image_frames"` ImageWidth string `json:"image_width"` ImageHeight string `json:"image_height"` FixedHeightDownsampledURL string `json:"fixed_height_downsampled_url"` FixedHeightDownsampledWidth string `json:"fixed_height_downsampled_width"` FixedHeightDownsampledHeight string `json:"fixed_height_downsampled_height"` FixedWidthDownsampledURL string `json:"fixed_width_downsampled_url"` FixedWidthDownsampledWidth string `json:"fixed_width_downsampled_width"` FixedWidthDownsampledHeight string `json:"fixed_width_downsampled_height"` Rating string `json:"rating"` Username string `json:"username"` Caption string `json:"caption"` Tags []string `json:"tags"` }
RandomData represents data section in random response from the Giphy API
func (RandomData) MediaURL ¶
func (rd RandomData) MediaURL() string
MediaURL points directly to GIF image on media.giphy.com
type Search ¶
type Search struct { Data []Data `json:"data"` Meta Meta `json:"meta"` Pagination Pagination `json:"pagination"` }
Search represents a search response from the Giphy API
type Translate ¶
type Translate struct { Data RawData json.RawMessage `json:"data"` Meta Meta `json:"meta"` }
Translate represents a translate response from the Giphy API
type Trending ¶
type Trending struct { Data []Data `json:"data"` Meta Meta `json:"meta"` Pagination Pagination `json:"pagination"` }
Trending represents a trending response from the Giphy API