Migrate rgp extension to new API
This commit is contained in:
parent
31fc61f4b0
commit
9e1d11f9f3
|
@ -2,16 +2,13 @@
|
||||||
|
|
||||||
use epp_client_macros::*;
|
use epp_client_macros::*;
|
||||||
|
|
||||||
use crate::common::{ElementName, EppObject, Extension, StringValue};
|
use crate::common::{ElementName, NoExtension, StringValue};
|
||||||
use crate::domain::rgp::EPP_DOMAIN_RGP_EXT_XMLNS;
|
use crate::domain::rgp::EPP_DOMAIN_RGP_EXT_XMLNS;
|
||||||
use crate::domain::update::{DomainChangeInfo, DomainUpdateRequest, DomainUpdateRequestData};
|
use crate::request::EppExtension;
|
||||||
use crate::domain::EPP_DOMAIN_XMLNS;
|
|
||||||
use crate::request::CommandWithExtension;
|
|
||||||
use crate::response::EppCommandResponse;
|
|
||||||
use chrono::{DateTime, SecondsFormat, Utc};
|
use chrono::{DateTime, SecondsFormat, Utc};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// Type that represents the <epp> request for domain rgp restore report command
|
/// Type that represents the domain rgp restore report extension
|
||||||
///
|
///
|
||||||
/// ## Usage
|
/// ## Usage
|
||||||
///
|
///
|
||||||
|
@ -20,8 +17,11 @@ 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::domain::rgp::report::{EppDomainRgpRestoreReport, EppDomainRgpRestoreReportResponse};
|
/// use epp_client::common::{DomainStatus, DomainContact};
|
||||||
|
/// use epp_client::domain::rgp::report::RgpRestoreReport;
|
||||||
|
/// use epp_client::domain::update::DomainUpdate;
|
||||||
/// use epp_client::generate_client_tr_id;
|
/// use epp_client::generate_client_tr_id;
|
||||||
|
/// use epp_client::common::NoExtension;
|
||||||
/// use chrono::{DateTime, NaiveDate};
|
/// use chrono::{DateTime, NaiveDate};
|
||||||
/// use std::str::FromStr;
|
/// use std::str::FromStr;
|
||||||
///
|
///
|
||||||
|
@ -61,35 +61,30 @@ use serde::{Deserialize, Serialize};
|
||||||
/// ];
|
/// ];
|
||||||
/// let other = "Supporting information goes here.";
|
/// let other = "Supporting information goes here.";
|
||||||
///
|
///
|
||||||
/// // Create an EppDomainRgpRestoreReport instance
|
/// let domain_restore_report = RgpRestoreReport::new(
|
||||||
/// let domain_restore_report = EppDomainRgpRestoreReport::new(
|
|
||||||
/// "eppdev.com",
|
|
||||||
/// pre_data,
|
/// pre_data,
|
||||||
/// post_data,
|
/// post_data,
|
||||||
/// deleted_at,
|
/// deleted_at,
|
||||||
/// restored_at,
|
/// restored_at,
|
||||||
/// restore_reason,
|
/// restore_reason,
|
||||||
/// &statements,
|
/// &statements,
|
||||||
/// other,
|
/// other
|
||||||
/// generate_client_tr_id(&client).as_str()
|
|
||||||
/// );
|
/// );
|
||||||
///
|
///
|
||||||
/// // send it to the registry and receive a response of type EppDomainRgpRestoreReportResponse
|
/// // Create an DomainUpdate instance
|
||||||
/// let response = client.transact::<_, EppDomainRgpRestoreReportResponse>(&domain_restore_report).await.unwrap();
|
/// let mut domain_update = DomainUpdate::<RgpRestoreReport>::new("eppdev-100.com").with_extension(domain_restore_report);
|
||||||
|
///
|
||||||
|
/// // send it to the registry and receive a response of type EppDomainUpdateResponse
|
||||||
|
/// let response = client.transact_new(domain_update, generate_client_tr_id(&client).as_str()).await.unwrap();
|
||||||
///
|
///
|
||||||
/// println!("{:?}", response);
|
/// println!("{:?}", response);
|
||||||
///
|
///
|
||||||
/// client.logout().await.unwrap();
|
/// client.logout().await.unwrap();
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub type EppDomainRgpRestoreReport =
|
impl RgpRestoreReport {
|
||||||
EppObject<CommandWithExtension<DomainUpdateRequest, RgpRestoreReportRequest>>;
|
/// Create a new RGP restore report request
|
||||||
|
|
||||||
impl EppDomainRgpRestoreReport {
|
|
||||||
/// Creates a new EppObject for domain rgp restore report corresponding to the <epp> tag in EPP XML
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
|
||||||
pub fn new(
|
pub fn new(
|
||||||
name: &str,
|
|
||||||
pre_data: &str,
|
pre_data: &str,
|
||||||
post_data: &str,
|
post_data: &str,
|
||||||
deleted_at: DateTime<Utc>,
|
deleted_at: DateTime<Utc>,
|
||||||
|
@ -97,29 +92,14 @@ impl EppDomainRgpRestoreReport {
|
||||||
restore_reason: &str,
|
restore_reason: &str,
|
||||||
statements: &[&str],
|
statements: &[&str],
|
||||||
other: &str,
|
other: &str,
|
||||||
client_tr_id: &str,
|
) -> RgpRestoreReport {
|
||||||
) -> EppDomainRgpRestoreReport {
|
|
||||||
let statements = statements.iter().map(|&s| s.into()).collect();
|
let statements = statements.iter().map(|&s| s.into()).collect();
|
||||||
|
|
||||||
let command = CommandWithExtension::<DomainUpdateRequest, RgpRestoreReportRequest> {
|
RgpRestoreReport {
|
||||||
command: DomainUpdateRequest {
|
|
||||||
domain: DomainUpdateRequestData {
|
|
||||||
xmlns: EPP_DOMAIN_XMLNS.to_string(),
|
|
||||||
name: name.into(),
|
|
||||||
add: None,
|
|
||||||
remove: None,
|
|
||||||
change_info: Some(DomainChangeInfo {
|
|
||||||
registrant: None,
|
|
||||||
auth_info: None,
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
extension: Some(Extension {
|
|
||||||
data: RgpRestoreReportRequest {
|
|
||||||
xmlns: EPP_DOMAIN_RGP_EXT_XMLNS.to_string(),
|
xmlns: EPP_DOMAIN_RGP_EXT_XMLNS.to_string(),
|
||||||
restore: RgpRestoreReportRequestSection {
|
restore: RgpRestoreReportSection {
|
||||||
op: "report".to_string(),
|
op: "report".to_string(),
|
||||||
report: RgpRestoreReportRequestData {
|
report: RgpRestoreReportSectionData {
|
||||||
pre_data: pre_data.into(),
|
pre_data: pre_data.into(),
|
||||||
post_data: post_data.into(),
|
post_data: post_data.into(),
|
||||||
deleted_at: deleted_at
|
deleted_at: deleted_at
|
||||||
|
@ -133,21 +113,17 @@ impl EppDomainRgpRestoreReport {
|
||||||
other: other.into(),
|
other: other.into(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
}),
|
|
||||||
client_tr_id: client_tr_id.into(),
|
|
||||||
};
|
|
||||||
|
|
||||||
EppObject::build(command)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Type that represents the <epp> tag for the EPP XML rgp restore report response
|
impl EppExtension for RgpRestoreReport {
|
||||||
pub type EppDomainRgpRestoreReportResponse = EppCommandResponse;
|
type Response = NoExtension;
|
||||||
|
}
|
||||||
|
|
||||||
/// Type corresponding to the <report> section in the EPP rgp restore extension
|
/// Type corresponding to the <report> section in the EPP rgp restore extension
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
pub struct RgpRestoreReportRequestData {
|
pub struct RgpRestoreReportSectionData {
|
||||||
/// The pre-delete registration date
|
/// The pre-delete registration date
|
||||||
#[serde(rename = "rgp:preData", alias = "preData")]
|
#[serde(rename = "rgp:preData", alias = "preData")]
|
||||||
pre_data: StringValue,
|
pre_data: StringValue,
|
||||||
|
@ -173,22 +149,22 @@ pub struct RgpRestoreReportRequestData {
|
||||||
|
|
||||||
/// Type corresponding to the <restore> section in the rgp restore extension
|
/// Type corresponding to the <restore> section in the rgp restore extension
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
pub struct RgpRestoreReportRequestSection {
|
pub struct RgpRestoreReportSection {
|
||||||
/// The value of the op attribute for the <restore> tag
|
/// The value of the op attribute for the <restore> tag
|
||||||
op: String,
|
op: String,
|
||||||
/// Data for the <report> tag
|
/// Data for the <report> tag
|
||||||
#[serde(rename = "rgp:report", alias = "report")]
|
#[serde(rename = "rgp:report", alias = "report")]
|
||||||
report: RgpRestoreReportRequestData,
|
report: RgpRestoreReportSectionData,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, ElementName)]
|
#[derive(Serialize, Deserialize, Debug, ElementName)]
|
||||||
#[element_name(name = "rgp:update")]
|
#[element_name(name = "rgp:update")]
|
||||||
/// Type for EPP XML <check> command for domains
|
/// Type for EPP XML <check> command for domains
|
||||||
pub struct RgpRestoreReportRequest {
|
pub struct RgpRestoreReport {
|
||||||
/// XML namespace for the RGP restore extension
|
/// XML namespace for the RGP restore extension
|
||||||
#[serde(rename = "xmlns:rgp", alias = "xmlns")]
|
#[serde(rename = "xmlns:rgp", alias = "xmlns")]
|
||||||
xmlns: String,
|
xmlns: String,
|
||||||
/// The object holding the list of domains to be checked
|
/// The object holding the list of domains to be checked
|
||||||
#[serde(rename = "rgp:restore", alias = "restore")]
|
#[serde(rename = "rgp:restore", alias = "restore")]
|
||||||
restore: RgpRestoreReportRequestSection,
|
restore: RgpRestoreReportSection,
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,11 @@
|
||||||
|
|
||||||
use epp_client_macros::*;
|
use epp_client_macros::*;
|
||||||
|
|
||||||
use crate::common::{ElementName, EppObject, Extension, NoExtension};
|
use crate::common::ElementName;
|
||||||
use crate::domain::rgp::EPP_DOMAIN_RGP_EXT_XMLNS;
|
use crate::domain::rgp::EPP_DOMAIN_RGP_EXT_XMLNS;
|
||||||
use crate::domain::update::{DomainChangeInfo, DomainUpdateRequest, DomainUpdateRequestData};
|
|
||||||
use crate::domain::EPP_DOMAIN_XMLNS;
|
use crate::request::EppExtension;
|
||||||
use crate::request::CommandWithExtension;
|
|
||||||
use crate::response::CommandResponseWithExtension;
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// Type that represents the <epp> request for a domain rgp restore request command
|
/// Type that represents the <epp> request for a domain rgp restore request command
|
||||||
|
@ -19,7 +18,8 @@ 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::domain::rgp::request::{EppDomainRgpRestoreRequest, EppDomainRgpRestoreRequestResponse};
|
/// use epp_client::domain::rgp::request::RgpRestoreRequest;
|
||||||
|
/// use epp_client::domain::update::DomainUpdate;
|
||||||
/// use epp_client::generate_client_tr_id;
|
/// use epp_client::generate_client_tr_id;
|
||||||
///
|
///
|
||||||
/// #[tokio::main]
|
/// #[tokio::main]
|
||||||
|
@ -45,57 +45,41 @@ use serde::{Deserialize, Serialize};
|
||||||
/// Err(e) => panic!("Failed to create EppClient: {}", e)
|
/// Err(e) => panic!("Failed to create EppClient: {}", e)
|
||||||
/// };
|
/// };
|
||||||
///
|
///
|
||||||
/// // Create an EppDomainRgpRestoreRequest instance
|
/// // Create an RgpRestoreRequest instance
|
||||||
/// let domain_restore_req = EppDomainRgpRestoreRequest::new(
|
/// let domain_restore_req = RgpRestoreRequest::new();
|
||||||
/// "eppdev.com",
|
|
||||||
/// generate_client_tr_id(&client).as_str()
|
|
||||||
/// );
|
|
||||||
///
|
///
|
||||||
/// // send it to the registry and receive a response of type EppDomainRgpRestoreRequestResponse
|
/// // Create an DomainUpdate instance
|
||||||
/// let response = client.transact::<_, EppDomainRgpRestoreRequestResponse>(&domain_restore_req).await.unwrap();
|
/// let mut domain_update = DomainUpdate::<RgpRestoreRequest>::new("eppdev-100.com").with_extension(domain_restore_req);
|
||||||
|
///
|
||||||
|
/// // send it to the registry and receive a response of type EppDomainUpdateResponse
|
||||||
|
/// let response = client.transact_new(domain_update, generate_client_tr_id(&client).as_str()).await.unwrap();
|
||||||
///
|
///
|
||||||
/// println!("{:?}", response);
|
/// println!("{:?}", response);
|
||||||
///
|
///
|
||||||
/// client.logout().await.unwrap();
|
/// client.logout().await.unwrap();
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub type EppDomainRgpRestoreRequest =
|
impl RgpRestoreRequest {
|
||||||
EppObject<CommandWithExtension<DomainUpdateRequest, RgpRestoreRequest>>;
|
/// Creates a new instance of EppDomainRgpRestoreRequest
|
||||||
|
pub fn new() -> RgpRestoreRequest {
|
||||||
impl EppDomainRgpRestoreRequest {
|
RgpRestoreRequest {
|
||||||
/// Creates a new EppObject for domain rgp restore request corresponding to the <epp> tag in EPP XML
|
|
||||||
pub fn new(name: &str, client_tr_id: &str) -> EppDomainRgpRestoreRequest {
|
|
||||||
let command = CommandWithExtension::<DomainUpdateRequest, RgpRestoreRequest> {
|
|
||||||
command: DomainUpdateRequest {
|
|
||||||
domain: DomainUpdateRequestData {
|
|
||||||
xmlns: EPP_DOMAIN_XMLNS.to_string(),
|
|
||||||
name: name.into(),
|
|
||||||
add: None,
|
|
||||||
remove: None,
|
|
||||||
change_info: Some(DomainChangeInfo {
|
|
||||||
registrant: None,
|
|
||||||
auth_info: None,
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
extension: Some(Extension {
|
|
||||||
data: RgpRestoreRequest {
|
|
||||||
xmlns: EPP_DOMAIN_RGP_EXT_XMLNS.to_string(),
|
xmlns: EPP_DOMAIN_RGP_EXT_XMLNS.to_string(),
|
||||||
restore: RgpRestoreRequestData {
|
restore: RgpRestoreRequestData {
|
||||||
op: "request".to_string(),
|
op: "request".to_string(),
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
}),
|
|
||||||
client_tr_id: client_tr_id.into(),
|
|
||||||
};
|
|
||||||
|
|
||||||
EppObject::build(command)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Type that represents the <epp> tag for the EPP XML rgp restore request response
|
impl Default for RgpRestoreRequest {
|
||||||
pub type EppDomainRgpRestoreRequestResponse =
|
fn default() -> Self {
|
||||||
EppObject<CommandResponseWithExtension<NoExtension, RgpRequestResponse>>;
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl EppExtension for RgpRestoreRequest {
|
||||||
|
type Response = RgpRequestResponse;
|
||||||
|
}
|
||||||
|
|
||||||
// Request
|
// Request
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ mod response {
|
||||||
use crate::domain::delete::DomainDelete;
|
use crate::domain::delete::DomainDelete;
|
||||||
use crate::domain::info::DomainInfo;
|
use crate::domain::info::DomainInfo;
|
||||||
use crate::domain::renew::DomainRenew;
|
use crate::domain::renew::DomainRenew;
|
||||||
use crate::domain::rgp::request::EppDomainRgpRestoreRequestResponse;
|
use crate::domain::rgp::request::RgpRestoreRequest;
|
||||||
use crate::domain::transfer::DomainTransferApprove;
|
use crate::domain::transfer::DomainTransferApprove;
|
||||||
use crate::domain::transfer::DomainTransferCancel;
|
use crate::domain::transfer::DomainTransferCancel;
|
||||||
use crate::domain::transfer::DomainTransferQuery;
|
use crate::domain::transfer::DomainTransferQuery;
|
||||||
|
@ -639,13 +639,13 @@ mod response {
|
||||||
#[test]
|
#[test]
|
||||||
fn rgp_restore_response() {
|
fn rgp_restore_response() {
|
||||||
let xml = get_xml("response/domain/rgp_restore.xml").unwrap();
|
let xml = get_xml("response/domain/rgp_restore.xml").unwrap();
|
||||||
let object = EppDomainRgpRestoreRequestResponse::deserialize(xml.as_str()).unwrap();
|
let object = DomainUpdate::<RgpRestoreRequest>::deserialize_response(xml.as_str()).unwrap();
|
||||||
|
|
||||||
let ext = object.data.extension.unwrap();
|
let ext = object.extension.unwrap();
|
||||||
|
|
||||||
assert_eq!(object.data.result.code, 1000);
|
assert_eq!(object.result.code, 1000);
|
||||||
assert_eq!(object.data.result.message, SUCCESS_MSG.into());
|
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||||
assert_eq!(ext.data.rgp_status.status, "pendingRestore".to_string());
|
assert_eq!(ext.data.rgp_status.status, "pendingRestore".to_string());
|
||||||
assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.into());
|
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,8 +21,8 @@ mod request {
|
||||||
use crate::domain::delete::DomainDelete;
|
use crate::domain::delete::DomainDelete;
|
||||||
use crate::domain::info::DomainInfo;
|
use crate::domain::info::DomainInfo;
|
||||||
use crate::domain::renew::DomainRenew;
|
use crate::domain::renew::DomainRenew;
|
||||||
use crate::domain::rgp::report::EppDomainRgpRestoreReport;
|
use crate::domain::rgp::report::RgpRestoreReport;
|
||||||
use crate::domain::rgp::request::EppDomainRgpRestoreRequest;
|
use crate::domain::rgp::request::RgpRestoreRequest;
|
||||||
use crate::domain::transfer::DomainTransferApprove;
|
use crate::domain::transfer::DomainTransferApprove;
|
||||||
use crate::domain::transfer::DomainTransferCancel;
|
use crate::domain::transfer::DomainTransferCancel;
|
||||||
use crate::domain::transfer::DomainTransferQuery;
|
use crate::domain::transfer::DomainTransferQuery;
|
||||||
|
@ -524,9 +524,19 @@ mod request {
|
||||||
fn rgp_restore_request() {
|
fn rgp_restore_request() {
|
||||||
let xml = get_xml("request/domain/rgp_restore_request.xml").unwrap();
|
let xml = get_xml("request/domain/rgp_restore_request.xml").unwrap();
|
||||||
|
|
||||||
let object = EppDomainRgpRestoreRequest::new("eppdev.com", CLTRID);
|
let domain_restore_request = RgpRestoreRequest::new();
|
||||||
|
|
||||||
let serialized = object.serialize().unwrap();
|
let mut object = DomainUpdate::<RgpRestoreReport>::new("eppdev.com")
|
||||||
|
.with_extension(domain_restore_request);
|
||||||
|
|
||||||
|
let change_info = DomainChangeInfo {
|
||||||
|
registrant: None,
|
||||||
|
auth_info: None,
|
||||||
|
};
|
||||||
|
|
||||||
|
object.info(change_info);
|
||||||
|
|
||||||
|
let serialized = object.serialize_request(CLTRID).unwrap();
|
||||||
|
|
||||||
assert_eq!(xml, serialized);
|
assert_eq!(xml, serialized);
|
||||||
}
|
}
|
||||||
|
@ -548,8 +558,7 @@ mod request {
|
||||||
];
|
];
|
||||||
let other = "Supporting information goes here.";
|
let other = "Supporting information goes here.";
|
||||||
|
|
||||||
let object = EppDomainRgpRestoreReport::new(
|
let domain_restore_report = RgpRestoreReport::new(
|
||||||
"eppdev.com",
|
|
||||||
pre_data,
|
pre_data,
|
||||||
post_data,
|
post_data,
|
||||||
deleted_at,
|
deleted_at,
|
||||||
|
@ -557,10 +566,19 @@ mod request {
|
||||||
restore_reason,
|
restore_reason,
|
||||||
statements,
|
statements,
|
||||||
other,
|
other,
|
||||||
CLTRID,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
let serialized = object.serialize().unwrap();
|
let mut object = DomainUpdate::<RgpRestoreReport>::new("eppdev.com")
|
||||||
|
.with_extension(domain_restore_report);
|
||||||
|
|
||||||
|
let change_info = DomainChangeInfo {
|
||||||
|
registrant: None,
|
||||||
|
auth_info: None,
|
||||||
|
};
|
||||||
|
|
||||||
|
object.info(change_info);
|
||||||
|
|
||||||
|
let serialized = object.serialize_request(CLTRID).unwrap();
|
||||||
|
|
||||||
assert_eq!(xml, serialized);
|
assert_eq!(xml, serialized);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue