rtdlib 1.8.69

TDLib for rust
Documentation
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
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
use crate::errors::*;
use crate::types::*;
use uuid::Uuid;

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

/// TRAIT | Contains a detailed statistics about a chat
pub trait TDChatStatistics: Debug + RObject {}

/// Contains a detailed statistics about a chat
#[derive(Debug, Clone, Serialize)]
#[serde(untagged)]
pub enum ChatStatistics {
  #[doc(hidden)]
  _Default(()),
  /// A detailed statistics about a channel chat
  Channel(ChatStatisticsChannel),
  /// A detailed statistics about a supergroup chat
  Supergroup(ChatStatisticsSupergroup),
  /// Returns detailed statistics about a chat. Currently, this method can be used only for supergroups and channels. Can be used only if supergroupFullInfo.can_get_statistics == true
  GetChatStatistics(GetChatStatistics),
}

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

impl<'de> Deserialize<'de> for ChatStatistics {
  fn deserialize<D>(deserializer: D) -> Result<ChatStatistics, D::Error>
  where
    D: Deserializer<'de>,
  {
    use serde::de::Error;
    rtd_enum_deserialize!(
      ChatStatistics,
      (chatStatisticsChannel, Channel);
      (chatStatisticsSupergroup, Supergroup);
      (getChatStatistics, GetChatStatistics);

    )(deserializer)
  }
}

impl RObject for ChatStatistics {
  #[doc(hidden)]
  fn td_name(&self) -> &'static str {
    match self {
      ChatStatistics::Channel(t) => t.td_name(),
      ChatStatistics::Supergroup(t) => t.td_name(),
      ChatStatistics::GetChatStatistics(t) => t.td_name(),

      _ => "-1",
    }
  }
  #[doc(hidden)]
  fn extra(&self) -> Option<String> {
    match self {
      ChatStatistics::Channel(t) => t.extra(),
      ChatStatistics::Supergroup(t) => t.extra(),
      ChatStatistics::GetChatStatistics(t) => t.extra(),

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

impl ChatStatistics {
  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 {
    matches!(self, ChatStatistics::_Default(_))
  }

  pub fn is_channel(&self) -> bool {
    matches!(self, ChatStatistics::Channel(_))
  }
  pub fn is_supergroup(&self) -> bool {
    matches!(self, ChatStatistics::Supergroup(_))
  }
  pub fn is_get_chat_statistics(&self) -> bool {
    matches!(self, ChatStatistics::GetChatStatistics(_))
  }

  pub fn on_channel<F: FnOnce(&ChatStatisticsChannel)>(&self, fnc: F) -> &Self {
    if let ChatStatistics::Channel(t) = self {
      fnc(t)
    };
    self
  }
  pub fn on_supergroup<F: FnOnce(&ChatStatisticsSupergroup)>(&self, fnc: F) -> &Self {
    if let ChatStatistics::Supergroup(t) = self {
      fnc(t)
    };
    self
  }
  pub fn on_get_chat_statistics<F: FnOnce(&GetChatStatistics)>(&self, fnc: F) -> &Self {
    if let ChatStatistics::GetChatStatistics(t) = self {
      fnc(t)
    };
    self
  }

  pub fn as_channel(&self) -> Option<&ChatStatisticsChannel> {
    if let ChatStatistics::Channel(t) = self {
      return Some(t);
    }
    None
  }
  pub fn as_supergroup(&self) -> Option<&ChatStatisticsSupergroup> {
    if let ChatStatistics::Supergroup(t) = self {
      return Some(t);
    }
    None
  }
  pub fn as_get_chat_statistics(&self) -> Option<&GetChatStatistics> {
    if let ChatStatistics::GetChatStatistics(t) = self {
      return Some(t);
    }
    None
  }

  pub fn channel<T: AsRef<ChatStatisticsChannel>>(t: T) -> Self {
    ChatStatistics::Channel(t.as_ref().clone())
  }

  pub fn supergroup<T: AsRef<ChatStatisticsSupergroup>>(t: T) -> Self {
    ChatStatistics::Supergroup(t.as_ref().clone())
  }

  pub fn get_chat_statistics<T: AsRef<GetChatStatistics>>(t: T) -> Self {
    ChatStatistics::GetChatStatistics(t.as_ref().clone())
  }
}

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

/// A detailed statistics about a channel chat
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ChatStatisticsChannel {
  #[doc(hidden)]
  #[serde(rename(serialize = "@type", deserialize = "@type"))]
  td_name: String,
  #[doc(hidden)]
  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
  extra: Option<String>,
  /// A period to which the statistics applies
  period: DateRange,
  /// Number of members in the chat
  member_count: StatisticalValue,
  /// Mean number of times the recently sent messages were viewed
  mean_message_view_count: StatisticalValue,
  /// Mean number of times the recently sent messages were shared
  mean_message_share_count: StatisticalValue,
  /// Mean number of times reactions were added to the recently sent messages
  mean_message_reaction_count: StatisticalValue,
  /// Mean number of times the recently posted stories were viewed
  mean_story_view_count: StatisticalValue,
  /// Mean number of times the recently posted stories were shared
  mean_story_share_count: StatisticalValue,
  /// Mean number of times reactions were added to the recently posted stories
  mean_story_reaction_count: StatisticalValue,
  /// A percentage of users with enabled notifications for the chat; 0-100
  enabled_notifications_percentage: f32,
  /// A graph containing number of members in the chat
  member_count_graph: StatisticalGraph,
  /// A graph containing number of members joined and left the chat
  join_graph: StatisticalGraph,
  /// A graph containing number of members muted and unmuted the chat
  mute_graph: StatisticalGraph,
  /// A graph containing number of message views in a given hour in the last two weeks
  view_count_by_hour_graph: StatisticalGraph,
  /// A graph containing number of message views per source
  view_count_by_source_graph: StatisticalGraph,
  /// A graph containing number of new member joins per source
  join_by_source_graph: StatisticalGraph,
  /// A graph containing number of users viewed chat messages per language
  language_graph: StatisticalGraph,
  /// A graph containing number of chat message views and shares
  message_interaction_graph: StatisticalGraph,
  /// A graph containing number of reactions on messages
  message_reaction_graph: StatisticalGraph,
  /// A graph containing number of story views and shares
  story_interaction_graph: StatisticalGraph,
  /// A graph containing number of reactions on stories
  story_reaction_graph: StatisticalGraph,
  /// A graph containing number of views of associated with the chat instant views
  instant_view_interaction_graph: StatisticalGraph,
  /// Detailed statistics about number of views and shares of recently sent messages and posted stories
  recent_interactions: Vec<ChatStatisticsInteractionInfo>,
}

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

impl TDChatStatistics for ChatStatisticsChannel {}

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

  pub fn period(&self) -> &DateRange {
    &self.period
  }

  pub fn member_count(&self) -> &StatisticalValue {
    &self.member_count
  }

  pub fn mean_message_view_count(&self) -> &StatisticalValue {
    &self.mean_message_view_count
  }

  pub fn mean_message_share_count(&self) -> &StatisticalValue {
    &self.mean_message_share_count
  }

  pub fn mean_message_reaction_count(&self) -> &StatisticalValue {
    &self.mean_message_reaction_count
  }

  pub fn mean_story_view_count(&self) -> &StatisticalValue {
    &self.mean_story_view_count
  }

  pub fn mean_story_share_count(&self) -> &StatisticalValue {
    &self.mean_story_share_count
  }

  pub fn mean_story_reaction_count(&self) -> &StatisticalValue {
    &self.mean_story_reaction_count
  }

  pub fn enabled_notifications_percentage(&self) -> f32 {
    self.enabled_notifications_percentage
  }

  pub fn member_count_graph(&self) -> &StatisticalGraph {
    &self.member_count_graph
  }

  pub fn join_graph(&self) -> &StatisticalGraph {
    &self.join_graph
  }

  pub fn mute_graph(&self) -> &StatisticalGraph {
    &self.mute_graph
  }

  pub fn view_count_by_hour_graph(&self) -> &StatisticalGraph {
    &self.view_count_by_hour_graph
  }

  pub fn view_count_by_source_graph(&self) -> &StatisticalGraph {
    &self.view_count_by_source_graph
  }

  pub fn join_by_source_graph(&self) -> &StatisticalGraph {
    &self.join_by_source_graph
  }

  pub fn language_graph(&self) -> &StatisticalGraph {
    &self.language_graph
  }

  pub fn message_interaction_graph(&self) -> &StatisticalGraph {
    &self.message_interaction_graph
  }

  pub fn message_reaction_graph(&self) -> &StatisticalGraph {
    &self.message_reaction_graph
  }

  pub fn story_interaction_graph(&self) -> &StatisticalGraph {
    &self.story_interaction_graph
  }

  pub fn story_reaction_graph(&self) -> &StatisticalGraph {
    &self.story_reaction_graph
  }

  pub fn instant_view_interaction_graph(&self) -> &StatisticalGraph {
    &self.instant_view_interaction_graph
  }

  pub fn recent_interactions(&self) -> &Vec<ChatStatisticsInteractionInfo> {
    &self.recent_interactions
  }
}

#[doc(hidden)]
pub struct RTDChatStatisticsChannelBuilder {
  inner: ChatStatisticsChannel,
}

impl RTDChatStatisticsChannelBuilder {
  pub fn build(&self) -> ChatStatisticsChannel {
    self.inner.clone()
  }

  pub fn period<T: AsRef<DateRange>>(&mut self, period: T) -> &mut Self {
    self.inner.period = period.as_ref().clone();
    self
  }

  pub fn member_count<T: AsRef<StatisticalValue>>(&mut self, member_count: T) -> &mut Self {
    self.inner.member_count = member_count.as_ref().clone();
    self
  }

  pub fn mean_message_view_count<T: AsRef<StatisticalValue>>(
    &mut self,
    mean_message_view_count: T,
  ) -> &mut Self {
    self.inner.mean_message_view_count = mean_message_view_count.as_ref().clone();
    self
  }

  pub fn mean_message_share_count<T: AsRef<StatisticalValue>>(
    &mut self,
    mean_message_share_count: T,
  ) -> &mut Self {
    self.inner.mean_message_share_count = mean_message_share_count.as_ref().clone();
    self
  }

  pub fn mean_message_reaction_count<T: AsRef<StatisticalValue>>(
    &mut self,
    mean_message_reaction_count: T,
  ) -> &mut Self {
    self.inner.mean_message_reaction_count = mean_message_reaction_count.as_ref().clone();
    self
  }

  pub fn mean_story_view_count<T: AsRef<StatisticalValue>>(
    &mut self,
    mean_story_view_count: T,
  ) -> &mut Self {
    self.inner.mean_story_view_count = mean_story_view_count.as_ref().clone();
    self
  }

  pub fn mean_story_share_count<T: AsRef<StatisticalValue>>(
    &mut self,
    mean_story_share_count: T,
  ) -> &mut Self {
    self.inner.mean_story_share_count = mean_story_share_count.as_ref().clone();
    self
  }

  pub fn mean_story_reaction_count<T: AsRef<StatisticalValue>>(
    &mut self,
    mean_story_reaction_count: T,
  ) -> &mut Self {
    self.inner.mean_story_reaction_count = mean_story_reaction_count.as_ref().clone();
    self
  }

  pub fn enabled_notifications_percentage(
    &mut self,
    enabled_notifications_percentage: f32,
  ) -> &mut Self {
    self.inner.enabled_notifications_percentage = enabled_notifications_percentage;
    self
  }

  pub fn member_count_graph<T: AsRef<StatisticalGraph>>(
    &mut self,
    member_count_graph: T,
  ) -> &mut Self {
    self.inner.member_count_graph = member_count_graph.as_ref().clone();
    self
  }

  pub fn join_graph<T: AsRef<StatisticalGraph>>(&mut self, join_graph: T) -> &mut Self {
    self.inner.join_graph = join_graph.as_ref().clone();
    self
  }

  pub fn mute_graph<T: AsRef<StatisticalGraph>>(&mut self, mute_graph: T) -> &mut Self {
    self.inner.mute_graph = mute_graph.as_ref().clone();
    self
  }

  pub fn view_count_by_hour_graph<T: AsRef<StatisticalGraph>>(
    &mut self,
    view_count_by_hour_graph: T,
  ) -> &mut Self {
    self.inner.view_count_by_hour_graph = view_count_by_hour_graph.as_ref().clone();
    self
  }

  pub fn view_count_by_source_graph<T: AsRef<StatisticalGraph>>(
    &mut self,
    view_count_by_source_graph: T,
  ) -> &mut Self {
    self.inner.view_count_by_source_graph = view_count_by_source_graph.as_ref().clone();
    self
  }

  pub fn join_by_source_graph<T: AsRef<StatisticalGraph>>(
    &mut self,
    join_by_source_graph: T,
  ) -> &mut Self {
    self.inner.join_by_source_graph = join_by_source_graph.as_ref().clone();
    self
  }

  pub fn language_graph<T: AsRef<StatisticalGraph>>(&mut self, language_graph: T) -> &mut Self {
    self.inner.language_graph = language_graph.as_ref().clone();
    self
  }

  pub fn message_interaction_graph<T: AsRef<StatisticalGraph>>(
    &mut self,
    message_interaction_graph: T,
  ) -> &mut Self {
    self.inner.message_interaction_graph = message_interaction_graph.as_ref().clone();
    self
  }

  pub fn message_reaction_graph<T: AsRef<StatisticalGraph>>(
    &mut self,
    message_reaction_graph: T,
  ) -> &mut Self {
    self.inner.message_reaction_graph = message_reaction_graph.as_ref().clone();
    self
  }

  pub fn story_interaction_graph<T: AsRef<StatisticalGraph>>(
    &mut self,
    story_interaction_graph: T,
  ) -> &mut Self {
    self.inner.story_interaction_graph = story_interaction_graph.as_ref().clone();
    self
  }

  pub fn story_reaction_graph<T: AsRef<StatisticalGraph>>(
    &mut self,
    story_reaction_graph: T,
  ) -> &mut Self {
    self.inner.story_reaction_graph = story_reaction_graph.as_ref().clone();
    self
  }

  pub fn instant_view_interaction_graph<T: AsRef<StatisticalGraph>>(
    &mut self,
    instant_view_interaction_graph: T,
  ) -> &mut Self {
    self.inner.instant_view_interaction_graph = instant_view_interaction_graph.as_ref().clone();
    self
  }

  pub fn recent_interactions(
    &mut self,
    recent_interactions: Vec<ChatStatisticsInteractionInfo>,
  ) -> &mut Self {
    self.inner.recent_interactions = recent_interactions;
    self
  }
}

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

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

/// A detailed statistics about a supergroup chat
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ChatStatisticsSupergroup {
  #[doc(hidden)]
  #[serde(rename(serialize = "@type", deserialize = "@type"))]
  td_name: String,
  #[doc(hidden)]
  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
  extra: Option<String>,
  /// A period to which the statistics applies
  period: DateRange,
  /// Number of members in the chat
  member_count: StatisticalValue,
  /// Number of messages sent to the chat
  message_count: StatisticalValue,
  /// Number of users who viewed messages in the chat
  viewer_count: StatisticalValue,
  /// Number of users who sent messages to the chat
  sender_count: StatisticalValue,
  /// A graph containing number of members in the chat
  member_count_graph: StatisticalGraph,
  /// A graph containing number of members joined and left the chat
  join_graph: StatisticalGraph,
  /// A graph containing number of new member joins per source
  join_by_source_graph: StatisticalGraph,
  /// A graph containing distribution of active users per language
  language_graph: StatisticalGraph,
  /// A graph containing distribution of sent messages by content type
  message_content_graph: StatisticalGraph,
  /// A graph containing number of different actions in the chat
  action_graph: StatisticalGraph,
  /// A graph containing distribution of message views per hour
  day_graph: StatisticalGraph,
  /// A graph containing distribution of message views per day of week
  week_graph: StatisticalGraph,
  /// List of users sent most messages in the last week
  top_senders: Vec<ChatStatisticsMessageSenderInfo>,
  /// List of most active administrators in the last week
  top_administrators: Vec<ChatStatisticsAdministratorActionsInfo>,
  /// List of most active inviters of new members in the last week
  top_inviters: Vec<ChatStatisticsInviterInfo>,
}

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

impl TDChatStatistics for ChatStatisticsSupergroup {}

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

  pub fn period(&self) -> &DateRange {
    &self.period
  }

  pub fn member_count(&self) -> &StatisticalValue {
    &self.member_count
  }

  pub fn message_count(&self) -> &StatisticalValue {
    &self.message_count
  }

  pub fn viewer_count(&self) -> &StatisticalValue {
    &self.viewer_count
  }

  pub fn sender_count(&self) -> &StatisticalValue {
    &self.sender_count
  }

  pub fn member_count_graph(&self) -> &StatisticalGraph {
    &self.member_count_graph
  }

  pub fn join_graph(&self) -> &StatisticalGraph {
    &self.join_graph
  }

  pub fn join_by_source_graph(&self) -> &StatisticalGraph {
    &self.join_by_source_graph
  }

  pub fn language_graph(&self) -> &StatisticalGraph {
    &self.language_graph
  }

  pub fn message_content_graph(&self) -> &StatisticalGraph {
    &self.message_content_graph
  }

  pub fn action_graph(&self) -> &StatisticalGraph {
    &self.action_graph
  }

  pub fn day_graph(&self) -> &StatisticalGraph {
    &self.day_graph
  }

  pub fn week_graph(&self) -> &StatisticalGraph {
    &self.week_graph
  }

  pub fn top_senders(&self) -> &Vec<ChatStatisticsMessageSenderInfo> {
    &self.top_senders
  }

  pub fn top_administrators(&self) -> &Vec<ChatStatisticsAdministratorActionsInfo> {
    &self.top_administrators
  }

  pub fn top_inviters(&self) -> &Vec<ChatStatisticsInviterInfo> {
    &self.top_inviters
  }
}

#[doc(hidden)]
pub struct RTDChatStatisticsSupergroupBuilder {
  inner: ChatStatisticsSupergroup,
}

impl RTDChatStatisticsSupergroupBuilder {
  pub fn build(&self) -> ChatStatisticsSupergroup {
    self.inner.clone()
  }

  pub fn period<T: AsRef<DateRange>>(&mut self, period: T) -> &mut Self {
    self.inner.period = period.as_ref().clone();
    self
  }

  pub fn member_count<T: AsRef<StatisticalValue>>(&mut self, member_count: T) -> &mut Self {
    self.inner.member_count = member_count.as_ref().clone();
    self
  }

  pub fn message_count<T: AsRef<StatisticalValue>>(&mut self, message_count: T) -> &mut Self {
    self.inner.message_count = message_count.as_ref().clone();
    self
  }

  pub fn viewer_count<T: AsRef<StatisticalValue>>(&mut self, viewer_count: T) -> &mut Self {
    self.inner.viewer_count = viewer_count.as_ref().clone();
    self
  }

  pub fn sender_count<T: AsRef<StatisticalValue>>(&mut self, sender_count: T) -> &mut Self {
    self.inner.sender_count = sender_count.as_ref().clone();
    self
  }

  pub fn member_count_graph<T: AsRef<StatisticalGraph>>(
    &mut self,
    member_count_graph: T,
  ) -> &mut Self {
    self.inner.member_count_graph = member_count_graph.as_ref().clone();
    self
  }

  pub fn join_graph<T: AsRef<StatisticalGraph>>(&mut self, join_graph: T) -> &mut Self {
    self.inner.join_graph = join_graph.as_ref().clone();
    self
  }

  pub fn join_by_source_graph<T: AsRef<StatisticalGraph>>(
    &mut self,
    join_by_source_graph: T,
  ) -> &mut Self {
    self.inner.join_by_source_graph = join_by_source_graph.as_ref().clone();
    self
  }

  pub fn language_graph<T: AsRef<StatisticalGraph>>(&mut self, language_graph: T) -> &mut Self {
    self.inner.language_graph = language_graph.as_ref().clone();
    self
  }

  pub fn message_content_graph<T: AsRef<StatisticalGraph>>(
    &mut self,
    message_content_graph: T,
  ) -> &mut Self {
    self.inner.message_content_graph = message_content_graph.as_ref().clone();
    self
  }

  pub fn action_graph<T: AsRef<StatisticalGraph>>(&mut self, action_graph: T) -> &mut Self {
    self.inner.action_graph = action_graph.as_ref().clone();
    self
  }

  pub fn day_graph<T: AsRef<StatisticalGraph>>(&mut self, day_graph: T) -> &mut Self {
    self.inner.day_graph = day_graph.as_ref().clone();
    self
  }

  pub fn week_graph<T: AsRef<StatisticalGraph>>(&mut self, week_graph: T) -> &mut Self {
    self.inner.week_graph = week_graph.as_ref().clone();
    self
  }

  pub fn top_senders(&mut self, top_senders: Vec<ChatStatisticsMessageSenderInfo>) -> &mut Self {
    self.inner.top_senders = top_senders;
    self
  }

  pub fn top_administrators(
    &mut self,
    top_administrators: Vec<ChatStatisticsAdministratorActionsInfo>,
  ) -> &mut Self {
    self.inner.top_administrators = top_administrators;
    self
  }

  pub fn top_inviters(&mut self, top_inviters: Vec<ChatStatisticsInviterInfo>) -> &mut Self {
    self.inner.top_inviters = top_inviters;
    self
  }
}

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

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