Remove Command prefix from Response types

This commit is contained in:
Dirkjan Ochtman 2021-12-02 13:47:14 +01:00 committed by masalachai
parent 91070576cd
commit 340cc9c90a
3 changed files with 11 additions and 14 deletions

View File

@ -58,7 +58,7 @@ use crate::login::Login;
use crate::logout::Logout;
use crate::registry::{epp_connect, EppConnection};
use crate::request::{generate_client_tr_id, EppExtension, EppRequest};
use crate::response::{CommandResponseStatus, CommandResponseWithExtension};
use crate::response::{ResponseStatus, ResponseWithExtension};
use crate::xml::EppXml;
/// Instances of the EppClient type are used to transact with the registry.
@ -143,7 +143,7 @@ impl EppClient {
&mut self,
request: T,
id: &str,
) -> Result<CommandResponseWithExtension<<T as EppRequest<E>>::Output, E::Response>, error::Error>
) -> Result<ResponseWithExtension<<T as EppRequest<E>>::Output, E::Response>, error::Error>
where
T: EppRequest<E> + Debug,
E: EppExtension,
@ -179,10 +179,7 @@ impl EppClient {
/// Sends the EPP Logout command to log out of the EPP session
pub async fn logout(
&mut self,
) -> Result<
CommandResponseWithExtension<EppObject<CommandResponseStatus>, NoExtension>,
error::Error,
> {
) -> Result<ResponseWithExtension<EppObject<ResponseStatus>, NoExtension>, error::Error> {
let client_tr_id = generate_client_tr_id(&self.credentials.0).unwrap();
let epp_logout = Logout::<NoExtension>::new();

View File

@ -8,7 +8,7 @@ use std::time::SystemTime;
use crate::{
common::NoExtension,
common::{ElementName, EppObject, Extension, StringValue},
response::{CommandResponseStatus, CommandResponseWithExtension},
response::{ResponseStatus, ResponseWithExtension},
xml::EppXml,
};
use epp_client_macros::ElementName;
@ -35,15 +35,15 @@ pub trait EppRequest<E: EppExtension>: Sized + Debug {
fn deserialize_response(
epp_xml: &str,
) -> Result<CommandResponseWithExtension<Self::Output, E::Response>, crate::error::Error> {
) -> Result<ResponseWithExtension<Self::Output, E::Response>, crate::error::Error> {
let rsp =
<EppObject<CommandResponseWithExtension<Self::Output, E::Response>> as EppXml>::deserialize(
<EppObject<ResponseWithExtension<Self::Output, E::Response>> as EppXml>::deserialize(
epp_xml,
)?;
match rsp.data.result.code {
0..=2000 => Ok(rsp.data),
_ => Err(crate::error::Error::EppCommandError(EppObject::build(
CommandResponseStatus {
ResponseStatus {
result: rsp.data.result,
tr_ids: rsp.data.tr_ids,
},

View File

@ -7,7 +7,7 @@ use std::fmt::Debug;
use crate::common::{ElementName, EppObject, Extension, StringValue};
/// A generic EPP Response to an EPP command with a result section, a status code and a message
pub type EppCommandResponse = EppObject<CommandResponseStatus>;
pub type EppCommandResponse = EppObject<ResponseStatus>;
/// Type corresponding to the <undef> tag an EPP response XML
#[derive(Serialize, Deserialize, Debug, PartialEq)]
@ -76,7 +76,7 @@ pub struct MessageQueue {
#[element_name(name = "response")]
/// Type corresponding to the &lt;response&gt; tag in an EPP response XML
/// containing an &lt;extension&gt; tag
pub struct CommandResponseWithExtension<T, E: ElementName> {
pub struct ResponseWithExtension<T, E: ElementName> {
/// Data under the <result> tag
pub result: EppResult,
/// Data under the <msgQ> tag
@ -96,7 +96,7 @@ pub struct CommandResponseWithExtension<T, E: ElementName> {
#[element_name(name = "response")]
/// Type corresponding to the &lt;response&gt; tag in an EPP response XML
/// without <msgQ> or &lt;resData&gt; sections. Generally used for error handling
pub struct CommandResponseStatus {
pub struct ResponseStatus {
/// Data under the <result> tag
pub result: EppResult,
#[serde(rename = "trID")]
@ -104,7 +104,7 @@ pub struct CommandResponseStatus {
pub tr_ids: ResponseTRID,
}
impl<T, E: ElementName> CommandResponseWithExtension<T, E> {
impl<T, E: ElementName> ResponseWithExtension<T, E> {
/// Returns the data under the corresponding &lt;resData&gt; from the EPP XML
pub fn res_data(&self) -> Option<&T> {
match &self.res_data {