Skip to main content

twapi_v2/responses/
associated_metadata.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq)]
4pub struct AssociatedMetadata {
5    #[serde(skip_serializing_if = "Option::is_none")]
6    pub allow_download_status: Option<AllowDownloadStatus>,
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub alt_text: Option<AltText>,
9    #[serde(skip_serializing_if = "Option::is_none")]
10    pub found_media_origin: Option<FoundMediaOrigin>,
11    #[serde(skip_serializing_if = "Option::is_none")]
12    pub sticker_info: Option<StickerInfo>,
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub upload_source: Option<UploadSource>,
15    #[serde(flatten)]
16    pub extra: std::collections::HashMap<String, serde_json::Value>,
17}
18
19impl AssociatedMetadata {
20    pub fn is_empty_extra(&self) -> bool {
21        let res = self.extra.is_empty()
22            && self
23                .allow_download_status
24                .as_ref()
25                .map(|it| it.is_empty_extra())
26                .unwrap_or(true)
27            && self
28                .alt_text
29                .as_ref()
30                .map(|it| it.is_empty_extra())
31                .unwrap_or(true)
32            && self
33                .found_media_origin
34                .as_ref()
35                .map(|it| it.is_empty_extra())
36                .unwrap_or(true)
37            && self
38                .sticker_info
39                .as_ref()
40                .map(|it| it.is_empty_extra())
41                .unwrap_or(true)
42            && self
43                .upload_source
44                .as_ref()
45                .map(|it| it.is_empty_extra())
46                .unwrap_or(true);
47        if !res {
48            println!("AssociatedMetadata {:?}", self.extra);
49        }
50        res
51    }
52}
53
54#[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq)]
55pub struct AllowDownloadStatus {
56    #[serde(skip_serializing_if = "Option::is_none")]
57    pub allow_download: Option<String>,
58    #[serde(flatten)]
59    pub extra: std::collections::HashMap<String, serde_json::Value>,
60}
61
62impl AllowDownloadStatus {
63    pub fn is_empty_extra(&self) -> bool {
64        let res = self.extra.is_empty();
65        if !res {
66            println!("AllowDownloadStatus {:?}", self.extra);
67        }
68        res
69    }
70}
71
72#[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq)]
73pub struct AltText {
74    #[serde(skip_serializing_if = "Option::is_none")]
75    pub text: Option<String>,
76    #[serde(flatten)]
77    pub extra: std::collections::HashMap<String, serde_json::Value>,
78}
79
80impl AltText {
81    pub fn is_empty_extra(&self) -> bool {
82        let res = self.extra.is_empty();
83        if !res {
84            println!("AltText {:?}", self.extra);
85        }
86        res
87    }
88}
89
90#[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq)]
91pub struct FoundMediaOrigin {
92    #[serde(skip_serializing_if = "Option::is_none")]
93    pub id: Option<String>,
94    #[serde(skip_serializing_if = "Option::is_none")]
95    pub provider: Option<String>,
96    #[serde(flatten)]
97    pub extra: std::collections::HashMap<String, serde_json::Value>,
98}
99
100impl FoundMediaOrigin {
101    pub fn is_empty_extra(&self) -> bool {
102        let res = self.extra.is_empty();
103        if !res {
104            println!("FoundMediaOrigin {:?}", self.extra);
105        }
106        res
107    }
108}
109
110#[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq)]
111pub struct StickerInfo {
112    #[serde(skip_serializing_if = "Option::is_none")]
113    pub stickers: Option<Vec<String>>,
114    #[serde(flatten)]
115    pub extra: std::collections::HashMap<String, serde_json::Value>,
116}
117
118impl StickerInfo {
119    pub fn is_empty_extra(&self) -> bool {
120        let res = self.extra.is_empty();
121        if !res {
122            println!("StickerInfo {:?}", self.extra);
123        }
124        res
125    }
126}
127
128#[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq)]
129pub struct UploadSource {
130    #[serde(skip_serializing_if = "Option::is_none")]
131    pub text: Option<String>,
132    #[serde(flatten)]
133    pub extra: std::collections::HashMap<String, serde_json::Value>,
134}
135
136impl UploadSource {
137    pub fn is_empty_extra(&self) -> bool {
138        let res = self.extra.is_empty();
139        if !res {
140            println!("UploadSource {:?}", self.extra);
141        }
142        res
143    }
144}