use std::fmt::Debug; use serde::{Deserialize, Serialize}; use crate::{ common::{NoExtension, Options, ServiceExtension, Services, StringValue}, contact, domain, host, request::{Command, Transaction, EPP_LANG, EPP_VERSION}, }; impl Transaction for Login {} #[derive(Serialize, Deserialize, Debug, PartialEq)] /// Type corresponding to the <login> tag in an EPP XML login request pub struct Login { /// The username to use for the login #[serde(rename(serialize = "clID", deserialize = "clID"))] username: StringValue, /// The password to use for the login #[serde(rename = "pw", default)] password: StringValue, /// Data under the tag options: Options, /// Data under the tag #[serde(rename = "svcs")] services: Services, } impl Login { pub fn new(username: &str, password: &str, ext_uris: Option>) -> Self { let ext_uris = ext_uris.map(|uris| uris.iter().map(|u| u.as_str().into()).collect()); Self { username: username.into(), password: password.into(), options: Options { version: EPP_VERSION.into(), lang: EPP_LANG.into(), }, services: Services { obj_uris: vec![ host::XMLNS.into(), contact::XMLNS.into(), domain::XMLNS.into(), ], svc_ext: Some(ServiceExtension { ext_uris }), }, } } /// Sets the tag data pub fn options(&mut self, options: Options) { self.options = options; } /// Sets the tag data pub fn services(&mut self, services: Services) { self.services = services; } } impl Command for Login { type Response = (); const COMMAND: &'static str = "login"; }