diff --git a/epp-client/examples/client.rs b/epp-client/examples/client.rs index 9a43df2..118f8cf 100644 --- a/epp-client/examples/client.rs +++ b/epp-client/examples/client.rs @@ -1,4 +1,6 @@ -use epp_client::{epp::request::generate_client_tr_id, connection::EppClient, connection, epp::xml::EppXml, epp::response::EppGreeting}; +use epp_client::{epp::request::generate_client_tr_id, connection::EppClient, connection, epp::xml::EppXml}; +use epp_client::epp::request::EppHello; +use epp_client::epp::response::EppGreeting; use epp_client::epp::request::domain::check::EppDomainCheck; use epp_client::epp::response::domain::check::EppDomainCheckResponse; use epp_client::epp::request::contact::check::EppContactCheck; @@ -37,6 +39,12 @@ async fn create_contact() { //client.transact::(&contact_check).await.unwrap(); } +async fn hello(client: &mut EppClient) { + let hello = EppHello::new(); + + client.transact::<_, EppGreeting>(&hello).await.unwrap(); +} + #[tokio::main] async fn main() { let mut client = match connection::connect("hexonet").await { @@ -49,9 +57,11 @@ async fn main() { Err(e) => panic!("Error: {}", e) }; + hello(&mut client).await; + // check_domains(&mut client).await; - check_contacts(&mut client).await; + // check_contacts(&mut client).await; // create_contact().await; } diff --git a/epp-client/src/epp/command.rs b/epp-client/src/epp/command.rs index 59ef8d5..35c0f81 100644 --- a/epp-client/src/epp/command.rs +++ b/epp-client/src/epp/command.rs @@ -1,20 +1,16 @@ use crate::epp::object::{ElementName, StringValue}; +use epp_client_macros::*; use serde::ser::{SerializeStruct, Serializer}; use serde::{Deserialize, Serialize}; -#[derive(Deserialize, Debug, PartialEq)] +#[derive(Deserialize, Debug, PartialEq, ElementName)] +#[element_name(name = "command")] pub struct Command { pub command: T, #[serde(rename = "clTRID")] pub client_tr_id: StringValue, } -impl ElementName for Command { - fn element_name(&self) -> &'static str { - "command" - } -} - impl Serialize for Command { fn serialize(&self, serializer: S) -> Result where diff --git a/epp-client/src/epp/request.rs b/epp-client/src/epp/request.rs index e1f1108..a12f2f8 100644 --- a/epp-client/src/epp/request.rs +++ b/epp-client/src/epp/request.rs @@ -22,7 +22,6 @@ pub fn generate_client_tr_id(username: &str) -> Result> { } #[derive(Serialize, Deserialize, Debug, PartialEq, ElementName)] -#[serde(rename = "hello")] #[element_name(name = "hello")] pub struct Hello; @@ -33,7 +32,6 @@ impl EppHello { } #[derive(Serialize, Deserialize, Debug, PartialEq, ElementName)] -#[serde(rename = "login")] #[element_name(name = "login")] pub struct Login { #[serde(rename(serialize = "clID", deserialize = "clID"))]