-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtypes.go
141 lines (125 loc) · 4.89 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
package giphy
import "encoding/json"
// Search represents a search response from the Giphy API
type Search struct {
Data []Data `json:"data"`
Meta Meta `json:"meta"`
Pagination Pagination `json:"pagination"`
}
// GIF represents a ID response from the Giphy API
type GIF struct {
Data Data
RawData json.RawMessage `json:"data"`
Meta Meta `json:"meta"`
}
// Random represents a random response from the Giphy API
type Random struct {
Data RandomData
RawData json.RawMessage `json:"data"`
Meta Meta `json:"meta"`
}
// Translate represents a translate response from the Giphy API
type Translate struct {
Data
RawData json.RawMessage `json:"data"`
Meta Meta `json:"meta"`
}
// Trending represents a trending response from the Giphy API
type Trending struct {
Data []Data `json:"data"`
Meta Meta `json:"meta"`
Pagination Pagination `json:"pagination"`
}
// Data contains all the fields in a data response from the Giphy API
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"`
}
// MediaURL points directly to GIF image on media.giphy.com
func (d Data) MediaURL() string {
return "https://media.giphy.com/media/" + d.ID + "/giphy.gif"
}
// RandomData represents data section in random response from the Giphy API
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"`
}
// MediaURL points directly to GIF image on media.giphy.com
func (rd RandomData) MediaURL() string {
return "https://media.giphy.com/media/" + rd.ID + "/giphy.gif"
}
// Images represents all the different types of 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"`
}
// Image represents an 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"`
}
// Pagination represents the pagination section in a Giphy API response
type Pagination struct {
TotalCount int `json:"total_count"`
Count int `json:"count"`
Offset int `json:"offset"`
}
// Meta represents the meta section in a Giphy API response
type Meta struct {
Status int `json:"status"`
Msg string `json:"msg"`
}
// ActionURL contains a pingback URL for an action such as SEEN, CLICK or SENT
type ActionURL struct {
URL string `json:"url"`
}
// Analytics represents the analytics section in a Giphy API response
type Analytics struct {
Onload ActionURL `json:"onload"`
Onclick ActionURL `json:"onclick"`
Onsent ActionURL `json:"onsent"`
}