Refactor message ack models
This commit is contained in:
parent
388f153763
commit
dd102fa2cf
|
@ -5,10 +5,8 @@ pub mod request;
|
||||||
pub mod response;
|
pub mod response;
|
||||||
pub mod xml;
|
pub mod xml;
|
||||||
|
|
||||||
pub use request::message::ack::*;
|
|
||||||
pub use request::message::poll::*;
|
pub use request::message::poll::*;
|
||||||
|
|
||||||
pub use response::message::ack::*;
|
|
||||||
pub use response::message::poll::*;
|
pub use response::message::poll::*;
|
||||||
|
|
||||||
pub use crate::connection::client::default_client_tr_id_fn as generate_client_tr_id;
|
pub use crate::connection::client::default_client_tr_id_fn as generate_client_tr_id;
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
//! Types for EPP message requests
|
//! Types for EPP message requests
|
||||||
|
|
||||||
pub mod ack;
|
|
||||||
pub mod poll;
|
pub mod poll;
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
//! Types for EPP message responses
|
//! Types for EPP message responses
|
||||||
|
|
||||||
pub mod ack;
|
|
||||||
pub mod poll;
|
pub mod poll;
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
//! Types for EPP message ack response
|
|
||||||
|
|
||||||
use crate::epp::object::EppObject;
|
|
||||||
use crate::epp::response::CommandResponse;
|
|
||||||
|
|
||||||
/// Type that represents the <epp> tag for the EPP XML message ack response
|
|
||||||
pub type EppMessageAckResponse = EppObject<CommandResponse<String>>;
|
|
|
@ -107,6 +107,7 @@ pub mod domain;
|
||||||
pub mod epp;
|
pub mod epp;
|
||||||
pub mod error;
|
pub mod error;
|
||||||
pub mod host;
|
pub mod host;
|
||||||
|
pub mod message;
|
||||||
pub use connection::client::EppClient;
|
pub use connection::client::EppClient;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
pub mod ack;
|
|
@ -4,6 +4,7 @@ use epp_client_macros::*;
|
||||||
|
|
||||||
use crate::epp::object::{ElementName, EppObject};
|
use crate::epp::object::{ElementName, EppObject};
|
||||||
use crate::epp::request::Command;
|
use crate::epp::request::Command;
|
||||||
|
use crate::epp::response::CommandResponse;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// Type that represents the <epp> request for registry <poll op="ack"> command
|
/// Type that represents the <epp> request for registry <poll op="ack"> command
|
||||||
|
@ -14,7 +15,7 @@ use serde::{Deserialize, Serialize};
|
||||||
///
|
///
|
||||||
/// use epp_client::config::{EppClientConfig, EppClientConnection};
|
/// use epp_client::config::{EppClientConfig, EppClientConnection};
|
||||||
/// use epp_client::EppClient;
|
/// use epp_client::EppClient;
|
||||||
/// use epp_client::epp::{EppMessageAck, EppMessageAckResponse};
|
/// use epp_client::message::ack::{EppMessageAck, EppMessageAckResponse};
|
||||||
/// use epp_client::epp::generate_client_tr_id;
|
/// use epp_client::epp::generate_client_tr_id;
|
||||||
///
|
///
|
||||||
/// #[tokio::main]
|
/// #[tokio::main]
|
||||||
|
@ -51,25 +52,13 @@ use serde::{Deserialize, Serialize};
|
||||||
/// client.logout().await.unwrap();
|
/// client.logout().await.unwrap();
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub type EppMessageAck = EppObject<Command<MessageAck>>;
|
pub type EppMessageAck = EppObject<Command<MessageAckRequest>>;
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, ElementName)]
|
|
||||||
#[element_name(name = "poll")]
|
|
||||||
/// Type for EPP XML <poll> command for message ack
|
|
||||||
pub struct MessageAck {
|
|
||||||
/// The type of operation to perform
|
|
||||||
/// The value is "ack" for message acknowledgement
|
|
||||||
op: String,
|
|
||||||
/// The ID of the message to be acknowledged
|
|
||||||
#[serde(rename = "msgID")]
|
|
||||||
message_id: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl EppMessageAck {
|
impl EppMessageAck {
|
||||||
/// Creates a new EppObject for <poll> ack corresponding to the <epp> tag in EPP XML
|
/// Creates a new EppObject for <poll> ack corresponding to the <epp> tag in EPP XML
|
||||||
pub fn new(message_id: u32, client_tr_id: &str) -> EppMessageAck {
|
pub fn new(message_id: u32, client_tr_id: &str) -> EppMessageAck {
|
||||||
EppObject::build(Command::<MessageAck>::new(
|
EppObject::build(Command::<MessageAckRequest>::new(
|
||||||
MessageAck {
|
MessageAckRequest {
|
||||||
op: "ack".to_string(),
|
op: "ack".to_string(),
|
||||||
message_id: message_id.to_string(),
|
message_id: message_id.to_string(),
|
||||||
},
|
},
|
||||||
|
@ -77,3 +66,18 @@ impl EppMessageAck {
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Type that represents the <epp> tag for the EPP XML message ack response
|
||||||
|
pub type EppMessageAckResponse = EppObject<CommandResponse<String>>;
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, ElementName)]
|
||||||
|
#[element_name(name = "poll")]
|
||||||
|
/// Type for EPP XML <poll> command for message ack
|
||||||
|
pub struct MessageAckRequest {
|
||||||
|
/// The type of operation to perform
|
||||||
|
/// The value is "ack" for message acknowledgement
|
||||||
|
op: String,
|
||||||
|
/// The ID of the message to be acknowledged
|
||||||
|
#[serde(rename = "msgID")]
|
||||||
|
message_id: String,
|
||||||
|
}
|
|
@ -32,6 +32,7 @@ mod response {
|
||||||
use crate::host::delete::EppHostDeleteResponse;
|
use crate::host::delete::EppHostDeleteResponse;
|
||||||
use crate::host::info::EppHostInfoResponse;
|
use crate::host::info::EppHostInfoResponse;
|
||||||
use crate::host::update::EppHostUpdateResponse;
|
use crate::host::update::EppHostUpdateResponse;
|
||||||
|
use crate::message::ack::EppMessageAckResponse;
|
||||||
|
|
||||||
const SVTRID: &str = "RO-6879-1627224678242975";
|
const SVTRID: &str = "RO-6879-1627224678242975";
|
||||||
const SUCCESS_MSG: &str = "Command completed successfully";
|
const SUCCESS_MSG: &str = "Command completed successfully";
|
||||||
|
|
|
@ -37,6 +37,7 @@ mod request {
|
||||||
use crate::host::update::EppHostUpdate;
|
use crate::host::update::EppHostUpdate;
|
||||||
use crate::host::update::HostAddRemove;
|
use crate::host::update::HostAddRemove;
|
||||||
use crate::host::update::HostChangeInfo;
|
use crate::host::update::HostChangeInfo;
|
||||||
|
use crate::message::ack::EppMessageAck;
|
||||||
use chrono::{DateTime, NaiveDate};
|
use chrono::{DateTime, NaiveDate};
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue