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
use crate::CommandId;
use serde::Deserialize;
use std::fmt::{Display, Formatter, Result as FmtResult};
#[derive(Debug)]
pub struct C2bRegisterPayload<'a> {
pub validation_url: &'a str,
pub confirmation_url: &'a str,
pub response_type: ResponseType,
pub short_code: &'a str,
}
#[derive(Debug, Deserialize)]
pub struct C2bRegisterResponse {
pub ConversationID: String,
pub OriginatorConversationID: String,
pub ResponseDescription: String,
}
#[derive(Debug)]
pub enum ResponseType {
Complete,
Cancelled,
}
impl ResponseType {
fn response_type_string(&self) -> &'static str {
match self {
ResponseType::Cancelled => "Cancelled",
ResponseType::Complete => "Complete",
}
}
}
impl Display for ResponseType {
fn fmt(&self, f: &mut Formatter) -> FmtResult {
write!(f, "{:?}", self.response_type_string())
}
}
#[derive(Debug)]
pub struct C2bSimulatePayload<'a> {
pub command_id: CommandId,
pub amount: u32,
pub msisdn: &'a str,
pub bill_ref_number: &'a str,
pub short_code: &'a str,
}
#[derive(Debug, Deserialize)]
pub struct C2bSimulateResponse {
pub ConversationID: String,
pub OriginatorCoversationID: String,
pub ResponseDescription: String,
}