Migrate commands to new API

This commit is contained in:
Nicholas Rempel 2021-11-26 14:21:38 -08:00 committed by masalachai
parent aa54c14972
commit 31fc61f4b0
25 changed files with 1351 additions and 1050 deletions

View File

@ -7,8 +7,9 @@
//! //!
//! use epp_client::config::{EppClientConfig, EppClientConnection}; //! use epp_client::config::{EppClientConfig, EppClientConnection};
//! use epp_client::EppClient; //! use epp_client::EppClient;
//! use epp_client::domain::check::{EppDomainCheck, EppDomainCheckResponse}; //! use epp_client::domain::check::DomainCheck;
//! use epp_client::generate_client_tr_id; //! use epp_client::generate_client_tr_id;
//! use epp_client::common::NoExtension;
//! //!
//! #[tokio::main] //! #[tokio::main]
//! async fn main() { //! async fn main() {
@ -39,8 +40,8 @@
//! println!("{:?}", greeting); //! println!("{:?}", greeting);
//! //!
//! // Execute an EPP Command against the registry with distinct request and response objects //! // Execute an EPP Command against the registry with distinct request and response objects
//! let domain_check = EppDomainCheck::new(vec!["eppdev.com", "eppdev.net"], generate_client_tr_id(&client).as_str()); //! let domain_check = DomainCheck::<NoExtension>::new(vec!["eppdev.com", "eppdev.net"]);
//! let response = client.transact::<_, EppDomainCheckResponse>(&domain_check).await.unwrap(); //! let response = client.transact_new(domain_check, generate_client_tr_id(&client).as_str()).await.unwrap();
//! println!("{:?}", response); //! println!("{:?}", response);
//! //!
//! } //! }
@ -49,14 +50,18 @@
use std::time::SystemTime; use std::time::SystemTime;
use std::{error::Error, fmt::Debug}; use std::{error::Error, fmt::Debug};
use crate::common::{EppObject, NoExtension};
use crate::config::EppClientConfig; use crate::config::EppClientConfig;
use crate::connection::registry::{epp_connect, EppConnection}; use crate::connection::registry::{epp_connect, EppConnection};
use crate::error; use crate::error;
use crate::hello::{EppGreeting, EppHello}; use crate::hello::{EppGreeting, EppHello};
use crate::login::{EppLogin, EppLoginResponse}; use crate::login::Login;
use crate::logout::{EppLogout, EppLogoutResponse}; use crate::logout::Logout;
use crate::request::{generate_client_tr_id, EppExtension, EppRequest}; use crate::request::{generate_client_tr_id, EppExtension, EppRequest};
use crate::response::{CommandResponseWithExtension, EppCommandResponse, EppCommandResponseError}; use crate::response::{
CommandResponseStatus, CommandResponseWithExtension, EppCommandResponse,
EppCommandResponseError,
};
use crate::xml::EppXml; use crate::xml::EppXml;
/// Instances of the EppClient type are used to transact with the registry. /// Instances of the EppClient type are used to transact with the registry.
/// Once initialized, the EppClient instance can serialize EPP requests to XML and send them /// Once initialized, the EppClient instance can serialize EPP requests to XML and send them
@ -110,19 +115,17 @@ impl EppClient {
connection, connection,
credentials, credentials,
ext_uris, ext_uris,
// client_tr_id_fn: Arc::new(default_client_tr_id_fn),
}; };
let client_tr_id = generate_client_tr_id(&client.credentials.0)?; let client_tr_id = generate_client_tr_id(&client.credentials.0)?;
let login_request = EppLogin::new( let login_request = Login::<NoExtension>::new(
&client.credentials.0, &client.credentials.0,
&client.credentials.1, &client.credentials.1,
&client.ext_uris, &client.ext_uris,
client_tr_id.as_str(),
); );
client client
.transact::<_, EppLoginResponse>(&login_request) .transact_new(login_request, client_tr_id.as_str())
.await?; .await?;
Ok(client) Ok(client)
@ -197,11 +200,16 @@ impl EppClient {
} }
/// Sends the EPP Logout command to log out of the EPP session /// Sends the EPP Logout command to log out of the EPP session
pub async fn logout(&mut self) -> Result<EppLogoutResponse, error::Error> { pub async fn logout(
&mut self,
) -> Result<
CommandResponseWithExtension<EppObject<CommandResponseStatus>, NoExtension>,
error::Error,
> {
let client_tr_id = generate_client_tr_id(&self.credentials.0).unwrap(); let client_tr_id = generate_client_tr_id(&self.credentials.0).unwrap();
let epp_logout = EppLogout::new(client_tr_id.as_str()); let epp_logout = Logout::<NoExtension>::new();
let response = self.transact::<_, EppLogoutResponse>(&epp_logout).await?; let response = self.transact_new(epp_logout, client_tr_id.as_str()).await?;
self.connection.shutdown().await?; self.connection.shutdown().await?;

View File

@ -1,12 +1,28 @@
use std::fmt::Debug;
/// Types for EPP contact check request /// Types for EPP contact check request
use epp_client_macros::*; use epp_client_macros::*;
use crate::common::{ElementName, EppObject, StringValue}; use crate::common::{ElementName, NoExtension, StringValue};
use crate::contact::EPP_CONTACT_XMLNS; use crate::contact::EPP_CONTACT_XMLNS;
use crate::request::Command; use crate::request::{EppExtension, EppRequest};
use crate::response::CommandResponse;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Debug)]
pub struct ContactCheck<E> {
request: ContactCheckRequest,
extension: Option<E>,
}
impl<E: EppExtension> EppRequest<E> for ContactCheck<E> {
type Input = ContactCheckRequest;
type Output = ContactCheckResponse;
fn into_parts(self) -> (Self::Input, Option<E>) {
(self.request, self.extension)
}
}
/// Type that represents the &lt;epp&gt; request for contact &lt;check&gt; command /// Type that represents the &lt;epp&gt; request for contact &lt;check&gt; command
/// ///
/// ## Usage /// ## Usage
@ -16,8 +32,9 @@ use serde::{Deserialize, Serialize};
/// ///
/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::config::{EppClientConfig, EppClientConnection};
/// use epp_client::EppClient; /// use epp_client::EppClient;
/// use epp_client::contact::check::{EppContactCheck, EppContactCheckResponse}; /// use epp_client::contact::check::ContactCheck;
/// use epp_client::generate_client_tr_id; /// use epp_client::generate_client_tr_id;
/// use epp_client::common::NoExtension;
/// ///
/// #[tokio::main] /// #[tokio::main]
/// async fn main() { /// async fn main() {
@ -42,47 +59,45 @@ use serde::{Deserialize, Serialize};
/// Err(e) => panic!("Failed to create EppClient: {}", e) /// Err(e) => panic!("Failed to create EppClient: {}", e)
/// }; /// };
/// ///
/// // Create an EppContactCheck instance /// // Create an ContactCheck instance
/// let contact_check = EppContactCheck::new( /// let contact_check = ContactCheck::<NoExtension>::new(
/// &["epp-client-c1", "epp-client-c2"], /// &["epp-client-c1", "epp-client-c2"]
/// generate_client_tr_id(&client).as_str()
/// ); /// );
/// ///
/// // send it to the registry and receive a response of type EppContactCheckResponse /// // send it to the registry and receive a response of type ContactCheckResponse
/// let response = client.transact::<_, EppContactCheckResponse>(&contact_check).await.unwrap();
/// ///
/// let response = client.transact_new(contact_check, generate_client_tr_id(&client).as_str()).await.unwrap();
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.logout().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppContactCheck = EppObject<Command<ContactCheckRequest>>; impl<E: EppExtension> ContactCheck<E> {
pub fn new(contact_ids: &[&str]) -> ContactCheck<NoExtension> {
impl EppContactCheck {
/// Creates an EppObject corresponding to the &lt;epp&gt; tag with data for a contact check request
pub fn new(contact_ids: &[&str], client_tr_id: &str) -> EppContactCheck {
let contact_ids = contact_ids let contact_ids = contact_ids
.iter() .iter()
.map(|&d| d.into()) .map(|&d| d.into())
.collect::<Vec<StringValue>>(); .collect::<Vec<StringValue>>();
let contact_check = ContactCheckRequest { ContactCheck {
request: ContactCheckRequest {
list: ContactList { list: ContactList {
xmlns: EPP_CONTACT_XMLNS.to_string(), xmlns: EPP_CONTACT_XMLNS.to_string(),
contact_ids, contact_ids,
}, },
}; },
extension: None,
}
}
EppObject::build(Command::<ContactCheckRequest>::new( pub fn with_extension<F: EppExtension>(self, extension: F) -> ContactCheck<F> {
contact_check, ContactCheck {
client_tr_id, request: self.request,
)) extension: Some(extension),
}
} }
} }
/// Type that represents the &lt;epp&gt; tag for the EPP XML contact check response
pub type EppContactCheckResponse = EppObject<CommandResponse<ContactCheckResponse>>;
// Request // Request
/// Type that represents the &lt;check&gt; command for contact transactions /// Type that represents the &lt;check&gt; command for contact transactions
@ -109,7 +124,7 @@ pub struct ContactCheckRequest {
/// Type that represents the &lt;id&gt; tag for contact check response /// Type that represents the &lt;id&gt; tag for contact check response
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
pub struct ContactCheck { pub struct ContactAvailable {
/// The text of the &lt;id&gt; tag /// The text of the &lt;id&gt; tag
#[serde(rename = "$value")] #[serde(rename = "$value")]
pub id: StringValue, pub id: StringValue,
@ -123,7 +138,7 @@ pub struct ContactCheck {
pub struct ContactCheckResponseDataItem { pub struct ContactCheckResponseDataItem {
/// Data under the &lt;id&gt; tag /// Data under the &lt;id&gt; tag
#[serde(rename = "id")] #[serde(rename = "id")]
pub contact: ContactCheck, pub contact: ContactAvailable,
/// The reason for (un)availability /// The reason for (un)availability
pub reason: Option<StringValue>, pub reason: Option<StringValue>,
} }

View File

@ -2,12 +2,26 @@
use epp_client_macros::*; use epp_client_macros::*;
use crate::common::{ContactAuthInfo, ElementName, EppObject, Phone, PostalInfo, StringValue}; use crate::common::{ContactAuthInfo, ElementName, NoExtension, Phone, PostalInfo, StringValue};
use crate::contact::EPP_CONTACT_XMLNS; use crate::contact::EPP_CONTACT_XMLNS;
use crate::request::Command; use crate::request::{EppExtension, EppRequest};
use crate::response::CommandResponse;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Debug)]
pub struct ContactCreate<E> {
request: ContactCreateRequest,
extension: Option<E>,
}
impl<E: EppExtension> EppRequest<E> for ContactCreate<E> {
type Input = ContactCreateRequest;
type Output = ContactCreateResponse;
fn into_parts(self) -> (Self::Input, Option<E>) {
(self.request, self.extension)
}
}
/// Type that represents the &lt;epp&gt; request for contact &lt;create&gt; command /// Type that represents the &lt;epp&gt; request for contact &lt;create&gt; command
/// ///
/// ## Usage /// ## Usage
@ -18,8 +32,9 @@ use serde::{Deserialize, Serialize};
/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::config::{EppClientConfig, EppClientConnection};
/// use epp_client::EppClient; /// use epp_client::EppClient;
/// use epp_client::common::{Address, Phone, PostalInfo}; /// use epp_client::common::{Address, Phone, PostalInfo};
/// use epp_client::contact::create::{EppContactCreate, EppContactCreateResponse}; /// use epp_client::contact::create::ContactCreate;
/// use epp_client::generate_client_tr_id; /// use epp_client::generate_client_tr_id;
/// use epp_client::common::NoExtension;
/// ///
/// #[tokio::main] /// #[tokio::main]
/// async fn main() { /// async fn main() {
@ -53,38 +68,34 @@ use serde::{Deserialize, Serialize};
/// let mut fax = Phone::new("+1.86698799"); /// let mut fax = Phone::new("+1.86698799");
/// fax.set_extension("677"); /// fax.set_extension("677");
/// ///
/// // Create an EppContactCreate instance /// // Create an ContactCreate instance
/// let mut contact_create = EppContactCreate::new( /// let mut contact_create = ContactCreate::<NoExtension>::new(
/// "eppdev-contact-100", /// "eppdev-contact-100",
/// "contact@eppdev.net", /// "contact@eppdev.net",
/// postal_info, /// postal_info,
/// voice, /// voice,
/// "epP4uthd#v", /// "epP4uthd#v"
/// generate_client_tr_id(&client).as_str()
/// ); /// );
/// contact_create.set_fax(fax); /// contact_create.set_fax(fax);
/// ///
/// // send it to the registry and receive a response of type EppContactCreateResponse /// // send it to the registry and receive a response of type ContactCreateResponse
/// let response = client.transact::<_, EppContactCreateResponse>(&contact_create).await.unwrap(); /// let response = client.transact_new(contact_create, generate_client_tr_id(&client).as_str()).await.unwrap();
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.logout().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppContactCreate = EppObject<Command<ContactCreateRequest>>; impl<E: EppExtension> ContactCreate<E> {
impl EppContactCreate {
/// Creates a new EppObject for contact create corresponding to the &lt;epp&gt; tag in EPP XML
pub fn new( pub fn new(
id: &str, id: &str,
email: &str, email: &str,
postal_info: PostalInfo, postal_info: PostalInfo,
voice: Phone, voice: Phone,
auth_password: &str, auth_password: &str,
client_tr_id: &str, ) -> ContactCreate<NoExtension> {
) -> EppContactCreate { ContactCreate {
let contact_create = ContactCreateRequest { request: ContactCreateRequest {
contact: Contact { contact: Contact {
xmlns: EPP_CONTACT_XMLNS.to_string(), xmlns: EPP_CONTACT_XMLNS.to_string(),
id: id.into(), id: id.into(),
@ -94,23 +105,24 @@ impl EppContactCreate {
email: email.into(), email: email.into(),
auth_info: ContactAuthInfo::new(auth_password), auth_info: ContactAuthInfo::new(auth_password),
}, },
}; },
extension: None,
}
}
EppObject::build(Command::<ContactCreateRequest>::new( pub fn with_extension<F: EppExtension>(self, extension: F) -> ContactCreate<F> {
contact_create, ContactCreate {
client_tr_id, request: self.request,
)) extension: Some(extension),
}
} }
/// Sets the &lt;fax&gt; data for the request /// Sets the &lt;fax&gt; data for the request
pub fn set_fax(&mut self, fax: Phone) { pub fn set_fax(&mut self, fax: Phone) {
self.data.command.contact.fax = Some(fax); self.request.contact.fax = Some(fax);
} }
} }
/// Type that represents the &lt;epp&gt; tag for the EPP XML contact create response
pub type EppContactCreateResponse = EppObject<CommandResponse<ContactCreateResult>>;
// Request // Request
/// Type for elements under the contact &lt;create&gt; tag /// Type for elements under the contact &lt;create&gt; tag
@ -165,7 +177,7 @@ pub struct ContactCreateData {
/// Type that represents the &lt;resData&gt; tag for contact create response /// Type that represents the &lt;resData&gt; tag for contact create response
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
pub struct ContactCreateResult { pub struct ContactCreateResponse {
/// Data under the &lt;creData&gt; tag /// Data under the &lt;creData&gt; tag
#[serde(rename = "creData")] #[serde(rename = "creData")]
pub create_data: ContactCreateData, pub create_data: ContactCreateData,

View File

@ -2,12 +2,27 @@
use epp_client_macros::*; use epp_client_macros::*;
use crate::common::{ElementName, EppObject, StringValue}; use crate::common::{ElementName, NoExtension, StringValue};
use crate::contact::EPP_CONTACT_XMLNS; use crate::contact::EPP_CONTACT_XMLNS;
use crate::request::Command; use crate::request::{EppExtension, EppRequest};
use crate::response::EppCommandResponse; use crate::response::EppCommandResponse;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Debug)]
pub struct ContactDelete<E> {
request: ContactDeleteRequest,
extension: Option<E>,
}
impl<E: EppExtension> EppRequest<E> for ContactDelete<E> {
type Input = ContactDeleteRequest;
type Output = EppCommandResponse;
fn into_parts(self) -> (Self::Input, Option<E>) {
(self.request, self.extension)
}
}
/// Type for the &lt;epp&gt; request for contact &lt;delete&gt; command /// Type for the &lt;epp&gt; request for contact &lt;delete&gt; command
/// ///
/// ## Usage /// ## Usage
@ -17,8 +32,9 @@ use serde::{Deserialize, Serialize};
/// ///
/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::config::{EppClientConfig, EppClientConnection};
/// use epp_client::EppClient; /// use epp_client::EppClient;
/// use epp_client::contact::delete::{EppContactDelete, EppContactDeleteResponse}; /// use epp_client::contact::delete::ContactDelete;
/// use epp_client::generate_client_tr_id; /// use epp_client::generate_client_tr_id;
/// use epp_client::common::NoExtension;
/// ///
/// #[tokio::main] /// #[tokio::main]
/// async fn main() { /// async fn main() {
@ -43,42 +59,40 @@ use serde::{Deserialize, Serialize};
/// Err(e) => panic!("Failed to create EppClient: {}", e) /// Err(e) => panic!("Failed to create EppClient: {}", e)
/// }; /// };
/// ///
/// // Create an EppContactDelete instance /// // Create an ContactDelete instance
/// let contact_delete = EppContactDelete::new( /// let contact_delete = ContactDelete::<NoExtension>::new(
/// "eppdev-contact-100", /// "eppdev-contact-100"
/// generate_client_tr_id(&client).as_str()
/// ); /// );
/// ///
/// // send it to the registry and receive a response of type EppContactDeleteResponse /// // send it to the registry and receive a response of type ContactDeleteResponse
/// let response = client.transact::<_, EppContactDeleteResponse>(&contact_delete).await.unwrap(); /// let response = client.transact_new(contact_delete, generate_client_tr_id(&client).as_str()).await.unwrap();
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.logout().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppContactDelete = EppObject<Command<ContactDeleteRequest>>; impl<E: EppExtension> ContactDelete<E> {
pub fn new(id: &str) -> ContactDelete<NoExtension> {
impl EppContactDelete { ContactDelete {
/// Creates a new EppObject for contact delete corresponding to the &lt;epp&gt; tag in EPP XML request: ContactDeleteRequest {
pub fn new(id: &str, client_tr_id: &str) -> EppContactDelete {
let contact_delete = ContactDeleteRequest {
contact: ContactDeleteRequestData { contact: ContactDeleteRequestData {
xmlns: EPP_CONTACT_XMLNS.to_string(), xmlns: EPP_CONTACT_XMLNS.to_string(),
id: id.into(), id: id.into(),
}, },
}; },
extension: None,
}
}
EppObject::build(Command::<ContactDeleteRequest>::new( pub fn with_extension<F: EppExtension>(self, extension: F) -> ContactDelete<F> {
contact_delete, ContactDelete {
client_tr_id, request: self.request,
)) extension: Some(extension),
}
} }
} }
/// Type that represents the &lt;epp&gt; tag for the EPP XML contact delete response
pub type EppContactDeleteResponse = EppCommandResponse;
/// Type containing the data for the &lt;delete&gt; tag for contacts /// Type containing the data for the &lt;delete&gt; tag for contacts
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
pub struct ContactDeleteRequestData { pub struct ContactDeleteRequestData {

View File

@ -3,13 +3,27 @@
use epp_client_macros::*; use epp_client_macros::*;
use crate::common::{ use crate::common::{
ContactAuthInfo, ContactStatus, ElementName, EppObject, Phone, PostalInfo, StringValue, ContactAuthInfo, ContactStatus, ElementName, NoExtension, Phone, PostalInfo, StringValue,
}; };
use crate::contact::EPP_CONTACT_XMLNS; use crate::contact::EPP_CONTACT_XMLNS;
use crate::request::Command; use crate::request::{EppExtension, EppRequest};
use crate::response::CommandResponse;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Debug)]
pub struct ContactInfo<E> {
request: ContactInfoRequest,
extension: Option<E>,
}
impl<E: EppExtension> EppRequest<E> for ContactInfo<E> {
type Input = ContactInfoRequest;
type Output = ContactInfoResponse;
fn into_parts(self) -> (Self::Input, Option<E>) {
(self.request, self.extension)
}
}
/// Type for the &lt;epp&gt; request for contact &lt;info&gt; command /// Type for the &lt;epp&gt; request for contact &lt;info&gt; command
/// ///
/// ## Usage /// ## Usage
@ -19,8 +33,9 @@ use serde::{Deserialize, Serialize};
/// ///
/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::config::{EppClientConfig, EppClientConnection};
/// use epp_client::EppClient; /// use epp_client::EppClient;
/// use epp_client::contact::info::{EppContactInfo, EppContactInfoResponse}; /// use epp_client::contact::info::ContactInfo;
/// use epp_client::generate_client_tr_id; /// use epp_client::generate_client_tr_id;
/// use epp_client::common::NoExtension;
/// ///
/// #[tokio::main] /// #[tokio::main]
/// async fn main() { /// async fn main() {
@ -45,44 +60,42 @@ use serde::{Deserialize, Serialize};
/// Err(e) => panic!("Failed to create EppClient: {}", e) /// Err(e) => panic!("Failed to create EppClient: {}", e)
/// }; /// };
/// ///
/// // Create an EppContactInfo instance /// // Create an ContactInfo instance
/// let contact_info = EppContactInfo::new( /// let contact_info = ContactInfo::<NoExtension>::new(
/// "eppdev-contact-100", /// "eppdev-contact-100",
/// "epP4uthd#v", /// "epP4uthd#v"
/// generate_client_tr_id(&client).as_str()
/// ); /// );
/// ///
/// // send it to the registry and receive a response of type EppContactInfoResponse /// // send it to the registry and receive a response of type ContactInfoResponse
/// let response = client.transact::<_, EppContactInfoResponse>(&contact_info).await.unwrap(); /// let response = client.transact_new(contact_info, generate_client_tr_id(&client).as_str()).await.unwrap();
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.logout().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppContactInfo = EppObject<Command<ContactInfoRequest>>; impl<E: EppExtension> ContactInfo<E> {
pub fn new(id: &str, auth_password: &str) -> ContactInfo<NoExtension> {
impl EppContactInfo { ContactInfo {
/// Creates a new EppObject for contact info corresponding to the &lt;epp&gt; tag in EPP XML request: ContactInfoRequest {
pub fn new(id: &str, auth_password: &str, client_tr_id: &str) -> EppContactInfo {
let contact_info = ContactInfoRequest {
info: ContactInfoRequestData { info: ContactInfoRequestData {
xmlns: EPP_CONTACT_XMLNS.to_string(), xmlns: EPP_CONTACT_XMLNS.to_string(),
id: id.into(), id: id.into(),
auth_info: ContactAuthInfo::new(auth_password), auth_info: ContactAuthInfo::new(auth_password),
}, },
}; },
extension: None,
}
}
EppObject::build(Command::<ContactInfoRequest>::new( pub fn with_extension<F: EppExtension>(self, extension: F) -> ContactInfo<F> {
contact_info, ContactInfo {
client_tr_id, request: self.request,
)) extension: Some(extension),
}
} }
} }
/// Type that represents the &lt;epp&gt; tag for the EPP XML contact info response
pub type EppContactInfoResponse = EppObject<CommandResponse<ContactInfoResponse>>;
// Request // Request
/// Type for elements under the contact &lt;info&gt; tag /// Type for elements under the contact &lt;info&gt; tag

View File

@ -3,15 +3,28 @@
use epp_client_macros::*; use epp_client_macros::*;
use crate::common::{ use crate::common::{
ContactAuthInfo, ContactStatus, ElementName, EppObject, Phone, PostalInfo, StringValue, ContactAuthInfo, ContactStatus, ElementName, NoExtension, Phone, PostalInfo, StringValue,
}; };
use crate::contact::info::EppContactInfoResponse;
use crate::contact::EPP_CONTACT_XMLNS; use crate::contact::EPP_CONTACT_XMLNS;
use crate::error; use crate::request::{EppExtension, EppRequest};
use crate::request::Command;
use crate::response::EppCommandResponse; use crate::response::EppCommandResponse;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Debug)]
pub struct ContactUpdate<E> {
request: ContactUpdateRequest,
extension: Option<E>,
}
impl<E: EppExtension> EppRequest<E> for ContactUpdate<E> {
type Input = ContactUpdateRequest;
type Output = EppCommandResponse;
fn into_parts(self) -> (Self::Input, Option<E>) {
(self.request, self.extension)
}
}
/// Type that represents the &lt;epp&gt; request for contact &lt;update&gt; command /// Type that represents the &lt;epp&gt; request for contact &lt;update&gt; command
/// ///
/// ## Usage /// ## Usage
@ -21,9 +34,10 @@ use serde::{Deserialize, Serialize};
/// ///
/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::config::{EppClientConfig, EppClientConnection};
/// use epp_client::EppClient; /// use epp_client::EppClient;
/// use epp_client::contact::update::{EppContactUpdate, EppContactUpdateResponse}; /// use epp_client::contact::update::ContactUpdate;
/// use epp_client::generate_client_tr_id; /// use epp_client::generate_client_tr_id;
/// use epp_client::common::ContactStatus; /// use epp_client::common::ContactStatus;
/// use epp_client::common::NoExtension;
/// ///
/// #[tokio::main] /// #[tokio::main]
/// async fn main() { /// async fn main() {
@ -48,10 +62,9 @@ use serde::{Deserialize, Serialize};
/// Err(e) => panic!("Failed to create EppClient: {}", e) /// Err(e) => panic!("Failed to create EppClient: {}", e)
/// }; /// };
/// ///
/// // Create an EppContactUpdate instance /// // Create an ContactUpdate instance
/// let mut contact_update = EppContactUpdate::new( /// let mut contact_update = ContactUpdate::<NoExtension>::new(
/// "eppdev-contact-100", /// "eppdev-contact-100"
/// generate_client_tr_id(&client).as_str()
/// ); /// );
/// ///
/// let add_statuses = vec![ /// let add_statuses = vec![
@ -62,20 +75,18 @@ use serde::{Deserialize, Serialize};
/// ///
/// contact_update.add(add_statuses); /// contact_update.add(add_statuses);
/// ///
/// // send it to the registry and receive a response of type EppContactUpdateResponse /// // send it to the registry and receive a response of type ContactUpdateResponse
/// let response = client.transact::<_, EppContactUpdateResponse>(&contact_update).await.unwrap(); /// let response = client.transact_new(contact_update, generate_client_tr_id(&client).as_str()).await.unwrap();
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.logout().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppContactUpdate = EppObject<Command<ContactUpdateRequest>>; impl<E: EppExtension> ContactUpdate<E> {
pub fn new(id: &str) -> ContactUpdate<NoExtension> {
impl EppContactUpdate { ContactUpdate {
/// Creates a new EppObject for contact update corresponding to the &lt;epp&gt; tag in EPP XML request: ContactUpdateRequest {
pub fn new(id: &str, client_tr_id: &str) -> EppContactUpdate {
let contact_update = ContactUpdateRequest {
contact: ContactUpdateRequestData { contact: ContactUpdateRequestData {
xmlns: EPP_CONTACT_XMLNS.to_string(), xmlns: EPP_CONTACT_XMLNS.to_string(),
id: id.into(), id: id.into(),
@ -83,11 +94,16 @@ impl EppContactUpdate {
remove_statuses: None, remove_statuses: None,
change_info: None, change_info: None,
}, },
}; },
EppObject::build(Command::<ContactUpdateRequest>::new( extension: None,
contact_update, }
client_tr_id, }
))
pub fn with_extension<F: EppExtension>(self, extension: F) -> ContactUpdate<F> {
ContactUpdate {
request: self.request,
extension: Some(extension),
}
} }
/// Sets the data for the &lt;chg&gt; tag for the contact update request /// Sets the data for the &lt;chg&gt; tag for the contact update request
@ -98,7 +114,7 @@ impl EppContactUpdate {
voice: Phone, voice: Phone,
auth_password: &str, auth_password: &str,
) { ) {
self.data.command.contact.change_info = Some(ContactChangeInfo { self.request.contact.change_info = Some(ContactChangeInfo {
email: Some(email.into()), email: Some(email.into()),
postal_info: Some(postal_info), postal_info: Some(postal_info),
voice: Some(voice), voice: Some(voice),
@ -109,47 +125,22 @@ impl EppContactUpdate {
/// Sets the data for the &lt;fax&gt; tag under &lt;chg&gt; for the contact update request /// Sets the data for the &lt;fax&gt; tag under &lt;chg&gt; for the contact update request
pub fn set_fax(&mut self, fax: Phone) { pub fn set_fax(&mut self, fax: Phone) {
if let Some(info) = &mut self.data.command.contact.change_info { if let Some(info) = &mut self.request.contact.change_info {
info.fax = Some(fax) info.fax = Some(fax)
} }
} }
/// Sets the data for the &lt;add&gt; tag for the contact update request /// Sets the data for the &lt;add&gt; tag for the contact update request
pub fn add(&mut self, statuses: Vec<ContactStatus>) { pub fn add(&mut self, statuses: Vec<ContactStatus>) {
self.data.command.contact.add_statuses = Some(StatusList { status: statuses }); self.request.contact.add_statuses = Some(StatusList { status: statuses });
} }
/// Sets the data for the &lt;rem&gt; tag for the contact update request /// Sets the data for the &lt;rem&gt; tag for the contact update request
pub fn remove(&mut self, statuses: Vec<ContactStatus>) { pub fn remove(&mut self, statuses: Vec<ContactStatus>) {
self.data.command.contact.remove_statuses = Some(StatusList { status: statuses }); self.request.contact.remove_statuses = Some(StatusList { status: statuses });
}
/// Loads data into the &lt;chg&gt; tag from an existing EppContactInfoResponse object
pub fn load_from_epp_contact_info(
&mut self,
contact_info: EppContactInfoResponse,
) -> Result<(), error::Error> {
match contact_info.data.res_data {
Some(res_data) => {
self.data.command.contact.change_info = Some(ContactChangeInfo {
email: Some(res_data.info_data.email.clone()),
postal_info: Some(res_data.info_data.postal_info.clone()),
voice: Some(res_data.info_data.voice.clone()),
fax: res_data.info_data.fax,
auth_info: None,
});
Ok(())
}
None => Err(error::Error::Other(
"No res_data in EppContactInfoResponse object".to_string(),
)),
}
} }
} }
/// Type that represents the &lt;epp&gt; tag for the EPP XML contact update response
pub type EppContactUpdateResponse = EppCommandResponse;
/// Type for elements under the &lt;chg&gt; tag for contact update request /// Type for elements under the &lt;chg&gt; tag for contact update request
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
pub struct ContactChangeInfo { pub struct ContactChangeInfo {

View File

@ -3,11 +3,25 @@
use epp_client_macros::*; use epp_client_macros::*;
use super::EPP_DOMAIN_XMLNS; use super::EPP_DOMAIN_XMLNS;
use crate::common::{ElementName, EppObject, StringValue}; use crate::common::{ElementName, NoExtension, StringValue};
use crate::request::Command; use crate::request::{EppExtension, EppRequest};
use crate::response::CommandResponse;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Debug)]
pub struct DomainCheck<E> {
request: DomainCheckRequest,
extension: Option<E>,
}
impl<E: EppExtension> EppRequest<E> for DomainCheck<E> {
type Input = DomainCheckRequest;
type Output = DomainCheckResponse;
fn into_parts(self) -> (Self::Input, Option<E>) {
(self.request, self.extension)
}
}
/// Type that represents the &lt;epp&gt; request for domain &lt;check&gt; command /// Type that represents the &lt;epp&gt; request for domain &lt;check&gt; command
/// ///
/// ## Usage /// ## Usage
@ -17,8 +31,9 @@ use serde::{Deserialize, Serialize};
/// ///
/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::config::{EppClientConfig, EppClientConnection};
/// use epp_client::EppClient; /// use epp_client::EppClient;
/// use epp_client::domain::check::{EppDomainCheck, EppDomainCheckResponse}; /// use epp_client::domain::check::DomainCheck;
/// use epp_client::generate_client_tr_id; /// use epp_client::generate_client_tr_id;
/// use epp_client::common::NoExtension;
/// ///
/// #[tokio::main] /// #[tokio::main]
/// async fn main() { /// async fn main() {
@ -43,44 +58,43 @@ use serde::{Deserialize, Serialize};
/// Err(e) => panic!("Failed to create EppClient: {}", e) /// Err(e) => panic!("Failed to create EppClient: {}", e)
/// }; /// };
/// ///
/// // Create an EppDomainCheck instance /// // Create an DomainCheck instance
/// let domain_check = EppDomainCheck::new( /// let domain_check = DomainCheck::<NoExtension>::new(
/// vec!["eppdev-100.com", "eppdev-100.net"], /// vec!["eppdev-100.com", "eppdev-100.net"],
/// generate_client_tr_id(&client).as_str()
/// ); /// );
/// ///
/// // send it to the registry and receive a response of type EppDomainCheckResponse /// // send it to the registry and receive a response of type EppDomainCheckResponse
/// let response = client.transact::<_, EppDomainCheckResponse>(&domain_check).await.unwrap(); /// let response = client.transact_new(domain_check, generate_client_tr_id(&client).as_str()).await.unwrap();
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.logout().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppDomainCheck = EppObject<Command<DomainCheckRequest>>; impl<E: EppExtension> DomainCheck<E> {
pub fn new(domains: Vec<&str>) -> DomainCheck<NoExtension> {
impl EppDomainCheck { DomainCheck {
/// Creates a new EppObject for domain check corresponding to the &lt;epp&gt; tag in EPP XML request: DomainCheckRequest {
pub fn new(domains: Vec<&str>, client_tr_id: &str) -> EppDomainCheck {
let domains = domains.into_iter().map(|d| d.into()).collect();
let domain_check = DomainCheckRequest {
list: DomainList { list: DomainList {
xmlns: EPP_DOMAIN_XMLNS.to_string(), xmlns: EPP_DOMAIN_XMLNS.to_string(),
domains, domains: domains
.into_iter()
.map(|d| d.into())
.collect::<Vec<StringValue>>(),
}, },
}; },
extension: None,
}
}
EppObject::build(Command::<DomainCheckRequest>::new( pub fn with_extension<F: EppExtension>(self, extension: F) -> DomainCheck<F> {
domain_check, DomainCheck {
client_tr_id, request: self.request,
)) extension: Some(extension),
}
} }
} }
/// Type that represents the &lt;epp&gt; tag for the EPP XML domain check response
pub type EppDomainCheckResponse = EppObject<CommandResponse<DomainCheckResponse>>;
// Request // Request
/// Type for &lt;name&gt; elements under the domain &lt;check&gt; tag /// Type for &lt;name&gt; elements under the domain &lt;check&gt; tag

View File

@ -4,13 +4,26 @@ use epp_client_macros::*;
use super::EPP_DOMAIN_XMLNS; use super::EPP_DOMAIN_XMLNS;
use crate::common::{ use crate::common::{
DomainAuthInfo, DomainContact, ElementName, EppObject, HostAttr, HostAttrList, HostList, DomainAuthInfo, DomainContact, ElementName, HostList, NoExtension, Period, StringValue,
HostObjList, Period, StringValue,
}; };
use crate::request::Command; use crate::request::{EppExtension, EppRequest};
use crate::response::CommandResponse;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Debug)]
pub struct DomainCreate<E> {
request: DomainCreateRequest,
extension: Option<E>,
}
impl<E: EppExtension> EppRequest<E> for DomainCreate<E> {
type Input = DomainCreateRequest;
type Output = DomainCreateResponse;
fn into_parts(self) -> (Self::Input, Option<E>) {
(self.request, self.extension)
}
}
/// Type that represents the &lt;epp&gt; request for domain &lt;create&gt; command /// Type that represents the &lt;epp&gt; request for domain &lt;create&gt; command
/// with &lt;hostObj&gt; elements in the request for &lt;ns&gt; list /// with &lt;hostObj&gt; elements in the request for &lt;ns&gt; list
/// ///
@ -22,9 +35,13 @@ use serde::{Deserialize, Serialize};
/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::config::{EppClientConfig, EppClientConnection};
/// use epp_client::EppClient; /// use epp_client::EppClient;
/// use epp_client::common::DomainContact; /// use epp_client::common::DomainContact;
/// use epp_client::domain::create::{EppDomainCreate, EppDomainCreateResponse}; /// use epp_client::domain::create::DomainCreate;
/// use epp_client::generate_client_tr_id; /// use epp_client::generate_client_tr_id;
/// /// use epp_client::common::NoExtension;
/// use epp_client::common::HostAttrList;
/// use epp_client::common::HostList;
/// use epp_client::common::HostObjList;
/// #[tokio::main] /// #[tokio::main]
/// async fn main() { /// async fn main() {
/// // Create a config /// // Create a config
@ -48,154 +65,78 @@ use serde::{Deserialize, Serialize};
/// Err(e) => panic!("Failed to create EppClient: {}", e) /// Err(e) => panic!("Failed to create EppClient: {}", e)
/// }; /// };
/// ///
/// /// Create a vector of existing domain contact IDs
/// let contacts = vec![ /// let contacts = vec![
/// DomainContact { /// DomainContact {
/// contact_type: "admin".to_string(), /// contact_type: "admin".to_string(),
/// id: "eppdev-contact-2".to_string() /// id: "eppdev-contact-3".to_string(),
/// }, /// },
/// DomainContact { /// DomainContact {
/// contact_type: "tech".to_string(), /// contact_type: "tech".to_string(),
/// id: "eppdev-contact-2".to_string() /// id: "eppdev-contact-3".to_string(),
/// }, /// },
/// DomainContact { /// DomainContact {
/// contact_type: "billing".to_string(), /// contact_type: "billing".to_string(),
/// id: "eppdev-contact-2".to_string() /// id: "eppdev-contact-3".to_string(),
/// } /// },
/// ]; /// ];
///
/// // Create an EppDomainCreate instance /// let ns = Some(HostList::HostObjList(HostObjList {
/// let domain_create = EppDomainCreate::new( /// hosts: vec!["ns1.test.com".into(), "ns2.test.com".into()],
/// "eppdev-100.com", 1, "eppdev-contact-2", "epP4uthd#v", contacts, generate_client_tr_id(&client).as_str() /// }));
/// let domain_create = DomainCreate::<NoExtension>::new(
/// "eppdev-1.com",
/// 1,
/// ns,
/// Some("eppdev-contact-3"),
/// "epP4uthd#v",
/// Some(contacts),
/// ); /// );
/// ///
/// // send it to the registry and receive a response of type EppDomainCreateResponse /// // send it to the registry and receive a response of type EppDomainCreateResponse
/// let response = client.transact::<_, EppDomainCreateResponse>(&domain_create).await.unwrap(); /// let response = client.transact_new(domain_create, generate_client_tr_id(&client).as_str()).await.unwrap();
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.logout().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppDomainCreate = EppObject<Command<DomainCreateRequest>>; impl<E: EppExtension> DomainCreate<E> {
impl EppDomainCreate {
/// Creates a new EppObject for domain create corresponding to the &lt;epp&gt; tag in EPP XML
/// with the &lt;ns&gt; tag containing &lt;hostObj&gt; tags
pub fn new_with_ns(
name: &str,
period: u16,
ns: &[&str],
registrant_id: &str,
auth_password: &str,
contacts: Vec<DomainContact>,
client_tr_id: &str,
) -> EppDomainCreate {
let ns_list = ns.iter().map(|&n| n.into()).collect();
let domain_create = DomainCreateRequest {
domain: DomainCreateRequestData {
xmlns: EPP_DOMAIN_XMLNS.to_string(),
name: name.into(),
period: Period::new(period),
ns: Some(HostList::HostObjList(HostObjList { hosts: ns_list })),
registrant: Some(registrant_id.into()),
auth_info: DomainAuthInfo::new(auth_password),
contacts: Some(contacts),
},
};
EppObject::build(Command::<DomainCreateRequest>::new(
domain_create,
client_tr_id,
))
}
/// Creates a new EppObject for domain create corresponding to the &lt;epp&gt; tag in EPP XML
/// without any nameservers
pub fn new( pub fn new(
name: &str, name: &str,
period: u16, period: u16,
registrant_id: &str, ns: Option<HostList>,
registrant_id: Option<&str>,
auth_password: &str, auth_password: &str,
contacts: Vec<DomainContact>, contacts: Option<Vec<DomainContact>>,
client_tr_id: &str, ) -> DomainCreate<NoExtension> {
) -> EppDomainCreate { let registrant = registrant_id.map(|id| id.into());
let domain_create = DomainCreateRequest { let domain_create = DomainCreateRequest {
domain: DomainCreateRequestData { domain: DomainCreateRequestData {
xmlns: EPP_DOMAIN_XMLNS.to_string(), xmlns: EPP_DOMAIN_XMLNS.to_string(),
name: name.into(), name: name.into(),
period: Period::new(period), period: Period::new(period),
ns: None, ns,
registrant: Some(registrant_id.into()), registrant,
auth_info: DomainAuthInfo::new(auth_password), auth_info: DomainAuthInfo::new(auth_password),
contacts: Some(contacts), contacts,
}, },
}; };
EppObject::build(Command::<DomainCreateRequest>::new(
domain_create, DomainCreate {
client_tr_id, request: domain_create,
)) extension: None,
}
} }
/// Creates a new EppObject for domain create corresponding to the &lt;epp&gt; tag in EPP XML pub fn with_extension<F: EppExtension>(self, extension: F) -> DomainCreate<F> {
/// without any contacts DomainCreate {
pub fn new_without_contacts( request: self.request,
name: &str, extension: Some(extension),
period: u16,
auth_password: &str,
client_tr_id: &str,
) -> EppDomainCreate {
let domain_create = DomainCreateRequest {
domain: DomainCreateRequestData {
xmlns: EPP_DOMAIN_XMLNS.to_string(),
name: name.into(),
period: Period::new(period),
ns: None,
registrant: None,
auth_info: DomainAuthInfo::new(auth_password),
contacts: None,
},
};
EppObject::build(Command::<DomainCreateRequest>::new(
domain_create,
client_tr_id,
))
} }
/// Creates a new EppObject for domain create corresponding to the &lt;epp&gt; tag in EPP XML
/// with the &lt;ns&gt; tag containing &lt;hostAttr&gt; tags
pub fn new_with_host_attr(
name: &str,
period: u16,
ns: Vec<HostAttr>,
registrant_id: &str,
auth_password: &str,
contacts: Vec<DomainContact>,
client_tr_id: &str,
) -> EppDomainCreate {
let domain_create = DomainCreateRequest {
domain: DomainCreateRequestData {
xmlns: EPP_DOMAIN_XMLNS.to_string(),
name: name.into(),
period: Period::new(period),
ns: Some(HostList::HostAttrList(HostAttrList { hosts: ns })),
registrant: Some(registrant_id.into()),
auth_info: DomainAuthInfo::new(auth_password),
contacts: Some(contacts),
},
};
EppObject::build(Command::<DomainCreateRequest>::new(
domain_create,
client_tr_id,
))
} }
} }
/// Type that represents the &lt;epp&gt; tag for the EPP XML domain create response
pub type EppDomainCreateResponse = EppObject<CommandResponse<DomainCreateResponse>>;
// Request // Request
/// Type for elements under the domain &lt;create&gt; tag /// Type for elements under the domain &lt;create&gt; tag
@ -203,26 +144,26 @@ pub type EppDomainCreateResponse = EppObject<CommandResponse<DomainCreateRespons
pub struct DomainCreateRequestData { pub struct DomainCreateRequestData {
/// XML namespace for domain commands /// XML namespace for domain commands
#[serde(rename = "xmlns:domain", alias = "xmlns")] #[serde(rename = "xmlns:domain", alias = "xmlns")]
xmlns: String, pub xmlns: String,
/// The domain name /// The domain name
#[serde(rename = "domain:name", alias = "name")] #[serde(rename = "domain:name", alias = "name")]
name: StringValue, pub name: StringValue,
/// The period of registration /// The period of registration
#[serde(rename = "domain:period", alias = "period")] #[serde(rename = "domain:period", alias = "period")]
period: Period, pub period: Period,
/// The list of nameserver hosts /// The list of nameserver hosts
/// either of type `HostObjList` or `HostAttrList` /// either of type `HostObjList` or `HostAttrList`
#[serde(rename = "domain:ns", alias = "ns")] #[serde(rename = "domain:ns", alias = "ns")]
ns: Option<HostList>, pub ns: Option<HostList>,
/// The domain registrant /// The domain registrant
#[serde(rename = "domain:registrant", alias = "registrant")] #[serde(rename = "domain:registrant", alias = "registrant")]
registrant: Option<StringValue>, pub registrant: Option<StringValue>,
/// The list of contacts for the domain /// The list of contacts for the domain
#[serde(rename = "domain:contact", alias = "contact")] #[serde(rename = "domain:contact", alias = "contact")]
contacts: Option<Vec<DomainContact>>, pub contacts: Option<Vec<DomainContact>>,
/// The auth info for the domain /// The auth info for the domain
#[serde(rename = "domain:authInfo", alias = "authInfo")] #[serde(rename = "domain:authInfo", alias = "authInfo")]
auth_info: DomainAuthInfo, pub auth_info: DomainAuthInfo,
} }
#[derive(Serialize, Deserialize, Debug, ElementName)] #[derive(Serialize, Deserialize, Debug, ElementName)]
@ -233,7 +174,7 @@ pub struct DomainCreateRequest {
/// T being the type of nameserver list (`HostObjList` or `HostAttrList`) /// T being the type of nameserver list (`HostObjList` or `HostAttrList`)
/// to be supplied /// to be supplied
#[serde(rename = "domain:create", alias = "create")] #[serde(rename = "domain:create", alias = "create")]
domain: DomainCreateRequestData, pub domain: DomainCreateRequestData,
} }
// Response // Response
@ -243,7 +184,7 @@ pub struct DomainCreateRequest {
pub struct DomainCreateResponseData { pub struct DomainCreateResponseData {
/// XML namespace for domain response data /// XML namespace for domain response data
#[serde(rename = "xmlns:domain")] #[serde(rename = "xmlns:domain")]
xmlns: String, pub xmlns: String,
/// The domain name /// The domain name
pub name: StringValue, pub name: StringValue,
/// The creation date /// The creation date

View File

@ -3,11 +3,26 @@
use epp_client_macros::*; use epp_client_macros::*;
use super::EPP_DOMAIN_XMLNS; use super::EPP_DOMAIN_XMLNS;
use crate::common::{ElementName, EppObject, StringValue}; use crate::common::{ElementName, NoExtension, StringValue};
use crate::request::Command; use crate::request::{EppExtension, EppRequest};
use crate::response::EppCommandResponse; use crate::response::EppCommandResponse;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Debug)]
pub struct DomainDelete<E> {
request: DomainDeleteRequest,
extension: Option<E>,
}
impl<E: EppExtension> EppRequest<E> for DomainDelete<E> {
type Input = DomainDeleteRequest;
type Output = EppCommandResponse;
fn into_parts(self) -> (Self::Input, Option<E>) {
(self.request, self.extension)
}
}
/// Type that represents the &lt;epp&gt; request for domain &lt;delete&gt; command /// Type that represents the &lt;epp&gt; request for domain &lt;delete&gt; command
/// ///
/// ## Usage /// ## Usage
@ -17,8 +32,9 @@ use serde::{Deserialize, Serialize};
/// ///
/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::config::{EppClientConfig, EppClientConnection};
/// use epp_client::EppClient; /// use epp_client::EppClient;
/// use epp_client::domain::delete::{EppDomainDelete, EppDomainDeleteResponse}; /// use epp_client::domain::delete::DomainDelete;
/// use epp_client::generate_client_tr_id; /// use epp_client::generate_client_tr_id;
/// use epp_client::common::NoExtension;
/// ///
/// #[tokio::main] /// #[tokio::main]
/// async fn main() { /// async fn main() {
@ -43,37 +59,38 @@ use serde::{Deserialize, Serialize};
/// Err(e) => panic!("Failed to create EppClient: {}", e) /// Err(e) => panic!("Failed to create EppClient: {}", e)
/// }; /// };
/// ///
/// // Create an EppDomainDelete instance /// // Create an DomainDelete instance
/// let mut domain_delete = EppDomainDelete::new("eppdev-100.com", generate_client_tr_id(&client).as_str()); /// let mut domain_delete = DomainDelete::<NoExtension>::new("eppdev-100.com");
/// ///
/// // send it to the registry and receive a response of type EppDomainDeleteResponse /// // send it to the registry and receive a response of type DomainDeleteResponse
/// let response = client.transact::<_, EppDomainDeleteResponse>(&domain_delete).await.unwrap(); /// let response = client.transact_new(domain_delete, generate_client_tr_id(&client).as_str()).await.unwrap();
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.logout().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppDomainDelete = EppObject<Command<DomainDeleteRequest>>; impl<E: EppExtension> DomainDelete<E> {
pub fn new(name: &str) -> DomainDelete<NoExtension> {
impl EppDomainDelete { DomainDelete {
/// Creates a new EppObject for domain delete corresponding to the &lt;epp&gt; tag in EPP XML request: DomainDeleteRequest {
pub fn new(name: &str, client_tr_id: &str) -> EppDomainDelete {
EppObject::build(Command::<DomainDeleteRequest>::new(
DomainDeleteRequest {
domain: DomainDeleteRequestData { domain: DomainDeleteRequestData {
xmlns: EPP_DOMAIN_XMLNS.to_string(), xmlns: EPP_DOMAIN_XMLNS.to_string(),
name: name.into(), name: name.into(),
}, },
}, },
client_tr_id, extension: None,
)) }
}
pub fn with_extension<F: EppExtension>(self, extension: F) -> DomainDelete<F> {
DomainDelete {
request: self.request,
extension: Some(extension),
}
} }
} }
/// Type that represents the &lt;epp&gt; tag for the EPP XML domain delete response
pub type EppDomainDeleteResponse = EppCommandResponse;
/// Type for &lt;name&gt; element under the domain &lt;delete&gt; tag /// Type for &lt;name&gt; element under the domain &lt;delete&gt; tag
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
pub struct DomainDeleteRequestData { pub struct DomainDeleteRequestData {

View File

@ -4,13 +4,26 @@ use epp_client_macros::*;
use super::EPP_DOMAIN_XMLNS; use super::EPP_DOMAIN_XMLNS;
use crate::common::{ use crate::common::{
DomainAuthInfo, DomainContact, DomainStatus, ElementName, EppObject, HostAttr, StringValue, DomainAuthInfo, DomainContact, DomainStatus, ElementName, HostAttr, NoExtension, StringValue,
}; };
use crate::domain::rgp::request::RgpRequestResponse; use crate::request::{EppExtension, EppRequest};
use crate::request::Command;
use crate::response::CommandResponseWithExtension;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Debug)]
pub struct DomainInfo<E> {
request: DomainInfoRequest,
extension: Option<E>,
}
impl<E: EppExtension> EppRequest<E> for DomainInfo<E> {
type Input = DomainInfoRequest;
type Output = DomainInfoResponse;
fn into_parts(self) -> (Self::Input, Option<E>) {
(self.request, self.extension)
}
}
/// Type that represents the &lt;epp&gt; request for domain &lt;info&gt; command /// Type that represents the &lt;epp&gt; request for domain &lt;info&gt; command
/// ///
/// ## Usage /// ## Usage
@ -20,8 +33,9 @@ use serde::{Deserialize, Serialize};
/// ///
/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::config::{EppClientConfig, EppClientConnection};
/// use epp_client::EppClient; /// use epp_client::EppClient;
/// use epp_client::domain::info::{EppDomainInfo, EppDomainInfoResponse}; /// use epp_client::domain::info::DomainInfo;
/// use epp_client::generate_client_tr_id; /// use epp_client::generate_client_tr_id;
/// use epp_client::common::NoExtension;
/// ///
/// #[tokio::main] /// #[tokio::main]
/// async fn main() { /// async fn main() {
@ -46,24 +60,21 @@ use serde::{Deserialize, Serialize};
/// Err(e) => panic!("Failed to create EppClient: {}", e) /// Err(e) => panic!("Failed to create EppClient: {}", e)
/// }; /// };
/// ///
/// // Create an EppDomainInfo instance /// // Create an DomainInfo instance
/// let domain_info = EppDomainInfo::new("eppdev-100.com", generate_client_tr_id(&client).as_str()); /// let domain_info = DomainInfo::<NoExtension>::new("eppdev-100.com");
/// ///
/// // send it to the registry and receive a response of type EppDomainInfoResponse /// // send it to the registry and receive a response of type DomainInfoResponse
/// let response = client.transact::<_, EppDomainInfoResponse>(&domain_info).await.unwrap(); /// let response = client.transact_new(domain_info, generate_client_tr_id(&client).as_str()).await.unwrap();
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.logout().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppDomainInfo = EppObject<Command<DomainInfoRequest>>; impl<E: EppExtension> DomainInfo<E> {
pub fn new(name: &str) -> DomainInfo<NoExtension> {
impl EppDomainInfo { DomainInfo {
/// Creates a new EppObject for domain info corresponding to the &lt;epp&gt; tag in EPP XML request: DomainInfoRequest {
pub fn new(name: &str, client_tr_id: &str) -> EppDomainInfo {
EppObject::build(Command::<DomainInfoRequest>::new(
DomainInfoRequest {
info: DomainInfoRequestData { info: DomainInfoRequestData {
xmlns: EPP_DOMAIN_XMLNS.to_string(), xmlns: EPP_DOMAIN_XMLNS.to_string(),
domain: Domain { domain: Domain {
@ -72,15 +83,18 @@ impl EppDomainInfo {
}, },
}, },
}, },
client_tr_id, extension: None,
)) }
}
pub fn with_extension<F: EppExtension>(self, extension: F) -> DomainInfo<F> {
DomainInfo {
request: self.request,
extension: Some(extension),
}
} }
} }
/// Type that represents the &lt;epp&gt; tag for the EPP XML domain info response
pub type EppDomainInfoResponse =
EppObject<CommandResponseWithExtension<DomainInfoResponse, RgpRequestResponse>>;
// Request // Request
/// Type for data under the &lt;name&gt; element tag for the domain &lt;info&gt; tag /// Type for data under the &lt;name&gt; element tag for the domain &lt;info&gt; tag

View File

@ -3,12 +3,26 @@
use epp_client_macros::*; use epp_client_macros::*;
use super::EPP_DOMAIN_XMLNS; use super::EPP_DOMAIN_XMLNS;
use crate::common::{ElementName, EppObject, Period, StringValue}; use crate::common::{ElementName, NoExtension, Period, StringValue};
use crate::request::Command; use crate::request::{EppExtension, EppRequest};
use crate::response::CommandResponse;
use chrono::NaiveDate; use chrono::NaiveDate;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Debug)]
pub struct DomainRenew<E> {
request: DomainRenewRequest,
extension: Option<E>,
}
impl<E: EppExtension> EppRequest<E> for DomainRenew<E> {
type Input = DomainRenewRequest;
type Output = DomainRenewResponse;
fn into_parts(self) -> (Self::Input, Option<E>) {
(self.request, self.extension)
}
}
/// Type that represents the &lt;epp&gt; request for domain &lt;renew&gt; command /// Type that represents the &lt;epp&gt; request for domain &lt;renew&gt; command
/// ///
/// ## Usage /// ## Usage
@ -20,8 +34,9 @@ use serde::{Deserialize, Serialize};
/// ///
/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::config::{EppClientConfig, EppClientConnection};
/// use epp_client::EppClient; /// use epp_client::EppClient;
/// use epp_client::domain::renew::{EppDomainRenew, EppDomainRenewResponse}; /// use epp_client::domain::renew::DomainRenew;
/// use epp_client::generate_client_tr_id; /// use epp_client::generate_client_tr_id;
/// use epp_client::common::NoExtension;
/// ///
/// #[tokio::main] /// #[tokio::main]
/// async fn main() { /// async fn main() {
@ -49,31 +64,22 @@ use serde::{Deserialize, Serialize};
/// // Create a date object to set the current expiry date /// // Create a date object to set the current expiry date
/// let exp_date = NaiveDate::from_ymd(2022, 7, 27); /// let exp_date = NaiveDate::from_ymd(2022, 7, 27);
/// ///
/// // Create an EppDomainRenew instance /// // Create an DomainRenew instance
/// let domain_renew = EppDomainRenew::new("eppdev-100.com", exp_date, 1, generate_client_tr_id(&client).as_str()); /// let domain_renew = DomainRenew::<NoExtension>::new("eppdev-100.com", exp_date, 1);
/// ///
/// // send it to the registry and receive a response of type EppDomainRenewResponse /// // send it to the registry and receive a response of type DomainRenewResponse
/// let response = client.transact::<_, EppDomainRenewResponse>(&domain_renew).await.unwrap(); /// let response = client.transact_new(domain_renew, generate_client_tr_id(&client).as_str()).await.unwrap();
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.logout().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppDomainRenew = EppObject<Command<DomainRenewRequest>>; impl<E: EppExtension> DomainRenew<E> {
pub fn new(name: &str, current_expiry_date: NaiveDate, years: u16) -> DomainRenew<NoExtension> {
impl EppDomainRenew {
/// Creates a new EppObject for domain renew corresponding to the &lt;epp&gt; tag in EPP XML
pub fn new(
name: &str,
current_expiry_date: NaiveDate,
years: u16,
client_tr_id: &str,
) -> EppDomainRenew {
let exp_date_str = current_expiry_date.format("%Y-%m-%d").to_string().into(); let exp_date_str = current_expiry_date.format("%Y-%m-%d").to_string().into();
DomainRenew {
EppObject::build(Command::<DomainRenewRequest>::new( request: DomainRenewRequest {
DomainRenewRequest {
domain: DomainRenewRequestData { domain: DomainRenewRequestData {
xmlns: EPP_DOMAIN_XMLNS.to_string(), xmlns: EPP_DOMAIN_XMLNS.to_string(),
name: name.into(), name: name.into(),
@ -81,18 +87,18 @@ impl EppDomainRenew {
period: Period::new(years), period: Period::new(years),
}, },
}, },
client_tr_id, extension: None,
)) }
} }
pub fn set_period(&mut self, period: Period) { pub fn with_extension<F: EppExtension>(self, extension: F) -> DomainRenew<F> {
self.data.command.domain.period = period; DomainRenew {
request: self.request,
extension: Some(extension),
}
} }
} }
/// Type that represents the &lt;epp&gt; tag for the EPP XML domain renew response
pub type EppDomainRenewResponse = EppObject<CommandResponse<DomainRenewResponse>>;
// Request // Request
/// Type for data under the domain &lt;renew&gt; tag /// Type for data under the domain &lt;renew&gt; tag

View File

@ -3,11 +3,86 @@
use epp_client_macros::*; use epp_client_macros::*;
use super::EPP_DOMAIN_XMLNS; use super::EPP_DOMAIN_XMLNS;
use crate::common::{DomainAuthInfo, ElementName, EppObject, Period, StringValue}; use crate::common::{DomainAuthInfo, ElementName, NoExtension, Period, StringValue};
use crate::request::Command; use crate::request::{EppExtension, EppRequest};
use crate::response::{CommandResponse, EppCommandResponse}; use crate::response::EppCommandResponse;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Debug)]
pub struct DomainTransferRequest<E> {
request: DomainTransferReq,
extension: Option<E>,
}
impl<E: EppExtension> EppRequest<E> for DomainTransferRequest<E> {
type Input = DomainTransferReq;
type Output = DomainTransferResponse;
fn into_parts(self) -> (Self::Input, Option<E>) {
(self.request, self.extension)
}
}
#[derive(Debug)]
pub struct DomainTransferApprove<E> {
request: DomainTransferReq,
extension: Option<E>,
}
impl<E: EppExtension> EppRequest<E> for DomainTransferApprove<E> {
type Input = DomainTransferReq;
type Output = EppCommandResponse;
fn into_parts(self) -> (Self::Input, Option<E>) {
(self.request, self.extension)
}
}
#[derive(Debug)]
pub struct DomainTransferReject<E> {
request: DomainTransferReq,
extension: Option<E>,
}
impl<E: EppExtension> EppRequest<E> for DomainTransferReject<E> {
type Input = DomainTransferReq;
type Output = EppCommandResponse;
fn into_parts(self) -> (Self::Input, Option<E>) {
(self.request, self.extension)
}
}
#[derive(Debug)]
pub struct DomainTransferCancel<E> {
request: DomainTransferReq,
extension: Option<E>,
}
impl<E: EppExtension> EppRequest<E> for DomainTransferCancel<E> {
type Input = DomainTransferReq;
type Output = EppCommandResponse;
fn into_parts(self) -> (Self::Input, Option<E>) {
(self.request, self.extension)
}
}
#[derive(Debug)]
pub struct DomainTransferQuery<E> {
request: DomainTransferReq,
extension: Option<E>,
}
impl<E: EppExtension> EppRequest<E> for DomainTransferQuery<E> {
type Input = DomainTransferReq;
type Output = DomainTransferResponse;
fn into_parts(self) -> (Self::Input, Option<E>) {
(self.request, self.extension)
}
}
/// Type that represents the &lt;epp&gt; request for transfer request for domain /// Type that represents the &lt;epp&gt; request for transfer request for domain
/// ///
/// ## Usage /// ## Usage
@ -17,8 +92,9 @@ use serde::{Deserialize, Serialize};
/// ///
/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::config::{EppClientConfig, EppClientConnection};
/// use epp_client::EppClient; /// use epp_client::EppClient;
/// use epp_client::domain::transfer::{EppDomainTransferRequest, EppDomainTransferRequestResponse}; /// use epp_client::domain::transfer::DomainTransferRequest;
/// use epp_client::generate_client_tr_id; /// use epp_client::generate_client_tr_id;
/// use epp_client::common::NoExtension;
/// ///
/// #[tokio::main] /// #[tokio::main]
/// async fn main() { /// async fn main() {
@ -43,20 +119,42 @@ use serde::{Deserialize, Serialize};
/// Err(e) => panic!("Failed to create EppClient: {}", e) /// Err(e) => panic!("Failed to create EppClient: {}", e)
/// }; /// };
/// ///
/// // Create an EppDomainTransferRequest instance /// // Create an DomainTransferRequest instance
/// let domain_transfer_request = EppDomainTransferRequest::request( /// let domain_transfer_request = DomainTransferRequest::<NoExtension>::new(
/// "eppdev-100.net", 1, "epP4uthd#v", generate_client_tr_id(&client).as_str() /// "eppdev-100.net", 1, "epP4uthd#v"
/// ); /// );
/// ///
/// // send it to the registry and receive a response of type EppDomainTransferRequestResponse /// // send it to the registry and receive a response of type DomainTransferRequestResponse
/// let response = client.transact::<_, EppDomainTransferRequestResponse>(&domain_transfer_request).await.unwrap(); /// let response = client.transact_new(domain_transfer_request, generate_client_tr_id(&client).as_str()).await.unwrap();
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.logout().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppDomainTransferRequest = EppObject<Command<DomainTransferRequest>>; impl<E: EppExtension> DomainTransferRequest<E> {
pub fn new(name: &str, years: u16, auth_password: &str) -> DomainTransferRequest<NoExtension> {
DomainTransferRequest {
request: DomainTransferReq {
operation: "request".to_string(),
domain: DomainTransferReqData {
xmlns: EPP_DOMAIN_XMLNS.to_string(),
name: name.into(),
period: Some(Period::new(years)),
auth_info: Some(DomainAuthInfo::new(auth_password)),
},
},
extension: None,
}
}
pub fn with_extension<F: EppExtension>(self, extension: F) -> DomainTransferRequest<F> {
DomainTransferRequest {
request: self.request,
extension: Some(extension),
}
}
}
/// Type that represents the &lt;epp&gt; request for transfer approval for domains /// Type that represents the &lt;epp&gt; request for transfer approval for domains
/// ///
@ -67,8 +165,9 @@ pub type EppDomainTransferRequest = EppObject<Command<DomainTransferRequest>>;
/// ///
/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::config::{EppClientConfig, EppClientConnection};
/// use epp_client::EppClient; /// use epp_client::EppClient;
/// use epp_client::domain::transfer::{EppDomainTransferApprove, EppDomainTransferApproveResponse}; /// use epp_client::domain::transfer::DomainTransferApprove;
/// use epp_client::generate_client_tr_id; /// use epp_client::generate_client_tr_id;
/// use epp_client::common::NoExtension;
/// ///
/// #[tokio::main] /// #[tokio::main]
/// async fn main() { /// async fn main() {
@ -93,20 +192,42 @@ pub type EppDomainTransferRequest = EppObject<Command<DomainTransferRequest>>;
/// Err(e) => panic!("Failed to create EppClient: {}", e) /// Err(e) => panic!("Failed to create EppClient: {}", e)
/// }; /// };
/// ///
/// // Create an EppDomainTransferApprove instance /// // Create an DomainTransferApprove instance
/// let domain_transfer_approve = EppDomainTransferApprove::approve( /// let domain_transfer_approve = DomainTransferApprove::<NoExtension>::new(
/// "eppdev-100.net", generate_client_tr_id(&client).as_str() /// "eppdev-100.net"
/// ); /// );
/// ///
/// // send it to the registry and receive a response of type EppDomainTransferApproveResponse /// // send it to the registry and receive a response of type DomainTransferApproveResponse
/// let response = client.transact::<_, EppDomainTransferApproveResponse>(&domain_transfer_approve).await.unwrap(); /// let response = client.transact_new(domain_transfer_approve, generate_client_tr_id(&client).as_str()).await.unwrap();
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.logout().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppDomainTransferApprove = EppObject<Command<DomainTransferRequest>>; impl<E: EppExtension> DomainTransferApprove<E> {
pub fn new(name: &str) -> DomainTransferApprove<NoExtension> {
DomainTransferApprove {
request: DomainTransferReq {
operation: "approve".to_string(),
domain: DomainTransferReqData {
xmlns: EPP_DOMAIN_XMLNS.to_string(),
name: name.into(),
period: None,
auth_info: None,
},
},
extension: None,
}
}
pub fn with_extension<F: EppExtension>(self, extension: F) -> DomainTransferApprove<F> {
DomainTransferApprove {
request: self.request,
extension: Some(extension),
}
}
}
/// Type that represents the &lt;epp&gt; request for transfer rejection for domains /// Type that represents the &lt;epp&gt; request for transfer rejection for domains
/// ///
@ -117,8 +238,9 @@ pub type EppDomainTransferApprove = EppObject<Command<DomainTransferRequest>>;
/// ///
/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::config::{EppClientConfig, EppClientConnection};
/// use epp_client::EppClient; /// use epp_client::EppClient;
/// use epp_client::domain::transfer::{EppDomainTransferReject, EppDomainTransferRejectResponse}; /// use epp_client::domain::transfer::DomainTransferReject;
/// use epp_client::generate_client_tr_id; /// use epp_client::generate_client_tr_id;
/// use epp_client::common::NoExtension;
/// ///
/// #[tokio::main] /// #[tokio::main]
/// async fn main() { /// async fn main() {
@ -143,20 +265,42 @@ pub type EppDomainTransferApprove = EppObject<Command<DomainTransferRequest>>;
/// Err(e) => panic!("Failed to create EppClient: {}", e) /// Err(e) => panic!("Failed to create EppClient: {}", e)
/// }; /// };
/// ///
/// // Create an EppDomainTransferReject instance /// // Create an DomainTransferReject instance
/// let domain_transfer_reject = EppDomainTransferReject::reject( /// let domain_transfer_reject = DomainTransferReject::<NoExtension>::new(
/// "eppdev-100.net", generate_client_tr_id(&client).as_str() /// "eppdev-100.net"
/// ); /// );
/// ///
/// // send it to the registry and receive a response of type EppDomainTransferRejectResponse /// // send it to the registry and receive a response of type DomainTransferRejectResponse
/// let response = client.transact::<_, EppDomainTransferRejectResponse>(&domain_transfer_reject).await.unwrap(); /// let response = client.transact_new(domain_transfer_reject, generate_client_tr_id(&client).as_str()).await.unwrap();
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.logout().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppDomainTransferReject = EppObject<Command<DomainTransferRequest>>; impl<E: EppExtension> DomainTransferReject<E> {
pub fn new(name: &str) -> DomainTransferReject<NoExtension> {
DomainTransferReject {
request: DomainTransferReq {
operation: "reject".to_string(),
domain: DomainTransferReqData {
xmlns: EPP_DOMAIN_XMLNS.to_string(),
name: name.into(),
period: None,
auth_info: None,
},
},
extension: None,
}
}
pub fn with_extension<F: EppExtension>(self, extension: F) -> DomainTransferReject<F> {
DomainTransferReject {
request: self.request,
extension: Some(extension),
}
}
}
/// Type that represents the &lt;epp&gt; request for transfer request cancellation for domains /// Type that represents the &lt;epp&gt; request for transfer request cancellation for domains
/// ///
@ -167,8 +311,9 @@ pub type EppDomainTransferReject = EppObject<Command<DomainTransferRequest>>;
/// ///
/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::config::{EppClientConfig, EppClientConnection};
/// use epp_client::EppClient; /// use epp_client::EppClient;
/// use epp_client::domain::transfer::{EppDomainTransferCancel, EppDomainTransferCancelResponse}; /// use epp_client::domain::transfer::DomainTransferCancel;
/// use epp_client::generate_client_tr_id; /// use epp_client::generate_client_tr_id;
/// use epp_client::common::NoExtension;
/// ///
/// #[tokio::main] /// #[tokio::main]
/// async fn main() { /// async fn main() {
@ -193,20 +338,42 @@ pub type EppDomainTransferReject = EppObject<Command<DomainTransferRequest>>;
/// Err(e) => panic!("Failed to create EppClient: {}", e) /// Err(e) => panic!("Failed to create EppClient: {}", e)
/// }; /// };
/// ///
/// // Create an EppDomainTransferCancel instance /// // Create an DomainTransferCancel instance
/// let domain_transfer_cancel = EppDomainTransferCancel::cancel( /// let domain_transfer_cancel = DomainTransferCancel::<NoExtension>::new(
/// "eppdev-100.net", generate_client_tr_id(&client).as_str() /// "eppdev-100.net"
/// ); /// );
/// ///
/// // send it to the registry and receive a response of type EppDomainTransferCancelResponse /// // send it to the registry and receive a response of type DomainTransferCancelResponse
/// let response = client.transact::<_, EppDomainTransferCancelResponse>(&domain_transfer_cancel).await.unwrap(); /// let response = client.transact_new(domain_transfer_cancel, generate_client_tr_id(&client).as_str()).await.unwrap();
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.logout().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppDomainTransferCancel = EppObject<Command<DomainTransferRequest>>; impl<E: EppExtension> DomainTransferCancel<E> {
pub fn new(name: &str) -> DomainTransferCancel<NoExtension> {
DomainTransferCancel {
request: DomainTransferReq {
operation: "cancel".to_string(),
domain: DomainTransferReqData {
xmlns: EPP_DOMAIN_XMLNS.to_string(),
name: name.into(),
period: None,
auth_info: None,
},
},
extension: None,
}
}
pub fn with_extension<F: EppExtension>(self, extension: F) -> DomainTransferCancel<F> {
DomainTransferCancel {
request: self.request,
extension: Some(extension),
}
}
}
/// Type that represents the &lt;epp&gt; request for transfer request query for domains /// Type that represents the &lt;epp&gt; request for transfer request query for domains
/// ///
@ -217,8 +384,9 @@ pub type EppDomainTransferCancel = EppObject<Command<DomainTransferRequest>>;
/// ///
/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::config::{EppClientConfig, EppClientConnection};
/// use epp_client::EppClient; /// use epp_client::EppClient;
/// use epp_client::domain::transfer::{EppDomainTransferQuery, EppDomainTransferQueryResponse}; /// use epp_client::domain::transfer::DomainTransferQuery;
/// use epp_client::generate_client_tr_id; /// use epp_client::generate_client_tr_id;
/// use epp_client::common::NoExtension;
/// ///
/// #[tokio::main] /// #[tokio::main]
/// async fn main() { /// async fn main() {
@ -243,137 +411,48 @@ pub type EppDomainTransferCancel = EppObject<Command<DomainTransferRequest>>;
/// Err(e) => panic!("Failed to create EppClient: {}", e) /// Err(e) => panic!("Failed to create EppClient: {}", e)
/// }; /// };
/// ///
/// // Create an EppDomainTransferQuery instance /// // Create an DomainTransferQuery instance
/// let domain_transfer_query = EppDomainTransferQuery::query( /// let domain_transfer_query = DomainTransferQuery::<NoExtension>::new(
/// "eppdev-100.net", "epP4uthd#v", generate_client_tr_id(&client).as_str() /// "eppdev-100.net", "epP4uthd#v"
/// ); /// );
/// ///
/// // send it to the registry and receive a response of type EppDomainTransferQueryResponse /// // send it to the registry and receive a response of type DomainTransferQueryResponse
/// let response = client.transact::<_, EppDomainTransferQueryResponse>(&domain_transfer_query).await.unwrap(); /// let response = client.transact_new(domain_transfer_query, generate_client_tr_id(&client).as_str()).await.unwrap();
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.logout().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppDomainTransferQuery = EppObject<Command<DomainTransferRequest>>; impl<E: EppExtension> DomainTransferQuery<E> {
pub fn new(name: &str, auth_password: &str) -> DomainTransferQuery<NoExtension> {
impl EppDomainTransferRequest { DomainTransferQuery {
/// Creates a new EppObject for domain transfer request corresponding to the &lt;epp&gt; tag in EPP XML request: DomainTransferReq {
pub fn request(
name: &str,
years: u16,
auth_password: &str,
client_tr_id: &str,
) -> EppDomainTransferRequest {
EppObject::build(Command::<DomainTransferRequest>::new(
DomainTransferRequest {
operation: "request".to_string(),
domain: DomainTransferRequestData {
xmlns: EPP_DOMAIN_XMLNS.to_string(),
name: name.into(),
period: Some(Period::new(years)),
auth_info: Some(DomainAuthInfo::new(auth_password)),
},
},
client_tr_id,
))
}
/// Sets the period for renewal in case of a successful transfer
pub fn set_period(&mut self, period: Period) {
self.data.command.domain.period = Some(period);
}
}
impl EppDomainTransferApprove {
/// Creates a new EppObject for domain transfer approval corresponding to the &lt;epp&gt; tag in EPP XML
pub fn approve(name: &str, client_tr_id: &str) -> EppDomainTransferApprove {
EppObject::build(Command::<DomainTransferRequest>::new(
DomainTransferRequest {
operation: "approve".to_string(),
domain: DomainTransferRequestData {
xmlns: EPP_DOMAIN_XMLNS.to_string(),
name: name.into(),
period: None,
auth_info: None,
},
},
client_tr_id,
))
}
}
impl EppDomainTransferCancel {
/// Creates a new EppObject for domain transfer request cancellation corresponding to the &lt;epp&gt; tag in EPP XML
pub fn cancel(name: &str, client_tr_id: &str) -> EppDomainTransferCancel {
EppObject::build(Command::<DomainTransferRequest>::new(
DomainTransferRequest {
operation: "cancel".to_string(),
domain: DomainTransferRequestData {
xmlns: EPP_DOMAIN_XMLNS.to_string(),
name: name.into(),
period: None,
auth_info: None,
},
},
client_tr_id,
))
}
}
impl EppDomainTransferReject {
/// Creates a new EppObject for domain transfer rejection corresponding to the &lt;epp&gt; tag in EPP XML
pub fn reject(name: &str, client_tr_id: &str) -> EppDomainTransferReject {
EppObject::build(Command::<DomainTransferRequest>::new(
DomainTransferRequest {
operation: "reject".to_string(),
domain: DomainTransferRequestData {
xmlns: EPP_DOMAIN_XMLNS.to_string(),
name: name.into(),
period: None,
auth_info: None,
},
},
client_tr_id,
))
}
}
impl EppDomainTransferQuery {
/// Creates a new EppObject for domain transfer request query corresponding to the &lt;epp&gt; tag in EPP XML
pub fn query(name: &str, auth_password: &str, client_tr_id: &str) -> EppDomainTransferQuery {
EppObject::build(Command::<DomainTransferRequest>::new(
DomainTransferRequest {
operation: "query".to_string(), operation: "query".to_string(),
domain: DomainTransferRequestData { domain: DomainTransferReqData {
xmlns: EPP_DOMAIN_XMLNS.to_string(), xmlns: EPP_DOMAIN_XMLNS.to_string(),
name: name.into(), name: name.into(),
period: None, period: None,
auth_info: Some(DomainAuthInfo::new(auth_password)), auth_info: Some(DomainAuthInfo::new(auth_password)),
}, },
}, },
client_tr_id, extension: None,
)) }
}
pub fn with_extension<F: EppExtension>(self, extension: F) -> DomainTransferQuery<F> {
DomainTransferQuery {
request: self.request,
extension: Some(extension),
}
} }
} }
/// Type that represents the &lt;epp&gt; tag for the EPP XML domain transfer request response
pub type EppDomainTransferRequestResponse = EppObject<CommandResponse<DomainTransferResponse>>;
/// Type that represents the &lt;epp&gt; tag for the EPP XML domain transfer approval response
pub type EppDomainTransferApproveResponse = EppCommandResponse;
/// Type that represents the &lt;epp&gt; tag for the EPP XML domain transfer rejection response
pub type EppDomainTransferRejectResponse = EppCommandResponse;
/// Type that represents the &lt;epp&gt; tag for the EPP XML domain transfer cancellation response
pub type EppDomainTransferCancelResponse = EppCommandResponse;
/// Type that represents the &lt;epp&gt; tag for the EPP XML domain transfer query response
pub type EppDomainTransferQueryResponse = EppObject<CommandResponse<DomainTransferResponse>>;
// Request // Request
/// Type for elements under the domain &lt;transfer&gt; tag /// Type for elements under the domain &lt;transfer&gt; tag
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
pub struct DomainTransferRequestData { pub struct DomainTransferReqData {
/// XML namespace for domain commands /// XML namespace for domain commands
#[serde(rename = "xmlns:domain")] #[serde(rename = "xmlns:domain")]
xmlns: String, xmlns: String,
@ -393,14 +472,14 @@ pub struct DomainTransferRequestData {
#[derive(Serialize, Deserialize, Debug, ElementName)] #[derive(Serialize, Deserialize, Debug, ElementName)]
#[element_name(name = "transfer")] #[element_name(name = "transfer")]
/// Type for EPP XML &lt;transfer&gt; command for domains /// Type for EPP XML &lt;transfer&gt; command for domains
pub struct DomainTransferRequest { pub struct DomainTransferReq {
/// The transfer operation to perform indicated by the 'op' attr /// The transfer operation to perform indicated by the 'op' attr
/// The values are one of transfer, approve, reject, cancel, or query /// The values are one of transfer, approve, reject, cancel, or query
#[serde(rename = "op")] #[serde(rename = "op")]
operation: String, operation: String,
/// The data under the &lt;transfer&gt; tag in the transfer request /// The data under the &lt;transfer&gt; tag in the transfer request
#[serde(rename = "domain:transfer")] #[serde(rename = "domain:transfer")]
domain: DomainTransferRequestData, domain: DomainTransferReqData,
} }
// Response // Response

View File

@ -2,15 +2,34 @@
use epp_client_macros::*; use epp_client_macros::*;
use crate::common::{ use crate::{
DomainAuthInfo, DomainContact, DomainStatus, ElementName, EppObject, HostList, StringValue, common::{
DomainAuthInfo, DomainContact, DomainStatus, ElementName, HostList, NoExtension,
StringValue,
},
request::{EppExtension, EppRequest},
}; };
use super::EPP_DOMAIN_XMLNS; use super::EPP_DOMAIN_XMLNS;
use crate::request::Command;
use crate::response::EppCommandResponse; use crate::response::EppCommandResponse;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Debug)]
pub struct DomainUpdate<E> {
request: DomainUpdateRequest,
extension: Option<E>,
}
impl<E: EppExtension> EppRequest<E> for DomainUpdate<E> {
type Input = DomainUpdateRequest;
type Output = EppCommandResponse;
fn into_parts(self) -> (Self::Input, Option<E>) {
(self.request, self.extension)
}
}
/// Type that represents the &lt;epp&gt; request for domain &lt;update&gt; command /// Type that represents the &lt;epp&gt; request for domain &lt;update&gt; command
/// with &lt;hostObj&gt; elements in the request for &lt;ns&gt; list /// with &lt;hostObj&gt; elements in the request for &lt;ns&gt; list
/// ///
@ -22,8 +41,9 @@ use serde::{Deserialize, Serialize};
/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::config::{EppClientConfig, EppClientConnection};
/// use epp_client::EppClient; /// use epp_client::EppClient;
/// use epp_client::common::{DomainStatus, DomainContact}; /// use epp_client::common::{DomainStatus, DomainContact};
/// use epp_client::domain::update::{EppDomainUpdate, EppDomainUpdateResponse, DomainAddRemove}; /// use epp_client::domain::update::{DomainUpdate, DomainAddRemove};
/// use epp_client::generate_client_tr_id; /// use epp_client::generate_client_tr_id;
/// use epp_client::common::NoExtension;
/// ///
/// #[tokio::main] /// #[tokio::main]
/// async fn main() { /// async fn main() {
@ -48,8 +68,8 @@ use serde::{Deserialize, Serialize};
/// Err(e) => panic!("Failed to create EppClient: {}", e) /// Err(e) => panic!("Failed to create EppClient: {}", e)
/// }; /// };
/// ///
/// // Create an EppDomainUpdate instance /// // Create an DomainUpdate instance
/// let mut domain_update = EppDomainUpdate::new("eppdev-100.com", generate_client_tr_id(&client).as_str()); /// let mut domain_update = DomainUpdate::<NoExtension>::new("eppdev-100.com");
/// ///
/// let add = DomainAddRemove { /// let add = DomainAddRemove {
/// ns: None, /// ns: None,
@ -76,21 +96,17 @@ use serde::{Deserialize, Serialize};
/// domain_update.remove(remove); /// domain_update.remove(remove);
/// ///
/// // send it to the registry and receive a response of type EppDomainUpdateResponse /// // send it to the registry and receive a response of type EppDomainUpdateResponse
/// let response = client.transact::<_, EppDomainUpdateResponse>(&domain_update).await.unwrap(); /// let response = client.transact_new(domain_update, generate_client_tr_id(&client).as_str()).await.unwrap();
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.logout().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppDomainUpdate = EppObject<Command<DomainUpdateRequest>>; impl<E: EppExtension> DomainUpdate<E> {
pub fn new(name: &str) -> DomainUpdate<NoExtension> {
impl EppDomainUpdate { DomainUpdate {
/// Creates a new EppObject for domain update corresponding to the &lt;epp&gt; tag in EPP XML request: DomainUpdateRequest {
/// with the &lt;ns&gt; tag containing &lt;hostObj&gt; tags
pub fn new(name: &str, client_tr_id: &str) -> EppDomainUpdate {
EppObject::build(Command::<DomainUpdateRequest>::new(
DomainUpdateRequest {
domain: DomainUpdateRequestData { domain: DomainUpdateRequestData {
xmlns: EPP_DOMAIN_XMLNS.to_string(), xmlns: EPP_DOMAIN_XMLNS.to_string(),
name: name.into(), name: name.into(),
@ -99,29 +115,33 @@ impl EppDomainUpdate {
change_info: None, change_info: None,
}, },
}, },
client_tr_id, extension: None,
)) }
}
pub fn with_extension<F: EppExtension>(self, extension: F) -> DomainUpdate<F> {
DomainUpdate {
request: self.request,
extension: Some(extension),
}
} }
/// Sets the data for the &lt;chg&gt; tag /// Sets the data for the &lt;chg&gt; tag
pub fn info(&mut self, info: DomainChangeInfo) { pub fn info(&mut self, info: DomainChangeInfo) {
self.data.command.domain.change_info = Some(info); self.request.domain.change_info = Some(info);
} }
/// Sets the data for the &lt;add&gt; tag /// Sets the data for the &lt;add&gt; tag
pub fn add(&mut self, add: DomainAddRemove) { pub fn add(&mut self, add: DomainAddRemove) {
self.data.command.domain.add = Some(add); self.request.domain.add = Some(add);
} }
/// Sets the data for the &lt;rem&gt; tag /// Sets the data for the &lt;rem&gt; tag
pub fn remove(&mut self, remove: DomainAddRemove) { pub fn remove(&mut self, remove: DomainAddRemove) {
self.data.command.domain.remove = Some(remove); self.request.domain.remove = Some(remove);
} }
} }
/// Type that represents the &lt;epp&gt; tag for the EPP XML domain update response
pub type EppDomainUpdateResponse = EppCommandResponse;
/// Type for elements under the &lt;chg&gt; tag for domain update /// Type for elements under the &lt;chg&gt; tag for domain update
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
pub struct DomainChangeInfo { pub struct DomainChangeInfo {

View File

@ -1,13 +1,29 @@
//! Types for EPP host check request //! Types for EPP host check request
use std::fmt::Debug;
use epp_client_macros::*; use epp_client_macros::*;
use crate::common::{ElementName, EppObject, StringValue}; use crate::common::{ElementName, NoExtension, StringValue};
use crate::host::EPP_HOST_XMLNS; use crate::host::EPP_HOST_XMLNS;
use crate::request::Command; use crate::request::{EppExtension, EppRequest};
use crate::response::CommandResponse;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Debug)]
pub struct HostCheck<E> {
request: HostCheckRequest,
extension: Option<E>,
}
impl<E: EppExtension> EppRequest<E> for HostCheck<E> {
type Input = HostCheckRequest;
type Output = HostCheckResponse;
fn into_parts(self) -> (Self::Input, Option<E>) {
(self.request, self.extension)
}
}
/// Type that represents the &lt;epp&gt; request for host &lt;check&gt; command /// Type that represents the &lt;epp&gt; request for host &lt;check&gt; command
/// ///
/// ## Usage /// ## Usage
@ -17,8 +33,9 @@ use serde::{Deserialize, Serialize};
/// ///
/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::config::{EppClientConfig, EppClientConnection};
/// use epp_client::EppClient; /// use epp_client::EppClient;
/// use epp_client::host::check::{EppHostCheck, EppHostCheckResponse}; /// use epp_client::host::check::HostCheck;
/// use epp_client::generate_client_tr_id; /// use epp_client::generate_client_tr_id;
/// use epp_client::common::NoExtension;
/// ///
/// #[tokio::main] /// #[tokio::main]
/// async fn main() { /// async fn main() {
@ -43,41 +60,42 @@ use serde::{Deserialize, Serialize};
/// Err(e) => panic!("Failed to create EppClient: {}", e) /// Err(e) => panic!("Failed to create EppClient: {}", e)
/// }; /// };
/// ///
/// // Create an EppHostCheck instance /// // Create an HostCheck instance
/// let host_check = EppHostCheck::new( /// let host_check = HostCheck::<NoExtension>::new(
/// &["ns1.eppdev-101.com", "ns2.eppdev-101.com"], /// &["ns1.eppdev-101.com", "ns2.eppdev-101.com"]
/// generate_client_tr_id(&client).as_str()
/// ); /// );
/// ///
/// // send it to the registry and receive a response of type EppHostCheckResponse /// // send it to the registry and receive a response of type HostCheckResponse
/// let response = client.transact::<_, EppHostCheckResponse>(&host_check).await.unwrap(); /// let response = client.transact_new(host_check, generate_client_tr_id(&client).as_str()).await.unwrap();
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.logout().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppHostCheck = EppObject<Command<HostCheckRequest>>; impl<E: EppExtension> HostCheck<E> {
pub fn new(hosts: &[&str]) -> HostCheck<NoExtension> {
impl EppHostCheck {
/// Creates a new EppObject for host check corresponding to the &lt;epp&gt; tag in EPP XML
pub fn new(hosts: &[&str], client_tr_id: &str) -> EppHostCheck {
let hosts = hosts.iter().map(|&d| d.into()).collect(); let hosts = hosts.iter().map(|&d| d.into()).collect();
let host_check = HostCheckRequest { HostCheck {
request: HostCheckRequest {
list: HostList { list: HostList {
xmlns: EPP_HOST_XMLNS.to_string(), xmlns: EPP_HOST_XMLNS.to_string(),
hosts, hosts,
}, },
}; },
extension: None,
}
}
EppObject::build(Command::<HostCheckRequest>::new(host_check, client_tr_id)) pub fn with_extension<F: EppExtension>(self, extension: F) -> HostCheck<F> {
HostCheck {
request: self.request,
extension: Some(extension),
}
} }
} }
/// Type that represents the &lt;epp&gt; tag for the EPP XML host check response
pub type EppHostCheckResponse = EppObject<CommandResponse<HostCheckResult>>;
// Request // Request
/// Type for data under the host &lt;check&gt; tag /// Type for data under the host &lt;check&gt; tag
@ -104,7 +122,7 @@ pub struct HostCheckRequest {
/// Type that represents the &lt;name&gt; tag for host check response /// Type that represents the &lt;name&gt; tag for host check response
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
pub struct HostCheck { pub struct HostAvailable {
/// The host name /// The host name
#[serde(rename = "$value")] #[serde(rename = "$value")]
pub name: StringValue, pub name: StringValue,
@ -118,7 +136,7 @@ pub struct HostCheck {
pub struct HostCheckDataItem { pub struct HostCheckDataItem {
/// Data under the &lt;name&gt; tag /// Data under the &lt;name&gt; tag
#[serde(rename = "name")] #[serde(rename = "name")]
pub host: HostCheck, pub host: HostAvailable,
/// The reason for (un)availability /// The reason for (un)availability
pub reason: Option<StringValue>, pub reason: Option<StringValue>,
} }
@ -136,7 +154,7 @@ pub struct HostCheckData {
/// Type that represents the &lt;resData&gt; tag for host check response /// Type that represents the &lt;resData&gt; tag for host check response
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
pub struct HostCheckResult { pub struct HostCheckResponse {
/// Data under the &lt;chkData&gt; tag /// Data under the &lt;chkData&gt; tag
#[serde(rename = "chkData")] #[serde(rename = "chkData")]
pub check_data: HostCheckData, pub check_data: HostCheckData,

View File

@ -2,12 +2,26 @@
use epp_client_macros::*; use epp_client_macros::*;
use crate::common::{ElementName, EppObject, HostAddr, StringValue}; use crate::common::{ElementName, HostAddr, NoExtension, StringValue};
use crate::host::EPP_HOST_XMLNS; use crate::host::EPP_HOST_XMLNS;
use crate::request::Command; use crate::request::{EppExtension, EppRequest};
use crate::response::CommandResponse;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Debug)]
pub struct HostCreate<E> {
request: HostCreateRequest,
extension: Option<E>,
}
impl<E: EppExtension> EppRequest<E> for HostCreate<E> {
type Input = HostCreateRequest;
type Output = HostCreateResponse;
fn into_parts(self) -> (Self::Input, Option<E>) {
(self.request, self.extension)
}
}
/// Type that represents the &lt;epp&gt; request for host &lt;create&gt; command /// Type that represents the &lt;epp&gt; request for host &lt;create&gt; command
/// ///
/// ## Usage /// ## Usage
@ -18,8 +32,9 @@ use serde::{Deserialize, Serialize};
/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::config::{EppClientConfig, EppClientConnection};
/// use epp_client::EppClient; /// use epp_client::EppClient;
/// use epp_client::common::HostAddr; /// use epp_client::common::HostAddr;
/// use epp_client::host::create::{EppHostCreate, EppHostCreateResponse}; /// use epp_client::host::create::HostCreate;
/// use epp_client::generate_client_tr_id; /// use epp_client::generate_client_tr_id;
/// use epp_client::common::NoExtension;
/// ///
/// #[tokio::main] /// #[tokio::main]
/// async fn main() { /// async fn main() {
@ -50,37 +65,39 @@ use serde::{Deserialize, Serialize};
/// HostAddr::new("v6", "2404:6800:4001:801::200e"), /// HostAddr::new("v6", "2404:6800:4001:801::200e"),
/// ]; /// ];
/// ///
/// // Create an EppHostCreate instance /// // Create an HostCreate instance
/// let host_create = EppHostCreate::new("ns1.eppdev-101.com", addresses, generate_client_tr_id(&client).as_str()); /// let host_create = HostCreate::<NoExtension>::new("ns1.eppdev-101.com", addresses);
/// ///
/// // send it to the registry and receive a response of type EppHostCreateResponse /// // send it to the registry and receive a response of type HostCreateResponse
/// let response = client.transact::<_, EppHostCreateResponse>(&host_create).await.unwrap(); /// let response = client.transact_new(host_create, generate_client_tr_id(&client).as_str()).await.unwrap();
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.logout().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppHostCreate = EppObject<Command<HostCreateRequest>>; impl<E: EppExtension> HostCreate<E> {
pub fn new(host: &str, addresses: Vec<HostAddr>) -> HostCreate<NoExtension> {
impl EppHostCreate { HostCreate {
/// Creates a new EppObject for host create corresponding to the &lt;epp&gt; tag in EPP XML request: HostCreateRequest {
pub fn new(host: &str, addresses: Vec<HostAddr>, client_tr_id: &str) -> EppHostCreate {
let host_create = HostCreateRequest {
host: HostCreateRequestData { host: HostCreateRequestData {
xmlns: EPP_HOST_XMLNS.to_string(), xmlns: EPP_HOST_XMLNS.to_string(),
name: host.into(), name: host.into(),
addresses: Some(addresses), addresses: Some(addresses),
}, },
}; },
extension: None,
}
}
EppObject::build(Command::<HostCreateRequest>::new(host_create, client_tr_id)) pub fn with_extension<F: EppExtension>(self, extension: F) -> HostCreate<F> {
HostCreate {
request: self.request,
extension: Some(extension),
}
} }
} }
/// Type that represents the &lt;epp&gt; tag for the EPP XML host create response
pub type EppHostCreateResponse = EppObject<CommandResponse<HostCreateResponse>>;
// Request // Request
/// Type for data under the host &lt;create&gt; tag /// Type for data under the host &lt;create&gt; tag

View File

@ -2,12 +2,27 @@
use epp_client_macros::*; use epp_client_macros::*;
use crate::common::{ElementName, EppObject, StringValue}; use crate::common::{ElementName, NoExtension, StringValue};
use crate::host::EPP_HOST_XMLNS; use crate::host::EPP_HOST_XMLNS;
use crate::request::Command; use crate::request::{EppExtension, EppRequest};
use crate::response::EppCommandResponse; use crate::response::EppCommandResponse;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Debug)]
pub struct HostDelete<E> {
request: HostDeleteRequest,
extension: Option<E>,
}
impl<E: EppExtension> EppRequest<E> for HostDelete<E> {
type Input = HostDeleteRequest;
type Output = EppCommandResponse;
fn into_parts(self) -> (Self::Input, Option<E>) {
(self.request, self.extension)
}
}
/// Type that represents the &lt;epp&gt; request for host &lt;delete&gt; command /// Type that represents the &lt;epp&gt; request for host &lt;delete&gt; command
/// ///
/// ## Usage /// ## Usage
@ -17,8 +32,9 @@ use serde::{Deserialize, Serialize};
/// ///
/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::config::{EppClientConfig, EppClientConnection};
/// use epp_client::EppClient; /// use epp_client::EppClient;
/// use epp_client::host::delete::{EppHostDelete, EppHostDeleteResponse}; /// use epp_client::host::delete::HostDelete;
/// use epp_client::generate_client_tr_id; /// use epp_client::generate_client_tr_id;
/// use epp_client::common::NoExtension;
/// ///
/// #[tokio::main] /// #[tokio::main]
/// async fn main() { /// async fn main() {
@ -43,37 +59,38 @@ use serde::{Deserialize, Serialize};
/// Err(e) => panic!("Failed to create EppClient: {}", e) /// Err(e) => panic!("Failed to create EppClient: {}", e)
/// }; /// };
/// ///
/// // Create an EppHostDelete instance /// // Create an HostDelete instance
/// let host_delete = EppHostDelete::new("ns2.eppdev-101.com", generate_client_tr_id(&client).as_str()); /// let host_delete = HostDelete::<NoExtension>::new("ns2.eppdev-101.com");
/// ///
/// // send it to the registry and receive a response of type EppHostDeleteResponse /// // send it to the registry and receive a response of type HostDeleteResponse
/// let response = client.transact::<_, EppHostDeleteResponse>(&host_delete).await.unwrap(); /// let response = client.transact_new(host_delete, generate_client_tr_id(&client).as_str()).await.unwrap();
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.logout().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppHostDelete = EppObject<Command<HostDeleteRequest>>; impl<E: EppExtension> HostDelete<E> {
pub fn new(name: &str) -> HostDelete<NoExtension> {
impl EppHostDelete { HostDelete {
/// Creates a new EppObject for host delete corresponding to the &lt;epp&gt; tag in EPP XML request: HostDeleteRequest {
pub fn new(name: &str, client_tr_id: &str) -> EppHostDelete {
EppObject::build(Command::<HostDeleteRequest>::new(
HostDeleteRequest {
host: HostDeleteRequestData { host: HostDeleteRequestData {
xmlns: EPP_HOST_XMLNS.to_string(), xmlns: EPP_HOST_XMLNS.to_string(),
name: name.into(), name: name.into(),
}, },
}, },
client_tr_id, extension: None,
)) }
}
pub fn with_extension<F: EppExtension>(self, extension: F) -> HostDelete<F> {
HostDelete {
request: self.request,
extension: Some(extension),
}
} }
} }
/// Type that represents the &lt;epp&gt; tag for the EPP XML host delete response
pub type EppHostDeleteResponse = EppCommandResponse;
/// Type for data under the host &lt;delete&gt; tag /// Type for data under the host &lt;delete&gt; tag
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
pub struct HostDeleteRequestData { pub struct HostDeleteRequestData {

View File

@ -2,12 +2,26 @@
use epp_client_macros::*; use epp_client_macros::*;
use crate::common::{ElementName, EppObject, HostAddr, HostStatus, StringValue}; use crate::common::{ElementName, HostAddr, HostStatus, NoExtension, StringValue};
use crate::host::EPP_HOST_XMLNS; use crate::host::EPP_HOST_XMLNS;
use crate::request::Command; use crate::request::{EppExtension, EppRequest};
use crate::response::CommandResponse;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Debug)]
pub struct HostInfo<E> {
request: HostInfoRequest,
extension: Option<E>,
}
impl<E: EppExtension> EppRequest<E> for HostInfo<E> {
type Input = HostInfoRequest;
type Output = HostInfoResponse;
fn into_parts(self) -> (Self::Input, Option<E>) {
(self.request, self.extension)
}
}
/// Type that represents the &lt;epp&gt; request for host &lt;info&gt; command /// Type that represents the &lt;epp&gt; request for host &lt;info&gt; command
/// ///
/// ## Usage /// ## Usage
@ -17,8 +31,9 @@ use serde::{Deserialize, Serialize};
/// ///
/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::config::{EppClientConfig, EppClientConnection};
/// use epp_client::EppClient; /// use epp_client::EppClient;
/// use epp_client::host::info::{EppHostInfo, EppHostInfoResponse}; /// use epp_client::host::info::HostInfo;
/// use epp_client::generate_client_tr_id; /// use epp_client::generate_client_tr_id;
/// use epp_client::common::NoExtension;
/// ///
/// #[tokio::main] /// #[tokio::main]
/// async fn main() { /// async fn main() {
@ -43,37 +58,38 @@ use serde::{Deserialize, Serialize};
/// Err(e) => panic!("Failed to create EppClient: {}", e) /// Err(e) => panic!("Failed to create EppClient: {}", e)
/// }; /// };
/// ///
/// // Create an EppHostCreate instance /// // Create an HostInfo instance
/// let host_info = EppHostInfo::new("ns2.eppdev-101.com", generate_client_tr_id(&client).as_str()); /// let host_info = HostInfo::<NoExtension>::new("ns2.eppdev-101.com");
/// ///
/// // send it to the registry and receive a response of type EppHostInfoResponse /// // send it to the registry and receive a response of type HostInfoResponse
/// let response = client.transact::<_, EppHostInfoResponse>(&host_info).await.unwrap(); /// let response = client.transact_new(host_info, generate_client_tr_id(&client).as_str()).await.unwrap();
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.logout().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppHostInfo = EppObject<Command<HostInfoRequest>>; impl<E: EppExtension> HostInfo<E> {
pub fn new(name: &str) -> HostInfo<NoExtension> {
impl EppHostInfo { HostInfo {
/// Creates a new EppObject for host info corresponding to the &lt;epp&gt; tag in EPP XML request: HostInfoRequest {
pub fn new(name: &str, client_tr_id: &str) -> EppHostInfo {
EppObject::build(Command::<HostInfoRequest>::new(
HostInfoRequest {
info: HostInfoRequestData { info: HostInfoRequestData {
xmlns: EPP_HOST_XMLNS.to_string(), xmlns: EPP_HOST_XMLNS.to_string(),
name: name.into(), name: name.into(),
}, },
}, },
client_tr_id, extension: None,
)) }
}
pub fn with_extension<F: EppExtension>(self, extension: F) -> HostInfo<F> {
HostInfo {
request: self.request,
extension: Some(extension),
}
} }
} }
/// Type that represents the &lt;epp&gt; tag for the EPP XML host info response
pub type EppHostInfoResponse = EppObject<CommandResponse<HostInfoResponse>>;
// Request // Request
/// Type for data under the host &lt;info&gt; tag /// Type for data under the host &lt;info&gt; tag

View File

@ -2,12 +2,27 @@
use epp_client_macros::*; use epp_client_macros::*;
use crate::common::{ElementName, EppObject, HostAddr, HostStatus, StringValue}; use crate::common::{ElementName, HostAddr, HostStatus, NoExtension, StringValue};
use crate::host::EPP_HOST_XMLNS; use crate::host::EPP_HOST_XMLNS;
use crate::request::Command; use crate::request::{EppExtension, EppRequest};
use crate::response::EppCommandResponse; use crate::response::EppCommandResponse;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Debug)]
pub struct HostUpdate<E> {
request: HostUpdateRequest,
extension: Option<E>,
}
impl<E: EppExtension> EppRequest<E> for HostUpdate<E> {
type Input = HostUpdateRequest;
type Output = EppCommandResponse;
fn into_parts(self) -> (Self::Input, Option<E>) {
(self.request, self.extension)
}
}
/// Type that represents the &lt;epp&gt; request for host &lt;update&gt; command /// Type that represents the &lt;epp&gt; request for host &lt;update&gt; command
/// ///
/// ## Usage /// ## Usage
@ -18,8 +33,9 @@ use serde::{Deserialize, Serialize};
/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::config::{EppClientConfig, EppClientConnection};
/// use epp_client::EppClient; /// use epp_client::EppClient;
/// use epp_client::common::{HostAddr, HostStatus}; /// use epp_client::common::{HostAddr, HostStatus};
/// use epp_client::host::update::{EppHostUpdate, EppHostUpdateResponse, HostAddRemove, HostChangeInfo}; /// use epp_client::host::update::{HostUpdate, HostAddRemove, HostChangeInfo};
/// use epp_client::generate_client_tr_id; /// use epp_client::generate_client_tr_id;
/// use epp_client::common::NoExtension;
/// ///
/// #[tokio::main] /// #[tokio::main]
/// async fn main() { /// async fn main() {
@ -44,8 +60,8 @@ use serde::{Deserialize, Serialize};
/// Err(e) => panic!("Failed to create EppClient: {}", e) /// Err(e) => panic!("Failed to create EppClient: {}", e)
/// }; /// };
/// ///
/// // Create an EppHostUpdate instance /// // Create an HostUpdate instance
/// let mut host_update = EppHostUpdate::new("ns1.eppdev-101.com", generate_client_tr_id(&client).as_str()); /// let mut host_update = HostUpdate::<NoExtension>::new("ns1.eppdev-101.com");
/// ///
/// /// Prepare the add and remove sections for the update /// /// Prepare the add and remove sections for the update
/// let add = HostAddRemove { /// let add = HostAddRemove {
@ -68,21 +84,18 @@ use serde::{Deserialize, Serialize};
/// // Send a &lt;chg&gt; section as well /// // Send a &lt;chg&gt; section as well
/// host_update.info(HostChangeInfo { name: "ns2.eppdev-101.com".into() }); /// host_update.info(HostChangeInfo { name: "ns2.eppdev-101.com".into() });
/// ///
/// // send it to the registry and receive a response of type EppHostUpdateResponse /// // send it to the registry and receive a response of type HostUpdateResponse
/// let response = client.transact::<_, EppHostUpdateResponse>(&host_update).await.unwrap(); /// let response = client.transact_new(host_update, generate_client_tr_id(&client).as_str()).await.unwrap();
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.logout().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppHostUpdate = EppObject<Command<HostUpdateRequest>>; impl<E: EppExtension> HostUpdate<E> {
pub fn new(name: &str) -> HostUpdate<NoExtension> {
impl EppHostUpdate { HostUpdate {
/// Creates a new EppObject for host update corresponding to the &lt;epp&gt; tag in EPP XML request: HostUpdateRequest {
pub fn new(name: &str, client_tr_id: &str) -> EppHostUpdate {
EppObject::build(Command::<HostUpdateRequest>::new(
HostUpdateRequest {
host: HostUpdateRequestData { host: HostUpdateRequestData {
xmlns: EPP_HOST_XMLNS.to_string(), xmlns: EPP_HOST_XMLNS.to_string(),
name: name.into(), name: name.into(),
@ -91,29 +104,33 @@ impl EppHostUpdate {
change_info: None, change_info: None,
}, },
}, },
client_tr_id, extension: None,
)) }
}
pub fn with_extension<F: EppExtension>(self, extension: F) -> HostUpdate<F> {
HostUpdate {
request: self.request,
extension: Some(extension),
}
} }
/// Sets the data for the &lt;chg&gt; element of the host update /// Sets the data for the &lt;chg&gt; element of the host update
pub fn info(&mut self, info: HostChangeInfo) { pub fn info(&mut self, info: HostChangeInfo) {
self.data.command.host.change_info = Some(info); self.request.host.change_info = Some(info);
} }
/// Sets the data for the &lt;add&gt; element of the host update /// Sets the data for the &lt;add&gt; element of the host update
pub fn add(&mut self, add: HostAddRemove) { pub fn add(&mut self, add: HostAddRemove) {
self.data.command.host.add = Some(add); self.request.host.add = Some(add);
} }
/// Sets the data for the &lt;rem&gt; element of the host update /// Sets the data for the &lt;rem&gt; element of the host update
pub fn remove(&mut self, remove: HostAddRemove) { pub fn remove(&mut self, remove: HostAddRemove) {
self.data.command.host.remove = Some(remove); self.request.host.remove = Some(remove);
} }
} }
/// Type that represents the &lt;epp&gt; tag for the EPP XML host update response
pub type EppHostUpdateResponse = EppCommandResponse;
/// Type for data under the &lt;chg&gt; tag /// Type for data under the &lt;chg&gt; tag
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
pub struct HostChangeInfo { pub struct HostChangeInfo {

View File

@ -43,8 +43,9 @@
//! //!
//! use epp_client::config::{EppClientConfig, EppClientConnection}; //! use epp_client::config::{EppClientConfig, EppClientConnection};
//! use epp_client::EppClient; //! use epp_client::EppClient;
//! use epp_client::domain::check::{EppDomainCheck, EppDomainCheckResponse}; //! use epp_client::domain::check::DomainCheck;
//! use epp_client::generate_client_tr_id; //! use epp_client::generate_client_tr_id;
//! use epp_client::common::NoExtension;
//! //!
//! #[tokio::main] //! #[tokio::main]
//! async fn main() { //! async fn main() {
@ -72,15 +73,14 @@
//! //!
//! // Make a domain check call, which returns an object of type EppDomainCheckResponse //! // Make a domain check call, which returns an object of type EppDomainCheckResponse
//! // that contains the result of the call //! // that contains the result of the call
//! let domain_check = EppDomainCheck::new( //! let domain_check = DomainCheck::<NoExtension>::new(
//! vec!["eppdev.com", "eppdev.net"], //! vec!["eppdev.com", "eppdev.net"],
//! generate_client_tr_id(&client).as_str()
//! ); //! );
//! //!
//! let response = client.transact::<_, EppDomainCheckResponse>(&domain_check).await.unwrap(); //! let response = client.transact_new(domain_check, generate_client_tr_id(&client).as_str()).await.unwrap();
//! //!
//! // print the availability results //! // print the availability results
//! response.data.res_data.unwrap().check_data.domain_list //! response.res_data.unwrap().check_data.domain_list
//! .iter() //! .iter()
//! .for_each(|chk| println!("Domain: {}, Available: {}", chk.domain.name, chk.domain.available)); //! .for_each(|chk| println!("Domain: {}, Available: {}", chk.domain.name, chk.domain.available));
//! //!

View File

@ -4,30 +4,41 @@ use epp_client_macros::ElementName;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::{ use crate::{
common::{ElementName, EppObject, Options, ServiceExtension, Services, StringValue}, common::{ElementName, NoExtension, Options, ServiceExtension, Services, StringValue},
contact::EPP_CONTACT_XMLNS, contact::EPP_CONTACT_XMLNS,
domain::EPP_DOMAIN_XMLNS, domain::EPP_DOMAIN_XMLNS,
host::EPP_HOST_XMLNS, host::EPP_HOST_XMLNS,
request::{Command, EPP_LANG, EPP_VERSION}, request::{EppExtension, EppRequest, EPP_LANG, EPP_VERSION},
response::EppCommandResponse, response::EppCommandResponse,
}; };
/// The EPP Login Request #[derive(Debug)]
pub type EppLogin = EppObject<Command<Login>>; pub struct Login<E> {
request: LoginRequest,
extension: Option<E>,
}
impl EppLogin { impl<E: EppExtension> EppRequest<E> for Login<E> {
/// Creates a new EPP Login request type Input = LoginRequest;
type Output = EppCommandResponse;
fn into_parts(self) -> (Self::Input, Option<E>) {
(self.request, self.extension)
}
}
impl<E: EppExtension> Login<E> {
pub fn new( pub fn new(
username: &str, username: &str,
password: &str, password: &str,
ext_uris: &Option<Vec<String>>, ext_uris: &Option<Vec<String>>,
client_tr_id: &str, ) -> Login<NoExtension> {
) -> EppLogin {
let ext_uris = ext_uris let ext_uris = ext_uris
.as_ref() .as_ref()
.map(|uris| uris.iter().map(|u| u.as_str().into()).collect()); .map(|uris| uris.iter().map(|u| u.as_str().into()).collect());
let login = Login { Login {
request: LoginRequest {
username: username.into(), username: username.into(),
password: password.into(), password: password.into(),
options: Options { options: Options {
@ -42,33 +53,33 @@ impl EppLogin {
], ],
svc_ext: Some(ServiceExtension { ext_uris }), svc_ext: Some(ServiceExtension { ext_uris }),
}, },
}; },
EppObject::build(Command::<Login> {
command: login,
extension: None, extension: None,
client_tr_id: client_tr_id.into(), }
}) }
pub fn with_extension<F: EppExtension>(self, extension: F) -> Login<F> {
Login {
request: self.request,
extension: Some(extension),
}
} }
/// Sets the <options> tag data /// Sets the <options> tag data
pub fn options(&mut self, options: Options) { pub fn options(&mut self, options: Options) {
self.data.command.options = options; self.request.options = options;
} }
/// Sets the <svcs> tag data /// Sets the <svcs> tag data
pub fn services(&mut self, services: Services) { pub fn services(&mut self, services: Services) {
self.data.command.services = services; self.request.services = services;
} }
} }
/// An alias of `EppCommandResponse` received in response to a successful login request
pub type EppLoginResponse = EppCommandResponse;
#[derive(Serialize, Deserialize, Debug, PartialEq, ElementName)] #[derive(Serialize, Deserialize, Debug, PartialEq, ElementName)]
#[element_name(name = "login")] #[element_name(name = "login")]
/// Type corresponding to the &lt;login&gt; tag in an EPP XML login request /// Type corresponding to the &lt;login&gt; tag in an EPP XML login request
pub struct Login { pub struct LoginRequest {
/// The username to use for the login /// The username to use for the login
#[serde(rename(serialize = "clID", deserialize = "clID"))] #[serde(rename(serialize = "clID", deserialize = "clID"))]
username: StringValue, username: StringValue,

View File

@ -4,29 +4,43 @@ use epp_client_macros::ElementName;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::{ use crate::{
common::{ElementName, EppObject}, common::{ElementName, NoExtension},
request::Command, request::{EppExtension, EppRequest},
response::EppCommandResponse, response::EppCommandResponse,
}; };
/// The EPP Logout request #[derive(Debug)]
pub type EppLogout = EppObject<Command<Logout>>; pub struct Logout<E> {
request: LogoutRequest,
extension: Option<E>,
}
impl EppLogout { impl<E: EppExtension> EppRequest<E> for Logout<E> {
/// Creates a new EPP Logout request type Input = LogoutRequest;
pub fn new(client_tr_id: &str) -> EppLogout { type Output = EppCommandResponse;
EppObject::build(Command::<Logout> {
command: Logout, fn into_parts(self) -> (Self::Input, Option<E>) {
extension: None, (self.request, self.extension)
client_tr_id: client_tr_id.into(),
})
} }
} }
/// An alias of `EppCommandResponse` received in response to a successful logout request impl<E: EppExtension> Logout<E> {
pub type EppLogoutResponse = EppCommandResponse; pub fn new() -> Logout<NoExtension> {
Logout {
request: LogoutRequest {},
extension: None,
}
}
pub fn with_extension<F: EppExtension>(self, extension: F) -> Logout<F> {
Logout {
request: self.request,
extension: Some(extension),
}
}
}
#[derive(Serialize, Deserialize, Debug, PartialEq, ElementName)] #[derive(Serialize, Deserialize, Debug, PartialEq, ElementName)]
#[element_name(name = "logout")] #[element_name(name = "logout")]
/// Type corresponding to the &lt;logout&gt; tag in an EPP XML logout request /// Type corresponding to the &lt;logout&gt; tag in an EPP XML logout request
pub struct Logout; pub struct LogoutRequest;

View File

@ -2,11 +2,25 @@
use epp_client_macros::*; use epp_client_macros::*;
use crate::common::{ElementName, EppObject}; use crate::common::{ElementName, NoExtension};
use crate::request::Command; use crate::request::{EppExtension, EppRequest};
use crate::response::CommandResponse;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Debug)]
pub struct MessageAck<E> {
request: MessageAckRequest,
extension: Option<E>,
}
impl<E: EppExtension> EppRequest<E> for MessageAck<E> {
type Input = MessageAckRequest;
type Output = String;
fn into_parts(self) -> (Self::Input, Option<E>) {
(self.request, self.extension)
}
}
/// Type that represents the &lt;epp&gt; request for registry <poll op="ack"> command /// Type that represents the &lt;epp&gt; request for registry <poll op="ack"> command
/// ## Usage /// ## Usage
/// ///
@ -15,8 +29,9 @@ use serde::{Deserialize, Serialize};
/// ///
/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::config::{EppClientConfig, EppClientConnection};
/// use epp_client::EppClient; /// use epp_client::EppClient;
/// use epp_client::message::ack::{EppMessageAck, EppMessageAckResponse}; /// use epp_client::message::ack::MessageAck;
/// use epp_client::generate_client_tr_id; /// use epp_client::generate_client_tr_id;
/// use epp_client::common::NoExtension;
/// ///
/// #[tokio::main] /// #[tokio::main]
/// async fn main() { /// async fn main() {
@ -41,35 +56,36 @@ use serde::{Deserialize, Serialize};
/// Err(e) => panic!("Failed to create EppClient: {}", e) /// Err(e) => panic!("Failed to create EppClient: {}", e)
/// }; /// };
/// ///
/// // Create an EppMessageAck instance /// // Create an MessageAck instance
/// let message_ack = EppMessageAck::new(12345, generate_client_tr_id(&client).as_str()); /// let message_ack = MessageAck::<NoExtension>::new(12345);
/// ///
/// // send it to the registry and receive a response of type EppMessageAckResponse /// // send it to the registry and receive a response of type MessageAckResponse
/// let response = client.transact::<_, EppMessageAckResponse>(&message_ack).await.unwrap(); /// let response = client.transact_new(message_ack, generate_client_tr_id(&client).as_str()).await.unwrap();
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.logout().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppMessageAck = EppObject<Command<MessageAckRequest>>; impl<E: EppExtension> MessageAck<E> {
pub fn new(message_id: u32) -> MessageAck<NoExtension> {
impl EppMessageAck { MessageAck {
/// Creates a new EppObject for &lt;poll&gt; ack corresponding to the &lt;epp&gt; tag in EPP XML request: MessageAckRequest {
pub fn new(message_id: u32, client_tr_id: &str) -> EppMessageAck {
EppObject::build(Command::<MessageAckRequest>::new(
MessageAckRequest {
op: "ack".to_string(), op: "ack".to_string(),
message_id: message_id.to_string(), message_id: message_id.to_string(),
}, },
client_tr_id, extension: None,
)) }
}
pub fn with_extension<F: EppExtension>(self, extension: F) -> MessageAck<F> {
MessageAck {
request: self.request,
extension: Some(extension),
}
} }
} }
/// Type that represents the &lt;epp&gt; tag for the EPP XML message ack response
pub type EppMessageAckResponse = EppObject<CommandResponse<String>>;
#[derive(Serialize, Deserialize, Debug, ElementName)] #[derive(Serialize, Deserialize, Debug, ElementName)]
#[element_name(name = "poll")] #[element_name(name = "poll")]
/// Type for EPP XML &lt;poll&gt; command for message ack /// Type for EPP XML &lt;poll&gt; command for message ack

View File

@ -2,11 +2,25 @@
use epp_client_macros::*; use epp_client_macros::*;
use crate::common::{ElementName, EppObject, StringValue}; use crate::common::{ElementName, NoExtension, StringValue};
use crate::request::Command; use crate::request::{EppExtension, EppRequest};
use crate::response::CommandResponse;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Debug)]
pub struct MessagePoll<E> {
request: MessagePollRequest,
extension: Option<E>,
}
impl<E: EppExtension> EppRequest<E> for MessagePoll<E> {
type Input = MessagePollRequest;
type Output = MessagePollResponse;
fn into_parts(self) -> (Self::Input, Option<E>) {
(self.request, self.extension)
}
}
/// Type that represents the &lt;epp&gt; request for registry <poll op="req"> command /// Type that represents the &lt;epp&gt; request for registry <poll op="req"> command
/// ///
/// ## Usage /// ## Usage
@ -16,8 +30,9 @@ use serde::{Deserialize, Serialize};
/// ///
/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::config::{EppClientConfig, EppClientConnection};
/// use epp_client::EppClient; /// use epp_client::EppClient;
/// use epp_client::message::poll::{EppMessagePoll, EppMessagePollResponse}; /// use epp_client::message::poll::MessagePoll;
/// use epp_client::generate_client_tr_id; /// use epp_client::generate_client_tr_id;
/// use epp_client::common::NoExtension;
/// ///
/// #[tokio::main] /// #[tokio::main]
/// async fn main() { /// async fn main() {
@ -42,34 +57,35 @@ use serde::{Deserialize, Serialize};
/// Err(e) => panic!("Failed to create EppClient: {}", e) /// Err(e) => panic!("Failed to create EppClient: {}", e)
/// }; /// };
/// ///
/// // Create an EppMessagePoll instance /// // Create an MessagePoll instance
/// let message_poll = EppMessagePoll::new(generate_client_tr_id(&client).as_str()); /// let message_poll = MessagePoll::<NoExtension>::new();
/// ///
/// // send it to the registry and receive a response of type EppMessagePollResponse /// // send it to the registry and receive a response of type MessagePollResponse
/// let response = client.transact::<_, EppMessagePollResponse>(&message_poll).await.unwrap(); /// let response = client.transact_new(message_poll, generate_client_tr_id(&client).as_str()).await.unwrap();
/// ///
/// println!("{:?}", response); /// println!("{:?}", response);
/// ///
/// client.logout().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppMessagePoll = EppObject<Command<MessagePollRequest>>; impl<E: EppExtension> MessagePoll<E> {
pub fn new() -> MessagePoll<NoExtension> {
impl EppMessagePoll { MessagePoll {
/// Creates a new EppObject for &lt;poll&gt; req corresponding to the &lt;epp&gt; tag in EPP XML request: MessagePollRequest {
pub fn new(client_tr_id: &str) -> EppMessagePoll {
EppObject::build(Command::<MessagePollRequest>::new(
MessagePollRequest {
op: "req".to_string(), op: "req".to_string(),
}, },
client_tr_id, extension: None,
)) }
}
pub fn with_extension<F: EppExtension>(self, extension: F) -> MessagePoll<F> {
MessagePoll {
request: self.request,
extension: Some(extension),
}
} }
} }
/// Type that represents the &lt;epp&gt; tag for the EPP XML message poll response
pub type EppMessagePollResponse = EppObject<CommandResponse<MessagePollResponse>>;
// Request // Request
#[derive(Serialize, Deserialize, Debug, ElementName)] #[derive(Serialize, Deserialize, Debug, ElementName)]

View File

@ -3,35 +3,37 @@
mod response { mod response {
use super::super::get_xml; use super::super::get_xml;
use super::super::CLTRID; use super::super::CLTRID;
use crate::contact::check::EppContactCheckResponse; use crate::common::NoExtension;
use crate::contact::create::EppContactCreateResponse; use crate::contact::check::ContactCheck;
use crate::contact::delete::EppContactDeleteResponse; use crate::contact::create::ContactCreate;
use crate::contact::info::EppContactInfoResponse; use crate::contact::delete::ContactDelete;
use crate::contact::update::EppContactUpdateResponse; use crate::contact::info::ContactInfo;
use crate::domain::check::EppDomainCheckResponse; use crate::contact::update::ContactUpdate;
use crate::domain::create::EppDomainCreateResponse; use crate::domain::check::DomainCheck;
use crate::domain::delete::EppDomainDeleteResponse; use crate::domain::create::DomainCreate;
use crate::domain::info::EppDomainInfoResponse; use crate::domain::delete::DomainDelete;
use crate::domain::renew::EppDomainRenewResponse; use crate::domain::info::DomainInfo;
use crate::domain::renew::DomainRenew;
use crate::domain::rgp::request::EppDomainRgpRestoreRequestResponse; use crate::domain::rgp::request::EppDomainRgpRestoreRequestResponse;
use crate::domain::transfer::EppDomainTransferApproveResponse; use crate::domain::transfer::DomainTransferApprove;
use crate::domain::transfer::EppDomainTransferCancelResponse; use crate::domain::transfer::DomainTransferCancel;
use crate::domain::transfer::EppDomainTransferQueryResponse; use crate::domain::transfer::DomainTransferQuery;
use crate::domain::transfer::EppDomainTransferRejectResponse; use crate::domain::transfer::DomainTransferReject;
use crate::domain::transfer::EppDomainTransferRequestResponse; use crate::domain::transfer::DomainTransferRequest;
use crate::domain::update::EppDomainUpdateResponse; use crate::domain::update::DomainUpdate;
use crate::hello::EppGreeting; use crate::hello::EppGreeting;
use crate::hello::ExpiryType; use crate::hello::ExpiryType;
use crate::hello::Relative; use crate::hello::Relative;
use crate::host::check::EppHostCheckResponse; use crate::host::check::HostCheck;
use crate::host::create::EppHostCreateResponse; use crate::host::create::HostCreate;
use crate::host::delete::EppHostDeleteResponse; use crate::host::delete::HostDelete;
use crate::host::info::EppHostInfoResponse; use crate::host::info::HostInfo;
use crate::host::update::EppHostUpdateResponse; use crate::host::update::HostUpdate;
use crate::login::EppLoginResponse; use crate::login::Login;
use crate::logout::EppLogoutResponse; use crate::logout::Logout;
use crate::message::ack::EppMessageAckResponse; use crate::message::ack::MessageAck;
use crate::message::poll::EppMessagePollResponse; use crate::message::poll::MessagePoll;
use crate::request::EppRequest;
use crate::response::EppCommandResponseError; use crate::response::EppCommandResponseError;
use crate::xml::EppXml; use crate::xml::EppXml;
@ -87,37 +89,37 @@ mod response {
#[test] #[test]
fn login() { fn login() {
let xml = get_xml("response/login.xml").unwrap(); let xml = get_xml("response/login.xml").unwrap();
let object = EppLoginResponse::deserialize(xml.as_str()).unwrap(); let object = Login::<NoExtension>::deserialize_response(xml.as_str()).unwrap();
assert_eq!(object.data.result.code, 1000); assert_eq!(object.result.code, 1000);
assert_eq!(object.data.result.message, SUCCESS_MSG.into()); assert_eq!(object.result.message, SUCCESS_MSG.into());
assert_eq!(object.data.tr_ids.client_tr_id.unwrap(), CLTRID.into()); assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.into()); assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
} }
#[test] #[test]
fn logout() { fn logout() {
let xml = get_xml("response/logout.xml").unwrap(); let xml = get_xml("response/logout.xml").unwrap();
let object = EppLogoutResponse::deserialize(xml.as_str()).unwrap(); let object = Logout::<NoExtension>::deserialize_response(xml.as_str()).unwrap();
assert_eq!(object.data.result.code, 1500); assert_eq!(object.result.code, 1500);
assert_eq!( assert_eq!(
object.data.result.message, object.result.message,
"Command completed successfully; ending session".into() "Command completed successfully; ending session".into()
); );
assert_eq!(object.data.tr_ids.client_tr_id.unwrap(), CLTRID.into()); assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.into()); assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
} }
#[test] #[test]
fn contact_check() { fn contact_check() {
let xml = get_xml("response/contact/check.xml").unwrap(); let xml = get_xml("response/contact/check.xml").unwrap();
let object = EppContactCheckResponse::deserialize(xml.as_str()).unwrap(); let object = ContactCheck::<NoExtension>::deserialize_response(xml.as_str()).unwrap();
let results = object.data.res_data().unwrap(); let results = object.res_data().unwrap();
assert_eq!(object.data.result.code, 1000); assert_eq!(object.result.code, 1000);
assert_eq!(object.data.result.message, SUCCESS_MSG.into()); assert_eq!(object.result.message, SUCCESS_MSG.into());
assert_eq!( assert_eq!(
results.check_data.contact_list[0].contact.id, results.check_data.contact_list[0].contact.id,
"eppdev-contact-1".into() "eppdev-contact-1".into()
@ -128,52 +130,52 @@ mod response {
"eppdev-contact-2".into() "eppdev-contact-2".into()
); );
assert_eq!(results.check_data.contact_list[1].contact.available, 1); assert_eq!(results.check_data.contact_list[1].contact.available, 1);
assert_eq!(object.data.tr_ids.client_tr_id.unwrap(), CLTRID.into()); assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.into()); assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
} }
#[test] #[test]
fn contact_create() { fn contact_create() {
let xml = get_xml("response/contact/create.xml").unwrap(); let xml = get_xml("response/contact/create.xml").unwrap();
let object = EppContactCreateResponse::deserialize(xml.as_str()).unwrap(); let object = ContactCreate::<NoExtension>::deserialize_response(xml.as_str()).unwrap();
let results = object.data.res_data().unwrap(); let results = object.res_data().unwrap();
assert_eq!(object.data.result.code, 1000); assert_eq!(object.result.code, 1000);
assert_eq!(object.data.result.message, SUCCESS_MSG.into()); assert_eq!(object.result.message, SUCCESS_MSG.into());
assert_eq!(results.create_data.id, "eppdev-contact-4".into()); assert_eq!(results.create_data.id, "eppdev-contact-4".into());
assert_eq!( assert_eq!(
results.create_data.created_at, results.create_data.created_at,
"2021-07-25T16:05:32.0Z".into() "2021-07-25T16:05:32.0Z".into()
); );
assert_eq!(object.data.tr_ids.client_tr_id.unwrap(), CLTRID.into()); assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.into()); assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
} }
#[test] #[test]
fn contact_delete() { fn contact_delete() {
let xml = get_xml("response/contact/delete.xml").unwrap(); let xml = get_xml("response/contact/delete.xml").unwrap();
let object = EppContactDeleteResponse::deserialize(xml.as_str()).unwrap(); let object = ContactDelete::<NoExtension>::deserialize_response(xml.as_str()).unwrap();
assert_eq!(object.data.result.code, 1000); assert_eq!(object.result.code, 1000);
assert_eq!(object.data.result.message, SUCCESS_MSG.into()); assert_eq!(object.result.message, SUCCESS_MSG.into());
assert_eq!(object.data.tr_ids.client_tr_id.unwrap(), CLTRID.into()); assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.into()); assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
} }
#[test] #[test]
fn contact_info() { fn contact_info() {
let xml = get_xml("response/contact/info.xml").unwrap(); let xml = get_xml("response/contact/info.xml").unwrap();
let object = EppContactInfoResponse::deserialize(xml.as_str()).unwrap(); let object = ContactInfo::<NoExtension>::deserialize_response(xml.as_str()).unwrap();
let result = object.data.res_data().unwrap(); let result = object.res_data().unwrap();
let fax = result.info_data.fax.as_ref().unwrap(); let fax = result.info_data.fax.as_ref().unwrap();
let voice_ext = result.info_data.voice.extension.as_ref().unwrap(); let voice_ext = result.info_data.voice.extension.as_ref().unwrap();
let fax_ext = fax.extension.as_ref().unwrap(); let fax_ext = fax.extension.as_ref().unwrap();
let auth_info = result.info_data.auth_info.as_ref().unwrap(); let auth_info = result.info_data.auth_info.as_ref().unwrap();
assert_eq!(object.data.result.code, 1000); assert_eq!(object.result.code, 1000);
assert_eq!(object.data.result.message, SUCCESS_MSG.into()); assert_eq!(object.result.message, SUCCESS_MSG.into());
assert_eq!(result.info_data.id, "eppdev-contact-3".into()); assert_eq!(result.info_data.id, "eppdev-contact-3".into());
assert_eq!(result.info_data.roid, "UNDEF-ROID".into()); assert_eq!(result.info_data.roid, "UNDEF-ROID".into());
assert_eq!(result.info_data.statuses[0].status, "ok".to_string()); assert_eq!(result.info_data.statuses[0].status, "ok".to_string());
@ -218,30 +220,30 @@ mod response {
"2021-07-23T13:09:09.0Z".into() "2021-07-23T13:09:09.0Z".into()
); );
assert_eq!((*auth_info).password, "eppdev-387323".into()); assert_eq!((*auth_info).password, "eppdev-387323".into());
assert_eq!(object.data.tr_ids.client_tr_id.unwrap(), CLTRID.into()); assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.into()); assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
} }
#[test] #[test]
fn contact_update() { fn contact_update() {
let xml = get_xml("response/contact/update.xml").unwrap(); let xml = get_xml("response/contact/update.xml").unwrap();
let object = EppContactUpdateResponse::deserialize(xml.as_str()).unwrap(); let object = ContactUpdate::<NoExtension>::deserialize_response(xml.as_str()).unwrap();
assert_eq!(object.data.result.code, 1000); assert_eq!(object.result.code, 1000);
assert_eq!(object.data.result.message, SUCCESS_MSG.into()); assert_eq!(object.result.message, SUCCESS_MSG.into());
assert_eq!(object.data.tr_ids.client_tr_id.unwrap(), CLTRID.into()); assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.into()); assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
} }
#[test] #[test]
fn domain_check() { fn domain_check() {
let xml = get_xml("response/domain/check.xml").unwrap(); let xml = get_xml("response/domain/check.xml").unwrap();
let object = EppDomainCheckResponse::deserialize(xml.as_str()).unwrap(); let object = DomainCheck::<NoExtension>::deserialize_response(xml.as_str()).unwrap();
let result = object.data.res_data().unwrap(); let result = object.res_data().unwrap();
assert_eq!(object.data.result.code, 1000); assert_eq!(object.result.code, 1000);
assert_eq!(object.data.result.message, SUCCESS_MSG.into()); assert_eq!(object.result.message, SUCCESS_MSG.into());
assert_eq!( assert_eq!(
result.check_data.domain_list[0].domain.name, result.check_data.domain_list[0].domain.name,
"eppdev.com".into() "eppdev.com".into()
@ -252,19 +254,19 @@ mod response {
"eppdev.net".into() "eppdev.net".into()
); );
assert_eq!(result.check_data.domain_list[1].domain.available, 0); assert_eq!(result.check_data.domain_list[1].domain.available, 0);
assert_eq!(object.data.tr_ids.client_tr_id.unwrap(), CLTRID.into()); assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.into()); assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
} }
#[test] #[test]
fn domain_create() { fn domain_create() {
let xml = get_xml("response/domain/create.xml").unwrap(); let xml = get_xml("response/domain/create.xml").unwrap();
let object = EppDomainCreateResponse::deserialize(xml.as_str()).unwrap(); let object = DomainCreate::<NoExtension>::deserialize_response(xml.as_str()).unwrap();
let result = object.data.res_data().unwrap(); let result = object.res_data().unwrap();
assert_eq!(object.data.result.code, 1000); assert_eq!(object.result.code, 1000);
assert_eq!(object.data.result.message, SUCCESS_MSG.into()); assert_eq!(object.result.message, SUCCESS_MSG.into());
assert_eq!(result.create_data.name, "eppdev-2.com".into()); assert_eq!(result.create_data.name, "eppdev-2.com".into());
assert_eq!( assert_eq!(
result.create_data.created_at, result.create_data.created_at,
@ -274,34 +276,34 @@ mod response {
result.create_data.expiring_at, result.create_data.expiring_at,
"2022-07-25T18:11:34.0Z".into() "2022-07-25T18:11:34.0Z".into()
); );
assert_eq!(object.data.tr_ids.client_tr_id.unwrap(), CLTRID.into()); assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.into()); assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
} }
#[test] #[test]
fn domain_delete() { fn domain_delete() {
let xml = get_xml("response/domain/delete.xml").unwrap(); let xml = get_xml("response/domain/delete.xml").unwrap();
let object = EppDomainDeleteResponse::deserialize(xml.as_str()).unwrap(); let object = DomainDelete::<NoExtension>::deserialize_response(xml.as_str()).unwrap();
assert_eq!(object.data.result.code, 1000); assert_eq!(object.result.code, 1000);
assert_eq!(object.data.result.message, SUCCESS_MSG.into()); assert_eq!(object.result.message, SUCCESS_MSG.into());
assert_eq!(object.data.tr_ids.client_tr_id.unwrap(), CLTRID.into()); assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.into()); assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
} }
#[test] #[test]
fn domain_info() { fn domain_info() {
let xml = get_xml("response/domain/info.xml").unwrap(); let xml = get_xml("response/domain/info.xml").unwrap();
let object = EppDomainInfoResponse::deserialize(xml.as_str()).unwrap(); let object = DomainInfo::<NoExtension>::deserialize_response(xml.as_str()).unwrap();
let result = object.data.res_data().unwrap(); let result = object.res_data().unwrap();
let auth_info = result.info_data.auth_info.as_ref().unwrap(); let auth_info = result.info_data.auth_info.as_ref().unwrap();
let ns_list = result.info_data.ns.as_ref().unwrap(); let ns_list = result.info_data.ns.as_ref().unwrap();
let ns = (*ns_list).host_obj.as_ref().unwrap(); let ns = (*ns_list).host_obj.as_ref().unwrap();
let hosts = result.info_data.hosts.as_ref().unwrap(); let hosts = result.info_data.hosts.as_ref().unwrap();
assert_eq!(object.data.result.code, 1000); assert_eq!(object.result.code, 1000);
assert_eq!(object.data.result.message, SUCCESS_MSG.into()); assert_eq!(object.result.message, SUCCESS_MSG.into());
assert_eq!(result.info_data.name, "eppdev-1.com".into()); assert_eq!(result.info_data.name, "eppdev-1.com".into());
assert_eq!(result.info_data.roid, "125899511_DOMAIN_COM-VRSN".into()); assert_eq!(result.info_data.roid, "125899511_DOMAIN_COM-VRSN".into());
assert_eq!(result.info_data.statuses[0].status, "ok".to_string()); assert_eq!(result.info_data.statuses[0].status, "ok".to_string());
@ -348,38 +350,39 @@ mod response {
"2023-07-23T15:31:20.0Z".into() "2023-07-23T15:31:20.0Z".into()
); );
assert_eq!((*auth_info).password, "epP4uthd#v".into()); assert_eq!((*auth_info).password, "epP4uthd#v".into());
assert_eq!(object.data.tr_ids.client_tr_id.unwrap(), CLTRID.into()); assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.into()); assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
} }
#[test] #[test]
fn domain_renew() { fn domain_renew() {
let xml = get_xml("response/domain/renew.xml").unwrap(); let xml = get_xml("response/domain/renew.xml").unwrap();
let object = EppDomainRenewResponse::deserialize(xml.as_str()).unwrap(); let object = DomainRenew::<NoExtension>::deserialize_response(xml.as_str()).unwrap();
let result = object.data.res_data().unwrap(); let result = object.res_data().unwrap();
assert_eq!(object.data.result.code, 1000); assert_eq!(object.result.code, 1000);
assert_eq!(object.data.result.message, SUCCESS_MSG.into()); assert_eq!(object.result.message, SUCCESS_MSG.into());
assert_eq!(result.renew_data.name, "eppdev-1.com".into()); assert_eq!(result.renew_data.name, "eppdev-1.com".into());
assert_eq!( assert_eq!(
result.renew_data.expiring_at, result.renew_data.expiring_at,
"2024-07-23T15:31:20.0Z".into() "2024-07-23T15:31:20.0Z".into()
); );
assert_eq!(object.data.tr_ids.client_tr_id.unwrap(), CLTRID.into()); assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.into()); assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
} }
#[test] #[test]
fn domain_transfer_request() { fn domain_transfer_request() {
let xml = get_xml("response/domain/transfer_request.xml").unwrap(); let xml = get_xml("response/domain/transfer_request.xml").unwrap();
let object = EppDomainTransferRequestResponse::deserialize(xml.as_str()).unwrap(); let object =
DomainTransferRequest::<NoExtension>::deserialize_response(xml.as_str()).unwrap();
let result = object.data.res_data().unwrap(); let result = object.res_data().unwrap();
assert_eq!(object.data.result.code, 1001); assert_eq!(object.result.code, 1001);
assert_eq!( assert_eq!(
object.data.result.message, object.result.message,
"Command completed successfully; action pending".into() "Command completed successfully; action pending".into()
); );
assert_eq!(result.transfer_data.name, "eppdev-transfer.com".into()); assert_eq!(result.transfer_data.name, "eppdev-transfer.com".into());
@ -395,52 +398,56 @@ mod response {
result.transfer_data.expiring_at, result.transfer_data.expiring_at,
"2022-07-02T14:53:19.0Z".into() "2022-07-02T14:53:19.0Z".into()
); );
assert_eq!(object.data.tr_ids.client_tr_id.unwrap(), CLTRID.into()); assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.into()); assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
} }
#[test] #[test]
fn domain_transfer_approve() { fn domain_transfer_approve() {
let xml = get_xml("response/domain/transfer_approve.xml").unwrap(); let xml = get_xml("response/domain/transfer_approve.xml").unwrap();
let object = EppDomainTransferApproveResponse::deserialize(xml.as_str()).unwrap(); let object =
DomainTransferApprove::<NoExtension>::deserialize_response(xml.as_str()).unwrap();
assert_eq!(object.data.result.code, 1000); assert_eq!(object.result.code, 1000);
assert_eq!(object.data.result.message, SUCCESS_MSG.into()); assert_eq!(object.result.message, SUCCESS_MSG.into());
assert_eq!(object.data.tr_ids.client_tr_id.unwrap(), CLTRID.into()); assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.into()); assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
} }
#[test] #[test]
fn domain_transfer_reject() { fn domain_transfer_reject() {
let xml = get_xml("response/domain/transfer_reject.xml").unwrap(); let xml = get_xml("response/domain/transfer_reject.xml").unwrap();
let object = EppDomainTransferRejectResponse::deserialize(xml.as_str()).unwrap(); let object =
DomainTransferReject::<NoExtension>::deserialize_response(xml.as_str()).unwrap();
assert_eq!(object.data.result.code, 1000); assert_eq!(object.result.code, 1000);
assert_eq!(object.data.result.message, SUCCESS_MSG.into()); assert_eq!(object.result.message, SUCCESS_MSG.into());
assert_eq!(object.data.tr_ids.client_tr_id.unwrap(), CLTRID.into()); assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.into()); assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
} }
#[test] #[test]
fn domain_transfer_cancel() { fn domain_transfer_cancel() {
let xml = get_xml("response/domain/transfer_cancel.xml").unwrap(); let xml = get_xml("response/domain/transfer_cancel.xml").unwrap();
let object = EppDomainTransferCancelResponse::deserialize(xml.as_str()).unwrap(); let object =
DomainTransferCancel::<NoExtension>::deserialize_response(xml.as_str()).unwrap();
assert_eq!(object.data.result.code, 1000); assert_eq!(object.result.code, 1000);
assert_eq!(object.data.result.message, SUCCESS_MSG.into()); assert_eq!(object.result.message, SUCCESS_MSG.into());
assert_eq!(object.data.tr_ids.client_tr_id.unwrap(), CLTRID.into()); assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.into()); assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
} }
#[test] #[test]
fn domain_transfer_query() { fn domain_transfer_query() {
let xml = get_xml("response/domain/transfer_query.xml").unwrap(); let xml = get_xml("response/domain/transfer_query.xml").unwrap();
let object = EppDomainTransferQueryResponse::deserialize(xml.as_str()).unwrap(); let object =
DomainTransferQuery::<NoExtension>::deserialize_response(xml.as_str()).unwrap();
let result = object.data.res_data().unwrap(); let result = object.res_data().unwrap();
assert_eq!(object.data.result.code, 1000); assert_eq!(object.result.code, 1000);
assert_eq!(object.data.result.message, SUCCESS_MSG.into()); assert_eq!(object.result.message, SUCCESS_MSG.into());
assert_eq!(result.transfer_data.name, "eppdev-transfer.com".into()); assert_eq!(result.transfer_data.name, "eppdev-transfer.com".into());
assert_eq!(result.transfer_data.transfer_status, "pending".into()); assert_eq!(result.transfer_data.transfer_status, "pending".into());
assert_eq!(result.transfer_data.requester_id, "eppdev".into()); assert_eq!(result.transfer_data.requester_id, "eppdev".into());
@ -454,30 +461,30 @@ mod response {
result.transfer_data.expiring_at, result.transfer_data.expiring_at,
"2022-07-02T14:53:19.0Z".into() "2022-07-02T14:53:19.0Z".into()
); );
assert_eq!(object.data.tr_ids.client_tr_id.unwrap(), CLTRID.into()); assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.into()); assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
} }
#[test] #[test]
fn domain_update() { fn domain_update() {
let xml = get_xml("response/domain/update.xml").unwrap(); let xml = get_xml("response/domain/update.xml").unwrap();
let object = EppDomainUpdateResponse::deserialize(xml.as_str()).unwrap(); let object = DomainUpdate::<NoExtension>::deserialize_response(xml.as_str()).unwrap();
assert_eq!(object.data.result.code, 1000); assert_eq!(object.result.code, 1000);
assert_eq!(object.data.result.message, SUCCESS_MSG.into()); assert_eq!(object.result.message, SUCCESS_MSG.into());
assert_eq!(object.data.tr_ids.client_tr_id.unwrap(), CLTRID.into()); assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.into()); assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
} }
#[test] #[test]
fn host_check() { fn host_check() {
let xml = get_xml("response/host/check.xml").unwrap(); let xml = get_xml("response/host/check.xml").unwrap();
let object = EppHostCheckResponse::deserialize(xml.as_str()).unwrap(); let object = HostCheck::<NoExtension>::deserialize_response(xml.as_str()).unwrap();
let result = object.data.res_data().unwrap(); let result = object.res_data().unwrap();
assert_eq!(object.data.result.code, 1000); assert_eq!(object.result.code, 1000);
assert_eq!(object.data.result.message, SUCCESS_MSG.into()); assert_eq!(object.result.message, SUCCESS_MSG.into());
assert_eq!( assert_eq!(
result.check_data.host_list[0].host.name, result.check_data.host_list[0].host.name,
"host1.eppdev-1.com".into() "host1.eppdev-1.com".into()
@ -488,37 +495,37 @@ mod response {
"ns1.testing.com".into() "ns1.testing.com".into()
); );
assert_eq!(result.check_data.host_list[1].host.available, 0); assert_eq!(result.check_data.host_list[1].host.available, 0);
assert_eq!(object.data.tr_ids.client_tr_id.unwrap(), CLTRID.into()); assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.into()); assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
} }
#[test] #[test]
fn host_create() { fn host_create() {
let xml = get_xml("response/host/create.xml").unwrap(); let xml = get_xml("response/host/create.xml").unwrap();
let object = EppHostCreateResponse::deserialize(xml.as_str()).unwrap(); let object = HostCreate::<NoExtension>::deserialize_response(xml.as_str()).unwrap();
let result = object.data.res_data().unwrap(); let result = object.res_data().unwrap();
assert_eq!(object.data.result.code, 1000); assert_eq!(object.result.code, 1000);
assert_eq!(object.data.result.message, SUCCESS_MSG.into()); assert_eq!(object.result.message, SUCCESS_MSG.into());
assert_eq!(result.create_data.name, "host2.eppdev-1.com".into()); assert_eq!(result.create_data.name, "host2.eppdev-1.com".into());
assert_eq!( assert_eq!(
result.create_data.created_at, result.create_data.created_at,
"2021-07-26T05:28:55.0Z".into() "2021-07-26T05:28:55.0Z".into()
); );
assert_eq!(object.data.tr_ids.client_tr_id.unwrap(), CLTRID.into()); assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.into()); assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
} }
#[test] #[test]
fn host_info() { fn host_info() {
let xml = get_xml("response/host/info.xml").unwrap(); let xml = get_xml("response/host/info.xml").unwrap();
let object = EppHostInfoResponse::deserialize(xml.as_str()).unwrap(); let object = HostInfo::<NoExtension>::deserialize_response(xml.as_str()).unwrap();
let result = object.data.res_data().unwrap(); let result = object.res_data().unwrap();
assert_eq!(object.data.result.code, 1000); assert_eq!(object.result.code, 1000);
assert_eq!(object.data.result.message, SUCCESS_MSG.into()); assert_eq!(object.result.message, SUCCESS_MSG.into());
assert_eq!(result.info_data.name, "host2.eppdev-1.com".into()); assert_eq!(result.info_data.name, "host2.eppdev-1.com".into());
assert_eq!(result.info_data.roid, "UNDEF-ROID".into()); assert_eq!(result.info_data.roid, "UNDEF-ROID".into());
assert_eq!(result.info_data.statuses[0].status, "ok".to_string()); assert_eq!(result.info_data.statuses[0].status, "ok".to_string());
@ -549,43 +556,43 @@ mod response {
*(result.info_data.updated_at.as_ref().unwrap()), *(result.info_data.updated_at.as_ref().unwrap()),
"2021-07-26T05:28:55.0Z".into() "2021-07-26T05:28:55.0Z".into()
); );
assert_eq!(object.data.tr_ids.client_tr_id.unwrap(), CLTRID.into()); assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.into()); assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
} }
#[test] #[test]
fn host_update() { fn host_update() {
let xml = get_xml("response/host/update.xml").unwrap(); let xml = get_xml("response/host/update.xml").unwrap();
let object = EppHostUpdateResponse::deserialize(xml.as_str()).unwrap(); let object = HostUpdate::<NoExtension>::deserialize_response(xml.as_str()).unwrap();
assert_eq!(object.data.result.code, 1000); assert_eq!(object.result.code, 1000);
assert_eq!(object.data.result.message, SUCCESS_MSG.into()); assert_eq!(object.result.message, SUCCESS_MSG.into());
assert_eq!(object.data.tr_ids.client_tr_id.unwrap(), CLTRID.into()); assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.into()); assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
} }
#[test] #[test]
fn host_delete() { fn host_delete() {
let xml = get_xml("response/host/delete.xml").unwrap(); let xml = get_xml("response/host/delete.xml").unwrap();
let object = EppHostDeleteResponse::deserialize(xml.as_str()).unwrap(); let object = HostDelete::<NoExtension>::deserialize_response(xml.as_str()).unwrap();
assert_eq!(object.data.result.code, 1000); assert_eq!(object.result.code, 1000);
assert_eq!(object.data.result.message, SUCCESS_MSG.into()); assert_eq!(object.result.message, SUCCESS_MSG.into());
assert_eq!(object.data.tr_ids.client_tr_id.unwrap(), CLTRID.into()); assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.into()); assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
} }
#[test] #[test]
fn message_poll() { fn message_poll() {
let xml = get_xml("response/message/poll.xml").unwrap(); let xml = get_xml("response/message/poll.xml").unwrap();
let object = EppMessagePollResponse::deserialize(xml.as_str()).unwrap(); let object = MessagePoll::<NoExtension>::deserialize_response(xml.as_str()).unwrap();
let result = object.data.res_data().unwrap(); let result = object.res_data().unwrap();
let msg = object.data.message_queue().unwrap(); let msg = object.message_queue().unwrap();
assert_eq!(object.data.result.code, 1301); assert_eq!(object.result.code, 1301);
assert_eq!( assert_eq!(
object.data.result.message, object.result.message,
"Command completed successfully; ack to dequeue".into() "Command completed successfully; ack to dequeue".into()
); );
assert_eq!(msg.count, 5); assert_eq!(msg.count, 5);
@ -611,22 +618,22 @@ mod response {
result.message_data.expiring_at, result.message_data.expiring_at,
"2022-07-02T14:53:19.0Z".into() "2022-07-02T14:53:19.0Z".into()
); );
assert_eq!(object.data.tr_ids.client_tr_id.unwrap(), CLTRID.into()); assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.into()); assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
} }
#[test] #[test]
fn message_ack() { fn message_ack() {
let xml = get_xml("response/message/ack.xml").unwrap(); let xml = get_xml("response/message/ack.xml").unwrap();
let object = EppMessageAckResponse::deserialize(xml.as_str()).unwrap(); let object = MessageAck::<NoExtension>::deserialize_response(xml.as_str()).unwrap();
let msg = object.data.message_queue().unwrap(); let msg = object.message_queue().unwrap();
assert_eq!(object.data.result.code, 1000); assert_eq!(object.result.code, 1000);
assert_eq!(object.data.result.message, SUCCESS_MSG.into()); assert_eq!(object.result.message, SUCCESS_MSG.into());
assert_eq!(msg.count, 4); assert_eq!(msg.count, 4);
assert_eq!(msg.id, "12345".to_string()); assert_eq!(msg.id, "12345".to_string());
assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.into()); assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
} }
#[test] #[test]

View File

@ -3,42 +3,47 @@
mod request { mod request {
use super::super::get_xml; use super::super::get_xml;
use super::super::CLTRID; use super::super::CLTRID;
use crate::common::HostAttrList;
use crate::common::HostList;
use crate::common::HostObjList;
use crate::common::NoExtension;
use crate::common::{ use crate::common::{
Address, ContactStatus, DomainAuthInfo, DomainContact, DomainStatus, HostAddr, HostAttr, Address, ContactStatus, DomainAuthInfo, DomainContact, DomainStatus, HostAddr, HostAttr,
HostStatus, Phone, PostalInfo, HostStatus, Phone, PostalInfo,
}; };
use crate::contact::check::EppContactCheck; use crate::contact::check::ContactCheck;
use crate::contact::create::EppContactCreate; use crate::contact::create::ContactCreate;
use crate::contact::delete::EppContactDelete; use crate::contact::delete::ContactDelete;
use crate::contact::info::EppContactInfo; use crate::contact::info::ContactInfo;
use crate::contact::update::EppContactUpdate; use crate::contact::update::ContactUpdate;
use crate::domain::check::EppDomainCheck; use crate::domain::check::DomainCheck;
use crate::domain::create::EppDomainCreate; use crate::domain::create::DomainCreate;
use crate::domain::delete::EppDomainDelete; use crate::domain::delete::DomainDelete;
use crate::domain::info::EppDomainInfo; use crate::domain::info::DomainInfo;
use crate::domain::renew::EppDomainRenew; use crate::domain::renew::DomainRenew;
use crate::domain::rgp::report::EppDomainRgpRestoreReport; use crate::domain::rgp::report::EppDomainRgpRestoreReport;
use crate::domain::rgp::request::EppDomainRgpRestoreRequest; use crate::domain::rgp::request::EppDomainRgpRestoreRequest;
use crate::domain::transfer::EppDomainTransferApprove; use crate::domain::transfer::DomainTransferApprove;
use crate::domain::transfer::EppDomainTransferCancel; use crate::domain::transfer::DomainTransferCancel;
use crate::domain::transfer::EppDomainTransferQuery; use crate::domain::transfer::DomainTransferQuery;
use crate::domain::transfer::EppDomainTransferReject; use crate::domain::transfer::DomainTransferReject;
use crate::domain::transfer::EppDomainTransferRequest; use crate::domain::transfer::DomainTransferRequest;
use crate::domain::update::DomainAddRemove; use crate::domain::update::DomainAddRemove;
use crate::domain::update::DomainChangeInfo; use crate::domain::update::DomainChangeInfo;
use crate::domain::update::EppDomainUpdate; use crate::domain::update::DomainUpdate;
use crate::hello::EppHello; use crate::hello::EppHello;
use crate::host::check::EppHostCheck; use crate::host::check::HostCheck;
use crate::host::create::EppHostCreate; use crate::host::create::HostCreate;
use crate::host::delete::EppHostDelete; use crate::host::delete::HostDelete;
use crate::host::info::EppHostInfo; use crate::host::info::HostInfo;
use crate::host::update::EppHostUpdate;
use crate::host::update::HostAddRemove; use crate::host::update::HostAddRemove;
use crate::host::update::HostChangeInfo; use crate::host::update::HostChangeInfo;
use crate::login::EppLogin; use crate::host::update::HostUpdate;
use crate::logout::EppLogout; use crate::login::Login;
use crate::message::ack::EppMessageAck; use crate::logout::Logout;
use crate::message::poll::EppMessagePoll; use crate::message::ack::MessageAck;
use crate::message::poll::MessagePoll;
use crate::request::EppRequest;
use crate::xml::EppXml; use crate::xml::EppXml;
use chrono::{DateTime, NaiveDate}; use chrono::{DateTime, NaiveDate};
use std::str::FromStr; use std::str::FromStr;
@ -59,8 +64,8 @@ mod request {
]); ]);
let xml = get_xml("request/login.xml").unwrap(); let xml = get_xml("request/login.xml").unwrap();
let object = EppLogin::new("username", "password", &ext_uris, CLTRID); let object = Login::<NoExtension>::new("username", "password", &ext_uris);
let serialized = object.serialize().unwrap(); let serialized = object.serialize_request(CLTRID).unwrap();
assert_eq!(xml, serialized); assert_eq!(xml, serialized);
} }
@ -68,8 +73,8 @@ mod request {
#[test] #[test]
fn logout() { fn logout() {
let xml = get_xml("request/logout.xml").unwrap(); let xml = get_xml("request/logout.xml").unwrap();
let object = EppLogout::new(CLTRID); let object = Logout::<NoExtension>::new();
let serialized = object.serialize().unwrap(); let serialized = object.serialize_request(CLTRID).unwrap();
assert_eq!(xml, serialized); assert_eq!(xml, serialized);
} }
@ -77,8 +82,8 @@ mod request {
#[test] #[test]
fn contact_check() { fn contact_check() {
let xml = get_xml("request/contact/check.xml").unwrap(); let xml = get_xml("request/contact/check.xml").unwrap();
let object = EppContactCheck::new(&["eppdev-contact-1", "eppdev-contact-2"], CLTRID); let object = ContactCheck::<NoExtension>::new(&["eppdev-contact-1", "eppdev-contact-2"]);
let serialized = object.serialize().unwrap(); let serialized = object.serialize_request(CLTRID).unwrap();
assert_eq!(xml, serialized); assert_eq!(xml, serialized);
} }
@ -95,17 +100,16 @@ mod request {
let mut fax = Phone::new("+33.86698799"); let mut fax = Phone::new("+33.86698799");
fax.set_extension("677"); fax.set_extension("677");
let mut object = EppContactCreate::new( let mut object = ContactCreate::<NoExtension>::new(
"eppdev-contact-3", "eppdev-contact-3",
"contact@eppdev.net", "contact@eppdev.net",
postal_info, postal_info,
voice, voice,
"eppdev-387323", "eppdev-387323",
CLTRID,
); );
object.set_fax(fax); object.set_fax(fax);
let serialized = object.serialize().unwrap(); let serialized = object.serialize_request(CLTRID).unwrap();
assert_eq!(xml, serialized); assert_eq!(xml, serialized);
} }
@ -114,9 +118,9 @@ mod request {
fn contact_info() { fn contact_info() {
let xml = get_xml("request/contact/info.xml").unwrap(); let xml = get_xml("request/contact/info.xml").unwrap();
let object = EppContactInfo::new("eppdev-contact-3", "eppdev-387323", CLTRID); let object = ContactInfo::<NoExtension>::new("eppdev-contact-3", "eppdev-387323");
let serialized = object.serialize().unwrap(); let serialized = object.serialize_request(CLTRID).unwrap();
assert_eq!(xml, serialized); assert_eq!(xml, serialized);
} }
@ -125,7 +129,7 @@ mod request {
fn contact_update() { fn contact_update() {
let xml = get_xml("request/contact/update.xml").unwrap(); let xml = get_xml("request/contact/update.xml").unwrap();
let mut object = EppContactUpdate::new("eppdev-contact-3", CLTRID); let mut object = ContactUpdate::<NoExtension>::new("eppdev-contact-3");
let street = &["58", "Orchid Road"]; let street = &["58", "Orchid Road"];
let address = Address::new(street, "Paris", "Paris", "392374", "FR"); let address = Address::new(street, "Paris", "Paris", "392374", "FR");
@ -142,7 +146,7 @@ mod request {
}]; }];
object.remove(remove_statuses); object.remove(remove_statuses);
let serialized = object.serialize().unwrap(); let serialized = object.serialize_request(CLTRID).unwrap();
assert_eq!(xml, serialized); assert_eq!(xml, serialized);
} }
@ -151,9 +155,9 @@ mod request {
fn contact_delete() { fn contact_delete() {
let xml = get_xml("request/contact/delete.xml").unwrap(); let xml = get_xml("request/contact/delete.xml").unwrap();
let object = EppContactDelete::new("eppdev-contact-3", CLTRID); let object = ContactDelete::<NoExtension>::new("eppdev-contact-3");
let serialized = object.serialize().unwrap(); let serialized = object.serialize_request(CLTRID).unwrap();
assert_eq!(xml, serialized); assert_eq!(xml, serialized);
} }
@ -162,9 +166,9 @@ mod request {
fn domain_check() { fn domain_check() {
let xml = get_xml("request/domain/check.xml").unwrap(); let xml = get_xml("request/domain/check.xml").unwrap();
let object = EppDomainCheck::new(vec!["eppdev.com", "eppdev.net"], CLTRID); let object = DomainCheck::<NoExtension>::new(vec!["eppdev.com", "eppdev.net"]);
let serialized = object.serialize().unwrap(); let serialized = object.serialize_request(CLTRID).unwrap();
assert_eq!(xml, serialized); assert_eq!(xml, serialized);
} }
@ -188,16 +192,16 @@ mod request {
}, },
]; ];
let object = EppDomainCreate::new( let object = DomainCreate::<NoExtension>::new(
"eppdev-1.com", "eppdev-1.com",
1, 1,
"eppdev-contact-3", None,
Some("eppdev-contact-3"),
"epP4uthd#v", "epP4uthd#v",
contacts, Some(contacts),
CLTRID,
); );
let serialized = object.serialize().unwrap(); let serialized = object.serialize_request(CLTRID).unwrap();
assert_eq!(xml, serialized); assert_eq!(xml, serialized);
} }
@ -221,17 +225,20 @@ mod request {
}, },
]; ];
let object = EppDomainCreate::new_with_ns( let ns = Some(HostList::HostObjList(HostObjList {
hosts: vec!["ns1.test.com".into(), "ns2.test.com".into()],
}));
let object = DomainCreate::<NoExtension>::new(
"eppdev-1.com", "eppdev-1.com",
1, 1,
&["ns1.test.com", "ns2.test.com"], ns,
"eppdev-contact-3", Some("eppdev-contact-3"),
"epP4uthd#v", "epP4uthd#v",
contacts, Some(contacts),
CLTRID,
); );
let serialized = object.serialize().unwrap(); let serialized = object.serialize_request(CLTRID).unwrap();
assert_eq!(xml, serialized); assert_eq!(xml, serialized);
} }
@ -255,7 +262,8 @@ mod request {
}, },
]; ];
let host_attr = vec![ let host_attr = HostList::HostAttrList(HostAttrList {
hosts: vec![
HostAttr { HostAttr {
name: "ns1.eppdev-1.com".into(), name: "ns1.eppdev-1.com".into(),
addresses: None, addresses: None,
@ -267,19 +275,19 @@ mod request {
HostAddr::new_v6("2404:6800:4001:801::200e"), HostAddr::new_v6("2404:6800:4001:801::200e"),
]), ]),
}, },
]; ],
});
let object = EppDomainCreate::new_with_host_attr( let object = DomainCreate::<NoExtension>::new(
"eppdev-2.com", "eppdev-2.com",
1, 1,
host_attr, Some(host_attr),
"eppdev-contact-3", Some("eppdev-contact-3"),
"epP4uthd#v", "epP4uthd#v",
contacts, Some(contacts),
CLTRID,
); );
let serialized = object.serialize().unwrap(); let serialized = object.serialize_request(CLTRID).unwrap();
assert_eq!(xml, serialized); assert_eq!(xml, serialized);
} }
@ -288,9 +296,9 @@ mod request {
fn domain_info() { fn domain_info() {
let xml = get_xml("request/domain/info.xml").unwrap(); let xml = get_xml("request/domain/info.xml").unwrap();
let object = EppDomainInfo::new("eppdev.com", CLTRID); let object = DomainInfo::<NoExtension>::new("eppdev.com");
let serialized = object.serialize().unwrap(); let serialized = object.serialize_request(CLTRID).unwrap();
assert_eq!(xml, serialized); assert_eq!(xml, serialized);
} }
@ -299,7 +307,7 @@ mod request {
fn domain_update() { fn domain_update() {
let xml = get_xml("request/domain/update.xml").unwrap(); let xml = get_xml("request/domain/update.xml").unwrap();
let mut object = EppDomainUpdate::new("eppdev.com", CLTRID); let mut object = DomainUpdate::<NoExtension>::new("eppdev.com");
let add = DomainAddRemove { let add = DomainAddRemove {
ns: None, ns: None,
@ -327,7 +335,7 @@ mod request {
object.remove(remove); object.remove(remove);
object.info(change_info); object.info(change_info);
let serialized = object.serialize().unwrap(); let serialized = object.serialize_request(CLTRID).unwrap();
assert_eq!(xml, serialized); assert_eq!(xml, serialized);
} }
@ -336,9 +344,9 @@ mod request {
fn domain_delete() { fn domain_delete() {
let xml = get_xml("request/domain/delete.xml").unwrap(); let xml = get_xml("request/domain/delete.xml").unwrap();
let object = EppDomainDelete::new("eppdev.com", CLTRID); let object = DomainDelete::<NoExtension>::new("eppdev.com");
let serialized = object.serialize().unwrap(); let serialized = object.serialize_request(CLTRID).unwrap();
assert_eq!(xml, serialized); assert_eq!(xml, serialized);
} }
@ -348,9 +356,9 @@ mod request {
let xml = get_xml("request/domain/renew.xml").unwrap(); let xml = get_xml("request/domain/renew.xml").unwrap();
let exp_date = NaiveDate::from_ymd(2022, 7, 23); let exp_date = NaiveDate::from_ymd(2022, 7, 23);
let object = EppDomainRenew::new("eppdev.com", exp_date, 1, CLTRID); let object = DomainRenew::<NoExtension>::new("eppdev.com", exp_date, 1);
let serialized = object.serialize().unwrap(); let serialized = object.serialize_request(CLTRID).unwrap();
assert_eq!(xml, serialized); assert_eq!(xml, serialized);
} }
@ -359,9 +367,9 @@ mod request {
fn domain_transfer_request() { fn domain_transfer_request() {
let xml = get_xml("request/domain/transfer_request.xml").unwrap(); let xml = get_xml("request/domain/transfer_request.xml").unwrap();
let object = EppDomainTransferRequest::request("testing.com", 1, "epP4uthd#v", CLTRID); let object = DomainTransferRequest::<NoExtension>::new("testing.com", 1, "epP4uthd#v");
let serialized = object.serialize().unwrap(); let serialized = object.serialize_request(CLTRID).unwrap();
assert_eq!(xml, serialized); assert_eq!(xml, serialized);
} }
@ -370,9 +378,9 @@ mod request {
fn domain_transfer_approve() { fn domain_transfer_approve() {
let xml = get_xml("request/domain/transfer_approve.xml").unwrap(); let xml = get_xml("request/domain/transfer_approve.xml").unwrap();
let object = EppDomainTransferApprove::approve("testing.com", CLTRID); let object = DomainTransferApprove::<NoExtension>::new("testing.com");
let serialized = object.serialize().unwrap(); let serialized = object.serialize_request(CLTRID).unwrap();
assert_eq!(xml, serialized); assert_eq!(xml, serialized);
} }
@ -381,9 +389,9 @@ mod request {
fn domain_transfer_reject() { fn domain_transfer_reject() {
let xml = get_xml("request/domain/transfer_reject.xml").unwrap(); let xml = get_xml("request/domain/transfer_reject.xml").unwrap();
let object = EppDomainTransferReject::reject("testing.com", CLTRID); let object = DomainTransferReject::<NoExtension>::new("testing.com");
let serialized = object.serialize().unwrap(); let serialized = object.serialize_request(CLTRID).unwrap();
assert_eq!(xml, serialized); assert_eq!(xml, serialized);
} }
@ -392,9 +400,9 @@ mod request {
fn domain_transfer_cancel() { fn domain_transfer_cancel() {
let xml = get_xml("request/domain/transfer_cancel.xml").unwrap(); let xml = get_xml("request/domain/transfer_cancel.xml").unwrap();
let object = EppDomainTransferCancel::cancel("testing.com", CLTRID); let object = DomainTransferCancel::<NoExtension>::new("testing.com");
let serialized = object.serialize().unwrap(); let serialized = object.serialize_request(CLTRID).unwrap();
assert_eq!(xml, serialized); assert_eq!(xml, serialized);
} }
@ -403,9 +411,9 @@ mod request {
fn domain_transfer_query() { fn domain_transfer_query() {
let xml = get_xml("request/domain/transfer_query.xml").unwrap(); let xml = get_xml("request/domain/transfer_query.xml").unwrap();
let object = EppDomainTransferQuery::query("testing.com", "epP4uthd#v", CLTRID); let object = DomainTransferQuery::<NoExtension>::new("testing.com", "epP4uthd#v");
let serialized = object.serialize().unwrap(); let serialized = object.serialize_request(CLTRID).unwrap();
assert_eq!(xml, serialized); assert_eq!(xml, serialized);
} }
@ -414,9 +422,9 @@ mod request {
fn host_check() { fn host_check() {
let xml = get_xml("request/host/check.xml").unwrap(); let xml = get_xml("request/host/check.xml").unwrap();
let object = EppHostCheck::new(&["ns1.eppdev-1.com", "host1.eppdev-1.com"], CLTRID); let object = HostCheck::<NoExtension>::new(&["ns1.eppdev-1.com", "host1.eppdev-1.com"]);
let serialized = object.serialize().unwrap(); let serialized = object.serialize_request(CLTRID).unwrap();
assert_eq!(xml, serialized); assert_eq!(xml, serialized);
} }
@ -430,9 +438,9 @@ mod request {
HostAddr::new("v6", "2404:6800:4001:801::200e"), HostAddr::new("v6", "2404:6800:4001:801::200e"),
]; ];
let object = EppHostCreate::new("host1.eppdev-1.com", addresses, CLTRID); let object = HostCreate::<NoExtension>::new("host1.eppdev-1.com", addresses);
let serialized = object.serialize().unwrap(); let serialized = object.serialize_request(CLTRID).unwrap();
assert_eq!(xml, serialized); assert_eq!(xml, serialized);
} }
@ -441,9 +449,9 @@ mod request {
fn host_info() { fn host_info() {
let xml = get_xml("request/host/info.xml").unwrap(); let xml = get_xml("request/host/info.xml").unwrap();
let object = EppHostInfo::new("ns1.eppdev-1.com", CLTRID); let object = HostInfo::<NoExtension>::new("ns1.eppdev-1.com");
let serialized = object.serialize().unwrap(); let serialized = object.serialize_request(CLTRID).unwrap();
assert_eq!(xml, serialized); assert_eq!(xml, serialized);
} }
@ -466,7 +474,7 @@ mod request {
}]), }]),
}; };
let mut object = EppHostUpdate::new("host1.eppdev-1.com", CLTRID); let mut object = HostUpdate::<NoExtension>::new("host1.eppdev-1.com");
object.add(add); object.add(add);
object.remove(remove); object.remove(remove);
@ -474,7 +482,7 @@ mod request {
name: "host2.eppdev-1.com".into(), name: "host2.eppdev-1.com".into(),
}); });
let serialized = object.serialize().unwrap(); let serialized = object.serialize_request(CLTRID).unwrap();
assert_eq!(xml, serialized); assert_eq!(xml, serialized);
} }
@ -483,9 +491,9 @@ mod request {
fn host_delete() { fn host_delete() {
let xml = get_xml("request/host/delete.xml").unwrap(); let xml = get_xml("request/host/delete.xml").unwrap();
let object = EppHostDelete::new("ns1.eppdev-1.com", CLTRID); let object = HostDelete::<NoExtension>::new("ns1.eppdev-1.com");
let serialized = object.serialize().unwrap(); let serialized = object.serialize_request(CLTRID).unwrap();
assert_eq!(xml, serialized); assert_eq!(xml, serialized);
} }
@ -494,9 +502,9 @@ mod request {
fn message_poll() { fn message_poll() {
let xml = get_xml("request/message/poll.xml").unwrap(); let xml = get_xml("request/message/poll.xml").unwrap();
let object = EppMessagePoll::new(CLTRID); let object = MessagePoll::<NoExtension>::new();
let serialized = object.serialize().unwrap(); let serialized = object.serialize_request(CLTRID).unwrap();
assert_eq!(xml, serialized); assert_eq!(xml, serialized);
} }
@ -505,9 +513,9 @@ mod request {
fn message_ack() { fn message_ack() {
let xml = get_xml("request/message/ack.xml").unwrap(); let xml = get_xml("request/message/ack.xml").unwrap();
let object = EppMessageAck::new(12345, CLTRID); let object = MessageAck::<NoExtension>::new(12345);
let serialized = object.serialize().unwrap(); let serialized = object.serialize_request(CLTRID).unwrap();
assert_eq!(xml, serialized); assert_eq!(xml, serialized);
} }