From e5f5ba0695b556b54e9ea5a0c4c688045b824721 Mon Sep 17 00:00:00 2001 From: Nick Rempel Date: Thu, 25 Nov 2021 21:28:03 -0800 Subject: [PATCH] Refactor domain delete models --- epp-client/src/domain.rs | 1 + .../src/{epp/request => }/domain/delete.rs | 44 ++++++++++--------- epp-client/src/epp.rs | 2 - epp-client/src/epp/request/domain.rs | 1 - epp-client/src/epp/response/domain.rs | 1 - epp-client/src/epp/response/domain/delete.rs | 6 --- epp-client/src/tests/de.rs | 1 + epp-client/src/tests/se.rs | 1 + 8 files changed, 27 insertions(+), 30 deletions(-) rename epp-client/src/{epp/request => }/domain/delete.rs (82%) delete mode 100644 epp-client/src/epp/response/domain/delete.rs diff --git a/epp-client/src/domain.rs b/epp-client/src/domain.rs index 3aa3078..d08059a 100644 --- a/epp-client/src/domain.rs +++ b/epp-client/src/domain.rs @@ -1,2 +1,3 @@ pub mod check; pub mod create; +pub mod delete; diff --git a/epp-client/src/epp/request/domain/delete.rs b/epp-client/src/domain/delete.rs similarity index 82% rename from epp-client/src/epp/request/domain/delete.rs rename to epp-client/src/domain/delete.rs index aa15b1d..e28b5ea 100644 --- a/epp-client/src/epp/request/domain/delete.rs +++ b/epp-client/src/domain/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_DOMAIN_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::{EppDomainDelete, EppDomainDeleteResponse}; +/// use epp_client::domain::delete::{EppDomainDelete, EppDomainDeleteResponse}; /// use epp_client::epp::generate_client_tr_id; /// /// #[tokio::main] @@ -53,11 +54,29 @@ use serde::{Deserialize, Serialize}; /// client.logout().await.unwrap(); /// } /// ``` -pub type EppDomainDelete = EppObject>; +pub type EppDomainDelete = EppObject>; + +impl EppDomainDelete { + /// Creates a new EppObject for domain delete corresponding to the <epp> tag in EPP XML + pub fn new(name: &str, client_tr_id: &str) -> EppDomainDelete { + EppObject::build(Command::::new( + DomainDeleteRequest { + domain: DomainDeleteRequestData { + xmlns: EPP_DOMAIN_XMLNS.to_string(), + name: name.into(), + }, + }, + client_tr_id, + )) + } +} + +/// Type that represents the <epp> tag for the EPP XML domain delete response +pub type EppDomainDeleteResponse = EppCommandResponse; /// Type for <name> element under the domain <delete> tag #[derive(Serialize, Deserialize, Debug)] -pub struct DomainDeleteData { +pub struct DomainDeleteRequestData { /// XML namespace for domain commands #[serde(rename = "xmlns:domain", alias = "xmlns")] xmlns: String, @@ -69,23 +88,8 @@ pub struct DomainDeleteData { #[derive(Serialize, Deserialize, Debug, ElementName)] #[element_name(name = "delete")] /// Type for EPP XML <delete> command for domains -pub struct DomainDelete { +pub struct DomainDeleteRequest { /// The data under the <delete> tag for domain deletion #[serde(rename = "domain:delete", alias = "delete")] - domain: DomainDeleteData, -} - -impl EppDomainDelete { - /// Creates a new EppObject for domain delete corresponding to the <epp> tag in EPP XML - pub fn new(name: &str, client_tr_id: &str) -> EppDomainDelete { - EppObject::build(Command::::new( - DomainDelete { - domain: DomainDeleteData { - xmlns: EPP_DOMAIN_XMLNS.to_string(), - name: name.into(), - }, - }, - client_tr_id, - )) - } + domain: DomainDeleteRequestData, } diff --git a/epp-client/src/epp.rs b/epp-client/src/epp.rs index 3512707..e93c07c 100644 --- a/epp-client/src/epp.rs +++ b/epp-client/src/epp.rs @@ -10,7 +10,6 @@ pub use request::contact::create::*; pub use request::contact::delete::*; pub use request::contact::info::*; pub use request::contact::update::*; -pub use request::domain::delete::*; pub use request::domain::info::*; pub use request::domain::renew::*; pub use request::domain::rgp::report::*; @@ -30,7 +29,6 @@ pub use response::contact::create::*; pub use response::contact::delete::*; pub use response::contact::info::*; pub use response::contact::update::*; -pub use response::domain::delete::*; pub use response::domain::info::*; pub use response::domain::renew::*; pub use response::domain::rgp::report::*; diff --git a/epp-client/src/epp/request/domain.rs b/epp-client/src/epp/request/domain.rs index f3ee577..eed4a33 100644 --- a/epp-client/src/epp/request/domain.rs +++ b/epp-client/src/epp/request/domain.rs @@ -1,6 +1,5 @@ //! Types for EPP domain requests -pub mod delete; pub mod info; pub mod renew; pub mod rgp; diff --git a/epp-client/src/epp/response/domain.rs b/epp-client/src/epp/response/domain.rs index 8d77b0c..eb8e74c 100644 --- a/epp-client/src/epp/response/domain.rs +++ b/epp-client/src/epp/response/domain.rs @@ -1,6 +1,5 @@ //! Types for EPP domain responses -pub mod delete; pub mod info; pub mod renew; pub mod rgp; diff --git a/epp-client/src/epp/response/domain/delete.rs b/epp-client/src/epp/response/domain/delete.rs deleted file mode 100644 index b127fbc..0000000 --- a/epp-client/src/epp/response/domain/delete.rs +++ /dev/null @@ -1,6 +0,0 @@ -//! Types for EPP domain delete response - -use crate::epp::response::EppCommandResponse; - -/// Type that represents the <epp> tag for the EPP XML domain delete response -pub type EppDomainDeleteResponse = EppCommandResponse; diff --git a/epp-client/src/tests/de.rs b/epp-client/src/tests/de.rs index 6fabc43..f6522d2 100644 --- a/epp-client/src/tests/de.rs +++ b/epp-client/src/tests/de.rs @@ -5,6 +5,7 @@ mod response { use super::super::CLTRID; use crate::domain::check::EppDomainCheckResponse; use crate::domain::create::EppDomainCreateResponse; + use crate::domain::delete::EppDomainDeleteResponse; use crate::epp::response::ExpiryType; use crate::epp::response::Relative; use crate::epp::response::{ diff --git a/epp-client/src/tests/se.rs b/epp-client/src/tests/se.rs index 58f62be..504e390 100644 --- a/epp-client/src/tests/se.rs +++ b/epp-client/src/tests/se.rs @@ -5,6 +5,7 @@ mod request { use super::super::CLTRID; use crate::domain::check::EppDomainCheck; use crate::domain::create::EppDomainCreate; + use crate::domain::delete::EppDomainDelete; use crate::epp::object::data::{ Address, ContactStatus, DomainAuthInfo, DomainContact, DomainStatus, HostAddr, HostAttr, HostStatus, Phone, PostalInfo,