//! Types for EPP message poll request use epp_client_macros::*; use crate::epp::object::{ElementName, EppObject}; use crate::epp::request::Command; use serde::{Deserialize, Serialize}; /// Type that represents the <epp> request for registry command /// /// ## Usage /// /// ```no_run /// use std::collections::HashMap; /// /// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::epp::{EppMessagePoll, EppMessagePollResponse}; /// use epp_client::epp::generate_client_tr_id; /// /// #[tokio::main] /// async fn main() { /// // Create a config /// let mut registry: HashMap = HashMap::new(); /// registry.insert( /// "registry_name".to_owned(), /// EppClientConnection { /// host: "example.com".to_owned(), /// port: 700, /// username: "username".to_owned(), /// password: "password".to_owned(), /// ext_uris: None, /// tls_files: None, /// }, /// ); /// let config = EppClientConfig { registry }; /// /// // Create an instance of EppClient, passing the config and the registry you want to connect to /// let mut client = match EppClient::new(&config, "registry_name").await { /// Ok(client) => client, /// Err(e) => panic!("Failed to create EppClient: {}", e) /// }; /// /// // Create an EppMessagePoll instance /// let message_poll = EppMessagePoll::new(generate_client_tr_id(&client).as_str()); /// /// // send it to the registry and receive a response of type EppMessagePollResponse /// let response = client.transact::<_, EppMessagePollResponse>(&message_poll).await.unwrap(); /// /// println!("{:?}", response); /// /// client.logout().await.unwrap(); /// } /// ``` pub type EppMessagePoll = EppObject>; #[derive(Serialize, Deserialize, Debug, ElementName)] #[element_name(name = "poll")] /// Type for EPP XML <poll> command for message poll pub struct MessagePoll { /// The type of operation to perform /// The value is "req" for message polling op: String, } impl EppMessagePoll { /// Creates a new EppObject for <poll> req corresponding to the <epp> tag in EPP XML pub fn new(client_tr_id: &str) -> EppMessagePoll { EppObject::build(Command::::new( MessagePoll { op: "req".to_string(), }, client_tr_id, )) } }