termii_rust/common/switch/
templates.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Deserialize, Serialize)]
4pub struct TemplatesData {
5 pub product_name: String,
6 pub otp: String,
7 pub expiry_time: String,
8}
9
10impl TemplatesData {
11 pub fn new(product_name: String, otp: String, expiry_time: String) -> TemplatesData {
12 TemplatesData {
13 product_name,
14 otp,
15 expiry_time,
16 }
17 }
18}
19
20#[derive(Debug, Deserialize, Serialize)]
21pub struct TemplatesRequest {
22 pub phone_number: String,
23 pub device_id: String,
24 pub template_id: String,
25 pub data: TemplatesData,
26 api_key: Option<String>,
27}
28
29impl TemplatesRequest {
30 pub fn new(
31 phone_number: String,
32 device_id: String,
33 template_id: String,
34 data: TemplatesData,
35 ) -> TemplatesRequest {
36 TemplatesRequest {
37 phone_number,
38 device_id,
39 template_id,
40 data,
41 api_key: None,
42 }
43 }
44
45 pub(crate) fn set_api_key(&mut self, api_key: &str) {
46 self.api_key = Some(api_key.to_string());
47 }
48}
49
50#[derive(Debug, Deserialize, Serialize)]
51pub struct TemplateItem {
52 code: String,
53 message_id: String,
54 message: String,
55 balance: String,
56 user: String,
57}