giphy

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAllGiphy

func GetAllGiphy(folder string, search []string, count int) error

GetAllGiphy havest all teh gifts

func GetIntopt

func GetIntopt(name string, dfault int) int

GetIntopt reads environment variables. If not found will return a supplied default value

func Getopt

func Getopt(name, dfault string) string

Getopt reads environment variables. If not found will return a supplied default value

Types

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

func NewClient(httpClients ...*http.Client) *Client

NewClient returns a new Giphy API client. If no *http.Client were provided then http.DefaultClient is used.

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error)

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

func (c *Client) NewRequest(s string) (*http.Request, error)

NewRequest creates an API request.

func (*Client) Search

func (c *Client) Search(args []string, offset int) (Search, error)

Search Search all GIPHY GIFs for a word or phrase. Punctuation will be stripped and ignored. Use a plus or url encode for phrases. Example paul+rudd, ryan+gosling or american+psycho.

type Gif

type Gif struct {
	Type       string `json:"type,omitempty"`
	ID         string `json:"id,omitempty"`
	Slug       string `json:"slug,omitempty"`
	URL        string `json:"url,omitempty"`
	BitlyURL   string `json:"bitly_url,omitempty"`
	EmbedURL   string `json:"embed_url,omitempty"`
	Username   string `json:"username,omitempty"`
	Source     string `json:"source,omitempty"`
	Rating     string `json:"rating,omitempty"`
	Caption    string `json:"caption,omitempty"`
	ContentURL string `json:"content_url,omitempty"`

	Tags         []string `json:"tags,omitempty"`
	FeaturedTags []string `json:"featured_tags,omitempty"`

	User User `json:"user,omitempty"`

	SourceTld     string `json:"source_tld,omitempty"`
	SourcePostURL string `json:"source_post_url,omitempty"`

	UpdateDatetime   string `json:"update_datetime,omitempty"`
	CreateDatetime   string `json:"create_datetime,omitempty"`
	ImportDatetime   string `json:"import_datetime,omitempty"`
	TrendingDatetime string `json:"trending_datetime,omitempty"`

	Images Images `json:"images,omitempty"`
}

Gif giphy gif structure

type Images

type Images struct {
	FixedHeight            gipyImageDataExtended       `json:"fixed_height,omitempty"`
	FixedHeightStill       gipyImageData               `json:"fixed_height_still,omitempty"`
	FixedHeightDownsampled gipyImageDataExtended       `json:"fixed_height_downsampled,omitempty"`
	FixedWidth             gipyImageDataExtended       `json:"fixed_width,omitempty"`
	FixedWidthStill        gipyImageData               `json:"fixed_width_still,omitempty"`
	FixedWidthDownsampled  gipyImageDataExtended       `json:"fixed_width_downsampled,omitempty"`
	FixedHeightSmall       gipyImageDataExtended       `json:"fixed_height_small,omitempty"`
	FixedHeightSmallStill  gipyImageData               `json:"fixed_height_small_still,omitempty"`
	FixedWidthSmall        gipyImageDataExtended       `json:"fixed_width_small,omitempty"`
	FixedWidthSmallStill   gipyImageData               `json:"fixed_width_small_still,omitempty"`
	Downsized              gipyImageDataSized          `json:"downsized,omitempty"`
	DownsizedStill         gipyImageData               `json:"downsized_still,omitempty"`
	DownsizedLarge         gipyImageDataSized          `json:"downsized_large,omitempty"`
	DownsizedMedium        gipyImageDataSized          `json:"downsized_medium,omitempty"`
	DownsizedSmall         gipyImageDataSized          `json:"downsized_small,omitempty"`
	Original               gipyImageDataExtendedFrames `json:"original,omitempty"`
	OriginalStill          gipyImageData               `json:"original_still,omitempty"`
	Looping                gipyImageLooping            `json:"looping,omitempty"`
	Preview                gipyImagePreview            `json:"preview,omitempty"`
	PreviewGif             gipyImageDataSized          `json:"preview_gif,omitempty"`
}

Images giphy image structure

type Meta

type Meta struct {
	Status     int    `json:"status,omitempty"`
	Msg        string `json:"msg,omitempty"`
	ResponseID string `json:"response_id,omitempty"`
}

Meta The Meta Object

type Pagination

type Pagination struct {
	TotalCount int `json:"total_count,omitempty"`
	Count      int `json:"count,omitempty"`
	Offset     int `json:"offset,omitempty"`
}

Pagination The Pagination Object

type Search struct {
	Data       []Gif      `json:"data"`
	Meta       Meta       `json:"meta"`
	Pagination Pagination `json:"pagination"`
}

Search represents a search response from the Giphy API

type User

type User struct {
}

User The User Object

Jump to

Keyboard shortcuts

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