Rename transact_new to transact

This commit is contained in:
Nicholas Rempel 2021-11-26 14:21:38 -08:00 committed by masalachai
parent 9e1d11f9f3
commit 3978c426da
23 changed files with 31 additions and 55 deletions

View File

@ -41,7 +41,7 @@
//!
//! // Execute an EPP Command against the registry with distinct request and response objects
//! 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();
//! let response = client.transact(domain_check, generate_client_tr_id(&client).as_str()).await.unwrap();
//! println!("{:?}", response);
//!
//! }
@ -58,10 +58,7 @@ use crate::hello::{EppGreeting, EppHello};
use crate::login::Login;
use crate::logout::Logout;
use crate::request::{generate_client_tr_id, EppExtension, EppRequest};
use crate::response::{
CommandResponseStatus, CommandResponseWithExtension, EppCommandResponse,
EppCommandResponseError,
};
use crate::response::{CommandResponseStatus, CommandResponseWithExtension};
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
@ -125,7 +122,7 @@ impl EppClient {
);
client
.transact_new(login_request, client_tr_id.as_str())
.transact(login_request, client_tr_id.as_str())
.await?;
Ok(client)
@ -141,28 +138,7 @@ impl EppClient {
Ok(EppGreeting::deserialize(&response)?)
}
/// Accepts an EPP request object to convert to a request to send to the registry. The response from the
/// registry is deserialized to response type E and returned.
pub async fn transact<T: EppXml + Debug, E: EppXml + Debug>(
&mut self,
request: &T,
) -> Result<E::Output, error::Error> {
let epp_xml = request.serialize()?;
let response = self.connection.transact(&epp_xml).await?;
let status = EppCommandResponse::deserialize(&response)?;
if status.data.result.code < 2000 {
let response = E::deserialize(&response)?;
Ok(response)
} else {
let epp_error = EppCommandResponseError::deserialize(&response)?;
Err(error::Error::EppCommandError(epp_error))
}
}
pub async fn transact_new<T, E>(
pub async fn transact<T, E>(
&mut self,
request: T,
id: &str,
@ -209,7 +185,7 @@ impl EppClient {
let client_tr_id = generate_client_tr_id(&self.credentials.0).unwrap();
let epp_logout = Logout::<NoExtension>::new();
let response = self.transact_new(epp_logout, client_tr_id.as_str()).await?;
let response = self.transact(epp_logout, client_tr_id.as_str()).await?;
self.connection.shutdown().await?;

View File

@ -66,7 +66,7 @@ impl<E: EppExtension> EppRequest<E> for ContactCheck<E> {
///
/// // 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();
/// let response = client.transact(contact_check, generate_client_tr_id(&client).as_str()).await.unwrap();
/// println!("{:?}", response);
///
/// client.logout().await.unwrap();

View File

@ -79,7 +79,7 @@ impl<E: EppExtension> EppRequest<E> for ContactCreate<E> {
/// contact_create.set_fax(fax);
///
/// // 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();
/// let response = client.transact(contact_create, generate_client_tr_id(&client).as_str()).await.unwrap();
///
/// println!("{:?}", response);
///

View File

@ -65,7 +65,7 @@ impl<E: EppExtension> EppRequest<E> for ContactDelete<E> {
/// );
///
/// // 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();
/// let response = client.transact(contact_delete, generate_client_tr_id(&client).as_str()).await.unwrap();
///
/// println!("{:?}", response);
///

View File

@ -67,7 +67,7 @@ impl<E: EppExtension> EppRequest<E> for ContactInfo<E> {
/// );
///
/// // 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();
/// let response = client.transact(contact_info, generate_client_tr_id(&client).as_str()).await.unwrap();
///
/// println!("{:?}", response);
///

View File

@ -76,7 +76,7 @@ impl<E: EppExtension> EppRequest<E> for ContactUpdate<E> {
/// contact_update.add(add_statuses);
///
/// // 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();
/// let response = client.transact(contact_update, generate_client_tr_id(&client).as_str()).await.unwrap();
///
/// println!("{:?}", response);
///

View File

@ -64,7 +64,7 @@ impl<E: EppExtension> EppRequest<E> for DomainCheck<E> {
/// );
///
/// // send it to the registry and receive a response of type EppDomainCheckResponse
/// let response = client.transact_new(domain_check, generate_client_tr_id(&client).as_str()).await.unwrap();
/// let response = client.transact(domain_check, generate_client_tr_id(&client).as_str()).await.unwrap();
///
/// println!("{:?}", response);
///

View File

@ -94,7 +94,7 @@ impl<E: EppExtension> EppRequest<E> for DomainCreate<E> {
/// );
///
/// // send it to the registry and receive a response of type EppDomainCreateResponse
/// let response = client.transact_new(domain_create, generate_client_tr_id(&client).as_str()).await.unwrap();
/// let response = client.transact(domain_create, generate_client_tr_id(&client).as_str()).await.unwrap();
///
/// println!("{:?}", response);
///

View File

@ -63,7 +63,7 @@ impl<E: EppExtension> EppRequest<E> for DomainDelete<E> {
/// let mut domain_delete = DomainDelete::<NoExtension>::new("eppdev-100.com");
///
/// // 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();
/// let response = client.transact(domain_delete, generate_client_tr_id(&client).as_str()).await.unwrap();
///
/// println!("{:?}", response);
///

View File

@ -64,7 +64,7 @@ impl<E: EppExtension> EppRequest<E> for DomainInfo<E> {
/// let domain_info = DomainInfo::<NoExtension>::new("eppdev-100.com");
///
/// // 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();
/// let response = client.transact(domain_info, generate_client_tr_id(&client).as_str()).await.unwrap();
///
/// println!("{:?}", response);
///

View File

@ -68,7 +68,7 @@ impl<E: EppExtension> EppRequest<E> for DomainRenew<E> {
/// let domain_renew = DomainRenew::<NoExtension>::new("eppdev-100.com", exp_date, 1);
///
/// // 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();
/// let response = client.transact(domain_renew, generate_client_tr_id(&client).as_str()).await.unwrap();
///
/// println!("{:?}", response);
///

View File

@ -75,7 +75,7 @@ use serde::{Deserialize, Serialize};
/// let mut domain_update = DomainUpdate::<RgpRestoreReport>::new("eppdev-100.com").with_extension(domain_restore_report);
///
/// // send it to the registry and receive a response of type EppDomainUpdateResponse
/// let response = client.transact_new(domain_update, generate_client_tr_id(&client).as_str()).await.unwrap();
/// let response = client.transact(domain_update, generate_client_tr_id(&client).as_str()).await.unwrap();
///
/// println!("{:?}", response);
///

View File

@ -52,7 +52,7 @@ use serde::{Deserialize, Serialize};
/// let mut domain_update = DomainUpdate::<RgpRestoreRequest>::new("eppdev-100.com").with_extension(domain_restore_req);
///
/// // send it to the registry and receive a response of type EppDomainUpdateResponse
/// let response = client.transact_new(domain_update, generate_client_tr_id(&client).as_str()).await.unwrap();
/// let response = client.transact(domain_update, generate_client_tr_id(&client).as_str()).await.unwrap();
///
/// println!("{:?}", response);
///

View File

@ -125,7 +125,7 @@ impl<E: EppExtension> EppRequest<E> for DomainTransferQuery<E> {
/// );
///
/// // 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();
/// let response = client.transact(domain_transfer_request, generate_client_tr_id(&client).as_str()).await.unwrap();
///
/// println!("{:?}", response);
///
@ -198,7 +198,7 @@ impl<E: EppExtension> DomainTransferRequest<E> {
/// );
///
/// // 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();
/// let response = client.transact(domain_transfer_approve, generate_client_tr_id(&client).as_str()).await.unwrap();
///
/// println!("{:?}", response);
///
@ -271,7 +271,7 @@ impl<E: EppExtension> DomainTransferApprove<E> {
/// );
///
/// // 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();
/// let response = client.transact(domain_transfer_reject, generate_client_tr_id(&client).as_str()).await.unwrap();
///
/// println!("{:?}", response);
///
@ -344,7 +344,7 @@ impl<E: EppExtension> DomainTransferReject<E> {
/// );
///
/// // 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();
/// let response = client.transact(domain_transfer_cancel, generate_client_tr_id(&client).as_str()).await.unwrap();
///
/// println!("{:?}", response);
///
@ -417,7 +417,7 @@ impl<E: EppExtension> DomainTransferCancel<E> {
/// );
///
/// // 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();
/// let response = client.transact(domain_transfer_query, generate_client_tr_id(&client).as_str()).await.unwrap();
///
/// println!("{:?}", response);
///

View File

@ -96,7 +96,7 @@ impl<E: EppExtension> EppRequest<E> for DomainUpdate<E> {
/// domain_update.remove(remove);
///
/// // send it to the registry and receive a response of type EppDomainUpdateResponse
/// let response = client.transact_new(domain_update, generate_client_tr_id(&client).as_str()).await.unwrap();
/// let response = client.transact(domain_update, generate_client_tr_id(&client).as_str()).await.unwrap();
///
/// println!("{:?}", response);
///

View File

@ -66,7 +66,7 @@ impl<E: EppExtension> EppRequest<E> for HostCheck<E> {
/// );
///
/// // 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();
/// let response = client.transact(host_check, generate_client_tr_id(&client).as_str()).await.unwrap();
///
/// println!("{:?}", response);
///

View File

@ -69,7 +69,7 @@ impl<E: EppExtension> EppRequest<E> for HostCreate<E> {
/// let host_create = HostCreate::<NoExtension>::new("ns1.eppdev-101.com", addresses);
///
/// // 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();
/// let response = client.transact(host_create, generate_client_tr_id(&client).as_str()).await.unwrap();
///
/// println!("{:?}", response);
///

View File

@ -63,7 +63,7 @@ impl<E: EppExtension> EppRequest<E> for HostDelete<E> {
/// let host_delete = HostDelete::<NoExtension>::new("ns2.eppdev-101.com");
///
/// // 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();
/// let response = client.transact(host_delete, generate_client_tr_id(&client).as_str()).await.unwrap();
///
/// println!("{:?}", response);
///

View File

@ -62,7 +62,7 @@ impl<E: EppExtension> EppRequest<E> for HostInfo<E> {
/// let host_info = HostInfo::<NoExtension>::new("ns2.eppdev-101.com");
///
/// // 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();
/// let response = client.transact(host_info, generate_client_tr_id(&client).as_str()).await.unwrap();
///
/// println!("{:?}", response);
///

View File

@ -85,7 +85,7 @@ impl<E: EppExtension> EppRequest<E> for HostUpdate<E> {
/// host_update.info(HostChangeInfo { name: "ns2.eppdev-101.com".into() });
///
/// // 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();
/// let response = client.transact(host_update, generate_client_tr_id(&client).as_str()).await.unwrap();
///
/// println!("{:?}", response);
///

View File

@ -77,7 +77,7 @@
//! vec!["eppdev.com", "eppdev.net"],
//! );
//!
//! let response = client.transact_new(domain_check, generate_client_tr_id(&client).as_str()).await.unwrap();
//! let response = client.transact(domain_check, generate_client_tr_id(&client).as_str()).await.unwrap();
//!
//! // print the availability results
//! response.res_data.unwrap().check_data.domain_list

View File

@ -60,7 +60,7 @@ impl<E: EppExtension> EppRequest<E> for MessageAck<E> {
/// let message_ack = MessageAck::<NoExtension>::new(12345);
///
/// // 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();
/// let response = client.transact(message_ack, generate_client_tr_id(&client).as_str()).await.unwrap();
///
/// println!("{:?}", response);
///

View File

@ -61,7 +61,7 @@ impl<E: EppExtension> EppRequest<E> for MessagePoll<E> {
/// let message_poll = MessagePoll::<NoExtension>::new();
///
/// // 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();
/// let response = client.transact(message_poll, generate_client_tr_id(&client).as_str()).await.unwrap();
///
/// println!("{:?}", response);
///