termii_rust/common/token/
in_app_token.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Deserialize, Serialize)]
4pub enum InAppTokenMessageType {
5 NUMERIC,
6 ALPHANUMERIC,
7}
8
9#[derive(Debug, Deserialize, Serialize)]
10pub struct InAppTokenRequest {
11 pub phone_number: String,
12 pub pin_type: InAppTokenMessageType,
13 pub pin_attempts: u8,
14 pub pin_time_to_live: usize,
15 pub pin_length: u8,
16 api_key: Option<String>,
17}
18
19impl InAppTokenRequest {
20 pub fn new(
21 phone_number: String,
22 pin_type: InAppTokenMessageType,
23 pin_attempts: u8,
24 pin_time_to_live: usize,
25 pin_length: u8,
26 ) -> InAppTokenRequest {
27 InAppTokenRequest {
28 phone_number,
29 pin_type,
30 pin_attempts,
31 pin_time_to_live,
32 pin_length,
33 api_key: None,
34 }
35 }
36
37 pub(crate) fn set_api_key(&mut self, api_key: &str) {
38 self.api_key = Some(api_key.to_string());
39 }
40}
41
42#[derive(Debug, Serialize, Deserialize)]
43pub struct InAppTokenResponse {
44 pub status: String,
45 pub data: Data,
46}
47
48#[derive(Debug, Serialize, Deserialize)]
49pub struct Data {
50 pub pin_id: String,
51 pub otp: String,
52 pub phone_number: String,
53 pub phone_number_other: String,
54}