instant-epp/src/contact/delete.rs

61 lines
1.7 KiB
Rust
Raw Normal View History

2021-07-25 14:34:01 +00:00
//! Types for EPP contact delete request
2022-11-21 19:34:25 +00:00
use instant_xml::ToXml;
use super::XMLNS;
2022-11-21 19:34:25 +00:00
use crate::common::{NoExtension, EPP_XMLNS};
use crate::request::{Command, Transaction};
2021-11-26 22:21:38 +00:00
impl<'a> Transaction<NoExtension> for ContactDelete<'a> {}
2021-11-26 22:21:38 +00:00
impl<'a> Command for ContactDelete<'a> {
type Response = ();
const COMMAND: &'static str = "delete";
2021-11-26 18:17:29 +00:00
}
2023-03-02 13:27:26 +00:00
/// Type containing the data for the `<delete>` tag for contacts
2022-11-21 19:34:25 +00:00
#[derive(Debug, ToXml)]
#[xml(rename = "delete", ns(XMLNS))]
pub struct ContactDeleteRequest<'a> {
2021-07-25 14:34:01 +00:00
/// The id of the contact to be deleted
2022-11-21 19:34:25 +00:00
id: &'a str,
}
2023-03-02 13:27:26 +00:00
/// The `<delete>` type for the contact delete EPP command
2022-11-21 19:34:25 +00:00
#[derive(Debug, ToXml)]
#[xml(rename = "delete", ns(EPP_XMLNS))]
pub struct ContactDelete<'a> {
2023-03-02 13:27:26 +00:00
/// The data for the `<delete>` tag for a contact delete command
2022-11-21 19:34:25 +00:00
contact: ContactDeleteRequest<'a>,
}
impl<'a> ContactDelete<'a> {
pub fn new(id: &'a str) -> Self {
Self {
2022-11-21 19:34:25 +00:00
contact: ContactDeleteRequest { id },
}
}
}
#[cfg(test)]
mod tests {
use super::ContactDelete;
2022-01-23 22:24:27 +00:00
use crate::response::ResultCode;
2022-03-12 17:02:51 +00:00
use crate::tests::{assert_serialized, response_from_file, CLTRID, SUCCESS_MSG, SVTRID};
#[test]
fn command() {
let object = ContactDelete::new("eppdev-contact-3");
assert_serialized("request/contact/delete.xml", &object);
}
#[test]
fn response() {
2022-03-12 17:02:51 +00:00
let object = response_from_file::<ContactDelete>("response/contact/delete.xml");
2022-01-23 22:24:27 +00:00
assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully);
2022-11-21 19:34:25 +00:00
assert_eq!(object.result.message, SUCCESS_MSG);
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID);
assert_eq!(object.tr_ids.server_tr_id, SVTRID);
}
}