Refactor contact update models
This commit is contained in:
parent
d7199c5ddb
commit
18097c14f0
|
@ -2,3 +2,4 @@ pub mod check;
|
||||||
pub mod create;
|
pub mod create;
|
||||||
pub mod delete;
|
pub mod delete;
|
||||||
pub mod info;
|
pub mod info;
|
||||||
|
pub mod update;
|
||||||
|
|
|
@ -6,6 +6,7 @@ use crate::contact::info::EppContactInfoResponse;
|
||||||
use crate::epp::object::data::{ContactAuthInfo, ContactStatus, Phone, PostalInfo};
|
use crate::epp::object::data::{ContactAuthInfo, ContactStatus, Phone, PostalInfo};
|
||||||
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_CONTACT_XMLNS;
|
use crate::epp::xml::EPP_CONTACT_XMLNS;
|
||||||
use crate::error;
|
use crate::error;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
@ -19,7 +20,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::{EppContactUpdate, EppContactUpdateResponse};
|
/// use epp_client::contact::update::{EppContactUpdate, EppContactUpdateResponse};
|
||||||
/// use epp_client::epp::generate_client_tr_id;
|
/// use epp_client::epp::generate_client_tr_id;
|
||||||
/// use epp_client::epp::object::data::ContactStatus;
|
/// use epp_client::epp::object::data::ContactStatus;
|
||||||
///
|
///
|
||||||
|
@ -68,59 +69,13 @@ use serde::{Deserialize, Serialize};
|
||||||
/// client.logout().await.unwrap();
|
/// client.logout().await.unwrap();
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub type EppContactUpdate = EppObject<Command<ContactUpdate>>;
|
pub type EppContactUpdate = EppObject<Command<ContactUpdateRequest>>;
|
||||||
|
|
||||||
/// Type for elements under the <chg> tag for contact update request
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
|
||||||
pub struct ContactChangeInfo {
|
|
||||||
#[serde(rename = "contact:postalInfo", alias = "postalInfo")]
|
|
||||||
postal_info: Option<PostalInfo>,
|
|
||||||
#[serde(rename = "contact:voice", alias = "voice")]
|
|
||||||
voice: Option<Phone>,
|
|
||||||
#[serde(rename = "contact:fax", alias = "fax")]
|
|
||||||
fax: Option<Phone>,
|
|
||||||
#[serde(rename = "contact:email", alias = "email")]
|
|
||||||
email: Option<StringValue>,
|
|
||||||
#[serde(rename = "contact:authInfo", alias = "authInfo")]
|
|
||||||
auth_info: Option<ContactAuthInfo>,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Type for list of elements of the <status> tag for contact update request
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
|
||||||
pub struct StatusList {
|
|
||||||
#[serde(rename = "contact:status", alias = "status")]
|
|
||||||
status: Vec<ContactStatus>,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Type for elements under the contact <update> tag
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
|
||||||
pub struct ContactUpdateData {
|
|
||||||
#[serde(rename = "xmlns:contact", alias = "xmlns")]
|
|
||||||
xmlns: String,
|
|
||||||
#[serde(rename = "contact:id", alias = "id")]
|
|
||||||
id: StringValue,
|
|
||||||
#[serde(rename = "contact:add", alias = "add")]
|
|
||||||
add_statuses: Option<StatusList>,
|
|
||||||
#[serde(rename = "contact:rem", alias = "rem")]
|
|
||||||
remove_statuses: Option<StatusList>,
|
|
||||||
#[serde(rename = "contact:chg", alias = "chg")]
|
|
||||||
change_info: Option<ContactChangeInfo>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, ElementName)]
|
|
||||||
#[element_name(name = "update")]
|
|
||||||
/// Type for EPP XML <update> command for contacts
|
|
||||||
pub struct ContactUpdate {
|
|
||||||
/// The data under the <update> tag for the contact update
|
|
||||||
#[serde(rename = "contact:update", alias = "update")]
|
|
||||||
contact: ContactUpdateData,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl EppContactUpdate {
|
impl EppContactUpdate {
|
||||||
/// Creates a new EppObject for contact update corresponding to the <epp> tag in EPP XML
|
/// Creates a new EppObject for contact update corresponding to the <epp> tag in EPP XML
|
||||||
pub fn new(id: &str, client_tr_id: &str) -> EppContactUpdate {
|
pub fn new(id: &str, client_tr_id: &str) -> EppContactUpdate {
|
||||||
let contact_update = ContactUpdate {
|
let contact_update = ContactUpdateRequest {
|
||||||
contact: ContactUpdateData {
|
contact: ContactUpdateRequestData {
|
||||||
xmlns: EPP_CONTACT_XMLNS.to_string(),
|
xmlns: EPP_CONTACT_XMLNS.to_string(),
|
||||||
id: id.into(),
|
id: id.into(),
|
||||||
add_statuses: None,
|
add_statuses: None,
|
||||||
|
@ -128,7 +83,10 @@ impl EppContactUpdate {
|
||||||
change_info: None,
|
change_info: None,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
EppObject::build(Command::<ContactUpdate>::new(contact_update, client_tr_id))
|
EppObject::build(Command::<ContactUpdateRequest>::new(
|
||||||
|
contact_update,
|
||||||
|
client_tr_id,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the data for the <chg> tag for the contact update request
|
/// Sets the data for the <chg> tag for the contact update request
|
||||||
|
@ -187,3 +145,52 @@ impl EppContactUpdate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Type that represents the <epp> tag for the EPP XML contact update response
|
||||||
|
pub type EppContactUpdateResponse = EppCommandResponse;
|
||||||
|
|
||||||
|
/// Type for elements under the <chg> tag for contact update request
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
pub struct ContactChangeInfo {
|
||||||
|
#[serde(rename = "contact:postalInfo", alias = "postalInfo")]
|
||||||
|
postal_info: Option<PostalInfo>,
|
||||||
|
#[serde(rename = "contact:voice", alias = "voice")]
|
||||||
|
voice: Option<Phone>,
|
||||||
|
#[serde(rename = "contact:fax", alias = "fax")]
|
||||||
|
fax: Option<Phone>,
|
||||||
|
#[serde(rename = "contact:email", alias = "email")]
|
||||||
|
email: Option<StringValue>,
|
||||||
|
#[serde(rename = "contact:authInfo", alias = "authInfo")]
|
||||||
|
auth_info: Option<ContactAuthInfo>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Type for list of elements of the <status> tag for contact update request
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
pub struct StatusList {
|
||||||
|
#[serde(rename = "contact:status", alias = "status")]
|
||||||
|
status: Vec<ContactStatus>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Type for elements under the contact <update> tag
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
pub struct ContactUpdateRequestData {
|
||||||
|
#[serde(rename = "xmlns:contact", alias = "xmlns")]
|
||||||
|
xmlns: String,
|
||||||
|
#[serde(rename = "contact:id", alias = "id")]
|
||||||
|
id: StringValue,
|
||||||
|
#[serde(rename = "contact:add", alias = "add")]
|
||||||
|
add_statuses: Option<StatusList>,
|
||||||
|
#[serde(rename = "contact:rem", alias = "rem")]
|
||||||
|
remove_statuses: Option<StatusList>,
|
||||||
|
#[serde(rename = "contact:chg", alias = "chg")]
|
||||||
|
change_info: Option<ContactChangeInfo>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, ElementName)]
|
||||||
|
#[element_name(name = "update")]
|
||||||
|
/// Type for EPP XML <update> command for contacts
|
||||||
|
pub struct ContactUpdateRequest {
|
||||||
|
/// The data under the <update> tag for the contact update
|
||||||
|
#[serde(rename = "contact:update", alias = "update")]
|
||||||
|
contact: ContactUpdateRequestData,
|
||||||
|
}
|
|
@ -5,7 +5,6 @@ pub mod request;
|
||||||
pub mod response;
|
pub mod response;
|
||||||
pub mod xml;
|
pub mod xml;
|
||||||
|
|
||||||
pub use request::contact::update::*;
|
|
||||||
pub use request::host::check::*;
|
pub use request::host::check::*;
|
||||||
pub use request::host::create::*;
|
pub use request::host::create::*;
|
||||||
pub use request::host::delete::*;
|
pub use request::host::delete::*;
|
||||||
|
@ -14,7 +13,6 @@ pub use request::host::update::*;
|
||||||
pub use request::message::ack::*;
|
pub use request::message::ack::*;
|
||||||
pub use request::message::poll::*;
|
pub use request::message::poll::*;
|
||||||
|
|
||||||
pub use response::contact::update::*;
|
|
||||||
pub use response::host::check::*;
|
pub use response::host::check::*;
|
||||||
pub use response::host::create::*;
|
pub use response::host::create::*;
|
||||||
pub use response::host::delete::*;
|
pub use response::host::delete::*;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
//! Types for EPP requests
|
//! Types for EPP requests
|
||||||
|
|
||||||
pub mod contact;
|
|
||||||
pub mod host;
|
pub mod host;
|
||||||
pub mod message;
|
pub mod message;
|
||||||
|
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
//! Types for EPP contact requests
|
|
||||||
|
|
||||||
pub mod update;
|
|
|
@ -1,6 +1,5 @@
|
||||||
//! Types for EPP responses
|
//! Types for EPP responses
|
||||||
|
|
||||||
pub mod contact;
|
|
||||||
pub mod host;
|
pub mod host;
|
||||||
pub mod message;
|
pub mod message;
|
||||||
|
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
//! Types for EPP contact responses
|
|
||||||
|
|
||||||
pub mod update;
|
|
|
@ -1,6 +0,0 @@
|
||||||
//! Types for EPP contact update response
|
|
||||||
|
|
||||||
use crate::epp::response::EppCommandResponse;
|
|
||||||
|
|
||||||
/// Type that represents the <epp> tag for the EPP XML contact update response
|
|
||||||
pub type EppContactUpdateResponse = EppCommandResponse;
|
|
|
@ -7,6 +7,7 @@ mod response {
|
||||||
use crate::contact::create::EppContactCreateResponse;
|
use crate::contact::create::EppContactCreateResponse;
|
||||||
use crate::contact::delete::EppContactDeleteResponse;
|
use crate::contact::delete::EppContactDeleteResponse;
|
||||||
use crate::contact::info::EppContactInfoResponse;
|
use crate::contact::info::EppContactInfoResponse;
|
||||||
|
use crate::contact::update::EppContactUpdateResponse;
|
||||||
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::domain::delete::EppDomainDeleteResponse;
|
||||||
|
|
|
@ -7,6 +7,7 @@ mod request {
|
||||||
use crate::contact::create::EppContactCreate;
|
use crate::contact::create::EppContactCreate;
|
||||||
use crate::contact::delete::EppContactDelete;
|
use crate::contact::delete::EppContactDelete;
|
||||||
use crate::contact::info::EppContactInfo;
|
use crate::contact::info::EppContactInfo;
|
||||||
|
use crate::contact::update::EppContactUpdate;
|
||||||
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::domain::delete::EppDomainDelete;
|
||||||
|
|
Loading…
Reference in New Issue