Remove Message prefixes from poll types
This commit is contained in:
parent
0c6283fbf4
commit
0901fab3d7
|
@ -34,17 +34,17 @@ const XMLNS: &str = "http://www.verisign.com/epp/lowbalance-poll-1.0";
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::poll::{MessagePoll, MessagePollResponse};
|
use crate::poll::{Poll, PollData};
|
||||||
use crate::response::ResultCode;
|
use crate::response::ResultCode;
|
||||||
use crate::tests::{response_from_file, CLTRID, SVTRID};
|
use crate::tests::{response_from_file, CLTRID, SVTRID};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn low_balance() {
|
fn low_balance() {
|
||||||
let object = response_from_file::<MessagePoll>("response/poll/poll_low_balance.xml");
|
let object = response_from_file::<Poll>("response/poll/poll_low_balance.xml");
|
||||||
dbg!(&object);
|
dbg!(&object);
|
||||||
|
|
||||||
let low_balance = match object.res_data() {
|
let low_balance = match object.res_data() {
|
||||||
Some(MessagePollResponse::LowBalance(low_balance)) => low_balance,
|
Some(PollData::LowBalance(low_balance)) => low_balance,
|
||||||
_ => panic!("Unexpected message data"),
|
_ => panic!("Unexpected message data"),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ pub mod extensions {
|
||||||
}
|
}
|
||||||
|
|
||||||
mod poll;
|
mod poll;
|
||||||
pub use poll::{MessageAck, MessagePoll};
|
pub use poll::{Ack, Poll};
|
||||||
|
|
||||||
pub use client::EppClient;
|
pub use client::EppClient;
|
||||||
pub use error::Error;
|
pub use error::Error;
|
||||||
|
|
40
src/poll.rs
40
src/poll.rs
|
@ -6,16 +6,16 @@ use crate::extensions::low_balance::LowBalance;
|
||||||
use crate::host::info::InfoData;
|
use crate::host::info::InfoData;
|
||||||
use crate::request::{Command, Transaction};
|
use crate::request::{Command, Transaction};
|
||||||
|
|
||||||
impl Transaction<NoExtension> for MessagePoll {}
|
impl Transaction<NoExtension> for Poll {}
|
||||||
|
|
||||||
impl Command for MessagePoll {
|
impl Command for Poll {
|
||||||
type Response = MessagePollResponse;
|
type Response = PollData;
|
||||||
const COMMAND: &'static str = "poll";
|
const COMMAND: &'static str = "poll";
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Transaction<NoExtension> for MessageAck<'_> {}
|
impl Transaction<NoExtension> for Ack<'_> {}
|
||||||
|
|
||||||
impl Command for MessageAck<'_> {
|
impl Command for Ack<'_> {
|
||||||
type Response = String;
|
type Response = String;
|
||||||
const COMMAND: &'static str = "poll";
|
const COMMAND: &'static str = "poll";
|
||||||
}
|
}
|
||||||
|
@ -24,9 +24,9 @@ impl Command for MessageAck<'_> {
|
||||||
|
|
||||||
/// Type for EPP XML `<poll>` command with `op="req"`
|
/// Type for EPP XML `<poll>` command with `op="req"`
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct MessagePoll;
|
pub struct Poll;
|
||||||
|
|
||||||
impl ToXml for MessagePoll {
|
impl ToXml for Poll {
|
||||||
fn serialize<W: std::fmt::Write + ?Sized>(
|
fn serialize<W: std::fmt::Write + ?Sized>(
|
||||||
&self,
|
&self,
|
||||||
_: Option<instant_xml::Id<'_>>,
|
_: Option<instant_xml::Id<'_>>,
|
||||||
|
@ -40,12 +40,12 @@ impl ToXml for MessagePoll {
|
||||||
|
|
||||||
/// Type for EPP XML `<poll>` command with `op="ack"`
|
/// Type for EPP XML `<poll>` command with `op="ack"`
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct MessageAck<'a> {
|
pub struct Ack<'a> {
|
||||||
/// The ID of the message to be acknowledged
|
/// The ID of the message to be acknowledged
|
||||||
pub message_id: &'a str,
|
pub message_id: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToXml for MessageAck<'_> {
|
impl ToXml for Ack<'_> {
|
||||||
fn serialize<W: std::fmt::Write + ?Sized>(
|
fn serialize<W: std::fmt::Write + ?Sized>(
|
||||||
&self,
|
&self,
|
||||||
_: Option<instant_xml::Id<'_>>,
|
_: Option<instant_xml::Id<'_>>,
|
||||||
|
@ -63,7 +63,7 @@ impl ToXml for MessageAck<'_> {
|
||||||
/// Type that represents the `<trnData>` tag for message poll response
|
/// Type that represents the `<trnData>` tag for message poll response
|
||||||
#[derive(Debug, FromXml)]
|
#[derive(Debug, FromXml)]
|
||||||
#[xml(forward)]
|
#[xml(forward)]
|
||||||
pub enum MessagePollResponse {
|
pub enum PollData {
|
||||||
/// Data under the `<domain:trnData>` tag
|
/// Data under the `<domain:trnData>` tag
|
||||||
DomainTransfer(TransferData),
|
DomainTransfer(TransferData),
|
||||||
/// Data under the `<host:infData>` tag
|
/// Data under the `<host:infData>` tag
|
||||||
|
@ -74,7 +74,7 @@ pub enum MessagePollResponse {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::{MessageAck, MessagePoll, MessagePollResponse};
|
use super::{Ack, Poll, PollData};
|
||||||
use crate::host::Status;
|
use crate::host::Status;
|
||||||
use crate::response::ResultCode;
|
use crate::response::ResultCode;
|
||||||
use crate::tests::{assert_serialized, response_from_file, CLTRID, SUCCESS_MSG, SVTRID};
|
use crate::tests::{assert_serialized, response_from_file, CLTRID, SUCCESS_MSG, SVTRID};
|
||||||
|
@ -84,7 +84,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn ack_command() {
|
fn ack_command() {
|
||||||
let object = MessageAck {
|
let object = Ack {
|
||||||
message_id: "12345",
|
message_id: "12345",
|
||||||
};
|
};
|
||||||
assert_serialized("request/poll/ack.xml", &object);
|
assert_serialized("request/poll/ack.xml", &object);
|
||||||
|
@ -92,7 +92,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn response() {
|
fn response() {
|
||||||
let object = response_from_file::<MessageAck>("response/poll/ack.xml");
|
let object = response_from_file::<Ack>("response/poll/ack.xml");
|
||||||
let msg = object.message_queue().unwrap();
|
let msg = object.message_queue().unwrap();
|
||||||
|
|
||||||
assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully);
|
assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully);
|
||||||
|
@ -104,13 +104,13 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn poll_command() {
|
fn poll_command() {
|
||||||
let object = MessagePoll;
|
let object = Poll;
|
||||||
assert_serialized("request/poll/poll.xml", &object);
|
assert_serialized("request/poll/poll.xml", &object);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn domain_transfer_response() {
|
fn domain_transfer_response() {
|
||||||
let object = response_from_file::<MessagePoll>("response/poll/poll_domain_transfer.xml");
|
let object = response_from_file::<Poll>("response/poll/poll_domain_transfer.xml");
|
||||||
let result = object.res_data().unwrap();
|
let result = object.res_data().unwrap();
|
||||||
let msg = object.message_queue().unwrap();
|
let msg = object.message_queue().unwrap();
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ mod tests {
|
||||||
);
|
);
|
||||||
assert_eq!(msg.message.as_ref().unwrap().text, "Transfer requested.");
|
assert_eq!(msg.message.as_ref().unwrap().text, "Transfer requested.");
|
||||||
|
|
||||||
if let MessagePollResponse::DomainTransfer(tr) = &result {
|
if let PollData::DomainTransfer(tr) = &result {
|
||||||
assert_eq!(tr.name, "eppdev-transfer.com");
|
assert_eq!(tr.name, "eppdev-transfer.com");
|
||||||
assert_eq!(tr.transfer_status, "pending");
|
assert_eq!(tr.transfer_status, "pending");
|
||||||
assert_eq!(tr.requester_id, "eppdev");
|
assert_eq!(tr.requester_id, "eppdev");
|
||||||
|
@ -157,7 +157,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn host_info_response() {
|
fn host_info_response() {
|
||||||
let object = response_from_file::<MessagePoll>("response/poll/poll_host_info.xml");
|
let object = response_from_file::<Poll>("response/poll/poll_host_info.xml");
|
||||||
let result = object.res_data().unwrap();
|
let result = object.res_data().unwrap();
|
||||||
let msg = object.message_queue().unwrap();
|
let msg = object.message_queue().unwrap();
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ mod tests {
|
||||||
);
|
);
|
||||||
assert_eq!(msg.message.as_ref().unwrap().text, "Unused objects policy");
|
assert_eq!(msg.message.as_ref().unwrap().text, "Unused objects policy");
|
||||||
|
|
||||||
if let MessagePollResponse::HostInfo(host) = &result {
|
if let PollData::HostInfo(host) = &result {
|
||||||
assert_eq!(host.name, "ns.test.com");
|
assert_eq!(host.name, "ns.test.com");
|
||||||
|
|
||||||
assert_eq!(host.roid, "1234");
|
assert_eq!(host.roid, "1234");
|
||||||
|
@ -207,7 +207,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn message_only_response() {
|
fn message_only_response() {
|
||||||
let object = response_from_file::<MessagePoll>("response/poll/poll_message_only.xml");
|
let object = response_from_file::<Poll>("response/poll/poll_message_only.xml");
|
||||||
let msg = object.message_queue().unwrap();
|
let msg = object.message_queue().unwrap();
|
||||||
dbg!(&msg);
|
dbg!(&msg);
|
||||||
|
|
||||||
|
@ -234,7 +234,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn empty_queue_response() {
|
fn empty_queue_response() {
|
||||||
let object = response_from_file::<MessagePoll>("response/poll/poll_empty_queue.xml");
|
let object = response_from_file::<Poll>("response/poll/poll_empty_queue.xml");
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
object.result.code,
|
object.result.code,
|
||||||
|
|
Loading…
Reference in New Issue