diff --git a/src/extensions/rgp/mod.rs b/src/extensions/rgp/mod.rs index 5c81cf4..5d0e529 100644 --- a/src/extensions/rgp/mod.rs +++ b/src/extensions/rgp/mod.rs @@ -2,6 +2,7 @@ //! //! As described in [RFC 3915](https://tools.ietf.org/html/rfc3915). +pub mod poll; // Technically a separate extension (different namespace, RFC) pub mod report; pub mod request; diff --git a/src/extensions/rgp/poll.rs b/src/extensions/rgp/poll.rs new file mode 100644 index 0000000..6b04911 --- /dev/null +++ b/src/extensions/rgp/poll.rs @@ -0,0 +1,42 @@ +//! https://www.verisign.com/assets/epp-sdk/verisign_epp-extension_rgp-poll_v00.html + +use chrono::{DateTime, Utc}; +use instant_xml::FromXml; + +/// RGP request status +#[derive(Debug, FromXml)] +#[xml(rename = "pollData", ns(XMLNS), rename_all = "camelCase")] +pub struct RgpPollData { + pub name: String, + pub rgp_status: RgpStatus, + pub req_date: DateTime, + pub report_due_date: DateTime, +} + +/// Type that represents the `` tag for domain rgp restore request response +#[derive(Debug, FromXml)] +#[xml(rename = "rgpStatus", ns(XMLNS))] +pub struct RgpStatus { + /// The domain RGP status + #[xml(rename = "s", attribute)] + pub status: String, +} + +const XMLNS: &str = "http://www.verisign.com/epp/rgp-poll-1.0"; + +#[cfg(test)] +mod tests { + use crate::poll::{Poll, PollData}; + use crate::tests::response_from_file; + + #[test] + fn rgp_poll_data() { + let object = response_from_file::("response/poll/poll_rgp_restore.xml"); + let Some(PollData::RgpPoll(data)) = object.res_data() else { + panic!("expected RgpPollData"); + }; + + assert_eq!(data.name, "EXAMPLE.COM"); + assert_eq!(data.rgp_status.status, "pendingRestore"); + } +} diff --git a/src/poll.rs b/src/poll.rs index a30fe2e..621e108 100644 --- a/src/poll.rs +++ b/src/poll.rs @@ -3,6 +3,7 @@ use instant_xml::{FromXml, ToXml}; use crate::common::{NoExtension, EPP_XMLNS}; use crate::domain::transfer::TransferData; use crate::extensions::low_balance::LowBalance; +use crate::extensions::rgp::poll::RgpPollData; use crate::host::info::InfoData; use crate::request::{Command, Transaction}; @@ -70,6 +71,8 @@ pub enum PollData { HostInfo(InfoData), /// Data under the `` tag LowBalance(LowBalance), + /// Data under the `` tag + RgpPoll(RgpPollData), } #[cfg(test)] diff --git a/tests/resources/response/poll/poll_rgp_restore.xml b/tests/resources/response/poll/poll_rgp_restore.xml new file mode 100644 index 0000000..008ce5b --- /dev/null +++ b/tests/resources/response/poll/poll_rgp_restore.xml @@ -0,0 +1,24 @@ + + + + + Command completed successfully; ack to dequeue + + + 2024-05-27T07:00:13Z + Restore Request Pending + + + + EXAMPLE.COM + + 2024-05-22T21:17:58Z + 2024-05-29T21:17:58Z + + + + c56ef937-d2b5-48fa-842f-73430072e84d + 11892404979-1716797141277 + + +