diff --git a/epp-client/src/domain.rs b/epp-client/src/domain.rs index d08059a..770e8c7 100644 --- a/epp-client/src/domain.rs +++ b/epp-client/src/domain.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/domain/info.rs b/epp-client/src/domain/info.rs similarity index 50% rename from epp-client/src/epp/request/domain/info.rs rename to epp-client/src/domain/info.rs index 2bef4e1..c76132c 100644 --- a/epp-client/src/epp/request/domain/info.rs +++ b/epp-client/src/domain/info.rs @@ -2,9 +2,12 @@ use epp_client_macros::*; -use crate::epp::object::{ElementName, EppObject}; +use crate::epp::object::data::{DomainAuthInfo, DomainContact, DomainStatus, HostAttr}; +use crate::epp::object::{ElementName, EppObject, StringValue}; use crate::epp::request::Command; +use crate::epp::response::CommandResponseWithExtension; use crate::epp::xml::EPP_DOMAIN_XMLNS; +use crate::epp::RgpRequestResult; use serde::{Deserialize, Serialize}; /// Type that represents the <epp> request for domain <info> command @@ -16,7 +19,7 @@ use serde::{Deserialize, Serialize}; /// /// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; -/// use epp_client::epp::{EppDomainInfo, EppDomainInfoResponse}; +/// use epp_client::domain::info::{EppDomainInfo, EppDomainInfoResponse}; /// use epp_client::epp::generate_client_tr_id; /// /// #[tokio::main] @@ -53,7 +56,31 @@ use serde::{Deserialize, Serialize}; /// client.logout().await.unwrap(); /// } /// ``` -pub type EppDomainInfo = EppObject>; +pub type EppDomainInfo = EppObject>; + +impl EppDomainInfo { + /// Creates a new EppObject for domain info corresponding to the <epp> tag in EPP XML + pub fn new(name: &str, client_tr_id: &str) -> EppDomainInfo { + EppObject::build(Command::::new( + DomainInfoRequest { + info: DomainInfoRequestData { + xmlns: EPP_DOMAIN_XMLNS.to_string(), + domain: Domain { + hosts: "all".to_string(), + name: name.to_string(), + }, + }, + }, + client_tr_id, + )) + } +} + +/// Type that represents the <epp> tag for the EPP XML domain info response +pub type EppDomainInfoResponse = + EppObject>; + +// Request /// Type for data under the <name> element tag for the domain <info> tag #[derive(Serialize, Deserialize, Debug)] @@ -67,7 +94,7 @@ pub struct Domain { /// Type for <name> element under the domain <info> tag #[derive(Serialize, Deserialize, Debug)] -pub struct DomainInfoData { +pub struct DomainInfoRequestData { /// XML namespace for domain commands #[serde(rename = "xmlns:domain", alias = "xmlns")] xmlns: String, @@ -79,26 +106,79 @@ pub struct DomainInfoData { #[derive(Serialize, Deserialize, Debug, ElementName)] #[element_name(name = "info")] /// Type for EPP XML <info> command for domains -pub struct DomainInfo { +pub struct DomainInfoRequest { /// The data under the <info> tag for domain info #[serde(rename = "domain:info", alias = "info")] - info: DomainInfoData, + info: DomainInfoRequestData, } -impl EppDomainInfo { - /// Creates a new EppObject for domain info corresponding to the <epp> tag in EPP XML - pub fn new(name: &str, client_tr_id: &str) -> EppDomainInfo { - EppObject::build(Command::::new( - DomainInfo { - info: DomainInfoData { - xmlns: EPP_DOMAIN_XMLNS.to_string(), - domain: Domain { - hosts: "all".to_string(), - name: name.to_string(), - }, - }, - }, - client_tr_id, - )) - } +// Response + +/// The two types of ns lists, hostObj and hostAttr, that may be returned in the +/// domain info response +#[derive(Serialize, Deserialize, Debug)] +pub struct DomainNsList { + /// List of <hostObj> ns elements + #[serde(rename = "hostObj")] + pub host_obj: Option>, + /// List of <hostAttr> ns elements + pub host_attr: Option>, +} + +/// Type that represents the <infData> tag for domain info response +#[derive(Serialize, Deserialize, Debug)] +pub struct DomainInfoResponseData { + /// XML namespace for domain response data + #[serde(rename = "xmlns:domain")] + xmlns: String, + /// The domain name + pub name: StringValue, + /// The domain ROID + pub roid: StringValue, + /// The list of domain statuses + #[serde(rename = "status")] + pub statuses: Vec, + /// The domain registrant + pub registrant: StringValue, + /// The list of domain contacts + #[serde(rename = "contact")] + pub contacts: Vec, + /// The list of domain nameservers + #[serde(rename = "ns")] + pub ns: Option, + /// The list of domain hosts + #[serde(rename = "host")] + pub hosts: Option>, + /// The epp user who owns the domain + #[serde(rename = "clID")] + pub client_id: StringValue, + /// The epp user who created the domain + #[serde(rename = "crID")] + pub creator_id: StringValue, + /// The domain creation date + #[serde(rename = "crDate")] + pub created_at: StringValue, + /// The epp user who last updated the domain + #[serde(rename = "upID")] + pub updater_id: StringValue, + /// The domain last updated date + #[serde(rename = "upDate")] + pub updated_at: StringValue, + /// The domain expiry date + #[serde(rename = "exDate")] + pub expiring_at: StringValue, + /// The domain transfer date + #[serde(rename = "trDate")] + pub transferred_at: Option, + /// The domain auth info + #[serde(rename = "authInfo")] + pub auth_info: Option, +} + +/// Type that represents the <resData> tag for domain info response +#[derive(Serialize, Deserialize, Debug)] +pub struct DomainInfoResponse { + /// Data under the <resData> tag + #[serde(rename = "infData")] + pub info_data: DomainInfoResponseData, } diff --git a/epp-client/src/epp.rs b/epp-client/src/epp.rs index e93c07c..707b115 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::info::*; pub use request::domain::renew::*; pub use request::domain::rgp::report::*; pub use request::domain::rgp::request::*; @@ -29,7 +28,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::info::*; pub use response::domain::renew::*; pub use response::domain::rgp::report::*; pub use response::domain::rgp::request::*; diff --git a/epp-client/src/epp/request/domain.rs b/epp-client/src/epp/request/domain.rs index eed4a33..1545533 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 info; pub mod renew; pub mod rgp; pub mod transfer; diff --git a/epp-client/src/epp/response/domain.rs b/epp-client/src/epp/response/domain.rs index eb8e74c..c86c669 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 info; pub mod renew; pub mod rgp; pub mod transfer; diff --git a/epp-client/src/epp/response/domain/info.rs b/epp-client/src/epp/response/domain/info.rs deleted file mode 100644 index 6652e68..0000000 --- a/epp-client/src/epp/response/domain/info.rs +++ /dev/null @@ -1,81 +0,0 @@ -//! Types for EPP domain info response - -use serde::{Deserialize, Serialize}; - -use crate::epp::object::data::{DomainAuthInfo, DomainContact, DomainStatus, HostAttr}; -use crate::epp::object::{EppObject, StringValue}; -use crate::epp::response::domain::rgp::request::RgpRequestResult; -use crate::epp::response::CommandResponseWithExtension; - -/// Type that represents the <epp> tag for the EPP XML domain info response -pub type EppDomainInfoResponse = - EppObject>; - -/// The two types of ns lists, hostObj and hostAttr, that may be returned in the -/// domain info response -#[derive(Serialize, Deserialize, Debug)] -pub struct DomainNsList { - /// List of <hostObj> ns elements - #[serde(rename = "hostObj")] - pub host_obj: Option>, - /// List of <hostAttr> ns elements - pub host_attr: Option>, -} - -/// Type that represents the <infData> tag for domain info response -#[derive(Serialize, Deserialize, Debug)] -pub struct DomainInfoData { - /// XML namespace for domain response data - #[serde(rename = "xmlns:domain")] - xmlns: String, - /// The domain name - pub name: StringValue, - /// The domain ROID - pub roid: StringValue, - /// The list of domain statuses - #[serde(rename = "status")] - pub statuses: Vec, - /// The domain registrant - pub registrant: StringValue, - /// The list of domain contacts - #[serde(rename = "contact")] - pub contacts: Vec, - /// The list of domain nameservers - #[serde(rename = "ns")] - pub ns: Option, - /// The list of domain hosts - #[serde(rename = "host")] - pub hosts: Option>, - /// The epp user who owns the domain - #[serde(rename = "clID")] - pub client_id: StringValue, - /// The epp user who created the domain - #[serde(rename = "crID")] - pub creator_id: StringValue, - /// The domain creation date - #[serde(rename = "crDate")] - pub created_at: StringValue, - /// The epp user who last updated the domain - #[serde(rename = "upID")] - pub updater_id: StringValue, - /// The domain last updated date - #[serde(rename = "upDate")] - pub updated_at: StringValue, - /// The domain expiry date - #[serde(rename = "exDate")] - pub expiring_at: StringValue, - /// The domain transfer date - #[serde(rename = "trDate")] - pub transferred_at: Option, - /// The domain auth info - #[serde(rename = "authInfo")] - pub auth_info: Option, -} - -/// Type that represents the <resData> tag for domain info response -#[derive(Serialize, Deserialize, Debug)] -pub struct DomainInfoResult { - /// Data under the <resData> tag - #[serde(rename = "infData")] - pub info_data: DomainInfoData, -} diff --git a/epp-client/src/tests/de.rs b/epp-client/src/tests/de.rs index f6522d2..bf52db5 100644 --- a/epp-client/src/tests/de.rs +++ b/epp-client/src/tests/de.rs @@ -6,6 +6,7 @@ mod response { use crate::domain::check::EppDomainCheckResponse; use crate::domain::create::EppDomainCreateResponse; use crate::domain::delete::EppDomainDeleteResponse; + use crate::domain::info::EppDomainInfoResponse; 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 504e390..bf17a65 100644 --- a/epp-client/src/tests/se.rs +++ b/epp-client/src/tests/se.rs @@ -6,6 +6,7 @@ mod request { use crate::domain::check::EppDomainCheck; use crate::domain::create::EppDomainCreate; use crate::domain::delete::EppDomainDelete; + use crate::domain::info::EppDomainInfo; use crate::epp::object::data::{ Address, ContactStatus, DomainAuthInfo, DomainContact, DomainStatus, HostAddr, HostAttr, HostStatus, Phone, PostalInfo,