diff --git a/epp-client/src/connection/client.rs b/epp-client/src/connection/client.rs index fd7d320..f5394ee 100644 --- a/epp-client/src/connection/client.rs +++ b/epp-client/src/connection/client.rs @@ -54,8 +54,9 @@ use crate::connection::registry::{epp_connect, EppConnection}; use crate::error; use crate::hello::{EppGreeting, EppHello}; use crate::login::{EppLogin, EppLoginResponse}; -use crate::request::{generate_client_tr_id, EppLogout}; -use crate::response::{EppCommandResponse, EppCommandResponseError, EppLogoutResponse}; +use crate::logout::{EppLogout, EppLogoutResponse}; +use crate::request::generate_client_tr_id; +use crate::response::{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 diff --git a/epp-client/src/lib.rs b/epp-client/src/lib.rs index 71b256d..66d0def 100644 --- a/epp-client/src/lib.rs +++ b/epp-client/src/lib.rs @@ -109,6 +109,7 @@ pub mod error; pub mod hello; pub mod host; pub mod login; +pub mod logout; pub mod message; pub mod request; pub mod response; diff --git a/epp-client/src/logout.rs b/epp-client/src/logout.rs new file mode 100644 index 0000000..51f56bb --- /dev/null +++ b/epp-client/src/logout.rs @@ -0,0 +1,32 @@ +use std::fmt::Debug; + +use epp_client_macros::ElementName; +use serde::{Deserialize, Serialize}; + +use crate::{ + common::{ElementName, EppObject}, + request::Command, + response::EppCommandResponse, +}; + +/// The EPP Logout request +pub type EppLogout = EppObject>; + +impl EppLogout { + /// Creates a new EPP Logout request + pub fn new(client_tr_id: &str) -> EppLogout { + EppObject::build(Command:: { + command: Logout, + 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; + +#[derive(Serialize, Deserialize, Debug, PartialEq, ElementName)] +#[element_name(name = "logout")] +/// Type corresponding to the <logout> tag in an EPP XML logout request +pub struct Logout; diff --git a/epp-client/src/request.rs b/epp-client/src/request.rs index 8d1ef50..9d758aa 100644 --- a/epp-client/src/request.rs +++ b/epp-client/src/request.rs @@ -4,7 +4,7 @@ use serde::{ser::SerializeStruct, ser::Serializer, Deserialize, Serialize}; use std::error::Error; use std::time::SystemTime; -use crate::common::{ElementName, EmptyTag, EppObject, Extension, StringValue}; +use crate::common::{ElementName, EmptyTag, Extension, StringValue}; use epp_client_macros::ElementName; pub const EPP_VERSION: &str = "1.0"; @@ -14,9 +14,6 @@ pub const EPP_LANG: &str = "en"; /// without an <extension> tag pub type Command = CommandWithExtension; -/// The EPP Logout request -pub type EppLogout = EppObject>; - #[derive(Deserialize, Debug, PartialEq, ElementName)] #[element_name(name = "command")] /// Type corresponding to the <command> tag in an EPP XML request @@ -73,19 +70,3 @@ pub fn generate_client_tr_id(username: &str) -> Result> { let timestamp = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH)?; Ok(format!("{}:{}", username, timestamp.as_secs())) } - -#[derive(Serialize, Deserialize, Debug, PartialEq, ElementName)] -#[element_name(name = "logout")] -/// Type corresponding to the <logout> tag in an EPP XML logout request -pub struct Logout; - -impl EppLogout { - /// Creates a new EPP Logout request - pub fn new(client_tr_id: &str) -> EppLogout { - EppObject::build(Command:: { - command: Logout, - extension: None, - client_tr_id: client_tr_id.into(), - }) - } -} diff --git a/epp-client/src/response.rs b/epp-client/src/response.rs index a8e6e36..be28bbf 100644 --- a/epp-client/src/response.rs +++ b/epp-client/src/response.rs @@ -13,8 +13,6 @@ pub type CommandResponse = CommandResponseWithExtension; pub type EppCommandResponse = EppObject; /// An alias of `EppCommandResponse` indicating an EPP Error pub type EppCommandResponseError = EppCommandResponse; -/// An alias of `EppCommandResponse` received in response to a successful logout request -pub type EppLogoutResponse = EppCommandResponse; /// Type corresponding to the tag an EPP response XML #[derive(Serialize, Deserialize, Debug, PartialEq)] diff --git a/epp-client/src/tests/de.rs b/epp-client/src/tests/de.rs index 51c6525..deaa0bf 100644 --- a/epp-client/src/tests/de.rs +++ b/epp-client/src/tests/de.rs @@ -29,9 +29,10 @@ mod response { 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::response::{EppCommandResponseError, EppLogoutResponse}; + use crate::response::EppCommandResponseError; use crate::xml::EppXml; const SVTRID: &str = "RO-6879-1627224678242975"; diff --git a/epp-client/src/tests/se.rs b/epp-client/src/tests/se.rs index ece42dc..cba71c4 100644 --- a/epp-client/src/tests/se.rs +++ b/epp-client/src/tests/se.rs @@ -36,9 +36,9 @@ mod request { 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::request::EppLogout; use crate::xml::EppXml; use chrono::{DateTime, NaiveDate}; use std::str::FromStr;