From f163d35a45edd0edec3af6940cfc2ce3c59a6444 Mon Sep 17 00:00:00 2001 From: Nicholas Rempel Date: Fri, 26 Nov 2021 10:17:29 -0800 Subject: [PATCH] Refactor contact delete models --- epp-client/src/contact.rs | 1 + .../src/{epp/request => }/contact/delete.rs | 45 +++++++++++-------- epp-client/src/epp.rs | 2 - epp-client/src/epp/request/contact.rs | 1 - epp-client/src/epp/response/contact.rs | 1 - epp-client/src/epp/response/contact/delete.rs | 6 --- epp-client/src/tests/de.rs | 1 + epp-client/src/tests/se.rs | 1 + 8 files changed, 29 insertions(+), 29 deletions(-) rename epp-client/src/{epp/request => }/contact/delete.rs (80%) delete mode 100644 epp-client/src/epp/response/contact/delete.rs diff --git a/epp-client/src/contact.rs b/epp-client/src/contact.rs index 3aa3078..d08059a 100644 --- a/epp-client/src/contact.rs +++ b/epp-client/src/contact.rs @@ -1,2 +1,3 @@ pub mod check; pub mod create; +pub mod delete; diff --git a/epp-client/src/epp/request/contact/delete.rs b/epp-client/src/contact/delete.rs similarity index 80% rename from epp-client/src/epp/request/contact/delete.rs rename to epp-client/src/contact/delete.rs index d6f4ffc..a75f0f7 100644 --- a/epp-client/src/epp/request/contact/delete.rs +++ b/epp-client/src/contact/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_CONTACT_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::{EppContactDelete, EppContactDeleteResponse}; +/// use epp_client::contact::delete::{EppContactDelete, EppContactDeleteResponse}; /// use epp_client::epp::generate_client_tr_id; /// /// #[tokio::main] @@ -56,11 +57,31 @@ use serde::{Deserialize, Serialize}; /// client.logout().await.unwrap(); /// } /// ``` -pub type EppContactDelete = EppObject>; +pub type EppContactDelete = EppObject>; + +impl EppContactDelete { + /// Creates a new EppObject for contact delete corresponding to the <epp> tag in EPP XML + pub fn new(id: &str, client_tr_id: &str) -> EppContactDelete { + let contact_delete = ContactDeleteRequest { + contact: ContactDeleteRequestData { + xmlns: EPP_CONTACT_XMLNS.to_string(), + id: id.into(), + }, + }; + + EppObject::build(Command::::new( + contact_delete, + client_tr_id, + )) + } +} + +/// Type that represents the <epp> tag for the EPP XML contact delete response +pub type EppContactDeleteResponse = EppCommandResponse; /// Type containing the data for the <delete> tag for contacts #[derive(Serialize, Deserialize, Debug)] -pub struct ContactDeleteData { +pub struct ContactDeleteRequestData { /// XML namespace for the <delete> command for contacts #[serde(rename = "xmlns:contact", alias = "xmlns")] xmlns: String, @@ -72,22 +93,8 @@ pub struct ContactDeleteData { #[derive(Serialize, Deserialize, Debug, ElementName)] #[element_name(name = "delete")] /// The <delete> type for the contact delete EPP command -pub struct ContactDelete { +pub struct ContactDeleteRequest { #[serde(rename = "contact:delete", alias = "delete")] /// The data for the <delete> tag for a contact delete command - contact: ContactDeleteData, -} - -impl EppContactDelete { - /// Creates a new EppObject for contact delete corresponding to the <epp> tag in EPP XML - pub fn new(id: &str, client_tr_id: &str) -> EppContactDelete { - let contact_delete = ContactDelete { - contact: ContactDeleteData { - xmlns: EPP_CONTACT_XMLNS.to_string(), - id: id.into(), - }, - }; - - EppObject::build(Command::::new(contact_delete, client_tr_id)) - } + contact: ContactDeleteRequestData, } diff --git a/epp-client/src/epp.rs b/epp-client/src/epp.rs index 88485d2..f43b23d 100644 --- a/epp-client/src/epp.rs +++ b/epp-client/src/epp.rs @@ -5,7 +5,6 @@ pub mod request; pub mod response; pub mod xml; -pub use request::contact::delete::*; pub use request::contact::info::*; pub use request::contact::update::*; pub use request::host::check::*; @@ -16,7 +15,6 @@ pub use request::host::update::*; pub use request::message::ack::*; pub use request::message::poll::*; -pub use response::contact::delete::*; pub use response::contact::info::*; pub use response::contact::update::*; pub use response::host::check::*; diff --git a/epp-client/src/epp/request/contact.rs b/epp-client/src/epp/request/contact.rs index bc3a47b..50c5aa2 100644 --- a/epp-client/src/epp/request/contact.rs +++ b/epp-client/src/epp/request/contact.rs @@ -1,5 +1,4 @@ //! Types for EPP contact requests -pub mod delete; pub mod info; pub mod update; diff --git a/epp-client/src/epp/response/contact.rs b/epp-client/src/epp/response/contact.rs index 98cf10e..856167c 100644 --- a/epp-client/src/epp/response/contact.rs +++ b/epp-client/src/epp/response/contact.rs @@ -1,5 +1,4 @@ //! Types for EPP contact responses -pub mod delete; pub mod info; pub mod update; diff --git a/epp-client/src/epp/response/contact/delete.rs b/epp-client/src/epp/response/contact/delete.rs deleted file mode 100644 index ec4833e..0000000 --- a/epp-client/src/epp/response/contact/delete.rs +++ /dev/null @@ -1,6 +0,0 @@ -//! Types for EPP contact delete response - -use crate::epp::response::EppCommandResponse; - -/// Type that represents the <epp> tag for the EPP XML contact delete response -pub type EppContactDeleteResponse = EppCommandResponse; diff --git a/epp-client/src/tests/de.rs b/epp-client/src/tests/de.rs index 24e6f71..e32767e 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::contact::check::EppContactCheckResponse; use crate::contact::create::EppContactCreateResponse; + use crate::contact::delete::EppContactDeleteResponse; use crate::domain::check::EppDomainCheckResponse; use crate::domain::create::EppDomainCreateResponse; use crate::domain::delete::EppDomainDeleteResponse; diff --git a/epp-client/src/tests/se.rs b/epp-client/src/tests/se.rs index fa5a447..40e6f5b 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::contact::check::EppContactCheck; use crate::contact::create::EppContactCreate; + use crate::contact::delete::EppContactDelete; use crate::domain::check::EppDomainCheck; use crate::domain::create::EppDomainCreate; use crate::domain::delete::EppDomainDelete;