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
use crate::types::*;
use crate::errors::*;
use uuid::Uuid;
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct Session {
#[doc(hidden)]
#[serde(rename(serialize = "@type", deserialize = "@type"))]
td_name: String,
#[doc(hidden)]
#[serde(rename(serialize = "@extra", deserialize = "@extra"))]
extra: Option<String>,
id: isize,
is_current: bool,
is_password_pending: bool,
api_id: i64,
application_name: String,
application_version: String,
is_official_application: bool,
device_model: String,
platform: String,
system_version: String,
log_in_date: i64,
last_active_date: i64,
ip: String,
country: String,
region: String,
}
impl RObject for Session {
#[doc(hidden)] fn td_name(&self) -> &'static str { "session" }
#[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
}
impl Session {
pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
pub fn builder() -> RTDSessionBuilder {
let mut inner = Session::default();
inner.td_name = "session".to_string();
inner.extra = Some(Uuid::new_v4().to_string());
RTDSessionBuilder { inner }
}
pub fn id(&self) -> isize { self.id }
pub fn is_current(&self) -> bool { self.is_current }
pub fn is_password_pending(&self) -> bool { self.is_password_pending }
pub fn api_id(&self) -> i64 { self.api_id }
pub fn application_name(&self) -> &String { &self.application_name }
pub fn application_version(&self) -> &String { &self.application_version }
pub fn is_official_application(&self) -> bool { self.is_official_application }
pub fn device_model(&self) -> &String { &self.device_model }
pub fn platform(&self) -> &String { &self.platform }
pub fn system_version(&self) -> &String { &self.system_version }
pub fn log_in_date(&self) -> i64 { self.log_in_date }
pub fn last_active_date(&self) -> i64 { self.last_active_date }
pub fn ip(&self) -> &String { &self.ip }
pub fn country(&self) -> &String { &self.country }
pub fn region(&self) -> &String { &self.region }
}
#[doc(hidden)]
pub struct RTDSessionBuilder {
inner: Session
}
impl RTDSessionBuilder {
pub fn build(&self) -> Session { self.inner.clone() }
pub fn id(&mut self, id: isize) -> &mut Self {
self.inner.id = id;
self
}
pub fn is_current(&mut self, is_current: bool) -> &mut Self {
self.inner.is_current = is_current;
self
}
pub fn is_password_pending(&mut self, is_password_pending: bool) -> &mut Self {
self.inner.is_password_pending = is_password_pending;
self
}
pub fn api_id(&mut self, api_id: i64) -> &mut Self {
self.inner.api_id = api_id;
self
}
pub fn application_name<T: AsRef<str>>(&mut self, application_name: T) -> &mut Self {
self.inner.application_name = application_name.as_ref().to_string();
self
}
pub fn application_version<T: AsRef<str>>(&mut self, application_version: T) -> &mut Self {
self.inner.application_version = application_version.as_ref().to_string();
self
}
pub fn is_official_application(&mut self, is_official_application: bool) -> &mut Self {
self.inner.is_official_application = is_official_application;
self
}
pub fn device_model<T: AsRef<str>>(&mut self, device_model: T) -> &mut Self {
self.inner.device_model = device_model.as_ref().to_string();
self
}
pub fn platform<T: AsRef<str>>(&mut self, platform: T) -> &mut Self {
self.inner.platform = platform.as_ref().to_string();
self
}
pub fn system_version<T: AsRef<str>>(&mut self, system_version: T) -> &mut Self {
self.inner.system_version = system_version.as_ref().to_string();
self
}
pub fn log_in_date(&mut self, log_in_date: i64) -> &mut Self {
self.inner.log_in_date = log_in_date;
self
}
pub fn last_active_date(&mut self, last_active_date: i64) -> &mut Self {
self.inner.last_active_date = last_active_date;
self
}
pub fn ip<T: AsRef<str>>(&mut self, ip: T) -> &mut Self {
self.inner.ip = ip.as_ref().to_string();
self
}
pub fn country<T: AsRef<str>>(&mut self, country: T) -> &mut Self {
self.inner.country = country.as_ref().to_string();
self
}
pub fn region<T: AsRef<str>>(&mut self, region: T) -> &mut Self {
self.inner.region = region.as_ref().to_string();
self
}
}
impl AsRef<Session> for Session {
fn as_ref(&self) -> &Session { self }
}
impl AsRef<Session> for RTDSessionBuilder {
fn as_ref(&self) -> &Session { &self.inner }
}