rust_tdlib/types/
phone_number_authentication_settings.rs1use crate::errors::Result;
2use crate::types::*;
3use uuid::Uuid;
4
5#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7pub struct PhoneNumberAuthenticationSettings {
8 #[doc(hidden)]
9 #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
10 extra: Option<String>,
11 #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
12 client_id: Option<i32>,
13 #[serde(default)]
16 allow_flash_call: bool,
17 #[serde(default)]
20 allow_missed_call: bool,
21 #[serde(default)]
24 is_current_phone_number: bool,
25 #[serde(default)]
28 allow_sms_retriever_api: bool,
29 #[serde(default)]
32 authentication_tokens: Vec<String>,
33}
34
35impl RObject for PhoneNumberAuthenticationSettings {
36 #[doc(hidden)]
37 fn extra(&self) -> Option<&str> {
38 self.extra.as_deref()
39 }
40 #[doc(hidden)]
41 fn client_id(&self) -> Option<i32> {
42 self.client_id
43 }
44}
45
46impl PhoneNumberAuthenticationSettings {
47 pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
48 Ok(serde_json::from_str(json.as_ref())?)
49 }
50 pub fn builder() -> PhoneNumberAuthenticationSettingsBuilder {
51 let mut inner = PhoneNumberAuthenticationSettings::default();
52 inner.extra = Some(Uuid::new_v4().to_string());
53
54 PhoneNumberAuthenticationSettingsBuilder { inner }
55 }
56
57 pub fn allow_flash_call(&self) -> bool {
58 self.allow_flash_call
59 }
60
61 pub fn allow_missed_call(&self) -> bool {
62 self.allow_missed_call
63 }
64
65 pub fn is_current_phone_number(&self) -> bool {
66 self.is_current_phone_number
67 }
68
69 pub fn allow_sms_retriever_api(&self) -> bool {
70 self.allow_sms_retriever_api
71 }
72
73 pub fn authentication_tokens(&self) -> &Vec<String> {
74 &self.authentication_tokens
75 }
76}
77
78#[doc(hidden)]
79pub struct PhoneNumberAuthenticationSettingsBuilder {
80 inner: PhoneNumberAuthenticationSettings,
81}
82
83#[deprecated]
84pub type RTDPhoneNumberAuthenticationSettingsBuilder = PhoneNumberAuthenticationSettingsBuilder;
85
86impl PhoneNumberAuthenticationSettingsBuilder {
87 pub fn build(&self) -> PhoneNumberAuthenticationSettings {
88 self.inner.clone()
89 }
90
91 pub fn allow_flash_call(&mut self, allow_flash_call: bool) -> &mut Self {
92 self.inner.allow_flash_call = allow_flash_call;
93 self
94 }
95
96 pub fn allow_missed_call(&mut self, allow_missed_call: bool) -> &mut Self {
97 self.inner.allow_missed_call = allow_missed_call;
98 self
99 }
100
101 pub fn is_current_phone_number(&mut self, is_current_phone_number: bool) -> &mut Self {
102 self.inner.is_current_phone_number = is_current_phone_number;
103 self
104 }
105
106 pub fn allow_sms_retriever_api(&mut self, allow_sms_retriever_api: bool) -> &mut Self {
107 self.inner.allow_sms_retriever_api = allow_sms_retriever_api;
108 self
109 }
110
111 pub fn authentication_tokens(&mut self, authentication_tokens: Vec<String>) -> &mut Self {
112 self.inner.authentication_tokens = authentication_tokens;
113 self
114 }
115}
116
117impl AsRef<PhoneNumberAuthenticationSettings> for PhoneNumberAuthenticationSettings {
118 fn as_ref(&self) -> &PhoneNumberAuthenticationSettings {
119 self
120 }
121}
122
123impl AsRef<PhoneNumberAuthenticationSettings> for PhoneNumberAuthenticationSettingsBuilder {
124 fn as_ref(&self) -> &PhoneNumberAuthenticationSettings {
125 &self.inner
126 }
127}