diff --git a/epp-client/src/domain.rs b/epp-client/src/domain.rs index 609acc0..cd7f494 100644 --- a/epp-client/src/domain.rs +++ b/epp-client/src/domain.rs @@ -4,3 +4,4 @@ pub mod delete; pub mod info; pub mod renew; pub mod transfer; +pub mod update; diff --git a/epp-client/src/epp/request/domain/update.rs b/epp-client/src/domain/update.rs similarity index 90% rename from epp-client/src/epp/request/domain/update.rs rename to epp-client/src/domain/update.rs index 04c6f70..5fa9bd6 100644 --- a/epp-client/src/epp/request/domain/update.rs +++ b/epp-client/src/domain/update.rs @@ -5,6 +5,7 @@ use epp_client_macros::*; use crate::epp::object::data::{DomainAuthInfo, DomainContact, DomainStatus, HostList}; 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}; @@ -19,7 +20,7 @@ use serde::{Deserialize, Serialize}; /// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::epp::object::data::{DomainStatus, DomainContact}; -/// use epp_client::epp::{EppDomainUpdate, EppDomainUpdateResponse, DomainAddRemove}; +/// use epp_client::domain::update::{EppDomainUpdate, EppDomainUpdateResponse, DomainAddRemove}; /// use epp_client::epp::generate_client_tr_id; /// /// #[tokio::main] @@ -80,7 +81,44 @@ use serde::{Deserialize, Serialize}; /// client.logout().await.unwrap(); /// } /// ``` -pub type EppDomainUpdate = EppObject>; +pub type EppDomainUpdate = EppObject>; + +impl EppDomainUpdate { + /// Creates a new EppObject for domain update corresponding to the <epp> tag in EPP XML + /// with the <ns> tag containing <hostObj> tags + pub fn new(name: &str, client_tr_id: &str) -> EppDomainUpdate { + EppObject::build(Command::::new( + DomainUpdateRequest { + domain: DomainUpdateRequestData { + xmlns: EPP_DOMAIN_XMLNS.to_string(), + name: name.into(), + add: None, + remove: None, + change_info: None, + }, + }, + client_tr_id, + )) + } + + /// Sets the data for the <chg> tag + pub fn info(&mut self, info: DomainChangeInfo) { + self.data.command.domain.change_info = Some(info); + } + + /// Sets the data for the <add> tag + pub fn add(&mut self, add: DomainAddRemove) { + self.data.command.domain.add = Some(add); + } + + /// Sets the data for the <rem> tag + pub fn remove(&mut self, remove: DomainAddRemove) { + self.data.command.domain.remove = Some(remove); + } +} + +/// Type that represents the <epp> tag for the EPP XML domain update response +pub type EppDomainUpdateResponse = EppCommandResponse; /// Type for elements under the <chg> tag for domain update #[derive(Serialize, Deserialize, Debug)] @@ -110,7 +148,7 @@ pub struct DomainAddRemove { /// Type for elements under the <update> tag for domain update #[derive(Serialize, Deserialize, Debug)] -pub struct DomainUpdateData { +pub struct DomainUpdateRequestData { /// XML namespace for domain commands #[serde(rename = "xmlns:domain", alias = "xmlns")] pub xmlns: String, @@ -133,41 +171,7 @@ pub struct DomainUpdateData { #[derive(Serialize, Deserialize, Debug, ElementName)] #[element_name(name = "update")] /// Type for EPP XML <update> command for domains -pub struct DomainUpdate { +pub struct DomainUpdateRequest { #[serde(rename = "domain:update", alias = "update")] - pub domain: DomainUpdateData, -} - -impl EppDomainUpdate { - /// Creates a new EppObject for domain update corresponding to the <epp> tag in EPP XML - /// with the <ns> tag containing <hostObj> tags - pub fn new(name: &str, client_tr_id: &str) -> EppDomainUpdate { - EppObject::build(Command::::new( - DomainUpdate { - domain: DomainUpdateData { - xmlns: EPP_DOMAIN_XMLNS.to_string(), - name: name.into(), - add: None, - remove: None, - change_info: None, - }, - }, - client_tr_id, - )) - } - - /// Sets the data for the <chg> tag - pub fn info(&mut self, info: DomainChangeInfo) { - self.data.command.domain.change_info = Some(info); - } - - /// Sets the data for the <add> tag - pub fn add(&mut self, add: DomainAddRemove) { - self.data.command.domain.add = Some(add); - } - - /// Sets the data for the <rem> tag - pub fn remove(&mut self, remove: DomainAddRemove) { - self.data.command.domain.remove = Some(remove); - } + pub domain: DomainUpdateRequestData, } diff --git a/epp-client/src/epp.rs b/epp-client/src/epp.rs index c2c4917..8747f38 100644 --- a/epp-client/src/epp.rs +++ b/epp-client/src/epp.rs @@ -12,7 +12,6 @@ pub use request::contact::info::*; pub use request::contact::update::*; pub use request::domain::rgp::report::*; pub use request::domain::rgp::request::*; -pub use request::domain::update::*; pub use request::host::check::*; pub use request::host::create::*; pub use request::host::delete::*; @@ -28,7 +27,6 @@ pub use response::contact::info::*; pub use response::contact::update::*; pub use response::domain::rgp::report::*; pub use response::domain::rgp::request::*; -pub use response::domain::update::*; pub use response::host::check::*; pub use response::host::create::*; pub use response::host::delete::*; diff --git a/epp-client/src/epp/request/domain.rs b/epp-client/src/epp/request/domain.rs index 7effcd4..5908bf1 100644 --- a/epp-client/src/epp/request/domain.rs +++ b/epp-client/src/epp/request/domain.rs @@ -1,4 +1,3 @@ //! Types for EPP domain requests pub mod rgp; -pub mod update; diff --git a/epp-client/src/epp/request/domain/rgp/report.rs b/epp-client/src/epp/request/domain/rgp/report.rs index f6b17ff..e9227e0 100644 --- a/epp-client/src/epp/request/domain/rgp/report.rs +++ b/epp-client/src/epp/request/domain/rgp/report.rs @@ -2,8 +2,8 @@ use epp_client_macros::*; +use crate::domain::update::{DomainChangeInfo, DomainUpdateRequest, DomainUpdateRequestData}; use crate::epp::object::{ElementName, EppObject, StringValue}; -use crate::epp::request::domain::update::{DomainChangeInfo, DomainUpdate, DomainUpdateData}; use crate::epp::request::{CommandWithExtension, Extension}; use crate::epp::xml::{EPP_DOMAIN_RGP_EXT_XMLNS, EPP_DOMAIN_XMLNS}; use chrono::{DateTime, SecondsFormat, Utc}; @@ -81,7 +81,7 @@ use serde::{Deserialize, Serialize}; /// } /// ``` pub type EppDomainRgpRestoreReport = - EppObject>; + EppObject>; /// Type corresponding to the <report> section in the EPP rgp restore extension #[derive(Serialize, Deserialize, Debug)] @@ -147,9 +147,9 @@ impl EppDomainRgpRestoreReport { ) -> EppDomainRgpRestoreReport { let statements = statements.iter().map(|&s| s.into()).collect(); - let command = CommandWithExtension:: { - command: DomainUpdate { - domain: DomainUpdateData { + let command = CommandWithExtension:: { + command: DomainUpdateRequest { + domain: DomainUpdateRequestData { xmlns: EPP_DOMAIN_XMLNS.to_string(), name: name.into(), add: None, diff --git a/epp-client/src/epp/request/domain/rgp/request.rs b/epp-client/src/epp/request/domain/rgp/request.rs index 6149ecd..80b98a8 100644 --- a/epp-client/src/epp/request/domain/rgp/request.rs +++ b/epp-client/src/epp/request/domain/rgp/request.rs @@ -2,8 +2,8 @@ use epp_client_macros::*; +use crate::domain::update::{DomainChangeInfo, DomainUpdateRequest, DomainUpdateRequestData}; use crate::epp::object::{ElementName, EppObject}; -use crate::epp::request::domain::update::{DomainChangeInfo, DomainUpdate, DomainUpdateData}; use crate::epp::request::{CommandWithExtension, Extension}; use crate::epp::xml::{EPP_DOMAIN_RGP_EXT_XMLNS, EPP_DOMAIN_XMLNS}; use serde::{Deserialize, Serialize}; @@ -58,7 +58,7 @@ use serde::{Deserialize, Serialize}; /// } /// ``` pub type EppDomainRgpRestoreRequest = - EppObject>; + EppObject>; /// Type corresponding to the <restore> tag for an rgp restore request #[derive(Serialize, Deserialize, Debug)] @@ -82,9 +82,9 @@ pub struct RgpRestoreRequest { impl EppDomainRgpRestoreRequest { /// Creates a new EppObject for domain rgp restore request corresponding to the <epp> tag in EPP XML pub fn new(name: &str, client_tr_id: &str) -> EppDomainRgpRestoreRequest { - let command = CommandWithExtension:: { - command: DomainUpdate { - domain: DomainUpdateData { + let command = CommandWithExtension:: { + command: DomainUpdateRequest { + domain: DomainUpdateRequestData { xmlns: EPP_DOMAIN_XMLNS.to_string(), name: name.into(), add: None, diff --git a/epp-client/src/epp/response/domain.rs b/epp-client/src/epp/response/domain.rs index 3922cb8..1ff5a7c 100644 --- a/epp-client/src/epp/response/domain.rs +++ b/epp-client/src/epp/response/domain.rs @@ -1,4 +1,3 @@ //! Types for EPP domain responses pub mod rgp; -pub mod update; diff --git a/epp-client/src/epp/response/domain/update.rs b/epp-client/src/epp/response/domain/update.rs deleted file mode 100644 index 716ced3..0000000 --- a/epp-client/src/epp/response/domain/update.rs +++ /dev/null @@ -1,6 +0,0 @@ -//! Types for EPP domain update response - -use crate::epp::response::EppCommandResponse; - -/// Type that represents the <epp> tag for the EPP XML domain update response -pub type EppDomainUpdateResponse = EppCommandResponse; diff --git a/epp-client/src/tests/de.rs b/epp-client/src/tests/de.rs index 412cccc..01c66df 100644 --- a/epp-client/src/tests/de.rs +++ b/epp-client/src/tests/de.rs @@ -13,6 +13,7 @@ mod response { use crate::domain::transfer::EppDomainTransferQueryResponse; use crate::domain::transfer::EppDomainTransferRejectResponse; use crate::domain::transfer::EppDomainTransferRequestResponse; + use crate::domain::update::EppDomainUpdateResponse; 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 9276ade..362fc31 100644 --- a/epp-client/src/tests/se.rs +++ b/epp-client/src/tests/se.rs @@ -13,6 +13,9 @@ mod request { use crate::domain::transfer::EppDomainTransferQuery; use crate::domain::transfer::EppDomainTransferReject; use crate::domain::transfer::EppDomainTransferRequest; + use crate::domain::update::DomainAddRemove; + use crate::domain::update::DomainChangeInfo; + use crate::domain::update::EppDomainUpdate; use crate::epp::object::data::{ Address, ContactStatus, DomainAuthInfo, DomainContact, DomainStatus, HostAddr, HostAttr, HostStatus, Phone, PostalInfo,