Refactor domain delete models

This commit is contained in:
Nick Rempel 2021-11-25 21:28:03 -08:00 committed by masalachai
parent 341e06dc14
commit e5f5ba0695
8 changed files with 27 additions and 30 deletions

View File

@ -1,2 +1,3 @@
pub mod check; pub mod check;
pub mod create; pub mod create;
pub mod delete;

View File

@ -4,6 +4,7 @@ use epp_client_macros::*;
use crate::epp::object::{ElementName, EppObject, StringValue}; use crate::epp::object::{ElementName, EppObject, StringValue};
use crate::epp::request::Command; use crate::epp::request::Command;
use crate::epp::response::EppCommandResponse;
use crate::epp::xml::EPP_DOMAIN_XMLNS; use crate::epp::xml::EPP_DOMAIN_XMLNS;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -16,7 +17,7 @@ use serde::{Deserialize, Serialize};
/// ///
/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::config::{EppClientConfig, EppClientConnection};
/// use epp_client::EppClient; /// use epp_client::EppClient;
/// use epp_client::epp::{EppDomainDelete, EppDomainDeleteResponse}; /// use epp_client::domain::delete::{EppDomainDelete, EppDomainDeleteResponse};
/// use epp_client::epp::generate_client_tr_id; /// use epp_client::epp::generate_client_tr_id;
/// ///
/// #[tokio::main] /// #[tokio::main]
@ -53,11 +54,29 @@ use serde::{Deserialize, Serialize};
/// client.logout().await.unwrap(); /// client.logout().await.unwrap();
/// } /// }
/// ``` /// ```
pub type EppDomainDelete = EppObject<Command<DomainDelete>>; 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 {
domain: DomainDeleteRequestData {
xmlns: EPP_DOMAIN_XMLNS.to_string(),
name: name.into(),
},
},
client_tr_id,
))
}
}
/// Type that represents the &lt;epp&gt; tag for the EPP XML domain delete response
pub type EppDomainDeleteResponse = EppCommandResponse;
/// Type for &lt;name&gt; element under the domain &lt;delete&gt; tag /// Type for &lt;name&gt; element under the domain &lt;delete&gt; tag
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
pub struct DomainDeleteData { pub struct DomainDeleteRequestData {
/// XML namespace for domain commands /// XML namespace for domain commands
#[serde(rename = "xmlns:domain", alias = "xmlns")] #[serde(rename = "xmlns:domain", alias = "xmlns")]
xmlns: String, xmlns: String,
@ -69,23 +88,8 @@ pub struct DomainDeleteData {
#[derive(Serialize, Deserialize, Debug, ElementName)] #[derive(Serialize, Deserialize, Debug, ElementName)]
#[element_name(name = "delete")] #[element_name(name = "delete")]
/// Type for EPP XML &lt;delete&gt; command for domains /// Type for EPP XML &lt;delete&gt; command for domains
pub struct DomainDelete { pub struct DomainDeleteRequest {
/// The data under the &lt;delete&gt; tag for domain deletion /// The data under the &lt;delete&gt; tag for domain deletion
#[serde(rename = "domain:delete", alias = "delete")] #[serde(rename = "domain:delete", alias = "delete")]
domain: DomainDeleteData, domain: DomainDeleteRequestData,
}
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::<DomainDelete>::new(
DomainDelete {
domain: DomainDeleteData {
xmlns: EPP_DOMAIN_XMLNS.to_string(),
name: name.into(),
},
},
client_tr_id,
))
}
} }

View File

@ -10,7 +10,6 @@ pub use request::contact::create::*;
pub use request::contact::delete::*; pub use request::contact::delete::*;
pub use request::contact::info::*; pub use request::contact::info::*;
pub use request::contact::update::*; pub use request::contact::update::*;
pub use request::domain::delete::*;
pub use request::domain::info::*; pub use request::domain::info::*;
pub use request::domain::renew::*; pub use request::domain::renew::*;
pub use request::domain::rgp::report::*; pub use request::domain::rgp::report::*;
@ -30,7 +29,6 @@ pub use response::contact::create::*;
pub use response::contact::delete::*; pub use response::contact::delete::*;
pub use response::contact::info::*; pub use response::contact::info::*;
pub use response::contact::update::*; pub use response::contact::update::*;
pub use response::domain::delete::*;
pub use response::domain::info::*; pub use response::domain::info::*;
pub use response::domain::renew::*; pub use response::domain::renew::*;
pub use response::domain::rgp::report::*; pub use response::domain::rgp::report::*;

View File

@ -1,6 +1,5 @@
//! Types for EPP domain requests //! Types for EPP domain requests
pub mod delete;
pub mod info; pub mod info;
pub mod renew; pub mod renew;
pub mod rgp; pub mod rgp;

View File

@ -1,6 +1,5 @@
//! Types for EPP domain responses //! Types for EPP domain responses
pub mod delete;
pub mod info; pub mod info;
pub mod renew; pub mod renew;
pub mod rgp; pub mod rgp;

View File

@ -1,6 +0,0 @@
//! Types for EPP domain delete response
use crate::epp::response::EppCommandResponse;
/// Type that represents the &lt;epp&gt; tag for the EPP XML domain delete response
pub type EppDomainDeleteResponse = EppCommandResponse;

View File

@ -5,6 +5,7 @@ mod response {
use super::super::CLTRID; use super::super::CLTRID;
use crate::domain::check::EppDomainCheckResponse; use crate::domain::check::EppDomainCheckResponse;
use crate::domain::create::EppDomainCreateResponse; use crate::domain::create::EppDomainCreateResponse;
use crate::domain::delete::EppDomainDeleteResponse;
use crate::epp::response::ExpiryType; use crate::epp::response::ExpiryType;
use crate::epp::response::Relative; use crate::epp::response::Relative;
use crate::epp::response::{ use crate::epp::response::{

View File

@ -5,6 +5,7 @@ mod request {
use super::super::CLTRID; use super::super::CLTRID;
use crate::domain::check::EppDomainCheck; use crate::domain::check::EppDomainCheck;
use crate::domain::create::EppDomainCreate; use crate::domain::create::EppDomainCreate;
use crate::domain::delete::EppDomainDelete;
use crate::epp::object::data::{ use crate::epp::object::data::{
Address, ContactStatus, DomainAuthInfo, DomainContact, DomainStatus, HostAddr, HostAttr, Address, ContactStatus, DomainAuthInfo, DomainContact, DomainStatus, HostAddr, HostAttr,
HostStatus, Phone, PostalInfo, HostStatus, Phone, PostalInfo,