diff --git a/epp-client/src/epp.rs b/epp-client/src/epp.rs index 41af5e4..3908599 100644 --- a/epp-client/src/epp.rs +++ b/epp-client/src/epp.rs @@ -5,13 +5,11 @@ pub mod request; pub mod response; pub mod xml; -pub use request::host::delete::*; pub use request::host::info::*; pub use request::host::update::*; pub use request::message::ack::*; pub use request::message::poll::*; -pub use response::host::delete::*; pub use response::host::info::*; pub use response::host::update::*; pub use response::message::ack::*; diff --git a/epp-client/src/epp/request/host.rs b/epp-client/src/epp/request/host.rs index 3e46c3c..aa1f14b 100644 --- a/epp-client/src/epp/request/host.rs +++ b/epp-client/src/epp/request/host.rs @@ -1,5 +1,4 @@ //! Types for EPP host requests -pub mod delete; 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 86b58b9..f689760 100644 --- a/epp-client/src/epp/response/host.rs +++ b/epp-client/src/epp/response/host.rs @@ -1,5 +1,4 @@ //! Types for EPP host responses -pub mod delete; pub mod info; pub mod update; diff --git a/epp-client/src/epp/response/host/delete.rs b/epp-client/src/epp/response/host/delete.rs deleted file mode 100644 index 3b3d9c8..0000000 --- a/epp-client/src/epp/response/host/delete.rs +++ /dev/null @@ -1,6 +0,0 @@ -//! Types for EPP host delete response - -use crate::epp::response::EppCommandResponse; - -/// Type that represents the <epp> tag for the EPP XML host delete response -pub type EppHostDeleteResponse = EppCommandResponse; diff --git a/epp-client/src/host.rs b/epp-client/src/host.rs index 3aa3078..d08059a 100644 --- a/epp-client/src/host.rs +++ b/epp-client/src/host.rs @@ -1,2 +1,3 @@ pub mod check; pub mod create; +pub mod delete; diff --git a/epp-client/src/epp/request/host/delete.rs b/epp-client/src/host/delete.rs similarity index 83% rename from epp-client/src/epp/request/host/delete.rs rename to epp-client/src/host/delete.rs index 49d8815..5932bad 100644 --- a/epp-client/src/epp/request/host/delete.rs +++ b/epp-client/src/host/delete.rs @@ -4,6 +4,7 @@ use epp_client_macros::*; use crate::epp::object::{ElementName, EppObject, StringValue}; use crate::epp::request::Command; +use crate::epp::response::EppCommandResponse; use crate::epp::xml::EPP_HOST_XMLNS; use serde::{Deserialize, Serialize}; @@ -16,7 +17,7 @@ use serde::{Deserialize, Serialize}; /// /// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; -/// use epp_client::epp::{EppHostDelete, EppHostDeleteResponse}; +/// use epp_client::host::delete::{EppHostDelete, EppHostDeleteResponse}; /// use epp_client::epp::generate_client_tr_id; /// /// #[tokio::main] @@ -53,11 +54,29 @@ use serde::{Deserialize, Serialize}; /// client.logout().await.unwrap(); /// } /// ``` -pub type EppHostDelete = EppObject>; +pub type EppHostDelete = EppObject>; + +impl EppHostDelete { + /// Creates a new EppObject for host delete corresponding to the <epp> tag in EPP XML + pub fn new(name: &str, client_tr_id: &str) -> EppHostDelete { + EppObject::build(Command::::new( + HostDeleteRequest { + host: HostDeleteRequestData { + xmlns: EPP_HOST_XMLNS.to_string(), + name: name.into(), + }, + }, + client_tr_id, + )) + } +} + +/// Type that represents the <epp> tag for the EPP XML host delete response +pub type EppHostDeleteResponse = EppCommandResponse; /// Type for data under the host <delete> tag #[derive(Serialize, Deserialize, Debug)] -pub struct HostDeleteData { +pub struct HostDeleteRequestData { /// XML namespace for host commands #[serde(rename = "xmlns:host", alias = "xmlns")] xmlns: String, @@ -69,23 +88,8 @@ pub struct HostDeleteData { #[derive(Serialize, Deserialize, Debug, ElementName)] #[element_name(name = "delete")] /// Type for EPP XML <delete> command for hosts -pub struct HostDelete { +pub struct HostDeleteRequest { /// The instance holding the data for the host to be deleted #[serde(rename = "host:delete", alias = "delete")] - host: HostDeleteData, -} - -impl EppHostDelete { - /// Creates a new EppObject for host delete corresponding to the <epp> tag in EPP XML - pub fn new(name: &str, client_tr_id: &str) -> EppHostDelete { - EppObject::build(Command::::new( - HostDelete { - host: HostDeleteData { - xmlns: EPP_HOST_XMLNS.to_string(), - name: name.into(), - }, - }, - client_tr_id, - )) - } + host: HostDeleteRequestData, } diff --git a/epp-client/src/tests/de.rs b/epp-client/src/tests/de.rs index 92e75cc..288d3b7 100644 --- a/epp-client/src/tests/de.rs +++ b/epp-client/src/tests/de.rs @@ -29,6 +29,7 @@ mod response { use crate::epp::*; use crate::host::check::EppHostCheckResponse; use crate::host::create::EppHostCreateResponse; + use crate::host::delete::EppHostDeleteResponse; 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 73f83c4..32ae041 100644 --- a/epp-client/src/tests/se.rs +++ b/epp-client/src/tests/se.rs @@ -32,6 +32,7 @@ mod request { use crate::epp::*; use crate::host::check::EppHostCheck; use crate::host::create::EppHostCreate; + use crate::host::delete::EppHostDelete; use chrono::{DateTime, NaiveDate}; use std::str::FromStr;