Refactor message poll models
This commit is contained in:
parent
dd102fa2cf
commit
8bf0283b7e
|
@ -5,8 +5,4 @@ pub mod request;
|
|||
pub mod response;
|
||||
pub mod xml;
|
||||
|
||||
pub use request::message::poll::*;
|
||||
|
||||
pub use response::message::poll::*;
|
||||
|
||||
pub use crate::connection::client::default_client_tr_id_fn as generate_client_tr_id;
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
//! Types for EPP requests
|
||||
|
||||
pub mod message;
|
||||
|
||||
use serde::{ser::SerializeStruct, ser::Serializer, Deserialize, Serialize};
|
||||
use std::error::Error;
|
||||
use std::time::SystemTime;
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
//! Types for EPP message requests
|
||||
|
||||
pub mod poll;
|
|
@ -1,7 +1,5 @@
|
|||
//! Types for EPP responses
|
||||
|
||||
pub mod message;
|
||||
|
||||
use epp_client_macros::*;
|
||||
use serde::{Deserialize, Deserializer, Serialize};
|
||||
use std::fmt::Debug;
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
//! Types for EPP message responses
|
||||
|
||||
pub mod poll;
|
|
@ -1,45 +0,0 @@
|
|||
//! Types for EPP message poll response
|
||||
|
||||
use crate::epp::object::{EppObject, StringValue};
|
||||
use crate::epp::response::CommandResponse;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Type that represents the <epp> tag for the EPP XML message poll response
|
||||
pub type EppMessagePollResponse = EppObject<CommandResponse<MessagePollResult>>;
|
||||
|
||||
/// Type that represents the <trnData> tag for message poll response
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct MessageDomainTransferData {
|
||||
/// XML namespace for message response data
|
||||
#[serde(rename = "xmlns:obj", alias = "xmlns")]
|
||||
xmlns: String,
|
||||
/// The name of the domain under transfer
|
||||
#[serde(rename = "obj:name", alias = "name")]
|
||||
pub name: StringValue,
|
||||
/// The domain transfer status
|
||||
#[serde(rename = "obj:trStatus", alias = "trStatus")]
|
||||
pub transfer_status: StringValue,
|
||||
/// The epp user who requested the transfer
|
||||
#[serde(rename = "obj:reID", alias = "reID")]
|
||||
pub requester_id: StringValue,
|
||||
/// The date of the transfer request
|
||||
#[serde(rename = "obj:reDate", alias = "reDate")]
|
||||
pub requested_at: StringValue,
|
||||
/// The epp user who should acknowledge the transfer request
|
||||
#[serde(rename = "obj:acID", alias = "acID")]
|
||||
pub ack_id: StringValue,
|
||||
/// The date by which the transfer request should be acknowledged
|
||||
#[serde(rename = "obj:acDate", alias = "acDate")]
|
||||
pub ack_by: StringValue,
|
||||
/// The domain expiry date
|
||||
#[serde(rename = "obj:exDate", alias = "exDate")]
|
||||
pub expiring_at: StringValue,
|
||||
}
|
||||
|
||||
/// Type that represents the <resData> tag for message poll response
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct MessagePollResult {
|
||||
/// Data under the <trnData> tag
|
||||
#[serde(rename = "obj:trnData", alias = "trnData")]
|
||||
pub message_data: MessageDomainTransferData,
|
||||
}
|
|
@ -1 +1,2 @@
|
|||
pub mod ack;
|
||||
pub mod poll;
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
|
||||
use epp_client_macros::*;
|
||||
|
||||
use crate::epp::object::{ElementName, EppObject};
|
||||
use crate::epp::object::{ElementName, EppObject, StringValue};
|
||||
use crate::epp::request::Command;
|
||||
use crate::epp::response::CommandResponse;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Type that represents the <epp> request for registry <poll op="req"> command
|
||||
|
@ -15,7 +16,7 @@ use serde::{Deserialize, Serialize};
|
|||
///
|
||||
/// use epp_client::config::{EppClientConfig, EppClientConnection};
|
||||
/// use epp_client::EppClient;
|
||||
/// use epp_client::epp::{EppMessagePoll, EppMessagePollResponse};
|
||||
/// use epp_client::message::poll::{EppMessagePoll, EppMessagePollResponse};
|
||||
/// use epp_client::epp::generate_client_tr_id;
|
||||
///
|
||||
/// #[tokio::main]
|
||||
|
@ -52,25 +53,69 @@ use serde::{Deserialize, Serialize};
|
|||
/// client.logout().await.unwrap();
|
||||
/// }
|
||||
/// ```
|
||||
pub type EppMessagePoll = EppObject<Command<MessagePoll>>;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, ElementName)]
|
||||
#[element_name(name = "poll")]
|
||||
/// Type for EPP XML <poll> command for message poll
|
||||
pub struct MessagePoll {
|
||||
/// The type of operation to perform
|
||||
/// The value is "req" for message polling
|
||||
op: String,
|
||||
}
|
||||
pub type EppMessagePoll = EppObject<Command<MessagePollRequest>>;
|
||||
|
||||
impl EppMessagePoll {
|
||||
/// Creates a new EppObject for <poll> req corresponding to the <epp> tag in EPP XML
|
||||
pub fn new(client_tr_id: &str) -> EppMessagePoll {
|
||||
EppObject::build(Command::<MessagePoll>::new(
|
||||
MessagePoll {
|
||||
EppObject::build(Command::<MessagePollRequest>::new(
|
||||
MessagePollRequest {
|
||||
op: "req".to_string(),
|
||||
},
|
||||
client_tr_id,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
/// Type that represents the <epp> tag for the EPP XML message poll response
|
||||
pub type EppMessagePollResponse = EppObject<CommandResponse<MessagePollResponse>>;
|
||||
|
||||
// Request
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, ElementName)]
|
||||
#[element_name(name = "poll")]
|
||||
/// Type for EPP XML <poll> command for message poll
|
||||
pub struct MessagePollRequest {
|
||||
/// The type of operation to perform
|
||||
/// The value is "req" for message polling
|
||||
op: String,
|
||||
}
|
||||
|
||||
// Response
|
||||
|
||||
/// Type that represents the <trnData> tag for message poll response
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct MessageDomainTransferData {
|
||||
/// XML namespace for message response data
|
||||
#[serde(rename = "xmlns:obj", alias = "xmlns")]
|
||||
xmlns: String,
|
||||
/// The name of the domain under transfer
|
||||
#[serde(rename = "obj:name", alias = "name")]
|
||||
pub name: StringValue,
|
||||
/// The domain transfer status
|
||||
#[serde(rename = "obj:trStatus", alias = "trStatus")]
|
||||
pub transfer_status: StringValue,
|
||||
/// The epp user who requested the transfer
|
||||
#[serde(rename = "obj:reID", alias = "reID")]
|
||||
pub requester_id: StringValue,
|
||||
/// The date of the transfer request
|
||||
#[serde(rename = "obj:reDate", alias = "reDate")]
|
||||
pub requested_at: StringValue,
|
||||
/// The epp user who should acknowledge the transfer request
|
||||
#[serde(rename = "obj:acID", alias = "acID")]
|
||||
pub ack_id: StringValue,
|
||||
/// The date by which the transfer request should be acknowledged
|
||||
#[serde(rename = "obj:acDate", alias = "acDate")]
|
||||
pub ack_by: StringValue,
|
||||
/// The domain expiry date
|
||||
#[serde(rename = "obj:exDate", alias = "exDate")]
|
||||
pub expiring_at: StringValue,
|
||||
}
|
||||
|
||||
/// Type that represents the <resData> tag for message poll response
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct MessagePollResponse {
|
||||
/// Data under the <trnData> tag
|
||||
#[serde(rename = "obj:trnData", alias = "trnData")]
|
||||
pub message_data: MessageDomainTransferData,
|
||||
}
|
|
@ -33,6 +33,7 @@ mod response {
|
|||
use crate::host::info::EppHostInfoResponse;
|
||||
use crate::host::update::EppHostUpdateResponse;
|
||||
use crate::message::ack::EppMessageAckResponse;
|
||||
use crate::message::poll::EppMessagePollResponse;
|
||||
|
||||
const SVTRID: &str = "RO-6879-1627224678242975";
|
||||
const SUCCESS_MSG: &str = "Command completed successfully";
|
||||
|
|
|
@ -38,6 +38,7 @@ mod request {
|
|||
use crate::host::update::HostAddRemove;
|
||||
use crate::host::update::HostChangeInfo;
|
||||
use crate::message::ack::EppMessageAck;
|
||||
use crate::message::poll::EppMessagePoll;
|
||||
use chrono::{DateTime, NaiveDate};
|
||||
use std::str::FromStr;
|
||||
|
||||
|
|
Loading…
Reference in New Issue