//! Types for EPP namestore request and responses use std::borrow::Cow; use serde::{Deserialize, Serialize}; use crate::{ common::StringValue, contact::{ check::ContactCheck, create::ContactCreate, delete::ContactDelete, info::ContactInfo, update::ContactUpdate, }, domain::{ check::DomainCheck, create::DomainCreate, delete::DomainDelete, info::DomainInfo, renew::DomainRenew, transfer::DomainTransfer, update::DomainUpdate, }, host::{ check::HostCheck, create::HostCreate, delete::HostDelete, info::HostInfo, update::HostUpdate, }, request::{Extension, Transaction}, }; pub const XMLNS: &str = "http://www.verisign-grs.com/epp/namestoreExt-1.1"; // Contact impl Transaction> for ContactCheck<'_> {} impl Transaction> for ContactCreate<'_> {} impl Transaction> for ContactDelete<'_> {} impl Transaction> for ContactInfo<'_> {} impl Transaction> for ContactUpdate<'_> {} // Domain impl Transaction> for DomainCheck<'_> {} impl Transaction> for DomainCreate<'_> {} impl Transaction> for DomainDelete<'_> {} impl Transaction> for DomainInfo<'_> {} impl Transaction> for DomainRenew<'_> {} impl Transaction> for DomainTransfer<'_> {} impl Transaction> for DomainUpdate<'_> {} // Host impl Transaction> for HostCheck<'_> {} impl Transaction> for HostCreate<'_> {} impl Transaction> for HostDelete<'_> {} impl Transaction> for HostInfo<'_> {} impl Transaction> for HostUpdate<'_> {} impl<'a> NameStore<'a> { /// Create a new RGP restore report request pub fn new(subproduct: &str) -> NameStore { NameStore { data: NameStoreData { xmlns: XMLNS.into(), subproduct: subproduct.to_owned().into(), }, } } } impl<'a> NameStoreData<'a> { /// Create a new RGP restore report request pub fn new(subproduct: &str) -> Self { Self { xmlns: XMLNS.into(), subproduct: subproduct.to_owned().into(), } } } impl<'a> Extension for NameStore<'a> { type Response = NameStore<'static>; } #[derive(Debug, Deserialize, Serialize)] #[serde(rename = "namestoreExt:namestoreExt")] pub struct NameStore<'a> { #[serde(rename = "namestoreExt:namestoreExt", alias = "namestoreExt")] pub data: NameStoreData<'a>, } #[derive(Serialize, Deserialize, Debug)] /// Type for EPP XML <namestoreExt> extension pub struct NameStoreData<'a> { /// XML namespace for the RGP restore extension #[serde(rename = "xmlns:namestoreExt", alias = "xmlns")] pub xmlns: Cow<'a, str>, /// The object holding the list of domains to be checked #[serde(rename = "namestoreExt:subProduct", alias = "subProduct")] pub subproduct: StringValue<'a>, } #[cfg(test)] mod tests { use super::NameStore; use crate::domain::check::DomainCheck; use crate::tests::{assert_serialized, response_from_file_with_ext}; #[test] fn command() { let namestore_ext = NameStore::new("com"); let object = DomainCheck { domains: &["example1.com", "example2.com", "example3.com"], }; assert_serialized( "request/extensions/namestore.xml", (&object, &namestore_ext), ); } #[test] fn response() { let object = response_from_file_with_ext::( "response/extensions/namestore.xml", ); let ext = object.extension.unwrap(); assert_eq!(ext.data.subproduct, "com".into()); } }