diff --git a/src/lib.rs b/src/lib.rs index e6688ec..8b89e46 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -63,11 +63,8 @@ pub mod extensions { } pub mod message { - pub mod ack; - pub use ack::MessageAck; - pub mod poll; - pub use poll::MessagePoll; + pub use poll::{MessagePoll, MessageAck}; } pub use client::EppClient; diff --git a/src/message/poll.rs b/src/message/poll.rs index 4f3e624..5386f4d 100644 --- a/src/message/poll.rs +++ b/src/message/poll.rs @@ -45,18 +45,65 @@ pub enum MessagePollResponse { LowBalance(LowBalance), } +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::{MessagePoll, MessagePollResponse}; + use super::{MessageAck, MessagePoll, MessagePollResponse}; use crate::host::Status; use crate::response::ResultCode; - use crate::tests::{assert_serialized, response_from_file, CLTRID, SVTRID}; + use crate::tests::{assert_serialized, response_from_file, CLTRID, SUCCESS_MSG, SVTRID}; use chrono::{TimeZone, Utc}; use std::net::IpAddr; #[test] - fn command() { + fn ack_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); + } + + #[test] + fn poll_command() { let object = MessagePoll::default(); assert_serialized("request/message/poll.xml", &object); }