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::EppClient;
//! use epp_client::domain::check::{EppDomainCheck, EppDomainCheckResponse};
//! use epp_client::domain::check::DomainCheck;
//! use epp_client::generate_client_tr_id;
//! use epp_client::common::NoExtension;
//!
//! #[tokio::main]
//! async fn main() {
@ -39,8 +40,8 @@
//! println!("{:?}", greeting);
//!
//! // 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 response = client.transact::<_, EppDomainCheckResponse>(&domain_check).await.unwrap();
//! let domain_check = DomainCheck::<NoExtension>::new(vec!["eppdev.com", "eppdev.net"]);
//! let response = client.transact_new(domain_check, generate_client_tr_id(&client).as_str()).await.unwrap();
//! println!("{:?}", response);
//!
//! }
@ -49,14 +50,18 @@
use std::time::SystemTime;
use std::{error::Error, fmt::Debug};
use crate::common::{EppObject, NoExtension};
use crate::config::EppClientConfig;
use crate::connection::registry::{epp_connect, EppConnection};
use crate::error;
use crate::hello::{EppGreeting, EppHello};
use crate::login::{EppLogin, EppLoginResponse};
use crate::logout::{EppLogout, EppLogoutResponse};
use crate::login::Login;
use crate::logout::Logout;
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;
/// 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
@ -110,19 +115,17 @@ impl EppClient {
connection,
credentials,
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 login_request = EppLogin::new(
let login_request = Login::<NoExtension>::new(
&client.credentials.0,
&client.credentials.1,
&client.ext_uris,
client_tr_id.as_str(),
);
client
.transact::<_, EppLoginResponse>(&login_request)
.transact_new(login_request, client_tr_id.as_str())
.await?;
Ok(client)
@ -197,11 +200,16 @@ impl EppClient {
}
/// 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 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?;

View File

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

View File

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

View File

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

View File

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

View File

@ -3,15 +3,28 @@
use epp_client_macros::*;
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::error;
use crate::request::Command;
use crate::request::{EppExtension, EppRequest};
use crate::response::EppCommandResponse;
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
///
/// ## Usage
@ -21,9 +34,10 @@ use serde::{Deserialize, Serialize};
///
/// use epp_client::config::{EppClientConfig, EppClientConnection};
/// 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::common::ContactStatus;
/// use epp_client::common::NoExtension;
///
/// #[tokio::main]
/// async fn main() {
@ -48,10 +62,9 @@ use serde::{Deserialize, Serialize};
/// Err(e) => panic!("Failed to create EppClient: {}", e)
/// };
///
/// // Create an EppContactUpdate instance
/// let mut contact_update = EppContactUpdate::new(
/// "eppdev-contact-100",
/// generate_client_tr_id(&client).as_str()
/// // Create an ContactUpdate instance
/// let mut contact_update = ContactUpdate::<NoExtension>::new(
/// "eppdev-contact-100"
/// );
///
/// let add_statuses = vec![
@ -62,20 +75,18 @@ use serde::{Deserialize, Serialize};
///
/// contact_update.add(add_statuses);
///
/// // send it to the registry and receive a response of type EppContactUpdateResponse
/// let response = client.transact::<_, EppContactUpdateResponse>(&contact_update).await.unwrap();
/// // send it to the registry and receive a response of type ContactUpdateResponse
/// let response = client.transact_new(contact_update, generate_client_tr_id(&client).as_str()).await.unwrap();
///
/// println!("{:?}", response);
///
/// client.logout().await.unwrap();
/// }
/// ```
pub type EppContactUpdate = EppObject<Command<ContactUpdateRequest>>;
impl EppContactUpdate {
/// Creates a new EppObject for contact update corresponding to the &lt;epp&gt; tag in EPP XML
pub fn new(id: &str, client_tr_id: &str) -> EppContactUpdate {
let contact_update = ContactUpdateRequest {
impl<E: EppExtension> ContactUpdate<E> {
pub fn new(id: &str) -> ContactUpdate<NoExtension> {
ContactUpdate {
request: ContactUpdateRequest {
contact: ContactUpdateRequestData {
xmlns: EPP_CONTACT_XMLNS.to_string(),
id: id.into(),
@ -83,11 +94,16 @@ impl EppContactUpdate {
remove_statuses: None,
change_info: None,
},
};
EppObject::build(Command::<ContactUpdateRequest>::new(
contact_update,
client_tr_id,
))
},
extension: None,
}
}
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
@ -98,7 +114,7 @@ impl EppContactUpdate {
voice: Phone,
auth_password: &str,
) {
self.data.command.contact.change_info = Some(ContactChangeInfo {
self.request.contact.change_info = Some(ContactChangeInfo {
email: Some(email.into()),
postal_info: Some(postal_info),
voice: Some(voice),
@ -109,46 +125,21 @@ impl EppContactUpdate {
/// 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) {
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)
}
}
/// Sets the data for the &lt;add&gt; tag for the contact update request
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
pub fn remove(&mut self, statuses: Vec<ContactStatus>) {
self.data.command.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(),
)),
self.request.contact.remove_statuses = Some(StatusList { status: statuses });
}
}
}
/// 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
#[derive(Serialize, Deserialize, Debug)]

View File

@ -3,11 +3,25 @@
use epp_client_macros::*;
use super::EPP_DOMAIN_XMLNS;
use crate::common::{ElementName, EppObject, StringValue};
use crate::request::Command;
use crate::response::CommandResponse;
use crate::common::{ElementName, NoExtension, StringValue};
use crate::request::{EppExtension, EppRequest};
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
///
/// ## Usage
@ -17,8 +31,9 @@ use serde::{Deserialize, Serialize};
///
/// use epp_client::config::{EppClientConfig, EppClientConnection};
/// 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::common::NoExtension;
///
/// #[tokio::main]
/// async fn main() {
@ -43,43 +58,42 @@ use serde::{Deserialize, Serialize};
/// Err(e) => panic!("Failed to create EppClient: {}", e)
/// };
///
/// // Create an EppDomainCheck instance
/// let domain_check = EppDomainCheck::new(
/// // Create an DomainCheck instance
/// let domain_check = DomainCheck::<NoExtension>::new(
/// 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
/// 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);
///
/// client.logout().await.unwrap();
/// }
/// ```
pub type EppDomainCheck = EppObject<Command<DomainCheckRequest>>;
impl EppDomainCheck {
/// Creates a new EppObject for domain check corresponding to the &lt;epp&gt; tag in EPP XML
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 {
impl<E: EppExtension> DomainCheck<E> {
pub fn new(domains: Vec<&str>) -> DomainCheck<NoExtension> {
DomainCheck {
request: DomainCheckRequest {
list: DomainList {
xmlns: EPP_DOMAIN_XMLNS.to_string(),
domains,
domains: domains
.into_iter()
.map(|d| d.into())
.collect::<Vec<StringValue>>(),
},
};
EppObject::build(Command::<DomainCheckRequest>::new(
domain_check,
client_tr_id,
))
},
extension: None,
}
}
/// Type that represents the &lt;epp&gt; tag for the EPP XML domain check response
pub type EppDomainCheckResponse = EppObject<CommandResponse<DomainCheckResponse>>;
pub fn with_extension<F: EppExtension>(self, extension: F) -> DomainCheck<F> {
DomainCheck {
request: self.request,
extension: Some(extension),
}
}
}
// Request

View File

@ -4,13 +4,26 @@ use epp_client_macros::*;
use super::EPP_DOMAIN_XMLNS;
use crate::common::{
DomainAuthInfo, DomainContact, ElementName, EppObject, HostAttr, HostAttrList, HostList,
HostObjList, Period, StringValue,
DomainAuthInfo, DomainContact, ElementName, HostList, NoExtension, Period, StringValue,
};
use crate::request::Command;
use crate::response::CommandResponse;
use crate::request::{EppExtension, EppRequest};
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
/// 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::EppClient;
/// 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::common::NoExtension;
/// use epp_client::common::HostAttrList;
/// use epp_client::common::HostList;
/// use epp_client::common::HostObjList;
/// #[tokio::main]
/// async fn main() {
/// // Create a config
@ -48,153 +65,77 @@ use serde::{Deserialize, Serialize};
/// Err(e) => panic!("Failed to create EppClient: {}", e)
/// };
///
/// /// Create a vector of existing domain contact IDs
/// let contacts = vec![
/// DomainContact {
/// contact_type: "admin".to_string(),
/// id: "eppdev-contact-2".to_string()
/// id: "eppdev-contact-3".to_string(),
/// },
/// DomainContact {
/// contact_type: "tech".to_string(),
/// id: "eppdev-contact-2".to_string()
/// id: "eppdev-contact-3".to_string(),
/// },
/// DomainContact {
/// contact_type: "billing".to_string(),
/// id: "eppdev-contact-2".to_string()
/// }
/// id: "eppdev-contact-3".to_string(),
/// },
/// ];
///
/// // Create an EppDomainCreate instance
/// let domain_create = EppDomainCreate::new(
/// "eppdev-100.com", 1, "eppdev-contact-2", "epP4uthd#v", contacts, generate_client_tr_id(&client).as_str()
/// let ns = Some(HostList::HostObjList(HostObjList {
/// hosts: vec!["ns1.test.com".into(), "ns2.test.com".into()],
/// }));
/// 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
/// 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);
///
/// client.logout().await.unwrap();
/// }
/// ```
pub type EppDomainCreate = EppObject<Command<DomainCreateRequest>>;
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
impl<E: EppExtension> DomainCreate<E> {
pub fn new(
name: &str,
period: u16,
registrant_id: &str,
ns: Option<HostList>,
registrant_id: Option<&str>,
auth_password: &str,
contacts: Vec<DomainContact>,
client_tr_id: &str,
) -> EppDomainCreate {
contacts: Option<Vec<DomainContact>>,
) -> DomainCreate<NoExtension> {
let registrant = registrant_id.map(|id| id.into());
let domain_create = DomainCreateRequest {
domain: DomainCreateRequestData {
xmlns: EPP_DOMAIN_XMLNS.to_string(),
name: name.into(),
period: Period::new(period),
ns: None,
registrant: Some(registrant_id.into()),
ns,
registrant,
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 contacts
pub fn new_without_contacts(
name: &str,
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,
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
/// 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,
))
DomainCreate {
request: domain_create,
extension: None,
}
}
/// Type that represents the &lt;epp&gt; tag for the EPP XML domain create response
pub type EppDomainCreateResponse = EppObject<CommandResponse<DomainCreateResponse>>;
pub fn with_extension<F: EppExtension>(self, extension: F) -> DomainCreate<F> {
DomainCreate {
request: self.request,
extension: Some(extension),
}
}
}
// Request
@ -203,26 +144,26 @@ pub type EppDomainCreateResponse = EppObject<CommandResponse<DomainCreateRespons
pub struct DomainCreateRequestData {
/// XML namespace for domain commands
#[serde(rename = "xmlns:domain", alias = "xmlns")]
xmlns: String,
pub xmlns: String,
/// The domain name
#[serde(rename = "domain:name", alias = "name")]
name: StringValue,
pub name: StringValue,
/// The period of registration
#[serde(rename = "domain:period", alias = "period")]
period: Period,
pub period: Period,
/// The list of nameserver hosts
/// either of type `HostObjList` or `HostAttrList`
#[serde(rename = "domain:ns", alias = "ns")]
ns: Option<HostList>,
pub ns: Option<HostList>,
/// The domain registrant
#[serde(rename = "domain:registrant", alias = "registrant")]
registrant: Option<StringValue>,
pub registrant: Option<StringValue>,
/// The list of contacts for the domain
#[serde(rename = "domain:contact", alias = "contact")]
contacts: Option<Vec<DomainContact>>,
pub contacts: Option<Vec<DomainContact>>,
/// The auth info for the domain
#[serde(rename = "domain:authInfo", alias = "authInfo")]
auth_info: DomainAuthInfo,
pub auth_info: DomainAuthInfo,
}
#[derive(Serialize, Deserialize, Debug, ElementName)]
@ -233,7 +174,7 @@ pub struct DomainCreateRequest {
/// T being the type of nameserver list (`HostObjList` or `HostAttrList`)
/// to be supplied
#[serde(rename = "domain:create", alias = "create")]
domain: DomainCreateRequestData,
pub domain: DomainCreateRequestData,
}
// Response
@ -243,7 +184,7 @@ pub struct DomainCreateRequest {
pub struct DomainCreateResponseData {
/// XML namespace for domain response data
#[serde(rename = "xmlns:domain")]
xmlns: String,
pub xmlns: String,
/// The domain name
pub name: StringValue,
/// The creation date

View File

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

View File

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

View File

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

View File

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

View File

@ -2,15 +2,34 @@
use epp_client_macros::*;
use crate::common::{
DomainAuthInfo, DomainContact, DomainStatus, ElementName, EppObject, HostList, StringValue,
use crate::{
common::{
DomainAuthInfo, DomainContact, DomainStatus, ElementName, HostList, NoExtension,
StringValue,
},
request::{EppExtension, EppRequest},
};
use super::EPP_DOMAIN_XMLNS;
use crate::request::Command;
use crate::response::EppCommandResponse;
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
/// 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::EppClient;
/// 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::common::NoExtension;
///
/// #[tokio::main]
/// async fn main() {
@ -48,8 +68,8 @@ use serde::{Deserialize, Serialize};
/// Err(e) => panic!("Failed to create EppClient: {}", e)
/// };
///
/// // Create an EppDomainUpdate instance
/// let mut domain_update = EppDomainUpdate::new("eppdev-100.com", generate_client_tr_id(&client).as_str());
/// // Create an DomainUpdate instance
/// let mut domain_update = DomainUpdate::<NoExtension>::new("eppdev-100.com");
///
/// let add = DomainAddRemove {
/// ns: None,
@ -76,21 +96,17 @@ use serde::{Deserialize, Serialize};
/// domain_update.remove(remove);
///
/// // 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);
///
/// client.logout().await.unwrap();
/// }
/// ```
pub type EppDomainUpdate = EppObject<Command<DomainUpdateRequest>>;
impl EppDomainUpdate {
/// Creates a new EppObject for domain update corresponding to the &lt;epp&gt; tag in EPP XML
/// 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 {
impl<E: EppExtension> DomainUpdate<E> {
pub fn new(name: &str) -> DomainUpdate<NoExtension> {
DomainUpdate {
request: DomainUpdateRequest {
domain: DomainUpdateRequestData {
xmlns: EPP_DOMAIN_XMLNS.to_string(),
name: name.into(),
@ -99,29 +115,33 @@ impl EppDomainUpdate {
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
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
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
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
#[derive(Serialize, Deserialize, Debug)]
pub struct DomainChangeInfo {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -43,8 +43,9 @@
//!
//! use epp_client::config::{EppClientConfig, EppClientConnection};
//! 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::common::NoExtension;
//!
//! #[tokio::main]
//! async fn main() {
@ -72,15 +73,14 @@
//!
//! // Make a domain check call, which returns an object of type EppDomainCheckResponse
//! // that contains the result of the call
//! let domain_check = EppDomainCheck::new(
//! let domain_check = DomainCheck::<NoExtension>::new(
//! 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
//! response.data.res_data.unwrap().check_data.domain_list
//! response.res_data.unwrap().check_data.domain_list
//! .iter()
//! .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 crate::{
common::{ElementName, EppObject, Options, ServiceExtension, Services, StringValue},
common::{ElementName, NoExtension, Options, ServiceExtension, Services, StringValue},
contact::EPP_CONTACT_XMLNS,
domain::EPP_DOMAIN_XMLNS,
host::EPP_HOST_XMLNS,
request::{Command, EPP_LANG, EPP_VERSION},
request::{EppExtension, EppRequest, EPP_LANG, EPP_VERSION},
response::EppCommandResponse,
};
/// The EPP Login Request
pub type EppLogin = EppObject<Command<Login>>;
#[derive(Debug)]
pub struct Login<E> {
request: LoginRequest,
extension: Option<E>,
}
impl EppLogin {
/// Creates a new EPP Login request
impl<E: EppExtension> EppRequest<E> for Login<E> {
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(
username: &str,
password: &str,
ext_uris: &Option<Vec<String>>,
client_tr_id: &str,
) -> EppLogin {
) -> Login<NoExtension> {
let ext_uris = ext_uris
.as_ref()
.map(|uris| uris.iter().map(|u| u.as_str().into()).collect());
let login = Login {
Login {
request: LoginRequest {
username: username.into(),
password: password.into(),
options: Options {
@ -42,33 +53,33 @@ impl EppLogin {
],
svc_ext: Some(ServiceExtension { ext_uris }),
},
};
EppObject::build(Command::<Login> {
command: login,
},
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
pub fn options(&mut self, options: Options) {
self.data.command.options = options;
self.request.options = options;
}
/// Sets the <svcs> tag data
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)]
#[element_name(name = "login")]
/// 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
#[serde(rename(serialize = "clID", deserialize = "clID"))]
username: StringValue,

View File

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

View File

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

View File

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

View File

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