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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489

use crate::types::*;
use crate::errors::*;
use uuid::Uuid;




use std::fmt::Debug;
use serde::de::{Deserialize, Deserializer};



/// TRAIT | Describes the reason why a chat is reported
pub trait TDChatReportReason: Debug + RObject {}

/// Describes the reason why a chat is reported
#[derive(Debug, Clone, Serialize)]
#[serde(untagged)]
pub enum ChatReportReason {
  #[doc(hidden)] _Default(()),
  /// The chat has child abuse related content
  ChildAbuse(ChatReportReasonChildAbuse),
  /// The chat contains copyrighted content
  Copyright(ChatReportReasonCopyright),
  /// A custom reason provided by the user
  Custom(ChatReportReasonCustom),
  /// The chat contains pornographic messages
  Pornography(ChatReportReasonPornography),
  /// The chat contains spam messages
  Spam(ChatReportReasonSpam),
  /// The chat promotes violence
  Violence(ChatReportReasonViolence),

}

impl Default for ChatReportReason {
  fn default() -> Self { ChatReportReason::_Default(()) }
}

impl<'de> Deserialize<'de> for ChatReportReason {
  fn deserialize<D>(deserializer: D) -> Result<ChatReportReason, D::Error> where D: Deserializer<'de> {
    use serde::de::Error;
    rtd_enum_deserialize!(
      ChatReportReason,
      (chatReportReasonChildAbuse, ChildAbuse);
      (chatReportReasonCopyright, Copyright);
      (chatReportReasonCustom, Custom);
      (chatReportReasonPornography, Pornography);
      (chatReportReasonSpam, Spam);
      (chatReportReasonViolence, Violence);

    )(deserializer)
  }
}

impl RObject for ChatReportReason {
  #[doc(hidden)] fn td_name(&self) -> &'static str {
    match self {
      ChatReportReason::ChildAbuse(t) => t.td_name(),
      ChatReportReason::Copyright(t) => t.td_name(),
      ChatReportReason::Custom(t) => t.td_name(),
      ChatReportReason::Pornography(t) => t.td_name(),
      ChatReportReason::Spam(t) => t.td_name(),
      ChatReportReason::Violence(t) => t.td_name(),

      _ => "-1",
    }
  }
  #[doc(hidden)] fn extra(&self) -> Option<String> {
    match self {
      ChatReportReason::ChildAbuse(t) => t.extra(),
      ChatReportReason::Copyright(t) => t.extra(),
      ChatReportReason::Custom(t) => t.extra(),
      ChatReportReason::Pornography(t) => t.extra(),
      ChatReportReason::Spam(t) => t.extra(),
      ChatReportReason::Violence(t) => t.extra(),

      _ => None,
    }
  }
  fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
}

impl ChatReportReason {
  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
  #[doc(hidden)] pub fn _is_default(&self) -> bool { if let ChatReportReason::_Default(_) = self { true } else { false } }

  pub fn is_child_abuse(&self) -> bool { if let ChatReportReason::ChildAbuse(_) = self { true } else { false } }
  pub fn is_copyright(&self) -> bool { if let ChatReportReason::Copyright(_) = self { true } else { false } }
  pub fn is_custom(&self) -> bool { if let ChatReportReason::Custom(_) = self { true } else { false } }
  pub fn is_pornography(&self) -> bool { if let ChatReportReason::Pornography(_) = self { true } else { false } }
  pub fn is_spam(&self) -> bool { if let ChatReportReason::Spam(_) = self { true } else { false } }
  pub fn is_violence(&self) -> bool { if let ChatReportReason::Violence(_) = self { true } else { false } }

  pub fn on_child_abuse<F: FnOnce(&ChatReportReasonChildAbuse)>(&self, fnc: F) -> &Self { if let ChatReportReason::ChildAbuse(t) = self { fnc(t) }; self }
  pub fn on_copyright<F: FnOnce(&ChatReportReasonCopyright)>(&self, fnc: F) -> &Self { if let ChatReportReason::Copyright(t) = self { fnc(t) }; self }
  pub fn on_custom<F: FnOnce(&ChatReportReasonCustom)>(&self, fnc: F) -> &Self { if let ChatReportReason::Custom(t) = self { fnc(t) }; self }
  pub fn on_pornography<F: FnOnce(&ChatReportReasonPornography)>(&self, fnc: F) -> &Self { if let ChatReportReason::Pornography(t) = self { fnc(t) }; self }
  pub fn on_spam<F: FnOnce(&ChatReportReasonSpam)>(&self, fnc: F) -> &Self { if let ChatReportReason::Spam(t) = self { fnc(t) }; self }
  pub fn on_violence<F: FnOnce(&ChatReportReasonViolence)>(&self, fnc: F) -> &Self { if let ChatReportReason::Violence(t) = self { fnc(t) }; self }

  pub fn as_child_abuse(&self) -> Option<&ChatReportReasonChildAbuse> { if let ChatReportReason::ChildAbuse(t) = self { return Some(t) } None }
  pub fn as_copyright(&self) -> Option<&ChatReportReasonCopyright> { if let ChatReportReason::Copyright(t) = self { return Some(t) } None }
  pub fn as_custom(&self) -> Option<&ChatReportReasonCustom> { if let ChatReportReason::Custom(t) = self { return Some(t) } None }
  pub fn as_pornography(&self) -> Option<&ChatReportReasonPornography> { if let ChatReportReason::Pornography(t) = self { return Some(t) } None }
  pub fn as_spam(&self) -> Option<&ChatReportReasonSpam> { if let ChatReportReason::Spam(t) = self { return Some(t) } None }
  pub fn as_violence(&self) -> Option<&ChatReportReasonViolence> { if let ChatReportReason::Violence(t) = self { return Some(t) } None }



  pub fn child_abuse<T: AsRef<ChatReportReasonChildAbuse>>(t: T) -> Self { ChatReportReason::ChildAbuse(t.as_ref().clone()) }

  pub fn copyright<T: AsRef<ChatReportReasonCopyright>>(t: T) -> Self { ChatReportReason::Copyright(t.as_ref().clone()) }

  pub fn custom<T: AsRef<ChatReportReasonCustom>>(t: T) -> Self { ChatReportReason::Custom(t.as_ref().clone()) }

  pub fn pornography<T: AsRef<ChatReportReasonPornography>>(t: T) -> Self { ChatReportReason::Pornography(t.as_ref().clone()) }

  pub fn spam<T: AsRef<ChatReportReasonSpam>>(t: T) -> Self { ChatReportReason::Spam(t.as_ref().clone()) }

  pub fn violence<T: AsRef<ChatReportReasonViolence>>(t: T) -> Self { ChatReportReason::Violence(t.as_ref().clone()) }

}

impl AsRef<ChatReportReason> for ChatReportReason {
  fn as_ref(&self) -> &ChatReportReason { self }
}







/// The chat has child abuse related content
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ChatReportReasonChildAbuse {
  #[doc(hidden)]
  #[serde(rename(serialize = "@type", deserialize = "@type"))]
  td_name: String,
  #[doc(hidden)]
  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
  extra: Option<String>,
  
}

impl RObject for ChatReportReasonChildAbuse {
  #[doc(hidden)] fn td_name(&self) -> &'static str { "chatReportReasonChildAbuse" }
  #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
  fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
}


impl TDChatReportReason for ChatReportReasonChildAbuse {}



impl ChatReportReasonChildAbuse {
  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
  pub fn builder() -> RTDChatReportReasonChildAbuseBuilder {
    let mut inner = ChatReportReasonChildAbuse::default();
    inner.td_name = "chatReportReasonChildAbuse".to_string();
    inner.extra = Some(Uuid::new_v4().to_string());
    RTDChatReportReasonChildAbuseBuilder { inner }
  }

}

#[doc(hidden)]
pub struct RTDChatReportReasonChildAbuseBuilder {
  inner: ChatReportReasonChildAbuse
}

impl RTDChatReportReasonChildAbuseBuilder {
  pub fn build(&self) -> ChatReportReasonChildAbuse { self.inner.clone() }

}

impl AsRef<ChatReportReasonChildAbuse> for ChatReportReasonChildAbuse {
  fn as_ref(&self) -> &ChatReportReasonChildAbuse { self }
}

impl AsRef<ChatReportReasonChildAbuse> for RTDChatReportReasonChildAbuseBuilder {
  fn as_ref(&self) -> &ChatReportReasonChildAbuse { &self.inner }
}







/// The chat contains copyrighted content
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ChatReportReasonCopyright {
  #[doc(hidden)]
  #[serde(rename(serialize = "@type", deserialize = "@type"))]
  td_name: String,
  #[doc(hidden)]
  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
  extra: Option<String>,
  
}

impl RObject for ChatReportReasonCopyright {
  #[doc(hidden)] fn td_name(&self) -> &'static str { "chatReportReasonCopyright" }
  #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
  fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
}


impl TDChatReportReason for ChatReportReasonCopyright {}



impl ChatReportReasonCopyright {
  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
  pub fn builder() -> RTDChatReportReasonCopyrightBuilder {
    let mut inner = ChatReportReasonCopyright::default();
    inner.td_name = "chatReportReasonCopyright".to_string();
    inner.extra = Some(Uuid::new_v4().to_string());
    RTDChatReportReasonCopyrightBuilder { inner }
  }

}

#[doc(hidden)]
pub struct RTDChatReportReasonCopyrightBuilder {
  inner: ChatReportReasonCopyright
}

impl RTDChatReportReasonCopyrightBuilder {
  pub fn build(&self) -> ChatReportReasonCopyright { self.inner.clone() }

}

impl AsRef<ChatReportReasonCopyright> for ChatReportReasonCopyright {
  fn as_ref(&self) -> &ChatReportReasonCopyright { self }
}

impl AsRef<ChatReportReasonCopyright> for RTDChatReportReasonCopyrightBuilder {
  fn as_ref(&self) -> &ChatReportReasonCopyright { &self.inner }
}







/// A custom reason provided by the user
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ChatReportReasonCustom {
  #[doc(hidden)]
  #[serde(rename(serialize = "@type", deserialize = "@type"))]
  td_name: String,
  #[doc(hidden)]
  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
  extra: Option<String>,
  /// Report text
  text: String,
  
}

impl RObject for ChatReportReasonCustom {
  #[doc(hidden)] fn td_name(&self) -> &'static str { "chatReportReasonCustom" }
  #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
  fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
}


impl TDChatReportReason for ChatReportReasonCustom {}



impl ChatReportReasonCustom {
  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
  pub fn builder() -> RTDChatReportReasonCustomBuilder {
    let mut inner = ChatReportReasonCustom::default();
    inner.td_name = "chatReportReasonCustom".to_string();
    inner.extra = Some(Uuid::new_v4().to_string());
    RTDChatReportReasonCustomBuilder { inner }
  }

  pub fn text(&self) -> &String { &self.text }

}

#[doc(hidden)]
pub struct RTDChatReportReasonCustomBuilder {
  inner: ChatReportReasonCustom
}

impl RTDChatReportReasonCustomBuilder {
  pub fn build(&self) -> ChatReportReasonCustom { self.inner.clone() }

   
  pub fn text<T: AsRef<str>>(&mut self, text: T) -> &mut Self {
    self.inner.text = text.as_ref().to_string();
    self
  }

}

impl AsRef<ChatReportReasonCustom> for ChatReportReasonCustom {
  fn as_ref(&self) -> &ChatReportReasonCustom { self }
}

impl AsRef<ChatReportReasonCustom> for RTDChatReportReasonCustomBuilder {
  fn as_ref(&self) -> &ChatReportReasonCustom { &self.inner }
}







/// The chat contains pornographic messages
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ChatReportReasonPornography {
  #[doc(hidden)]
  #[serde(rename(serialize = "@type", deserialize = "@type"))]
  td_name: String,
  #[doc(hidden)]
  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
  extra: Option<String>,
  
}

impl RObject for ChatReportReasonPornography {
  #[doc(hidden)] fn td_name(&self) -> &'static str { "chatReportReasonPornography" }
  #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
  fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
}


impl TDChatReportReason for ChatReportReasonPornography {}



impl ChatReportReasonPornography {
  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
  pub fn builder() -> RTDChatReportReasonPornographyBuilder {
    let mut inner = ChatReportReasonPornography::default();
    inner.td_name = "chatReportReasonPornography".to_string();
    inner.extra = Some(Uuid::new_v4().to_string());
    RTDChatReportReasonPornographyBuilder { inner }
  }

}

#[doc(hidden)]
pub struct RTDChatReportReasonPornographyBuilder {
  inner: ChatReportReasonPornography
}

impl RTDChatReportReasonPornographyBuilder {
  pub fn build(&self) -> ChatReportReasonPornography { self.inner.clone() }

}

impl AsRef<ChatReportReasonPornography> for ChatReportReasonPornography {
  fn as_ref(&self) -> &ChatReportReasonPornography { self }
}

impl AsRef<ChatReportReasonPornography> for RTDChatReportReasonPornographyBuilder {
  fn as_ref(&self) -> &ChatReportReasonPornography { &self.inner }
}







/// The chat contains spam messages
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ChatReportReasonSpam {
  #[doc(hidden)]
  #[serde(rename(serialize = "@type", deserialize = "@type"))]
  td_name: String,
  #[doc(hidden)]
  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
  extra: Option<String>,
  
}

impl RObject for ChatReportReasonSpam {
  #[doc(hidden)] fn td_name(&self) -> &'static str { "chatReportReasonSpam" }
  #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
  fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
}


impl TDChatReportReason for ChatReportReasonSpam {}



impl ChatReportReasonSpam {
  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
  pub fn builder() -> RTDChatReportReasonSpamBuilder {
    let mut inner = ChatReportReasonSpam::default();
    inner.td_name = "chatReportReasonSpam".to_string();
    inner.extra = Some(Uuid::new_v4().to_string());
    RTDChatReportReasonSpamBuilder { inner }
  }

}

#[doc(hidden)]
pub struct RTDChatReportReasonSpamBuilder {
  inner: ChatReportReasonSpam
}

impl RTDChatReportReasonSpamBuilder {
  pub fn build(&self) -> ChatReportReasonSpam { self.inner.clone() }

}

impl AsRef<ChatReportReasonSpam> for ChatReportReasonSpam {
  fn as_ref(&self) -> &ChatReportReasonSpam { self }
}

impl AsRef<ChatReportReasonSpam> for RTDChatReportReasonSpamBuilder {
  fn as_ref(&self) -> &ChatReportReasonSpam { &self.inner }
}







/// The chat promotes violence
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ChatReportReasonViolence {
  #[doc(hidden)]
  #[serde(rename(serialize = "@type", deserialize = "@type"))]
  td_name: String,
  #[doc(hidden)]
  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
  extra: Option<String>,
  
}

impl RObject for ChatReportReasonViolence {
  #[doc(hidden)] fn td_name(&self) -> &'static str { "chatReportReasonViolence" }
  #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
  fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
}


impl TDChatReportReason for ChatReportReasonViolence {}



impl ChatReportReasonViolence {
  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
  pub fn builder() -> RTDChatReportReasonViolenceBuilder {
    let mut inner = ChatReportReasonViolence::default();
    inner.td_name = "chatReportReasonViolence".to_string();
    inner.extra = Some(Uuid::new_v4().to_string());
    RTDChatReportReasonViolenceBuilder { inner }
  }

}

#[doc(hidden)]
pub struct RTDChatReportReasonViolenceBuilder {
  inner: ChatReportReasonViolence
}

impl RTDChatReportReasonViolenceBuilder {
  pub fn build(&self) -> ChatReportReasonViolence { self.inner.clone() }

}

impl AsRef<ChatReportReasonViolence> for ChatReportReasonViolence {
  fn as_ref(&self) -> &ChatReportReasonViolence { self }
}

impl AsRef<ChatReportReasonViolence> for RTDChatReportReasonViolenceBuilder {
  fn as_ref(&self) -> &ChatReportReasonViolence { &self.inner }
}