epp_client/extensions/
low_balance.rs1use serde::Deserialize;
6
7#[derive(Clone, Debug, Deserialize, PartialEq)]
8#[serde(rename_all = "camelCase")]
9pub struct LowBalance {
10 pub registrar_name: String,
11 pub credit_limit: String,
12 pub credit_threshold: Threshold,
13 pub available_credit: String,
14}
15
16#[derive(Clone, Debug, Deserialize, PartialEq)]
17pub struct Threshold {
18 pub r#type: ThresholdType,
19 #[serde(rename = "$value")]
20 pub value: String,
21}
22
23#[derive(Clone, Copy, Debug, Deserialize, PartialEq)]
24#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
25pub enum ThresholdType {
26 Fixed,
27 Percent,
28}
29
30#[cfg(test)]
31mod tests {
32 use super::*;
33 use crate::message::poll::{MessageData, MessagePollResponse};
34 use crate::message::MessagePoll;
35 use crate::response::ResultCode;
36 use crate::tests::{response_from_file, CLTRID, SVTRID};
37
38 #[test]
39 fn low_balance() {
40 let object = response_from_file::<MessagePoll>("response/message/poll_low_balance.xml");
41 dbg!(&object);
42
43 let low_balance = match object.res_data {
44 Some(MessagePollResponse {
45 message_data: MessageData::LowBalance(low_balance),
46 }) => low_balance,
47 _ => panic!("Unexpected message data"),
48 };
49
50 assert_eq!(low_balance.registrar_name, "Foobar, Inc.");
51 assert_eq!(low_balance.credit_limit, "0");
52 assert_eq!(
53 low_balance.credit_threshold,
54 Threshold {
55 r#type: ThresholdType::Fixed,
56 value: "500".into(),
57 }
58 );
59 assert_eq!(low_balance.available_credit, "491.31");
60
61 assert_eq!(
62 object.result.code,
63 ResultCode::CommandCompletedSuccessfullyAckToDequeue
64 );
65 assert_eq!(
66 object.result.message,
67 "Command completed successfully; ack to dequeue".into()
68 );
69
70 assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
71 assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
72 }
73}