Skip to main content

giphy_api/
types.rs

1//! The data types sent to and returned from the API client.
2use schemars::JsonSchema;
3use serde::{Deserialize, Serialize};
4
5/// All of the following types are flattened into one object:
6///
7/// - `Image`
8/// - `serde_json::Value`
9///
10#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)]
11pub struct LoopingAllOf {
12    #[serde(flatten)]
13    pub image: Image,
14    /**
15     * Data surrounding a version of this GIF downsized to be under 2mb.
16     */
17    #[serde(flatten)]
18    pub value: serde_json::Value,
19}
20
21/// An object containing data for various available formats and sizes of this GIF.
22#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)]
23pub struct Images {
24    /**
25     * An object containing data for various available formats and sizes of this GIF.
26     */
27    #[serde(default, skip_serializing_if = "Option::is_none")]
28    pub downsized: Option<LoopingAllOf>,
29    /**
30     * An object containing data for various available formats and sizes of this GIF.
31     */
32    #[serde(default, skip_serializing_if = "Option::is_none")]
33    pub downsized_large: Option<LoopingAllOf>,
34    /**
35     * An object containing data for various available formats and sizes of this GIF.
36     */
37    #[serde(default, skip_serializing_if = "Option::is_none")]
38    pub downsized_medium: Option<LoopingAllOf>,
39    /**
40     * An object containing data for various available formats and sizes of this GIF.
41     */
42    #[serde(default, skip_serializing_if = "Option::is_none")]
43    pub downsized_small: Option<LoopingAllOf>,
44    /**
45     * An object containing data for various available formats and sizes of this GIF.
46     */
47    #[serde(default, skip_serializing_if = "Option::is_none")]
48    pub downsized_still: Option<LoopingAllOf>,
49    /**
50     * An object containing data for various available formats and sizes of this GIF.
51     */
52    #[serde(default, skip_serializing_if = "Option::is_none")]
53    pub fixed_height: Option<LoopingAllOf>,
54    /**
55     * An object containing data for various available formats and sizes of this GIF.
56     */
57    #[serde(default, skip_serializing_if = "Option::is_none")]
58    pub fixed_height_downsampled: Option<LoopingAllOf>,
59    /**
60     * An object containing data for various available formats and sizes of this GIF.
61     */
62    #[serde(default, skip_serializing_if = "Option::is_none")]
63    pub fixed_height_small: Option<LoopingAllOf>,
64    /**
65     * An object containing data for various available formats and sizes of this GIF.
66     */
67    #[serde(default, skip_serializing_if = "Option::is_none")]
68    pub fixed_height_small_still: Option<LoopingAllOf>,
69    /**
70     * An object containing data for various available formats and sizes of this GIF.
71     */
72    #[serde(default, skip_serializing_if = "Option::is_none")]
73    pub fixed_height_still: Option<LoopingAllOf>,
74    /**
75     * An object containing data for various available formats and sizes of this GIF.
76     */
77    #[serde(default, skip_serializing_if = "Option::is_none")]
78    pub fixed_width: Option<LoopingAllOf>,
79    /**
80     * An object containing data for various available formats and sizes of this GIF.
81     */
82    #[serde(default, skip_serializing_if = "Option::is_none")]
83    pub fixed_width_downsampled: Option<LoopingAllOf>,
84    /**
85     * An object containing data for various available formats and sizes of this GIF.
86     */
87    #[serde(default, skip_serializing_if = "Option::is_none")]
88    pub fixed_width_small: Option<LoopingAllOf>,
89    /**
90     * An object containing data for various available formats and sizes of this GIF.
91     */
92    #[serde(default, skip_serializing_if = "Option::is_none")]
93    pub fixed_width_small_still: Option<LoopingAllOf>,
94    /**
95     * An object containing data for various available formats and sizes of this GIF.
96     */
97    #[serde(default, skip_serializing_if = "Option::is_none")]
98    pub fixed_width_still: Option<LoopingAllOf>,
99    /**
100     * An object containing data for various available formats and sizes of this GIF.
101     */
102    #[serde(default, skip_serializing_if = "Option::is_none")]
103    pub looping: Option<LoopingAllOf>,
104    /**
105     * An object containing data for various available formats and sizes of this GIF.
106     */
107    #[serde(default, skip_serializing_if = "Option::is_none")]
108    pub original: Option<LoopingAllOf>,
109    /**
110     * An object containing data for various available formats and sizes of this GIF.
111     */
112    #[serde(default, skip_serializing_if = "Option::is_none")]
113    pub original_still: Option<LoopingAllOf>,
114    /**
115     * An object containing data for various available formats and sizes of this GIF.
116     */
117    #[serde(default, skip_serializing_if = "Option::is_none")]
118    pub preview: Option<LoopingAllOf>,
119    /**
120     * An object containing data for various available formats and sizes of this GIF.
121     */
122    #[serde(default, skip_serializing_if = "Option::is_none")]
123    pub preview_gif: Option<LoopingAllOf>,
124}
125
126/**
127 * Type of the gif. By default, this is almost always gif
128 */
129#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema, Default)]
130pub enum Type {
131    #[serde(rename = "gif")]
132    #[default]
133    Gif,
134    #[serde(other)]
135    FallthroughString,
136}
137
138impl std::fmt::Display for Type {
139    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
140        match self {
141            Type::Gif => "gif",
142            Type::FallthroughString => "*",
143        }
144        .fmt(f)
145    }
146}
147
148#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)]
149pub struct Gif {
150    /**
151     * The unique bit.ly URL for this GIF
152     */
153    #[serde(
154        default,
155        skip_serializing_if = "String::is_empty",
156        deserialize_with = "crate::utils::deserialize_null_string::deserialize"
157    )]
158    pub bitly_url: String,
159    /**
160     * The unique bit.ly URL for this GIF
161     */
162    #[serde(
163        default,
164        skip_serializing_if = "String::is_empty",
165        deserialize_with = "crate::utils::deserialize_null_string::deserialize"
166    )]
167    pub content_url: String,
168    /**
169     * The date this GIF was added to the GIPHY database.
170     */
171    #[serde(
172        default,
173        skip_serializing_if = "Option::is_none",
174        deserialize_with = "crate::utils::date_time_format::deserialize"
175    )]
176    pub create_datetime: Option<chrono::DateTime<chrono::Utc>>,
177    /**
178     * The unique bit.ly URL for this GIF
179     */
180    #[serde(
181        default,
182        skip_serializing_if = "String::is_empty",
183        deserialize_with = "crate::utils::deserialize_null_string::deserialize"
184    )]
185    pub embded_url: String,
186    /**
187     * An array of featured tags for this GIF (Note: Not available when using the Public Beta Key)
188     *
189     */
190    #[serde(
191        default,
192        skip_serializing_if = "Vec::is_empty",
193        deserialize_with = "crate::utils::deserialize_null_vector::deserialize"
194    )]
195    pub featured_tags: Vec<String>,
196    /**
197     * The unique bit.ly URL for this GIF
198     */
199    #[serde(
200        default,
201        skip_serializing_if = "String::is_empty",
202        deserialize_with = "crate::utils::deserialize_null_string::deserialize"
203    )]
204    pub id: String,
205    /**
206     * An object containing data for various available formats and sizes of this GIF.
207     */
208    #[serde(default, skip_serializing_if = "Option::is_none")]
209    pub images: Option<Images>,
210    /**
211     * The date this GIF was added to the GIPHY database.
212     */
213    #[serde(
214        default,
215        skip_serializing_if = "Option::is_none",
216        deserialize_with = "crate::utils::date_time_format::deserialize"
217    )]
218    pub import_datetime: Option<chrono::DateTime<chrono::Utc>>,
219    /**
220     * The unique bit.ly URL for this GIF
221     */
222    #[serde(
223        default,
224        skip_serializing_if = "String::is_empty",
225        deserialize_with = "crate::utils::deserialize_null_string::deserialize"
226    )]
227    pub rating: String,
228    /**
229     * The unique bit.ly URL for this GIF
230     */
231    #[serde(
232        default,
233        skip_serializing_if = "String::is_empty",
234        deserialize_with = "crate::utils::deserialize_null_string::deserialize"
235    )]
236    pub slug: String,
237    /**
238     * The unique bit.ly URL for this GIF
239     */
240    #[serde(
241        default,
242        skip_serializing_if = "String::is_empty",
243        deserialize_with = "crate::utils::deserialize_null_string::deserialize"
244    )]
245    pub source: String,
246    /**
247     * The unique bit.ly URL for this GIF
248     */
249    #[serde(
250        default,
251        skip_serializing_if = "String::is_empty",
252        deserialize_with = "crate::utils::deserialize_null_string::deserialize"
253    )]
254    pub source_post_url: String,
255    /**
256     * The unique bit.ly URL for this GIF
257     */
258    #[serde(
259        default,
260        skip_serializing_if = "String::is_empty",
261        deserialize_with = "crate::utils::deserialize_null_string::deserialize"
262    )]
263    pub source_tld: String,
264    /**
265     * An array of featured tags for this GIF (Note: Not available when using the Public Beta Key)
266     *
267     */
268    #[serde(
269        default,
270        skip_serializing_if = "Vec::is_empty",
271        deserialize_with = "crate::utils::deserialize_null_vector::deserialize"
272    )]
273    pub tags: Vec<String>,
274    /**
275     * The date this GIF was added to the GIPHY database.
276     */
277    #[serde(
278        default,
279        skip_serializing_if = "Option::is_none",
280        deserialize_with = "crate::utils::date_time_format::deserialize"
281    )]
282    pub trending_datetime: Option<chrono::DateTime<chrono::Utc>>,
283    /**
284     * Type of the gif. By default, this is almost always gif
285     */
286    #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")]
287    pub type_: Option<Type>,
288    /**
289     * The date this GIF was added to the GIPHY database.
290     */
291    #[serde(
292        default,
293        skip_serializing_if = "Option::is_none",
294        deserialize_with = "crate::utils::date_time_format::deserialize"
295    )]
296    pub update_datetime: Option<chrono::DateTime<chrono::Utc>>,
297    /**
298     * The unique bit.ly URL for this GIF
299     */
300    #[serde(
301        default,
302        skip_serializing_if = "String::is_empty",
303        deserialize_with = "crate::utils::deserialize_null_string::deserialize"
304    )]
305    pub url: String,
306    /**
307     * The User Object contains information about the user associated with a GIF and URLs to assets such as that user's avatar image, profile, and more.
308     */
309    #[serde(default, skip_serializing_if = "Option::is_none")]
310    pub user: Option<User>,
311    /**
312     * The unique bit.ly URL for this GIF
313     */
314    #[serde(
315        default,
316        skip_serializing_if = "String::is_empty",
317        deserialize_with = "crate::utils::deserialize_null_string::deserialize"
318    )]
319    pub username: String,
320}
321
322#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)]
323pub struct Image {
324    /**
325     * The unique bit.ly URL for this GIF
326     */
327    #[serde(
328        default,
329        skip_serializing_if = "String::is_empty",
330        deserialize_with = "crate::utils::deserialize_null_string::deserialize"
331    )]
332    pub frames: String,
333    /**
334     * The unique bit.ly URL for this GIF
335     */
336    #[serde(
337        default,
338        skip_serializing_if = "String::is_empty",
339        deserialize_with = "crate::utils::deserialize_null_string::deserialize"
340    )]
341    pub height: String,
342    /**
343     * The unique bit.ly URL for this GIF
344     */
345    #[serde(
346        default,
347        skip_serializing_if = "String::is_empty",
348        deserialize_with = "crate::utils::deserialize_null_string::deserialize",
349        rename = "mp4"
350    )]
351    pub mp_4: String,
352    /**
353     * The unique bit.ly URL for this GIF
354     */
355    #[serde(
356        default,
357        skip_serializing_if = "String::is_empty",
358        deserialize_with = "crate::utils::deserialize_null_string::deserialize",
359        rename = "mp4_size"
360    )]
361    pub mp_4_size: String,
362    /**
363     * The unique bit.ly URL for this GIF
364     */
365    #[serde(
366        default,
367        skip_serializing_if = "String::is_empty",
368        deserialize_with = "crate::utils::deserialize_null_string::deserialize"
369    )]
370    pub size: String,
371    /**
372     * The unique bit.ly URL for this GIF
373     */
374    #[serde(
375        default,
376        skip_serializing_if = "String::is_empty",
377        deserialize_with = "crate::utils::deserialize_null_string::deserialize"
378    )]
379    pub url: String,
380    /**
381     * The unique bit.ly URL for this GIF
382     */
383    #[serde(
384        default,
385        skip_serializing_if = "String::is_empty",
386        deserialize_with = "crate::utils::deserialize_null_string::deserialize"
387    )]
388    pub webp: String,
389    /**
390     * The unique bit.ly URL for this GIF
391     */
392    #[serde(
393        default,
394        skip_serializing_if = "String::is_empty",
395        deserialize_with = "crate::utils::deserialize_null_string::deserialize"
396    )]
397    pub webp_size: String,
398    /**
399     * The unique bit.ly URL for this GIF
400     */
401    #[serde(
402        default,
403        skip_serializing_if = "String::is_empty",
404        deserialize_with = "crate::utils::deserialize_null_string::deserialize"
405    )]
406    pub width: String,
407}
408
409/// The Meta Object contains basic information regarding the request, whether it was successful, and the response given by the API.  Check `responses` to see a description of types of response codes the API might give you under different cirumstances.
410///
411#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)]
412pub struct Meta {
413    /**
414     * The Meta Object contains basic information regarding the request, whether it was successful, and the response given by the API.  Check `responses` to see a description of types of response codes the API might give you under different cirumstances.
415     *
416     */
417    #[serde(
418        default,
419        skip_serializing_if = "String::is_empty",
420        deserialize_with = "crate::utils::deserialize_null_string::deserialize"
421    )]
422    pub msg: String,
423    /**
424     * The Meta Object contains basic information regarding the request, whether it was successful, and the response given by the API.  Check `responses` to see a description of types of response codes the API might give you under different cirumstances.
425     *
426     */
427    #[serde(
428        default,
429        skip_serializing_if = "String::is_empty",
430        deserialize_with = "crate::utils::deserialize_null_string::deserialize"
431    )]
432    pub response_id: String,
433    /**
434     * The Meta Object contains basic information regarding the request, whether it was successful, and the response given by the API.  Check `responses` to see a description of types of response codes the API might give you under different cirumstances.
435     *
436     */
437    #[serde(
438        default,
439        skip_serializing_if = "crate::utils::zero_i64",
440        deserialize_with = "crate::utils::deserialize_null_i64::deserialize"
441    )]
442    pub status: i64,
443}
444
445/// The Pagination Object contains information relating to the number of total results available as well as the number of results fetched and their relative positions.
446///
447#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)]
448pub struct Pagination {
449    /**
450     * The Pagination Object contains information relating to the number of total results available as well as the number of results fetched and their relative positions.
451     *
452     */
453    #[serde(
454        default,
455        skip_serializing_if = "crate::utils::zero_i64",
456        deserialize_with = "crate::utils::deserialize_null_i64::deserialize"
457    )]
458    pub count: i64,
459    /**
460     * The Pagination Object contains information relating to the number of total results available as well as the number of results fetched and their relative positions.
461     *
462     */
463    #[serde(
464        default,
465        skip_serializing_if = "crate::utils::zero_i64",
466        deserialize_with = "crate::utils::deserialize_null_i64::deserialize"
467    )]
468    pub offset: i64,
469    /**
470     * The Pagination Object contains information relating to the number of total results available as well as the number of results fetched and their relative positions.
471     *
472     */
473    #[serde(
474        default,
475        skip_serializing_if = "crate::utils::zero_i64",
476        deserialize_with = "crate::utils::deserialize_null_i64::deserialize"
477    )]
478    pub total_count: i64,
479}
480
481/// The User Object contains information about the user associated with a GIF and URLs to assets such as that user's avatar image, profile, and more.
482#[derive(Serialize, Default, Deserialize, PartialEq, Debug, Clone, JsonSchema)]
483pub struct User {
484    /**
485     * The User Object contains information about the user associated with a GIF and URLs to assets such as that user's avatar image, profile, and more.
486     */
487    #[serde(
488        default,
489        skip_serializing_if = "String::is_empty",
490        deserialize_with = "crate::utils::deserialize_null_string::deserialize"
491    )]
492    pub avatar_url: String,
493    /**
494     * The User Object contains information about the user associated with a GIF and URLs to assets such as that user's avatar image, profile, and more.
495     */
496    #[serde(
497        default,
498        skip_serializing_if = "String::is_empty",
499        deserialize_with = "crate::utils::deserialize_null_string::deserialize"
500    )]
501    pub banner_url: String,
502    /**
503     * The User Object contains information about the user associated with a GIF and URLs to assets such as that user's avatar image, profile, and more.
504     */
505    #[serde(
506        default,
507        skip_serializing_if = "String::is_empty",
508        deserialize_with = "crate::utils::deserialize_null_string::deserialize"
509    )]
510    pub display_name: String,
511    /**
512     * The User Object contains information about the user associated with a GIF and URLs to assets such as that user's avatar image, profile, and more.
513     */
514    #[serde(
515        default,
516        skip_serializing_if = "String::is_empty",
517        deserialize_with = "crate::utils::deserialize_null_string::deserialize"
518    )]
519    pub profile_url: String,
520    /**
521     * The User Object contains information about the user associated with a GIF and URLs to assets such as that user's avatar image, profile, and more.
522     */
523    #[serde(
524        default,
525        skip_serializing_if = "String::is_empty",
526        deserialize_with = "crate::utils::deserialize_null_string::deserialize"
527    )]
528    pub twitter: String,
529    /**
530     * The User Object contains information about the user associated with a GIF and URLs to assets such as that user's avatar image, profile, and more.
531     */
532    #[serde(
533        default,
534        skip_serializing_if = "String::is_empty",
535        deserialize_with = "crate::utils::deserialize_null_string::deserialize"
536    )]
537    pub username: String,
538}
539
540#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)]
541pub struct GetGifsByResponse {
542    #[serde(
543        default,
544        skip_serializing_if = "Vec::is_empty",
545        deserialize_with = "crate::utils::deserialize_null_vector::deserialize"
546    )]
547    pub data: Vec<Gif>,
548    /**
549     * The Meta Object contains basic information regarding the request, whether it was successful, and the response given by the API.  Check `responses` to see a description of types of response codes the API might give you under different cirumstances.
550     *
551     */
552    #[serde(default, skip_serializing_if = "Option::is_none")]
553    pub meta: Option<Meta>,
554    /**
555     * The Pagination Object contains information relating to the number of total results available as well as the number of results fetched and their relative positions.
556     *
557     */
558    #[serde(default, skip_serializing_if = "Option::is_none")]
559    pub pagination: Option<Pagination>,
560}
561
562#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, JsonSchema)]
563pub struct RandomGifResponse {
564    #[serde(default, skip_serializing_if = "Option::is_none")]
565    pub data: Option<Gif>,
566    /**
567     * The Meta Object contains basic information regarding the request, whether it was successful, and the response given by the API.  Check `responses` to see a description of types of response codes the API might give you under different cirumstances.
568     *
569     */
570    #[serde(default, skip_serializing_if = "Option::is_none")]
571    pub meta: Option<Meta>,
572}