added epp message queue calls

This commit is contained in:
Ritesh Chitlangi 2021-07-24 14:42:08 +08:00
parent 5b4eb8509e
commit f9fd4080b9
8 changed files with 90 additions and 1 deletions

View File

@ -260,6 +260,22 @@ async fn delete_host(client: &mut EppClient) {
client.transact::<_, EppHostDeleteResponse>(&host_delete).await.unwrap(); client.transact::<_, EppHostDeleteResponse>(&host_delete).await.unwrap();
} }
async fn poll_message(client: &mut EppClient) {
let message_poll = EppMessagePoll::new(gen_client_tr_id("eppdev").unwrap().as_str());
// println!("{}", message_poll.serialize().unwrap());
client.transact::<_, EppMessagePollResponse>(&message_poll).await.unwrap();
}
async fn ack_message(client: &mut EppClient) {
let message_ack = EppMessageAck::new(12345, gen_client_tr_id("eppdev").unwrap().as_str());
println!("{}", message_ack.serialize().unwrap());
// client.transact::<_, EppMessageAckResponse>(&message_ack).await.unwrap();
}
async fn hello(client: &mut EppClient) { async fn hello(client: &mut EppClient) {
let greeting = client.hello().await.unwrap(); let greeting = client.hello().await.unwrap();
@ -294,7 +310,7 @@ async fn main() {
// create_domain(&mut client).await; // create_domain(&mut client).await;
query_domain(&mut client).await; // query_domain(&mut client).await;
// update_domain(&mut client).await; // update_domain(&mut client).await;
@ -321,4 +337,8 @@ async fn main() {
// update_host(&mut client).await; // update_host(&mut client).await;
// delete_host(&mut client).await; // delete_host(&mut client).await;
// poll_message(&mut client).await;
// ack_message(&mut client).await;
} }

View File

@ -22,6 +22,7 @@ pub use request::host::create::*;
pub use request::host::delete::*; pub use request::host::delete::*;
pub use request::host::info::*; pub use request::host::info::*;
pub use request::host::update::*; pub use request::host::update::*;
pub use request::message::ack::*;
pub use request::message::poll::*; pub use request::message::poll::*;
pub use response::contact::check::*; pub use response::contact::check::*;
@ -41,4 +42,5 @@ pub use response::host::create::*;
pub use response::host::delete::*; pub use response::host::delete::*;
pub use response::host::info::*; pub use response::host::info::*;
pub use response::host::update::*; pub use response::host::update::*;
pub use response::message::ack::*;
pub use response::message::poll::*; pub use response::message::poll::*;

View File

@ -1 +1,2 @@
pub mod ack;
pub mod poll; pub mod poll;

View File

@ -0,0 +1,27 @@
use epp_client_macros::*;
use crate::epp::command::Command;
use crate::epp::object::{ElementName, EppObject, StringValueTrait};
use serde::{Deserialize, Serialize};
pub type EppMessageAck = EppObject<Command<MessageAck>>;
#[derive(Serialize, Deserialize, Debug, ElementName)]
#[element_name(name = "ack")]
pub struct MessageAck {
op: String,
#[serde(rename = "msgID")]
message_id: String,
}
impl EppMessageAck {
pub fn new(message_id: u32, client_tr_id: &str) -> EppMessageAck {
EppObject::build(Command::<MessageAck> {
command: MessageAck {
op: "ack".to_string(),
message_id: message_id.to_string(),
},
client_tr_id: client_tr_id.to_string_value(),
})
}
}

View File

@ -153,11 +153,23 @@ pub struct ResponseTRID {
pub server_tr_id: StringValue, pub server_tr_id: StringValue,
} }
#[derive(Serialize, Deserialize, Debug, PartialEq, ElementName)]
pub struct MessageQueue {
pub count: u32,
pub id: String,
#[serde(rename = "qDate")]
pub date: StringValue,
#[serde(rename = "msg")]
pub message: StringValue,
}
#[derive(Serialize, Deserialize, Debug, PartialEq, ElementName)] #[derive(Serialize, Deserialize, Debug, PartialEq, ElementName)]
#[serde(rename_all = "lowercase")] #[serde(rename_all = "lowercase")]
#[element_name(name = "response")] #[element_name(name = "response")]
pub struct CommandResponse<T> { pub struct CommandResponse<T> {
pub result: EppResult, pub result: EppResult,
#[serde(rename = "msgQ")]
pub message_queue: Option<MessageQueue>,
#[serde(rename = "resData")] #[serde(rename = "resData")]
pub res_data: Option<T>, pub res_data: Option<T>,
#[serde(rename = "trID")] #[serde(rename = "trID")]

View File

@ -1 +1,2 @@
pub mod ack;
pub mod poll; pub mod poll;

View File

@ -0,0 +1,3 @@
use crate::epp::response::EppCommandResponse;
pub type EppMessageAckResponse = EppCommandResponse;

View File

@ -1 +1,24 @@
use crate::epp::object::{EppObject, StringValue};
use crate::epp::response::CommandResponse;
use serde::{Deserialize, Serialize};
pub type EppMessagePollResponse = EppObject<CommandResponse<MessageDomainTransferData>>;
#[derive(Serialize, Deserialize, Debug)]
pub struct MessageDomainTransferData {
#[serde(rename = "xmlns:obj")]
xmlns: String,
pub name: StringValue,
#[serde(rename = "trStatus")]
pub transfer_status: StringValue,
#[serde(rename = "reID")]
pub requester_id: StringValue,
#[serde(rename = "reDate")]
pub request_date: StringValue,
#[serde(rename = "acID")]
pub responder_id: StringValue,
#[serde(rename = "acDate")]
pub respond_by_date: StringValue,
#[serde(rename = "exDate")]
pub expiry_date: StringValue,
}