Refactor contact info models
This commit is contained in:
parent
f163d35a45
commit
d7199c5ddb
|
@ -1,3 +1,4 @@
|
|||
pub mod check;
|
||||
pub mod create;
|
||||
pub mod delete;
|
||||
pub mod info;
|
||||
|
|
|
@ -2,9 +2,10 @@
|
|||
|
||||
use epp_client_macros::*;
|
||||
|
||||
use crate::epp::object::data::ContactAuthInfo;
|
||||
use crate::epp::object::data::{ContactAuthInfo, ContactStatus, Phone, PostalInfo};
|
||||
use crate::epp::object::{ElementName, EppObject, StringValue};
|
||||
use crate::epp::request::Command;
|
||||
use crate::epp::response::CommandResponse;
|
||||
use crate::epp::xml::EPP_CONTACT_XMLNS;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
@ -17,7 +18,7 @@ use serde::{Deserialize, Serialize};
|
|||
///
|
||||
/// use epp_client::config::{EppClientConfig, EppClientConnection};
|
||||
/// use epp_client::EppClient;
|
||||
/// use epp_client::epp::{EppContactInfo, EppContactInfoResponse};
|
||||
/// use epp_client::contact::info::{EppContactInfo, EppContactInfoResponse};
|
||||
/// use epp_client::epp::generate_client_tr_id;
|
||||
///
|
||||
/// #[tokio::main]
|
||||
|
@ -58,11 +59,34 @@ use serde::{Deserialize, Serialize};
|
|||
/// client.logout().await.unwrap();
|
||||
/// }
|
||||
/// ```
|
||||
pub type EppContactInfo = EppObject<Command<ContactInfo>>;
|
||||
pub type EppContactInfo = EppObject<Command<ContactInfoRequest>>;
|
||||
|
||||
impl EppContactInfo {
|
||||
/// Creates a new EppObject for contact info corresponding to the <epp> tag in EPP XML
|
||||
pub fn new(id: &str, auth_password: &str, client_tr_id: &str) -> EppContactInfo {
|
||||
let contact_info = ContactInfoRequest {
|
||||
info: ContactInfoRequestData {
|
||||
xmlns: EPP_CONTACT_XMLNS.to_string(),
|
||||
id: id.into(),
|
||||
auth_info: ContactAuthInfo::new(auth_password),
|
||||
},
|
||||
};
|
||||
|
||||
EppObject::build(Command::<ContactInfoRequest>::new(
|
||||
contact_info,
|
||||
client_tr_id,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
/// Type that represents the <epp> tag for the EPP XML contact info response
|
||||
pub type EppContactInfoResponse = EppObject<CommandResponse<ContactInfoResponse>>;
|
||||
|
||||
// Request
|
||||
|
||||
/// Type for elements under the contact <info> tag
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct ContactInfoData {
|
||||
pub struct ContactInfoRequestData {
|
||||
/// XML namespace for contact commands
|
||||
#[serde(rename = "xmlns:contact", alias = "contact")]
|
||||
xmlns: String,
|
||||
|
@ -77,23 +101,63 @@ pub struct ContactInfoData {
|
|||
#[derive(Serialize, Deserialize, Debug, ElementName)]
|
||||
#[element_name(name = "info")]
|
||||
/// Type for EPP XML <info> command for contacts
|
||||
pub struct ContactInfo {
|
||||
pub struct ContactInfoRequest {
|
||||
/// Data for <info> command for contact
|
||||
#[serde(rename = "contact:info", alias = "info")]
|
||||
info: ContactInfoData,
|
||||
info: ContactInfoRequestData,
|
||||
}
|
||||
|
||||
impl EppContactInfo {
|
||||
/// Creates a new EppObject for contact info corresponding to the <epp> tag in EPP XML
|
||||
pub fn new(id: &str, auth_password: &str, client_tr_id: &str) -> EppContactInfo {
|
||||
let contact_info = ContactInfo {
|
||||
info: ContactInfoData {
|
||||
xmlns: EPP_CONTACT_XMLNS.to_string(),
|
||||
id: id.into(),
|
||||
auth_info: ContactAuthInfo::new(auth_password),
|
||||
},
|
||||
};
|
||||
// Response
|
||||
|
||||
EppObject::build(Command::<ContactInfo>::new(contact_info, client_tr_id))
|
||||
}
|
||||
/// Type that represents the <infData> tag for contact check response
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct ContactInfoData {
|
||||
/// XML namespace for contact response data
|
||||
#[serde(rename = "xmlns:contact")]
|
||||
xmlns: String,
|
||||
/// The contact id
|
||||
pub id: StringValue,
|
||||
/// The contact ROID
|
||||
pub roid: StringValue,
|
||||
/// The list of contact statuses
|
||||
#[serde(rename = "status")]
|
||||
pub statuses: Vec<ContactStatus>,
|
||||
/// The postal info for the contact
|
||||
#[serde(rename = "postalInfo")]
|
||||
pub postal_info: PostalInfo,
|
||||
/// The voice data for the contact
|
||||
pub voice: Phone,
|
||||
/// The fax data for the contact
|
||||
pub fax: Option<Phone>,
|
||||
/// The email for the contact
|
||||
pub email: StringValue,
|
||||
/// The epp user to whom the contact belongs
|
||||
#[serde(rename = "clID")]
|
||||
pub client_id: StringValue,
|
||||
/// The epp user who created the contact
|
||||
#[serde(rename = "crID")]
|
||||
pub creator_id: StringValue,
|
||||
/// The creation date
|
||||
#[serde(rename = "crDate")]
|
||||
pub created_at: StringValue,
|
||||
/// The epp user who last updated the contact
|
||||
#[serde(rename = "upID")]
|
||||
pub updater_id: Option<StringValue>,
|
||||
/// The last update date
|
||||
#[serde(rename = "upDate")]
|
||||
pub updated_at: Option<StringValue>,
|
||||
/// The contact transfer date
|
||||
#[serde(rename = "trDate")]
|
||||
pub transferred_at: Option<StringValue>,
|
||||
/// The contact auth info
|
||||
#[serde(rename = "authInfo")]
|
||||
pub auth_info: Option<ContactAuthInfo>,
|
||||
}
|
||||
|
||||
/// Type that represents the <resData> tag for contact info response
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct ContactInfoResponse {
|
||||
/// Data under the <infData> tag
|
||||
#[serde(rename = "infData")]
|
||||
pub info_data: ContactInfoData,
|
||||
}
|
|
@ -5,7 +5,6 @@ pub mod request;
|
|||
pub mod response;
|
||||
pub mod xml;
|
||||
|
||||
pub use request::contact::info::*;
|
||||
pub use request::contact::update::*;
|
||||
pub use request::host::check::*;
|
||||
pub use request::host::create::*;
|
||||
|
@ -15,7 +14,6 @@ pub use request::host::update::*;
|
|||
pub use request::message::ack::*;
|
||||
pub use request::message::poll::*;
|
||||
|
||||
pub use response::contact::info::*;
|
||||
pub use response::contact::update::*;
|
||||
pub use response::host::check::*;
|
||||
pub use response::host::create::*;
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
//! Types for EPP contact requests
|
||||
|
||||
pub mod info;
|
||||
pub mod update;
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
use epp_client_macros::*;
|
||||
|
||||
use crate::contact::info::EppContactInfoResponse;
|
||||
use crate::epp::object::data::{ContactAuthInfo, ContactStatus, Phone, PostalInfo};
|
||||
use crate::epp::object::{ElementName, EppObject, StringValue};
|
||||
use crate::epp::request::Command;
|
||||
use crate::epp::response::contact::info::EppContactInfoResponse;
|
||||
use crate::epp::xml::EPP_CONTACT_XMLNS;
|
||||
use crate::error;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
//! Types for EPP contact responses
|
||||
|
||||
pub mod info;
|
||||
pub mod update;
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
//! Types for EPP contact info response
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::epp::object::data::{ContactAuthInfo, ContactStatus, Phone, PostalInfo};
|
||||
use crate::epp::object::{EppObject, StringValue};
|
||||
use crate::epp::response::CommandResponse;
|
||||
|
||||
/// Type that represents the <epp> tag for the EPP XML contact info response
|
||||
pub type EppContactInfoResponse = EppObject<CommandResponse<ContactInfoResult>>;
|
||||
|
||||
/// Type that represents the <infData> tag for contact check response
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct ContactInfoData {
|
||||
/// XML namespace for contact response data
|
||||
#[serde(rename = "xmlns:contact")]
|
||||
xmlns: String,
|
||||
/// The contact id
|
||||
pub id: StringValue,
|
||||
/// The contact ROID
|
||||
pub roid: StringValue,
|
||||
/// The list of contact statuses
|
||||
#[serde(rename = "status")]
|
||||
pub statuses: Vec<ContactStatus>,
|
||||
/// The postal info for the contact
|
||||
#[serde(rename = "postalInfo")]
|
||||
pub postal_info: PostalInfo,
|
||||
/// The voice data for the contact
|
||||
pub voice: Phone,
|
||||
/// The fax data for the contact
|
||||
pub fax: Option<Phone>,
|
||||
/// The email for the contact
|
||||
pub email: StringValue,
|
||||
/// The epp user to whom the contact belongs
|
||||
#[serde(rename = "clID")]
|
||||
pub client_id: StringValue,
|
||||
/// The epp user who created the contact
|
||||
#[serde(rename = "crID")]
|
||||
pub creator_id: StringValue,
|
||||
/// The creation date
|
||||
#[serde(rename = "crDate")]
|
||||
pub created_at: StringValue,
|
||||
/// The epp user who last updated the contact
|
||||
#[serde(rename = "upID")]
|
||||
pub updater_id: Option<StringValue>,
|
||||
/// The last update date
|
||||
#[serde(rename = "upDate")]
|
||||
pub updated_at: Option<StringValue>,
|
||||
/// The contact transfer date
|
||||
#[serde(rename = "trDate")]
|
||||
pub transferred_at: Option<StringValue>,
|
||||
/// The contact auth info
|
||||
#[serde(rename = "authInfo")]
|
||||
pub auth_info: Option<ContactAuthInfo>,
|
||||
}
|
||||
|
||||
/// Type that represents the <resData> tag for contact info response
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct ContactInfoResult {
|
||||
/// Data under the <infData> tag
|
||||
#[serde(rename = "infData")]
|
||||
pub info_data: ContactInfoData,
|
||||
}
|
|
@ -6,6 +6,7 @@ mod response {
|
|||
use crate::contact::check::EppContactCheckResponse;
|
||||
use crate::contact::create::EppContactCreateResponse;
|
||||
use crate::contact::delete::EppContactDeleteResponse;
|
||||
use crate::contact::info::EppContactInfoResponse;
|
||||
use crate::domain::check::EppDomainCheckResponse;
|
||||
use crate::domain::create::EppDomainCreateResponse;
|
||||
use crate::domain::delete::EppDomainDeleteResponse;
|
||||
|
|
|
@ -6,6 +6,7 @@ mod request {
|
|||
use crate::contact::check::EppContactCheck;
|
||||
use crate::contact::create::EppContactCreate;
|
||||
use crate::contact::delete::EppContactDelete;
|
||||
use crate::contact::info::EppContactInfo;
|
||||
use crate::domain::check::EppDomainCheck;
|
||||
use crate::domain::create::EppDomainCreate;
|
||||
use crate::domain::delete::EppDomainDelete;
|
||||
|
|
Loading…
Reference in New Issue