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;
|
|
|
|
|
2021-12-02 10:00:33 +00:00
|
|
|
use super::XMLNS;
|
2022-11-21 19:34:25 +00:00
|
|
|
use crate::common::{NoExtension, EPP_XMLNS};
|
2021-12-09 09:17:00 +00:00
|
|
|
use crate::request::{Command, Transaction};
|
2021-11-26 22:21:38 +00:00
|
|
|
|
2021-12-14 10:07:01 +00:00
|
|
|
impl<'a> Transaction<NoExtension> for ContactDelete<'a> {}
|
2021-11-26 22:21:38 +00:00
|
|
|
|
2021-12-14 10:07:01 +00:00
|
|
|
impl<'a> Command for ContactDelete<'a> {
|
2021-12-09 09:17:00 +00:00
|
|
|
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,
|
2021-07-22 17:12:50 +00:00
|
|
|
}
|
|
|
|
|
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))]
|
2021-12-14 10:07:01 +00:00
|
|
|
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>,
|
2021-07-22 17:12:50 +00:00
|
|
|
}
|
2021-12-09 09:17:00 +00:00
|
|
|
|
2021-12-14 10:07:01 +00:00
|
|
|
impl<'a> ContactDelete<'a> {
|
|
|
|
pub fn new(id: &'a str) -> Self {
|
2021-12-09 09:17:00 +00:00
|
|
|
Self {
|
2022-11-21 19:34:25 +00:00
|
|
|
contact: ContactDeleteRequest { id },
|
2021-12-09 09:17:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-12-07 09:04:57 +00:00
|
|
|
|
|
|
|
#[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};
|
2021-12-07 09:04:57 +00:00
|
|
|
|
|
|
|
#[test]
|
2021-12-07 09:32:06 +00:00
|
|
|
fn command() {
|
|
|
|
let object = ContactDelete::new("eppdev-contact-3");
|
2022-03-10 11:50:09 +00:00
|
|
|
assert_serialized("request/contact/delete.xml", &object);
|
2021-12-07 09:32:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[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);
|
2021-12-07 09:04:57 +00:00
|
|
|
}
|
|
|
|
}
|