instant_epp/contact/
delete.rs

1//! Types for EPP contact delete request
2
3use instant_xml::ToXml;
4
5use super::XMLNS;
6use crate::common::{NoExtension, EPP_XMLNS};
7use crate::request::{Command, Transaction};
8
9impl<'a> Transaction<NoExtension> for ContactDelete<'a> {}
10
11impl<'a> Command for ContactDelete<'a> {
12    type Response = ();
13    const COMMAND: &'static str = "delete";
14}
15
16/// Type containing the data for the `<delete>` tag for contacts
17#[derive(Debug, ToXml)]
18#[xml(rename = "delete", ns(XMLNS))]
19pub struct ContactDeleteRequest<'a> {
20    /// The id of the contact to be deleted
21    id: &'a str,
22}
23
24/// The `<delete>` type for the contact delete EPP command
25#[derive(Debug, ToXml)]
26#[xml(rename = "delete", ns(EPP_XMLNS))]
27pub struct ContactDelete<'a> {
28    /// The data for the `<delete>` tag for a contact delete command
29    contact: ContactDeleteRequest<'a>,
30}
31
32impl<'a> ContactDelete<'a> {
33    pub fn new(id: &'a str) -> Self {
34        Self {
35            contact: ContactDeleteRequest { id },
36        }
37    }
38}
39
40#[cfg(test)]
41mod tests {
42    use super::ContactDelete;
43    use crate::response::ResultCode;
44    use crate::tests::{assert_serialized, response_from_file, CLTRID, SUCCESS_MSG, SVTRID};
45
46    #[test]
47    fn command() {
48        let object = ContactDelete::new("eppdev-contact-3");
49        assert_serialized("request/contact/delete.xml", &object);
50    }
51
52    #[test]
53    fn response() {
54        let object = response_from_file::<ContactDelete>("response/contact/delete.xml");
55        assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully);
56        assert_eq!(object.result.message, SUCCESS_MSG);
57        assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID);
58        assert_eq!(object.tr_ids.server_tr_id, SVTRID);
59    }
60}