Rename EppHello and EppGreeting

This commit is contained in:
Nicholas Rempel 2021-12-01 10:06:05 -08:00 committed by masalachai
parent 3978c426da
commit c32c19ce98
4 changed files with 18 additions and 18 deletions

View File

@ -54,7 +54,7 @@ use crate::common::{EppObject, NoExtension};
use crate::config::EppClientConfig;
use crate::connection::registry::{epp_connect, EppConnection};
use crate::error;
use crate::hello::{EppGreeting, EppHello};
use crate::hello::{Greeting, Hello};
use crate::login::Login;
use crate::logout::Logout;
use crate::request::{generate_client_tr_id, EppExtension, EppRequest};
@ -129,13 +129,13 @@ impl EppClient {
}
/// Executes an EPP Hello call and returns the response as an `EppGreeting`
pub async fn hello(&mut self) -> Result<EppGreeting, Box<dyn Error>> {
let hello = EppHello::new();
pub async fn hello(&mut self) -> Result<Greeting, Box<dyn Error>> {
let hello = Hello::new();
let hello_xml = hello.serialize()?;
let response = self.connection.transact(&hello_xml).await?;
Ok(EppGreeting::deserialize(&response)?)
Ok(Greeting::deserialize(&response)?)
}
pub async fn transact<T, E>(
@ -171,8 +171,8 @@ impl EppClient {
}
/// Returns the greeting received on establishment of the connection as an `EppGreeting`
pub fn greeting(&self) -> Result<EppGreeting, error::Error> {
EppGreeting::deserialize(&self.connection.greeting)
pub fn greeting(&self) -> Result<Greeting, error::Error> {
Greeting::deserialize(&self.connection.greeting)
}
/// Sends the EPP Logout command to log out of the EPP session

View File

@ -6,30 +6,30 @@ use serde::{Deserialize, Deserializer, Serialize};
use crate::common::{ElementName, EppObject, Options, ServiceExtension, Services, StringValue};
/// The EPP Hello request
pub type EppHello = EppObject<Hello>;
pub type Hello = EppObject<HelloRequest>;
impl EppHello {
impl Hello {
/// Creates a new Epp Hello request
pub fn new() -> EppHello {
EppObject::build(Hello {})
pub fn new() -> Hello {
EppObject::build(HelloRequest {})
}
}
impl Default for EppHello {
impl Default for Hello {
fn default() -> Self {
Self::new()
}
}
/// The EPP Greeting that is received on a successful connection and in response to an EPP hello
pub type EppGreeting = EppObject<Greeting>;
pub type Greeting = EppObject<GreetingResponse>;
// Request
#[derive(Serialize, Deserialize, Debug, PartialEq, ElementName)]
#[element_name(name = "hello")]
/// Type corresponding to the <hello> tag in an EPP XML hello request
pub struct Hello;
pub struct HelloRequest;
// Response
@ -284,7 +284,7 @@ pub struct Dcp {
#[serde(rename_all = "lowercase")]
#[element_name(name = "greeting")]
/// Type corresponding to the <greeting> tag in the EPP greeting XML
pub struct Greeting {
pub struct GreetingResponse {
/// The service ID
#[serde(rename = "svID")]
pub service_id: String,

View File

@ -21,8 +21,8 @@ mod response {
use crate::domain::transfer::DomainTransferReject;
use crate::domain::transfer::DomainTransferRequest;
use crate::domain::update::DomainUpdate;
use crate::hello::EppGreeting;
use crate::hello::ExpiryType;
use crate::hello::Greeting;
use crate::hello::Relative;
use crate::host::check::HostCheck;
use crate::host::create::HostCreate;
@ -43,7 +43,7 @@ mod response {
#[test]
fn greeting() {
let xml = get_xml("response/greeting.xml").unwrap();
let object = EppGreeting::deserialize(xml.as_str()).unwrap();
let object = Greeting::deserialize(xml.as_str()).unwrap();
assert_eq!(object.data.service_id, "ISPAPI EPP Server");
assert_eq!(object.data.service_date, "2021-07-25T14:51:17.0Z");

View File

@ -31,7 +31,7 @@ mod request {
use crate::domain::update::DomainAddRemove;
use crate::domain::update::DomainChangeInfo;
use crate::domain::update::DomainUpdate;
use crate::hello::EppHello;
use crate::hello::Hello;
use crate::host::check::HostCheck;
use crate::host::create::HostCreate;
use crate::host::delete::HostDelete;
@ -51,7 +51,7 @@ mod request {
#[test]
fn hello() {
let xml = get_xml("request/hello.xml").unwrap();
let object = EppHello::new();
let object = Hello::new();
let serialized = object.serialize().unwrap();
assert_eq!(xml, serialized);