Move poll module to the top level
This commit is contained in:
parent
10eedb6045
commit
f5ea188fbb
|
@ -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::<MessagePoll>("response/message/poll_low_balance.xml");
|
||||
let object = response_from_file::<MessagePoll>("response/poll/poll_low_balance.xml");
|
||||
dbg!(&object);
|
||||
|
||||
let low_balance = match object.res_data() {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<NoExtension> for MessageAck<'a> {}
|
||||
|
||||
impl<'a> Command for MessageAck<'a> {
|
||||
type Response = String;
|
||||
const COMMAND: &'static str = "poll";
|
||||
}
|
||||
|
||||
#[derive(Debug, ToXml)]
|
||||
/// Type for EPP XML `<poll>` 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::<MessageAck>("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);
|
||||
}
|
||||
}
|
|
@ -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::<MessageAck>("response/message/ack.xml");
|
||||
let object = response_from_file::<MessageAck>("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::<MessagePoll>("response/message/poll_domain_transfer.xml");
|
||||
let object = response_from_file::<MessagePoll>("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::<MessagePoll>("response/message/poll_host_info.xml");
|
||||
let object = response_from_file::<MessagePoll>("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::<MessagePoll>("response/message/poll_message_only.xml");
|
||||
let object = response_from_file::<MessagePoll>("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::<MessagePoll>("response/message/poll_empty_queue.xml");
|
||||
let object = response_from_file::<MessagePoll>("response/poll/poll_empty_queue.xml");
|
||||
|
||||
assert_eq!(
|
||||
object.result.code,
|
Loading…
Reference in New Issue