diff --git a/src/extensions/low_balance.rs b/src/extensions/low_balance.rs index 6e71555..fda002a 100644 --- a/src/extensions/low_balance.rs +++ b/src/extensions/low_balance.rs @@ -34,14 +34,13 @@ const XMLNS: &str = "http://www.verisign.com/epp/lowbalance-poll-1.0"; #[cfg(test)] mod tests { use super::*; - use crate::message::poll::MessagePollResponse; - use crate::message::MessagePoll; + use crate::poll::{MessagePoll, MessagePollResponse}; use crate::response::ResultCode; use crate::tests::{response_from_file, CLTRID, SVTRID}; #[test] fn low_balance() { - let object = response_from_file::("response/message/poll_low_balance.xml"); + let object = response_from_file::("response/poll/poll_low_balance.xml"); dbg!(&object); let low_balance = match object.res_data() { diff --git a/src/lib.rs b/src/lib.rs index 8b89e46..d34482d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -62,10 +62,8 @@ pub mod extensions { } } -pub mod message { - pub mod poll; - pub use poll::{MessagePoll, MessageAck}; -} +mod poll; +pub use poll::{MessageAck, MessagePoll}; pub use client::EppClient; pub use error::Error; diff --git a/src/message/ack.rs b/src/message/ack.rs deleted file mode 100644 index 561a950..0000000 --- a/src/message/ack.rs +++ /dev/null @@ -1,60 +0,0 @@ -//! Types for EPP message ack request - -use instant_xml::ToXml; - -use crate::common::{NoExtension, EPP_XMLNS}; -use crate::request::{Command, Transaction}; - -impl<'a> Transaction for MessageAck<'a> {} - -impl<'a> Command for MessageAck<'a> { - type Response = String; - const COMMAND: &'static str = "poll"; -} - -#[derive(Debug, ToXml)] -/// Type for EPP XML `` command for message ack -#[xml(rename = "poll", ns(EPP_XMLNS))] -pub struct MessageAck<'a> { - /// The type of operation to perform - /// The value is "ack" for message acknowledgement - #[xml(attribute)] - op: &'a str, - /// The ID of the message to be acknowledged - #[xml(rename = "msgID", attribute)] - message_id: &'a str, -} - -impl<'a> MessageAck<'a> { - pub fn new(message_id: &'a str) -> Self { - Self { - op: "ack", - message_id, - } - } -} - -#[cfg(test)] -mod tests { - use super::MessageAck; - use crate::response::ResultCode; - use crate::tests::{assert_serialized, response_from_file, SUCCESS_MSG, SVTRID}; - - #[test] - fn command() { - let object = MessageAck::new("12345"); - assert_serialized("request/message/ack.xml", &object); - } - - #[test] - fn response() { - let object = response_from_file::("response/message/ack.xml"); - let msg = object.message_queue().unwrap(); - - assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully); - assert_eq!(object.result.message, SUCCESS_MSG); - assert_eq!(msg.count, 4); - assert_eq!(msg.id, "12345".to_string()); - assert_eq!(object.tr_ids.server_tr_id, SVTRID); - } -} diff --git a/src/message/poll.rs b/src/poll.rs similarity index 96% rename from src/message/poll.rs rename to src/poll.rs index 5386f4d..11df360 100644 --- a/src/message/poll.rs +++ b/src/poll.rs @@ -87,12 +87,12 @@ mod tests { #[test] fn ack_command() { let object = MessageAck::new("12345"); - assert_serialized("request/message/ack.xml", &object); + assert_serialized("request/poll/ack.xml", &object); } #[test] fn response() { - let object = response_from_file::("response/message/ack.xml"); + let object = response_from_file::("response/poll/ack.xml"); let msg = object.message_queue().unwrap(); assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully); @@ -105,12 +105,12 @@ mod tests { #[test] fn poll_command() { let object = MessagePoll::default(); - assert_serialized("request/message/poll.xml", &object); + assert_serialized("request/poll/poll.xml", &object); } #[test] fn domain_transfer_response() { - let object = response_from_file::("response/message/poll_domain_transfer.xml"); + let object = response_from_file::("response/poll/poll_domain_transfer.xml"); let result = object.res_data().unwrap(); let msg = object.message_queue().unwrap(); @@ -157,7 +157,7 @@ mod tests { #[test] fn host_info_response() { - let object = response_from_file::("response/message/poll_host_info.xml"); + let object = response_from_file::("response/poll/poll_host_info.xml"); let result = object.res_data().unwrap(); let msg = object.message_queue().unwrap(); @@ -207,7 +207,7 @@ mod tests { #[test] fn message_only_response() { - let object = response_from_file::("response/message/poll_message_only.xml"); + let object = response_from_file::("response/poll/poll_message_only.xml"); let msg = object.message_queue().unwrap(); dbg!(&msg); @@ -234,7 +234,7 @@ mod tests { #[test] fn empty_queue_response() { - let object = response_from_file::("response/message/poll_empty_queue.xml"); + let object = response_from_file::("response/poll/poll_empty_queue.xml"); assert_eq!( object.result.code, diff --git a/tests/resources/request/message/ack.xml b/tests/resources/request/poll/ack.xml similarity index 100% rename from tests/resources/request/message/ack.xml rename to tests/resources/request/poll/ack.xml diff --git a/tests/resources/request/message/poll.xml b/tests/resources/request/poll/poll.xml similarity index 100% rename from tests/resources/request/message/poll.xml rename to tests/resources/request/poll/poll.xml diff --git a/tests/resources/response/message/ack.xml b/tests/resources/response/poll/ack.xml similarity index 100% rename from tests/resources/response/message/ack.xml rename to tests/resources/response/poll/ack.xml diff --git a/tests/resources/response/message/poll_domain_transfer.xml b/tests/resources/response/poll/poll_domain_transfer.xml similarity index 100% rename from tests/resources/response/message/poll_domain_transfer.xml rename to tests/resources/response/poll/poll_domain_transfer.xml diff --git a/tests/resources/response/message/poll_empty_queue.xml b/tests/resources/response/poll/poll_empty_queue.xml similarity index 100% rename from tests/resources/response/message/poll_empty_queue.xml rename to tests/resources/response/poll/poll_empty_queue.xml diff --git a/tests/resources/response/message/poll_host_info.xml b/tests/resources/response/poll/poll_host_info.xml similarity index 100% rename from tests/resources/response/message/poll_host_info.xml rename to tests/resources/response/poll/poll_host_info.xml diff --git a/tests/resources/response/message/poll_low_balance.xml b/tests/resources/response/poll/poll_low_balance.xml similarity index 100% rename from tests/resources/response/message/poll_low_balance.xml rename to tests/resources/response/poll/poll_low_balance.xml diff --git a/tests/resources/response/message/poll_message_only.xml b/tests/resources/response/poll/poll_message_only.xml similarity index 100% rename from tests/resources/response/message/poll_message_only.xml rename to tests/resources/response/poll/poll_message_only.xml