diff --git a/epp-client/src/epp.rs b/epp-client/src/epp.rs index 3908599..74875a7 100644 --- a/epp-client/src/epp.rs +++ b/epp-client/src/epp.rs @@ -5,12 +5,10 @@ pub mod request; pub mod response; pub mod xml; -pub use request::host::info::*; pub use request::host::update::*; pub use request::message::ack::*; pub use request::message::poll::*; -pub use response::host::info::*; pub use response::host::update::*; pub use response::message::ack::*; pub use response::message::poll::*; diff --git a/epp-client/src/epp/request/host.rs b/epp-client/src/epp/request/host.rs index aa1f14b..083e26b 100644 --- a/epp-client/src/epp/request/host.rs +++ b/epp-client/src/epp/request/host.rs @@ -1,4 +1,3 @@ //! Types for EPP host requests -pub mod info; pub mod update; diff --git a/epp-client/src/epp/response/host.rs b/epp-client/src/epp/response/host.rs index f689760..5047054 100644 --- a/epp-client/src/epp/response/host.rs +++ b/epp-client/src/epp/response/host.rs @@ -1,4 +1,3 @@ //! Types for EPP host responses -pub mod info; pub mod update; diff --git a/epp-client/src/epp/response/host/info.rs b/epp-client/src/epp/response/host/info.rs deleted file mode 100644 index 071ed66..0000000 --- a/epp-client/src/epp/response/host/info.rs +++ /dev/null @@ -1,54 +0,0 @@ -//! Types for EPP host info response - -use serde::{Deserialize, Serialize}; - -use crate::epp::object::data::{HostAddr, HostStatus}; -use crate::epp::object::{EppObject, StringValue}; -use crate::epp::response::CommandResponse; - -/// Type that represents the <epp> tag for the EPP XML host info response -pub type EppHostInfoResponse = EppObject>; - -/// Type that represents the <infData> tag for host info response -#[derive(Serialize, Deserialize, Debug)] -pub struct HostInfoData { - /// XML namespace for host response data - #[serde(rename = "xmlns:host")] - xmlns: String, - /// The host name - pub name: StringValue, - /// The host ROID - pub roid: StringValue, - /// The list of host statuses - #[serde(rename = "status")] - pub statuses: Vec, - /// The list of host IP addresses - #[serde(rename = "addr")] - pub addresses: Vec, - /// The epp user to whom the host belongs - #[serde(rename = "clID")] - pub client_id: StringValue, - /// THe epp user that created the host - #[serde(rename = "crID")] - pub creator_id: StringValue, - /// The host creation date - #[serde(rename = "crDate")] - pub created_at: StringValue, - /// The epp user that last updated the host - #[serde(rename = "upID")] - pub updater_id: Option, - /// The host last update date - #[serde(rename = "upDate")] - pub updated_at: Option, - /// The host transfer date - #[serde(rename = "trDate")] - pub transferred_at: Option, -} - -/// Type that represents the <resData> tag for host info response -#[derive(Serialize, Deserialize, Debug)] -pub struct HostInfoResult { - /// Data under the <infData> tag - #[serde(rename = "infData")] - pub info_data: HostInfoData, -} diff --git a/epp-client/src/host.rs b/epp-client/src/host.rs index d08059a..770e8c7 100644 --- a/epp-client/src/host.rs +++ b/epp-client/src/host.rs @@ -1,3 +1,4 @@ pub mod check; pub mod create; pub mod delete; +pub mod info; diff --git a/epp-client/src/epp/request/host/info.rs b/epp-client/src/host/info.rs similarity index 56% rename from epp-client/src/epp/request/host/info.rs rename to epp-client/src/host/info.rs index 05d1091..bf2beba 100644 --- a/epp-client/src/epp/request/host/info.rs +++ b/epp-client/src/host/info.rs @@ -2,8 +2,10 @@ use epp_client_macros::*; +use crate::epp::object::data::{HostAddr, HostStatus}; use crate::epp::object::{ElementName, EppObject, StringValue}; use crate::epp::request::Command; +use crate::epp::response::CommandResponse; use crate::epp::xml::EPP_HOST_XMLNS; use serde::{Deserialize, Serialize}; @@ -16,7 +18,7 @@ use serde::{Deserialize, Serialize}; /// /// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; -/// use epp_client::epp::{EppHostInfo, EppHostInfoResponse}; +/// use epp_client::host::info::{EppHostInfo, EppHostInfoResponse}; /// use epp_client::epp::generate_client_tr_id; /// /// #[tokio::main] @@ -53,11 +55,31 @@ use serde::{Deserialize, Serialize}; /// client.logout().await.unwrap(); /// } /// ``` -pub type EppHostInfo = EppObject>; +pub type EppHostInfo = EppObject>; + +impl EppHostInfo { + /// Creates a new EppObject for host info corresponding to the <epp> tag in EPP XML + pub fn new(name: &str, client_tr_id: &str) -> EppHostInfo { + EppObject::build(Command::::new( + HostInfoRequest { + info: HostInfoRequestData { + xmlns: EPP_HOST_XMLNS.to_string(), + name: name.into(), + }, + }, + client_tr_id, + )) + } +} + +/// Type that represents the <epp> tag for the EPP XML host info response +pub type EppHostInfoResponse = EppObject>; + +// Request /// Type for data under the host <info> tag #[derive(Serialize, Deserialize, Debug)] -pub struct HostInfoData { +pub struct HostInfoRequestData { /// XML namespace for host commands #[serde(rename = "xmlns:host", alias = "xmlns")] xmlns: String, @@ -69,23 +91,54 @@ pub struct HostInfoData { #[derive(Serialize, Deserialize, Debug, ElementName)] #[element_name(name = "info")] /// Type for EPP XML <info> command for hosts -pub struct HostInfo { +pub struct HostInfoRequest { /// The instance holding the data for the host query #[serde(rename = "host:info", alias = "info")] - info: HostInfoData, + info: HostInfoRequestData, } -impl EppHostInfo { - /// Creates a new EppObject for host info corresponding to the <epp> tag in EPP XML - pub fn new(name: &str, client_tr_id: &str) -> EppHostInfo { - EppObject::build(Command::::new( - HostInfo { - info: HostInfoData { - xmlns: EPP_HOST_XMLNS.to_string(), - name: name.into(), - }, - }, - client_tr_id, - )) - } +// Response + +/// Type that represents the <infData> tag for host info response +#[derive(Serialize, Deserialize, Debug)] +pub struct HostInfoResponseData { + /// XML namespace for host response data + #[serde(rename = "xmlns:host")] + xmlns: String, + /// The host name + pub name: StringValue, + /// The host ROID + pub roid: StringValue, + /// The list of host statuses + #[serde(rename = "status")] + pub statuses: Vec, + /// The list of host IP addresses + #[serde(rename = "addr")] + pub addresses: Vec, + /// The epp user to whom the host belongs + #[serde(rename = "clID")] + pub client_id: StringValue, + /// THe epp user that created the host + #[serde(rename = "crID")] + pub creator_id: StringValue, + /// The host creation date + #[serde(rename = "crDate")] + pub created_at: StringValue, + /// The epp user that last updated the host + #[serde(rename = "upID")] + pub updater_id: Option, + /// The host last update date + #[serde(rename = "upDate")] + pub updated_at: Option, + /// The host transfer date + #[serde(rename = "trDate")] + pub transferred_at: Option, +} + +/// Type that represents the <resData> tag for host info response +#[derive(Serialize, Deserialize, Debug)] +pub struct HostInfoResponse { + /// Data under the <infData> tag + #[serde(rename = "infData")] + pub info_data: HostInfoResponseData, } diff --git a/epp-client/src/tests/de.rs b/epp-client/src/tests/de.rs index 288d3b7..91e6cac 100644 --- a/epp-client/src/tests/de.rs +++ b/epp-client/src/tests/de.rs @@ -30,6 +30,7 @@ mod response { use crate::host::check::EppHostCheckResponse; use crate::host::create::EppHostCreateResponse; use crate::host::delete::EppHostDeleteResponse; + use crate::host::info::EppHostInfoResponse; const SVTRID: &str = "RO-6879-1627224678242975"; const SUCCESS_MSG: &str = "Command completed successfully"; diff --git a/epp-client/src/tests/se.rs b/epp-client/src/tests/se.rs index 32ae041..cd7a094 100644 --- a/epp-client/src/tests/se.rs +++ b/epp-client/src/tests/se.rs @@ -33,6 +33,7 @@ mod request { use crate::host::check::EppHostCheck; use crate::host::create::EppHostCreate; use crate::host::delete::EppHostDelete; + use crate::host::info::EppHostInfo; use chrono::{DateTime, NaiveDate}; use std::str::FromStr;