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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
use crate::Client;
use crate::ClientResult;
pub struct Stickers {
pub client: Client,
}
impl Stickers {
#[doc(hidden)]
pub fn new(client: Client) -> Self {
Stickers { client }
}
/**
* Random Sticker.
*
* This function performs a `GET` to the `/stickers/random` endpoint.
*
* Returns a random GIF, limited by tag. Excluding the tag parameter will return a random GIF from the GIPHY catalog.
*
*
* **Parameters:**
*
* * `tag: &str` -- The unique bit.ly URL for this GIF.
* * `rating: &str` -- The unique bit.ly URL for this GIF.
*/
pub async fn random(
&self,
tag: &str,
rating: &str,
) -> ClientResult<crate::Response<crate::types::RandomGifResponse>> {
let mut query_args: Vec<(String, String)> = Default::default();
if !rating.is_empty() {
query_args.push(("rating".to_string(), rating.to_string()));
}
if !tag.is_empty() {
query_args.push(("tag".to_string(), tag.to_string()));
}
let query_ = serde_urlencoded::to_string(&query_args).unwrap();
let url = self
.client
.url(&format!("/stickers/random?{}", query_), None);
self.client
.get(
&url,
crate::Message {
body: None,
content_type: None,
},
)
.await
}
/**
* Search Stickers.
*
* This function performs a `GET` to the `/stickers/search` endpoint.
*
* Replicates the functionality and requirements of the classic GIPHY search, but returns animated stickers rather than GIFs.
*
*
* **Parameters:**
*
* * `q: &str` -- The unique bit.ly URL for this GIF.
* * `limit: i64` -- The maximum number of records to return.
* * `offset: i64` -- An optional results offset.
* * `rating: &str` -- The unique bit.ly URL for this GIF.
* * `lang: &str` -- Specify default language for regional content; use a 2-letter ISO 639-1 language code.
*/
pub async fn search(
&self,
q: &str,
limit: i64,
offset: i64,
rating: &str,
lang: &str,
) -> ClientResult<crate::Response<crate::types::GetGifsByResponse>> {
let mut query_args: Vec<(String, String)> = Default::default();
if !lang.is_empty() {
query_args.push(("lang".to_string(), lang.to_string()));
}
if limit > 0 {
query_args.push(("limit".to_string(), limit.to_string()));
}
if offset > 0 {
query_args.push(("offset".to_string(), offset.to_string()));
}
if !q.is_empty() {
query_args.push(("q".to_string(), q.to_string()));
}
if !rating.is_empty() {
query_args.push(("rating".to_string(), rating.to_string()));
}
let query_ = serde_urlencoded::to_string(&query_args).unwrap();
let url = self
.client
.url(&format!("/stickers/search?{}", query_), None);
self.client
.get(
&url,
crate::Message {
body: None,
content_type: None,
},
)
.await
}
/**
* Translate phrase to Sticker.
*
* This function performs a `GET` to the `/stickers/translate` endpoint.
*
* The translate API draws on search, but uses the GIPHY `special sauce` to handle translating from one vocabulary to another. In this case, words and phrases to GIFs.
*
*
* **Parameters:**
*
* * `s: &str` -- The unique bit.ly URL for this GIF.
*/
pub async fn translate(
&self,
s: &str,
) -> ClientResult<crate::Response<crate::types::RandomGifResponse>> {
let mut query_args: Vec<(String, String)> = Default::default();
if !s.is_empty() {
query_args.push(("s".to_string(), s.to_string()));
}
let query_ = serde_urlencoded::to_string(&query_args).unwrap();
let url = self
.client
.url(&format!("/stickers/translate?{}", query_), None);
self.client
.get(
&url,
crate::Message {
body: None,
content_type: None,
},
)
.await
}
/**
* Trending Stickers.
*
* This function performs a `GET` to the `/stickers/trending` endpoint.
*
* Fetch Stickers currently trending online. Hand curated by the GIPHY editorial team. Returns 25 results by default.
*
*
* **Parameters:**
*
* * `limit: i64` -- The maximum number of records to return.
* * `offset: i64` -- An optional results offset.
* * `rating: &str` -- The unique bit.ly URL for this GIF.
*/
pub async fn trending(
&self,
limit: i64,
offset: i64,
rating: &str,
) -> ClientResult<crate::Response<crate::types::GetGifsByResponse>> {
let mut query_args: Vec<(String, String)> = Default::default();
if limit > 0 {
query_args.push(("limit".to_string(), limit.to_string()));
}
if offset > 0 {
query_args.push(("offset".to_string(), offset.to_string()));
}
if !rating.is_empty() {
query_args.push(("rating".to_string(), rating.to_string()));
}
let query_ = serde_urlencoded::to_string(&query_args).unwrap();
let url = self
.client
.url(&format!("/stickers/trending?{}", query_), None);
self.client
.get(
&url,
crate::Message {
body: None,
content_type: None,
},
)
.await
}
}