diff --git a/epp-client/src/contact.rs b/epp-client/src/contact.rs index d08059a..770e8c7 100644 --- a/epp-client/src/contact.rs +++ b/epp-client/src/contact.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/contact/info.rs b/epp-client/src/contact/info.rs similarity index 54% rename from epp-client/src/epp/request/contact/info.rs rename to epp-client/src/contact/info.rs index 440b013..9d1ab04 100644 --- a/epp-client/src/epp/request/contact/info.rs +++ b/epp-client/src/contact/info.rs @@ -2,9 +2,10 @@ use epp_client_macros::*; -use crate::epp::object::data::ContactAuthInfo; +use crate::epp::object::data::{ContactAuthInfo, ContactStatus, Phone, PostalInfo}; use crate::epp::object::{ElementName, EppObject, StringValue}; use crate::epp::request::Command; +use crate::epp::response::CommandResponse; use crate::epp::xml::EPP_CONTACT_XMLNS; use serde::{Deserialize, Serialize}; @@ -17,7 +18,7 @@ use serde::{Deserialize, Serialize}; /// /// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; -/// use epp_client::epp::{EppContactInfo, EppContactInfoResponse}; +/// use epp_client::contact::info::{EppContactInfo, EppContactInfoResponse}; /// use epp_client::epp::generate_client_tr_id; /// /// #[tokio::main] @@ -58,11 +59,34 @@ use serde::{Deserialize, Serialize}; /// client.logout().await.unwrap(); /// } /// ``` -pub type EppContactInfo = EppObject>; +pub type EppContactInfo = EppObject>; + +impl EppContactInfo { + /// Creates a new EppObject for contact info corresponding to the <epp> tag in EPP XML + pub fn new(id: &str, auth_password: &str, client_tr_id: &str) -> EppContactInfo { + let contact_info = ContactInfoRequest { + info: ContactInfoRequestData { + xmlns: EPP_CONTACT_XMLNS.to_string(), + id: id.into(), + auth_info: ContactAuthInfo::new(auth_password), + }, + }; + + EppObject::build(Command::::new( + contact_info, + client_tr_id, + )) + } +} + +/// Type that represents the <epp> tag for the EPP XML contact info response +pub type EppContactInfoResponse = EppObject>; + +// Request /// Type for elements under the contact <info> tag #[derive(Serialize, Deserialize, Debug)] -pub struct ContactInfoData { +pub struct ContactInfoRequestData { /// XML namespace for contact commands #[serde(rename = "xmlns:contact", alias = "contact")] xmlns: String, @@ -77,23 +101,63 @@ pub struct ContactInfoData { #[derive(Serialize, Deserialize, Debug, ElementName)] #[element_name(name = "info")] /// Type for EPP XML <info> command for contacts -pub struct ContactInfo { +pub struct ContactInfoRequest { /// Data for <info> command for contact #[serde(rename = "contact:info", alias = "info")] - info: ContactInfoData, + info: ContactInfoRequestData, } -impl EppContactInfo { - /// Creates a new EppObject for contact info corresponding to the <epp> tag in EPP XML - pub fn new(id: &str, auth_password: &str, client_tr_id: &str) -> EppContactInfo { - let contact_info = ContactInfo { - info: ContactInfoData { - xmlns: EPP_CONTACT_XMLNS.to_string(), - id: id.into(), - auth_info: ContactAuthInfo::new(auth_password), - }, - }; +// Response - EppObject::build(Command::::new(contact_info, client_tr_id)) - } +/// Type that represents the <infData> tag for contact check response +#[derive(Serialize, Deserialize, Debug)] +pub struct ContactInfoData { + /// XML namespace for contact response data + #[serde(rename = "xmlns:contact")] + xmlns: String, + /// The contact id + pub id: StringValue, + /// The contact ROID + pub roid: StringValue, + /// The list of contact statuses + #[serde(rename = "status")] + pub statuses: Vec, + /// The postal info for the contact + #[serde(rename = "postalInfo")] + pub postal_info: PostalInfo, + /// The voice data for the contact + pub voice: Phone, + /// The fax data for the contact + pub fax: Option, + /// The email for the contact + pub email: StringValue, + /// The epp user to whom the contact belongs + #[serde(rename = "clID")] + pub client_id: StringValue, + /// The epp user who created the contact + #[serde(rename = "crID")] + pub creator_id: StringValue, + /// The creation date + #[serde(rename = "crDate")] + pub created_at: StringValue, + /// The epp user who last updated the contact + #[serde(rename = "upID")] + pub updater_id: Option, + /// The last update date + #[serde(rename = "upDate")] + pub updated_at: Option, + /// The contact transfer date + #[serde(rename = "trDate")] + pub transferred_at: Option, + /// The contact auth info + #[serde(rename = "authInfo")] + pub auth_info: Option, +} + +/// Type that represents the <resData> tag for contact info response +#[derive(Serialize, Deserialize, Debug)] +pub struct ContactInfoResponse { + /// Data under the <infData> tag + #[serde(rename = "infData")] + pub info_data: ContactInfoData, } diff --git a/epp-client/src/epp.rs b/epp-client/src/epp.rs index f43b23d..5625e9d 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::info::*; pub use request::contact::update::*; pub use request::host::check::*; pub use request::host::create::*; @@ -15,7 +14,6 @@ pub use request::host::update::*; pub use request::message::ack::*; pub use request::message::poll::*; -pub use response::contact::info::*; pub use response::contact::update::*; pub use response::host::check::*; pub use response::host::create::*; diff --git a/epp-client/src/epp/request/contact.rs b/epp-client/src/epp/request/contact.rs index 50c5aa2..d36a0f9 100644 --- a/epp-client/src/epp/request/contact.rs +++ b/epp-client/src/epp/request/contact.rs @@ -1,4 +1,3 @@ //! Types for EPP contact requests -pub mod info; pub mod update; diff --git a/epp-client/src/epp/request/contact/update.rs b/epp-client/src/epp/request/contact/update.rs index a7fe9e1..8d5ded8 100644 --- a/epp-client/src/epp/request/contact/update.rs +++ b/epp-client/src/epp/request/contact/update.rs @@ -2,10 +2,10 @@ use epp_client_macros::*; +use crate::contact::info::EppContactInfoResponse; use crate::epp::object::data::{ContactAuthInfo, ContactStatus, Phone, PostalInfo}; use crate::epp::object::{ElementName, EppObject, StringValue}; use crate::epp::request::Command; -use crate::epp::response::contact::info::EppContactInfoResponse; use crate::epp::xml::EPP_CONTACT_XMLNS; use crate::error; use serde::{Deserialize, Serialize}; diff --git a/epp-client/src/epp/response/contact.rs b/epp-client/src/epp/response/contact.rs index 856167c..50c9a4a 100644 --- a/epp-client/src/epp/response/contact.rs +++ b/epp-client/src/epp/response/contact.rs @@ -1,4 +1,3 @@ //! Types for EPP contact responses -pub mod info; pub mod update; diff --git a/epp-client/src/epp/response/contact/info.rs b/epp-client/src/epp/response/contact/info.rs deleted file mode 100644 index 9db10c0..0000000 --- a/epp-client/src/epp/response/contact/info.rs +++ /dev/null @@ -1,63 +0,0 @@ -//! Types for EPP contact info response - -use serde::{Deserialize, Serialize}; - -use crate::epp::object::data::{ContactAuthInfo, ContactStatus, Phone, PostalInfo}; -use crate::epp::object::{EppObject, StringValue}; -use crate::epp::response::CommandResponse; - -/// Type that represents the <epp> tag for the EPP XML contact info response -pub type EppContactInfoResponse = EppObject>; - -/// Type that represents the <infData> tag for contact check response -#[derive(Serialize, Deserialize, Debug)] -pub struct ContactInfoData { - /// XML namespace for contact response data - #[serde(rename = "xmlns:contact")] - xmlns: String, - /// The contact id - pub id: StringValue, - /// The contact ROID - pub roid: StringValue, - /// The list of contact statuses - #[serde(rename = "status")] - pub statuses: Vec, - /// The postal info for the contact - #[serde(rename = "postalInfo")] - pub postal_info: PostalInfo, - /// The voice data for the contact - pub voice: Phone, - /// The fax data for the contact - pub fax: Option, - /// The email for the contact - pub email: StringValue, - /// The epp user to whom the contact belongs - #[serde(rename = "clID")] - pub client_id: StringValue, - /// The epp user who created the contact - #[serde(rename = "crID")] - pub creator_id: StringValue, - /// The creation date - #[serde(rename = "crDate")] - pub created_at: StringValue, - /// The epp user who last updated the contact - #[serde(rename = "upID")] - pub updater_id: Option, - /// The last update date - #[serde(rename = "upDate")] - pub updated_at: Option, - /// The contact transfer date - #[serde(rename = "trDate")] - pub transferred_at: Option, - /// The contact auth info - #[serde(rename = "authInfo")] - pub auth_info: Option, -} - -/// Type that represents the <resData> tag for contact info response -#[derive(Serialize, Deserialize, Debug)] -pub struct ContactInfoResult { - /// Data under the <infData> tag - #[serde(rename = "infData")] - pub info_data: ContactInfoData, -} diff --git a/epp-client/src/tests/de.rs b/epp-client/src/tests/de.rs index e32767e..127dd84 100644 --- a/epp-client/src/tests/de.rs +++ b/epp-client/src/tests/de.rs @@ -6,6 +6,7 @@ mod response { use crate::contact::check::EppContactCheckResponse; use crate::contact::create::EppContactCreateResponse; use crate::contact::delete::EppContactDeleteResponse; + use crate::contact::info::EppContactInfoResponse; 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 40e6f5b..dce52e8 100644 --- a/epp-client/src/tests/se.rs +++ b/epp-client/src/tests/se.rs @@ -6,6 +6,7 @@ mod request { use crate::contact::check::EppContactCheck; use crate::contact::create::EppContactCreate; use crate::contact::delete::EppContactDelete; + use crate::contact::info::EppContactInfo; use crate::domain::check::EppDomainCheck; use crate::domain::create::EppDomainCreate; use crate::domain::delete::EppDomainDelete;