diff --git a/epp-client/src/epp/request/contact.rs b/epp-client/src/epp/request/contact.rs index 035f812..50f15e3 100644 --- a/epp-client/src/epp/request/contact.rs +++ b/epp-client/src/epp/request/contact.rs @@ -1,3 +1,5 @@ +//! Types for EPP contact requests + pub mod check; pub mod create; pub mod delete; diff --git a/epp-client/src/epp/request/contact/check.rs b/epp-client/src/epp/request/contact/check.rs index 7839525..8118612 100644 --- a/epp-client/src/epp/request/contact/check.rs +++ b/epp-client/src/epp/request/contact/check.rs @@ -26,7 +26,10 @@ use serde::{Deserialize, Serialize}; /// }; /// /// // Create an EppContactCheck instance -/// let contact_check = EppContactCheck::new(vec!["epp-client-c1", "epp-client-c2"], generate_client_tr_id(&client).as_str()); +/// let contact_check = EppContactCheck::new( +/// vec!["epp-client-c1", "epp-client-c2"], +/// generate_client_tr_id(&client).as_str() +/// ); /// /// // send it to the registry and receive a response of type EppContactCheckResponse /// let response = client.transact::<_, EppContactCheckResponse>(&contact_check).await.unwrap(); diff --git a/epp-client/src/epp/request/contact/create.rs b/epp-client/src/epp/request/contact/create.rs index 1dde93e..4535ec7 100644 --- a/epp-client/src/epp/request/contact/create.rs +++ b/epp-client/src/epp/request/contact/create.rs @@ -9,6 +9,50 @@ use crate::epp::xml::EPP_CONTACT_XMLNS; use serde::{Deserialize, Serialize}; /// Type that represents the request for contact command +/// +/// ## Usage +/// +/// ```ignore +/// use epp_client::EppClient; +/// use epp_client::epp::object::data::{Address, Phone, PostalInfo}; +/// use epp_client::epp::{EppContactCreate, EppContactCreateResponse}; +/// use epp_client::epp::generate_client_tr_id; +/// +/// #[tokio::main] +/// async fn main() { +/// // Create an instance of EppClient, specifying the name of the registry as in +/// // the config file +/// let mut client = match EppClient::new("verisign").await { +/// Ok(client) => client, +/// Err(e) => panic!("Failed to create EppClient: {}", e) +/// }; +/// +/// // Create the address, postal_info, voice instances +/// let street = vec!["58", "Orchid Road"]; +/// let address = Address::new(street, "New York", "New York", "392374", "US"); +/// let postal_info = PostalInfo::new("int", "John Doe", "Acme Widgets", address); +/// let mut voice = Phone::new("+1.47237942"); +/// voice.set_extension("123"); +/// let mut fax = Phone::new("+1.86698799"); +/// fax.set_extension("677"); +/// +/// // Create an EppContactCreate instance +/// let mut contact_create = EppContactCreate::new( +/// "eppdev-contact-100", +/// "contact@eppdev.net", +/// postal_info, +/// voice, +/// "epP4uthd#v", +/// generate_client_tr_id(&client).as_str() +/// ); +/// 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(); +/// +/// println!("{:?}", response); +/// } +/// ``` pub type EppContactCreate = EppObject>; /// Type for elements under the contact tag diff --git a/epp-client/src/epp/request/contact/delete.rs b/epp-client/src/epp/request/contact/delete.rs index 9cab452..a8fe0a5 100644 --- a/epp-client/src/epp/request/contact/delete.rs +++ b/epp-client/src/epp/request/contact/delete.rs @@ -8,6 +8,35 @@ use crate::epp::xml::EPP_CONTACT_XMLNS; use serde::{Deserialize, Serialize}; /// Type for the request for contact command +/// +/// ## Usage +/// +/// ```ignore +/// use epp_client::EppClient; +/// use epp_client::epp::{EppContactDelete, EppContactDeleteResponse}; +/// use epp_client::epp::generate_client_tr_id; +/// +/// #[tokio::main] +/// async fn main() { +/// // Create an instance of EppClient, specifying the name of the registry as in +/// // the config file +/// let mut client = match EppClient::new("verisign").await { +/// Ok(client) => client, +/// 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() +/// ); +/// +/// // send it to the registry and receive a response of type EppContactDeleteResponse +/// let response = client.transact::<_, EppContactDeleteResponse>(&contact_delete).await.unwrap(); +/// +/// println!("{:?}", response); +/// } +/// ``` pub type EppContactDelete = EppObject>; /// Type containing the data for the tag for contacts diff --git a/epp-client/src/epp/request/contact/info.rs b/epp-client/src/epp/request/contact/info.rs index edc71d0..d8008c3 100644 --- a/epp-client/src/epp/request/contact/info.rs +++ b/epp-client/src/epp/request/contact/info.rs @@ -9,6 +9,36 @@ use crate::epp::xml::EPP_CONTACT_XMLNS; use serde::{Deserialize, Serialize}; /// Type for the request for contact command +/// +/// ## Usage +/// +/// ```ignore +/// use epp_client::EppClient; +/// use epp_client::epp::{EppContactInfo, EppContactInfoResponse}; +/// use epp_client::epp::generate_client_tr_id; +/// +/// #[tokio::main] +/// async fn main() { +/// // Create an instance of EppClient, specifying the name of the registry as in +/// // the config file +/// let mut client = match EppClient::new("verisign").await { +/// Ok(client) => client, +/// Err(e) => panic!("Failed to create EppClient: {}", e) +/// }; +/// +/// // Create an EppContactInfo instance +/// let contact_info = EppContactInfo::new( +/// "eppdev-contact-100", +/// "epP4uthd#v", +/// generate_client_tr_id(&client).as_str() +/// ); +/// +/// // send it to the registry and receive a response of type EppContactInfoResponse +/// let response = client.transact::<_, EppContactInfoResponse>(&contact_info).await.unwrap(); +/// +/// println!("{:?}", response); +/// } +/// ``` pub type EppContactInfo = EppObject>; /// Type for elements under the contact tag diff --git a/epp-client/src/epp/request/contact/update.rs b/epp-client/src/epp/request/contact/update.rs index e552cad..f377956 100644 --- a/epp-client/src/epp/request/contact/update.rs +++ b/epp-client/src/epp/request/contact/update.rs @@ -11,6 +11,43 @@ use crate::error; use serde::{Deserialize, Serialize}; /// Type that represents the request for contact command +/// +/// ## Usage +/// +/// ```ignore +/// use epp_client::EppClient; +/// use epp_client::epp::{EppContactUpdate, EppContactUpdateResponse}; +/// use epp_client::epp::generate_client_tr_id; +/// +/// #[tokio::main] +/// async fn main() { +/// // Create an instance of EppClient, specifying the name of the registry as in +/// // the config file +/// let mut client = match EppClient::new("verisign").await { +/// Ok(client) => client, +/// 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() +/// ); +/// +/// let add_statuses = vec![ +/// ContactStatus { +/// status: "clientTransferProhibited".to_string() +/// } +/// ]; +/// +/// 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(); +/// +/// println!("{:?}", response); +/// } +/// ``` pub type EppContactUpdate = EppObject>; /// Type for elements under the tag for contact update request @@ -96,12 +133,12 @@ impl EppContactUpdate { } /// Sets the data for the tag for the contact update request - pub fn add_statuses(&mut self, statuses: Vec) { + pub fn add(&mut self, statuses: Vec) { self.data.command.contact.add_statuses = Some(StatusList { status: statuses }); } /// Sets the data for the tag for the contact update request - pub fn remove_statuses(&mut self, statuses: Vec) { + pub fn remove(&mut self, statuses: Vec) { self.data.command.contact.remove_statuses = Some(StatusList { status: statuses }); } diff --git a/epp-client/src/epp/request/domain.rs b/epp-client/src/epp/request/domain.rs index cd7f494..0ef8def 100644 --- a/epp-client/src/epp/request/domain.rs +++ b/epp-client/src/epp/request/domain.rs @@ -1,3 +1,5 @@ +//! Types for EPP domain requests + pub mod check; pub mod create; pub mod delete; diff --git a/epp-client/src/epp/request/domain/check.rs b/epp-client/src/epp/request/domain/check.rs index ada5dca..2543cca 100644 --- a/epp-client/src/epp/request/domain/check.rs +++ b/epp-client/src/epp/request/domain/check.rs @@ -8,6 +8,35 @@ use crate::epp::xml::EPP_DOMAIN_XMLNS; use serde::{Deserialize, Serialize}; /// Type that represents the request for domain command +/// +/// ## Usage +/// +/// ```rust +/// use epp_client::EppClient; +/// use epp_client::epp::{EppDomainCheck, EppDomainCheckResponse}; +/// use epp_client::epp::generate_client_tr_id; +/// +/// #[tokio::main] +/// async fn main() { +/// // Create an instance of EppClient, specifying the name of the registry as in +/// // the config file +/// let mut client = match EppClient::new("verisign").await { +/// Ok(client) => client, +/// Err(e) => panic!("Failed to create EppClient: {}", e) +/// }; +/// +/// // Create an EppDomainCheck instance +/// let domain_check = EppDomainCheck::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(); +/// +/// println!("{:?}", response); +/// } +/// ``` pub type EppDomainCheck = EppObject>; /// Type for elements under the domain tag diff --git a/epp-client/src/epp/request/domain/create.rs b/epp-client/src/epp/request/domain/create.rs index ad2f65b..d2cde51 100644 --- a/epp-client/src/epp/request/domain/create.rs +++ b/epp-client/src/epp/request/domain/create.rs @@ -12,6 +12,51 @@ use serde::{Deserialize, Serialize}; /// Type that represents the request for domain command /// with elements in the request for list +/// +/// ## Usage +/// +/// ```ignore +/// use epp_client::EppClient; +/// use epp_client::epp::object::data::DomainContact; +/// use epp_client::epp::{EppDomainCreate, EppDomainCreateResponse}; +/// use epp_client::epp::generate_client_tr_id; +/// +/// #[tokio::main] +/// async fn main() { +/// // Create an instance of EppClient, specifying the name of the registry as in +/// // the config file +/// let mut client = match EppClient::new("verisign").await { +/// Ok(client) => client, +/// 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() +/// }, +/// DomainContact { +/// contact_type: "tech".to_string(), +/// id: "eppdev-contact-2".to_string() +/// }, +/// DomainContact { +/// contact_type: "billing".to_string(), +/// id: "eppdev-contact-2".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() +/// ); +/// +/// // send it to the registry and receive a response of type EppDomainCreateResponse +/// let response = client.transact::<_, EppDomainCreateResponse>(&domain_create).await.unwrap(); +/// +/// println!("{:?}", response); +/// } +/// ``` pub type EppDomainCreate = EppObject>>; /// Type that represents the request for domain command /// with elements in the request for list diff --git a/epp-client/src/epp/request/domain/delete.rs b/epp-client/src/epp/request/domain/delete.rs index bff0767..e3f7164 100644 --- a/epp-client/src/epp/request/domain/delete.rs +++ b/epp-client/src/epp/request/domain/delete.rs @@ -8,6 +8,32 @@ use crate::epp::xml::EPP_DOMAIN_XMLNS; use serde::{Deserialize, Serialize}; /// Type that represents the request for domain command +/// +/// ## Usage +/// +/// ```ignore +/// use epp_client::EppClient; +/// use epp_client::epp::{EppDomainDelete, EppDomainDeleteResponse}; +/// use epp_client::epp::generate_client_tr_id; +/// +/// #[tokio::main] +/// async fn main() { +/// // Create an instance of EppClient, specifying the name of the registry as in +/// // the config file +/// let mut client = match EppClient::new("verisign").await { +/// Ok(client) => client, +/// 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()); +/// +/// // send it to the registry and receive a response of type EppDomainDeleteResponse +/// let response = client.transact::<_, EppDomainDeleteResponse>(&domain_delete).await.unwrap(); +/// +/// println!("{:?}", response); +/// } +/// ``` pub type EppDomainDelete = EppObject>; /// Type for element under the domain tag diff --git a/epp-client/src/epp/request/domain/info.rs b/epp-client/src/epp/request/domain/info.rs index fd163a0..11ae09d 100644 --- a/epp-client/src/epp/request/domain/info.rs +++ b/epp-client/src/epp/request/domain/info.rs @@ -8,6 +8,32 @@ use crate::epp::xml::EPP_DOMAIN_XMLNS; use serde::{Deserialize, Serialize}; /// Type that represents the request for domain command +/// +/// ## Usage +/// +/// ```ignore +/// use epp_client::EppClient; +/// use epp_client::epp::{EppDomainInfo, EppDomainInfoResponse}; +/// use epp_client::epp::generate_client_tr_id; +/// +/// #[tokio::main] +/// async fn main() { +/// // Create an instance of EppClient, specifying the name of the registry as in +/// // the config file +/// let mut client = match EppClient::new("verisign").await { +/// Ok(client) => client, +/// 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()); +/// +/// // send it to the registry and receive a response of type EppDomainInfoResponse +/// let response = client.transact::<_, EppDomainInfoResponse>(&domain_info).await.unwrap(); +/// +/// println!("{:?}", response); +/// } +/// ``` pub type EppDomainInfo = EppObject>; /// Type for data under the element tag for the domain tag diff --git a/epp-client/src/epp/request/domain/renew.rs b/epp-client/src/epp/request/domain/renew.rs index 9363e11..18cce27 100644 --- a/epp-client/src/epp/request/domain/renew.rs +++ b/epp-client/src/epp/request/domain/renew.rs @@ -10,6 +10,36 @@ use chrono::NaiveDate; use serde::{Deserialize, Serialize}; /// Type that represents the request for domain command +/// +/// ## Usage +/// +/// ```ignore +/// use chrono::NaiveDate; +/// use epp_client::EppClient; +/// use epp_client::epp::{EppDomainRenew, EppDomainRenewResponse}; +/// use epp_client::epp::generate_client_tr_id; +/// +/// #[tokio::main] +/// async fn main() { +/// // Create an instance of EppClient, specifying the name of the registry as in +/// // the config file +/// let mut client = match EppClient::new("verisign").await { +/// Ok(client) => client, +/// Err(e) => panic!("Failed to create EppClient: {}", e) +/// }; +/// +/// // 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()); +/// +/// // send it to the registry and receive a response of type EppDomainRenewResponse +/// let response = client.transact::<_, EppDomainRenewResponse>(&domain_renew).await.unwrap(); +/// +/// println!("{:?}", response); +/// } +/// ``` pub type EppDomainRenew = EppObject>; /// Type for data under the domain tag diff --git a/epp-client/src/epp/request/domain/transfer.rs b/epp-client/src/epp/request/domain/transfer.rs index 74354a5..2996c28 100644 --- a/epp-client/src/epp/request/domain/transfer.rs +++ b/epp-client/src/epp/request/domain/transfer.rs @@ -9,14 +9,158 @@ use crate::epp::xml::EPP_DOMAIN_XMLNS; use serde::{Deserialize, Serialize}; /// Type that represents the request for transfer request for domain +/// +/// ## Usage +/// +/// ```ignore +/// use epp_client::EppClient; +/// use epp_client::epp::{EppDomainTransferRequest, EppDomainTransferRequestResponse}; +/// use epp_client::epp::generate_client_tr_id; +/// +/// #[tokio::main] +/// async fn main() { +/// // Create an instance of EppClient, specifying the name of the registry as in +/// // the config file +/// let mut client = match EppClient::new("verisign").await { +/// Ok(client) => client, +/// 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() +/// ); +/// +/// // send it to the registry and receive a response of type EppDomainTransferRequestResponse +/// let response = client.transact::<_, EppDomainTransferRequestResponse>(&domain_transfer_request).await.unwrap(); +/// +/// println!("{:?}", response); +/// } +/// ``` pub type EppDomainTransferRequest = EppObject>; + /// Type that represents the request for transfer approval for domains +/// +/// ## Usage +/// +/// ```ignore +/// use epp_client::EppClient; +/// use epp_client::epp::{EppDomainTransferApprove, EppDomainTransferApproveResponse}; +/// use epp_client::epp::generate_client_tr_id; +/// +/// #[tokio::main] +/// async fn main() { +/// // Create an instance of EppClient, specifying the name of the registry as in +/// // the config file +/// let mut client = match EppClient::new("verisign").await { +/// Ok(client) => client, +/// 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() +/// ); +/// +/// // send it to the registry and receive a response of type EppDomainTransferApproveResponse +/// let response = client.transact::<_, EppDomainTransferApproveResponse>(&domain_transfer_approve).await.unwrap(); +/// +/// println!("{:?}", response); +/// } +/// ``` pub type EppDomainTransferApprove = EppObject>; + /// Type that represents the request for transfer rejection for domains +/// +/// ## Usage +/// +/// ```ignore +/// use epp_client::EppClient; +/// use epp_client::epp::{EppDomainTransferReject, EppDomainTransferRejectResponse}; +/// use epp_client::epp::generate_client_tr_id; +/// +/// #[tokio::main] +/// async fn main() { +/// // Create an instance of EppClient, specifying the name of the registry as in +/// // the config file +/// let mut client = match EppClient::new("verisign").await { +/// Ok(client) => client, +/// 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() +/// ); +/// +/// // send it to the registry and receive a response of type EppDomainTransferRejectResponse +/// let response = client.transact::<_, EppDomainTransferRejectResponse>(&domain_transfer_reject).await.unwrap(); +/// +/// println!("{:?}", response); +/// } +/// ``` pub type EppDomainTransferReject = EppObject>; + /// Type that represents the request for transfer request cancellation for domains +/// +/// ## Usage +/// +/// ```ignore +/// use epp_client::EppClient; +/// use epp_client::epp::{EppDomainTransferCancel, EppDomainTransferCancelResponse}; +/// use epp_client::epp::generate_client_tr_id; +/// +/// #[tokio::main] +/// async fn main() { +/// // Create an instance of EppClient, specifying the name of the registry as in +/// // the config file +/// let mut client = match EppClient::new("verisign").await { +/// Ok(client) => client, +/// 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() +/// ); +/// +/// // send it to the registry and receive a response of type EppDomainTransferCancelResponse +/// let response = client.transact::<_, EppDomainTransferCancelResponse>(&domain_transfer_cancel).await.unwrap(); +/// +/// println!("{:?}", response); +/// } +/// ``` pub type EppDomainTransferCancel = EppObject>; + /// Type that represents the request for transfer request query for domains +/// +/// ## Usage +/// +/// ```ignore +/// use epp_client::EppClient; +/// use epp_client::epp::{EppDomainTransferQuery, EppDomainTransferQueryResponse}; +/// use epp_client::epp::generate_client_tr_id; +/// +/// #[tokio::main] +/// async fn main() { +/// // Create an instance of EppClient, specifying the name of the registry as in +/// // the config file +/// let mut client = match EppClient::new("verisign").await { +/// Ok(client) => client, +/// 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() +/// ); +/// +/// // send it to the registry and receive a response of type EppDomainTransferQueryResponse +/// let response = client.transact::<_, EppDomainTransferQueryResponse>(&domain_transfer_query).await.unwrap(); +/// +/// println!("{:?}", response); +/// } +/// ``` pub type EppDomainTransferQuery = EppObject>; /// Type for elements under the domain tag diff --git a/epp-client/src/epp/request/domain/update.rs b/epp-client/src/epp/request/domain/update.rs index 948571c..f9ef80c 100644 --- a/epp-client/src/epp/request/domain/update.rs +++ b/epp-client/src/epp/request/domain/update.rs @@ -10,6 +10,57 @@ use serde::{Deserialize, Serialize}; /// Type that represents the request for domain command /// with elements in the request for list +/// +/// ## Usage +/// +/// ```ignore +/// use epp_client::EppClient; +/// use epp_client::epp::object::data::{DomainStatus, DomainContact}; +/// use epp_client::epp::{EppDomainUpdate, EppDomainUpdateResponse, DomainAddRemove}; +/// use epp_client::epp::generate_client_tr_id; +/// +/// #[tokio::main] +/// async fn main() { +/// // Create an instance of EppClient, specifying the name of the registry as in +/// // the config file +/// let mut client = match EppClient::new("verisign").await { +/// Ok(client) => client, +/// 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()); +/// +/// let add = DomainAddRemove { +/// ns: None, +/// contacts: None, +/// statuses: Some(vec![ +/// DomainStatus { +/// status: "clientUpdateProhibited".to_string() +/// } +/// ]) +/// }; +/// +/// let remove = DomainAddRemove { +/// ns: None, +/// contacts: Some(vec![ +/// DomainContact { +/// contact_type: "billing".to_string(), +/// id: "eppdev-contact-2".to_string() +/// } +/// ]), +/// statuses: None, +/// }; +/// +/// domain_update.add(add); +/// 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(); +/// +/// println!("{:?}", response); +/// } +/// ``` pub type EppDomainUpdate = EppObject>>; /// Type that represents the request for domain command /// with elements in the request for list diff --git a/epp-client/src/epp/request/host.rs b/epp-client/src/epp/request/host.rs index 035f812..bf155e4 100644 --- a/epp-client/src/epp/request/host.rs +++ b/epp-client/src/epp/request/host.rs @@ -1,3 +1,5 @@ +//! Types for EPP host requests + pub mod check; pub mod create; pub mod delete; diff --git a/epp-client/src/epp/request/host/check.rs b/epp-client/src/epp/request/host/check.rs index 2633162..6a929a2 100644 --- a/epp-client/src/epp/request/host/check.rs +++ b/epp-client/src/epp/request/host/check.rs @@ -8,6 +8,35 @@ use crate::epp::xml::EPP_HOST_XMLNS; use serde::{Deserialize, Serialize}; /// Type that represents the request for host command +/// +/// ## Usage +/// +/// ```rust +/// use epp_client::EppClient; +/// use epp_client::epp::{EppHostCheck, EppHostCheckResponse}; +/// use epp_client::epp::generate_client_tr_id; +/// +/// #[tokio::main] +/// async fn main() { +/// // Create an instance of EppClient, specifying the name of the registry as in +/// // the config file +/// let mut client = match EppClient::new("verisign").await { +/// Ok(client) => client, +/// Err(e) => panic!("Failed to create EppClient: {}", e) +/// }; +/// +/// // Create an EppHostCheck instance +/// let host_check = EppHostCheck::new( +/// vec!["ns1.eppdev-101.com", "ns2.eppdev-101.com"], +/// generate_client_tr_id(&client).as_str() +/// ); +/// +/// // send it to the registry and receive a response of type EppHostCheckResponse +/// let response = client.transact::<_, EppHostCheckResponse>(&host_check).await.unwrap(); +/// +/// println!("{:?}", response); +/// } +/// ``` pub type EppHostCheck = EppObject>; /// Type for data under the host tag diff --git a/epp-client/src/epp/request/host/create.rs b/epp-client/src/epp/request/host/create.rs index 974ba6e..fea5427 100644 --- a/epp-client/src/epp/request/host/create.rs +++ b/epp-client/src/epp/request/host/create.rs @@ -2,13 +2,46 @@ use epp_client_macros::*; -use crate::epp::object::data::{Host, HostAddr}; +use crate::epp::object::data::HostAddr; use crate::epp::object::{ElementName, EppObject, StringValue, StringValueTrait}; use crate::epp::request::Command; use crate::epp::xml::EPP_HOST_XMLNS; use serde::{Deserialize, Serialize}; /// Type that represents the request for host command +/// +/// ## Usage +/// +/// ```ignore +/// use epp_client::EppClient; +/// use epp_client::epp::object::data::HostAddr; +/// use epp_client::epp::{EppHostCreate, EppHostCreateResponse}; +/// use epp_client::epp::generate_client_tr_id; +/// +/// #[tokio::main] +/// async fn main() { +/// // Create an instance of EppClient, specifying the name of the registry as in +/// // the config file +/// let mut client = match EppClient::new("verisign").await { +/// Ok(client) => client, +/// Err(e) => panic!("Failed to create EppClient: {}", e) +/// }; +/// +/// // Create a vector of IP addresses to assign to the host +/// let addresses = vec![ +/// HostAddr::new("v4", "29.245.122.14"), +/// 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()); +/// +/// // send it to the registry and receive a response of type EppHostCreateResponse +/// let response = client.transact::<_, EppHostCreateResponse>(&host_create).await.unwrap(); +/// +/// println!("{:?}", response); +/// } +/// ``` pub type EppHostCreate = EppObject>; /// Type for data under the host tag @@ -34,12 +67,12 @@ pub struct HostCreate { impl EppHostCreate { /// Creates a new EppObject for host create corresponding to the tag in EPP XML - pub fn new(host: Host, client_tr_id: &str) -> EppHostCreate { + pub fn new(host: &str, addresses: Vec, client_tr_id: &str) -> EppHostCreate { let host_create = HostCreate { host: HostCreateData { xmlns: EPP_HOST_XMLNS.to_string(), - name: host.name, - addresses: host.addresses, + name: host.to_string_value(), + addresses: Some(addresses), }, }; diff --git a/epp-client/src/epp/request/host/delete.rs b/epp-client/src/epp/request/host/delete.rs index d0bdf6a..3db9791 100644 --- a/epp-client/src/epp/request/host/delete.rs +++ b/epp-client/src/epp/request/host/delete.rs @@ -8,6 +8,32 @@ use crate::epp::xml::EPP_HOST_XMLNS; use serde::{Deserialize, Serialize}; /// Type that represents the request for host command +/// +/// ## Usage +/// +/// ```ignore +/// use epp_client::EppClient; +/// use epp_client::epp::{EppHostDelete, EppHostDeleteResponse}; +/// use epp_client::epp::generate_client_tr_id; +/// +/// #[tokio::main] +/// async fn main() { +/// // Create an instance of EppClient, specifying the name of the registry as in +/// // the config file +/// let mut client = match EppClient::new("verisign").await { +/// Ok(client) => client, +/// 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()); +/// +/// // send it to the registry and receive a response of type EppHostDeleteResponse +/// let response = client.transact::<_, EppHostDeleteResponse>(&host_delete).await.unwrap(); +/// +/// println!("{:?}", response); +/// } +/// ``` pub type EppHostDelete = EppObject>; /// Type for data under the host tag diff --git a/epp-client/src/epp/request/host/info.rs b/epp-client/src/epp/request/host/info.rs index f7feaad..7956312 100644 --- a/epp-client/src/epp/request/host/info.rs +++ b/epp-client/src/epp/request/host/info.rs @@ -8,6 +8,32 @@ use crate::epp::xml::EPP_HOST_XMLNS; use serde::{Deserialize, Serialize}; /// Type that represents the request for host command +/// +/// ## Usage +/// +/// ```ignore +/// use epp_client::EppClient; +/// use epp_client::epp::{EppHostInfo, EppHostInfoResponse}; +/// use epp_client::epp::generate_client_tr_id; +/// +/// #[tokio::main] +/// async fn main() { +/// // Create an instance of EppClient, specifying the name of the registry as in +/// // the config file +/// let mut client = match EppClient::new("verisign").await { +/// Ok(client) => client, +/// 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()); +/// +/// // send it to the registry and receive a response of type EppHostInfoResponse +/// let response = client.transact::<_, EppHostInfoResponse>(&host_info).await.unwrap(); +/// +/// println!("{:?}", response); +/// } +/// ``` pub type EppHostInfo = EppObject>; /// Type for data under the host tag diff --git a/epp-client/src/epp/request/host/update.rs b/epp-client/src/epp/request/host/update.rs index 1e62771..fdf1fc8 100644 --- a/epp-client/src/epp/request/host/update.rs +++ b/epp-client/src/epp/request/host/update.rs @@ -9,6 +9,55 @@ use crate::epp::xml::EPP_HOST_XMLNS; use serde::{Deserialize, Serialize}; /// Type that represents the request for host command +/// +/// ## Usage +/// +/// ```ignore +/// use epp_client::EppClient; +/// use epp_client::epp::object::StringValueTrait; +/// use epp_client::epp::object::data::{HostAddr, HostStatus}; +/// use epp_client::epp::{EppHostUpdate, EppHostUpdateResponse, HostAddRemove, HostChangeInfo}; +/// use epp_client::epp::generate_client_tr_id; +/// +/// #[tokio::main] +/// async fn main() { +/// // Create an instance of EppClient, specifying the name of the registry as in +/// // the config file +/// let mut client = match EppClient::new("verisign").await { +/// Ok(client) => client, +/// 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()); +/// +/// /// Prepare the add and remove sections for the update +/// let add = HostAddRemove { +/// addresses: Some(vec![ +/// HostAddr::new("v4", "177.34.126.17") +/// ]), +/// statuses: None +/// }; +/// +/// let remove = HostAddRemove { +/// addresses: Some(vec![ +/// HostAddr::new("v6", "2404:6800:4001:801::200e") +/// ]), +/// statuses: None, +/// }; +/// +/// host_update.add(add); +/// host_update.remove(remove); +/// +/// // Send a section as well +/// host_update.info(HostChangeInfo { name: "ns2.eppdev-101.com".to_string_value() }); +/// +/// // send it to the registry and receive a response of type EppHostUpdateResponse +/// let response = client.transact::<_, EppHostUpdateResponse>(&host_update).await.unwrap(); +/// +/// println!("{:?}", response); +/// } +/// ``` pub type EppHostUpdate = EppObject>; /// Type for data under the tag diff --git a/epp-client/src/epp/request/message.rs b/epp-client/src/epp/request/message.rs index 60b48c9..bc692a1 100644 --- a/epp-client/src/epp/request/message.rs +++ b/epp-client/src/epp/request/message.rs @@ -1,2 +1,4 @@ +//! Types for EPP message requests + pub mod ack; pub mod poll; diff --git a/epp-client/src/epp/request/message/ack.rs b/epp-client/src/epp/request/message/ack.rs index e78ce94..90a831a 100644 --- a/epp-client/src/epp/request/message/ack.rs +++ b/epp-client/src/epp/request/message/ack.rs @@ -7,6 +7,31 @@ use crate::epp::request::Command; use serde::{Deserialize, Serialize}; /// Type that represents the request for registry command +/// ## Usage +/// +/// ```ignore +/// use epp_client::EppClient; +/// use epp_client::epp::{EppMessageAck, EppMessageAckResponse}; +/// use epp_client::epp::generate_client_tr_id; +/// +/// #[tokio::main] +/// async fn main() { +/// // Create an instance of EppClient, specifying the name of the registry as in +/// // the config file +/// let mut client = match EppClient::new("verisign").await { +/// Ok(client) => client, +/// 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()); +/// +/// // send it to the registry and receive a response of type EppMessageAckResponse +/// let response = client.transact::<_, EppMessageAckResponse>(&message_ack).await.unwrap(); +/// +/// println!("{:?}", response); +/// } +/// ``` pub type EppMessageAck = EppObject>; #[derive(Serialize, Deserialize, Debug, ElementName)] diff --git a/epp-client/src/epp/request/message/poll.rs b/epp-client/src/epp/request/message/poll.rs index e31c8e0..49bb734 100644 --- a/epp-client/src/epp/request/message/poll.rs +++ b/epp-client/src/epp/request/message/poll.rs @@ -7,6 +7,32 @@ use crate::epp::request::Command; use serde::{Deserialize, Serialize}; /// Type that represents the request for registry command +/// +/// ## Usage +/// +/// ```rust +/// use epp_client::EppClient; +/// use epp_client::epp::{EppMessagePoll, EppMessagePollResponse}; +/// use epp_client::epp::generate_client_tr_id; +/// +/// #[tokio::main] +/// async fn main() { +/// // Create an instance of EppClient, specifying the name of the registry as in +/// // the config file +/// let mut client = match EppClient::new("verisign").await { +/// Ok(client) => client, +/// Err(e) => panic!("Failed to create EppClient: {}", e) +/// }; +/// +/// // Create an EppMessagePoll instance +/// let message_poll = EppMessagePoll::new(generate_client_tr_id(&client).as_str()); +/// +/// // send it to the registry and receive a response of type EppMessagePollResponse +/// let response = client.transact::<_, EppMessagePollResponse>(&message_poll).await.unwrap(); +/// +/// println!("{:?}", response); +/// } +/// ``` pub type EppMessagePoll = EppObject>; #[derive(Serialize, Deserialize, Debug, ElementName)] diff --git a/epp-client/src/epp/response/contact.rs b/epp-client/src/epp/response/contact.rs index d1d577c..ee8f7f9 100644 --- a/epp-client/src/epp/response/contact.rs +++ b/epp-client/src/epp/response/contact.rs @@ -1,4 +1,4 @@ -//! Module containing types for EPP contact transactions +//! Types for EPP contact responses pub mod check; pub mod create; diff --git a/epp-client/src/epp/response/domain.rs b/epp-client/src/epp/response/domain.rs index 224c575..c9cf686 100644 --- a/epp-client/src/epp/response/domain.rs +++ b/epp-client/src/epp/response/domain.rs @@ -1,4 +1,4 @@ -//! Module containing types for EPP domain transactions +//! Types for EPP domain responses pub mod check; pub mod create; diff --git a/epp-client/src/epp/response/host.rs b/epp-client/src/epp/response/host.rs index ad73ec2..52fbdcf 100644 --- a/epp-client/src/epp/response/host.rs +++ b/epp-client/src/epp/response/host.rs @@ -1,4 +1,4 @@ -//! Module containing types for EPP host transactions +//! Types for EPP host responses pub mod check; pub mod create; diff --git a/epp-client/src/epp/response/message.rs b/epp-client/src/epp/response/message.rs index 5601d0d..ecf5953 100644 --- a/epp-client/src/epp/response/message.rs +++ b/epp-client/src/epp/response/message.rs @@ -1,4 +1,4 @@ -//! Module containing types for EPP message transactions +//! Types for EPP message responses pub mod ack; pub mod poll; diff --git a/epp-client/src/tests/se.rs b/epp-client/src/tests/se.rs index 131860a..a732df7 100644 --- a/epp-client/src/tests/se.rs +++ b/epp-client/src/tests/se.rs @@ -4,7 +4,7 @@ mod request { use super::super::get_xml; use super::super::CLTRID; use crate::epp::object::data::{ - Address, AuthInfo, ContactStatus, DomainContact, DomainStatus, Host, HostAddr, HostAttr, + Address, AuthInfo, ContactStatus, DomainContact, DomainStatus, HostAddr, HostAttr, HostStatus, Phone, PostalInfo, }; use crate::epp::object::StringValueTrait; @@ -106,11 +106,11 @@ mod request { let add_statuses = vec![ContactStatus { status: "clientTransferProhibited".to_string(), }]; - object.add_statuses(add_statuses); + object.add(add_statuses); let remove_statuses = vec![ContactStatus { status: "clientDeleteProhibited".to_string(), }]; - object.remove_statuses(remove_statuses); + object.remove(remove_statuses); let serialized = object.serialize().unwrap(); @@ -395,15 +395,12 @@ mod request { fn host_create() { let xml = get_xml("request/host/create.xml").unwrap(); - let host = Host { - name: "host1.eppdev-1.com".to_string_value(), - addresses: Some(vec![ - HostAddr::new("v4", "29.245.122.14"), - HostAddr::new("v6", "2404:6800:4001:801::200e"), - ]), - }; + let addresses = vec![ + HostAddr::new("v4", "29.245.122.14"), + HostAddr::new("v6", "2404:6800:4001:801::200e"), + ]; - let object = EppHostCreate::new(host, CLTRID); + let object = EppHostCreate::new("host1.eppdev-1.com", addresses, CLTRID); let serialized = object.serialize().unwrap();