From ef1746cb851fd7b9f3fee34a856bb596d3c4fbdb Mon Sep 17 00:00:00 2001 From: gibbz00 Date: Mon, 21 Oct 2024 16:54:00 +0200 Subject: [PATCH] chore!: deprecate `Period::years` and `months` constructors --- src/domain/create.rs | 8 ++++---- src/domain/mod.rs | 10 ---------- src/domain/renew.rs | 7 ++++++- src/domain/transfer.rs | 8 ++++++-- src/extensions/secdns.rs | 8 ++++---- tests/basic.rs | 4 ++-- 6 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/domain/create.rs b/src/domain/create.rs index 961f2e1..2224a33 100644 --- a/src/domain/create.rs +++ b/src/domain/create.rs @@ -90,7 +90,7 @@ mod tests { use chrono::{TimeZone, Utc}; use super::{DomainContact, DomainCreate, Period}; - use crate::domain::{HostAttr, HostInfo, HostObj}; + use crate::domain::{HostAttr, HostInfo, HostObj, PeriodLength}; use crate::response::ResultCode; use crate::tests::{assert_serialized, response_from_file, CLTRID, SUCCESS_MSG, SVTRID}; @@ -113,7 +113,7 @@ mod tests { let object = DomainCreate::new( "eppdev-1.com", - Period::years(1).unwrap(), + Period::Years(PeriodLength::new(1).unwrap()), None, Some("eppdev-contact-3"), "epP4uthd#v", @@ -150,7 +150,7 @@ mod tests { ]; let object = DomainCreate::new( "eppdev-1.com", - Period::years(1).unwrap(), + Period::Years(PeriodLength::new(1).unwrap()), Some(hosts), Some("eppdev-contact-3"), "epP4uthd#v", @@ -193,7 +193,7 @@ mod tests { let object = DomainCreate::new( "eppdev-2.com", - Period::years(1).unwrap(), + Period::Years(PeriodLength::new(1).unwrap()), Some(hosts), Some("eppdev-contact-3"), "epP4uthd#v", diff --git a/src/domain/mod.rs b/src/domain/mod.rs index f56e03c..838c7ad 100644 --- a/src/domain/mod.rs +++ b/src/domain/mod.rs @@ -170,16 +170,6 @@ impl PeriodLength { } } -impl Period { - pub fn years(length: u8) -> Result { - PeriodLength::new(length).map(Self::Years) - } - - pub fn months(length: u8) -> Result { - PeriodLength::new(length).map(Self::Months) - } -} - impl ToXml for Period { fn serialize( &self, diff --git a/src/domain/renew.rs b/src/domain/renew.rs index 7b4c0db..7d08bfc 100644 --- a/src/domain/renew.rs +++ b/src/domain/renew.rs @@ -66,6 +66,7 @@ pub struct RenewData { #[cfg(test)] mod tests { use super::{DomainRenew, Period}; + use crate::domain::PeriodLength; use crate::response::ResultCode; use crate::tests::{assert_serialized, response_from_file, CLTRID, SUCCESS_MSG, SVTRID}; @@ -74,7 +75,11 @@ mod tests { #[test] fn command() { let exp_date = NaiveDate::from_ymd_opt(2022, 7, 23).unwrap(); - let object = DomainRenew::new("eppdev.com", exp_date, Period::years(1).unwrap()); + let object = DomainRenew::new( + "eppdev.com", + exp_date, + Period::Years(PeriodLength::new(1).unwrap()), + ); assert_serialized("request/domain/renew.xml", &object); } diff --git a/src/domain/transfer.rs b/src/domain/transfer.rs index b832152..358b6aa 100644 --- a/src/domain/transfer.rs +++ b/src/domain/transfer.rs @@ -124,13 +124,17 @@ mod tests { use chrono::{TimeZone, Utc}; use super::{DomainTransfer, Period}; + use crate::domain::PeriodLength; use crate::response::ResultCode; use crate::tests::{assert_serialized, response_from_file, CLTRID, SUCCESS_MSG, SVTRID}; #[test] fn request_command() { - let object = - DomainTransfer::new("testing.com", Some(Period::years(1).unwrap()), "epP4uthd#v"); + let object = DomainTransfer::new( + "testing.com", + Some(Period::Years(PeriodLength::new(1).unwrap())), + "epP4uthd#v", + ); assert_serialized("request/domain/transfer_request.xml", &object); } diff --git a/src/extensions/secdns.rs b/src/extensions/secdns.rs index 53cd631..20098fe 100644 --- a/src/extensions/secdns.rs +++ b/src/extensions/secdns.rs @@ -371,7 +371,7 @@ impl ToXml for Protocol { #[cfg(test)] mod tests { use super::*; - use crate::domain; + use crate::domain::{self, Period, PeriodLength}; use crate::tests::assert_serialized; #[test] @@ -404,7 +404,7 @@ mod tests { ]; let object = domain::DomainCreate::new( "example.com", - domain::Period::years(2).unwrap(), + Period::Years(PeriodLength::new(2).unwrap()), Some(&ns), Some("jd1234"), "2fooBAR", @@ -452,7 +452,7 @@ mod tests { ]; let object = domain::DomainCreate::new( "example.com", - domain::Period::years(2).unwrap(), + Period::Years(PeriodLength::new(2).unwrap()), Some(&ns), Some("jd1234"), "2fooBAR", @@ -493,7 +493,7 @@ mod tests { ]; let object = domain::DomainCreate::new( "example.com", - domain::Period::years(2).unwrap(), + Period::Years(PeriodLength::new(2).unwrap()), Some(&ns), Some("jd1234"), "2fooBAR", diff --git a/tests/basic.rs b/tests/basic.rs index 81b44e5..1dd64cd 100644 --- a/tests/basic.rs +++ b/tests/basic.rs @@ -9,7 +9,7 @@ use tokio::time::timeout; use tokio_test::io::Builder; use instant_epp::client::{Connector, EppClient}; -use instant_epp::domain::{DomainCheck, DomainContact, DomainCreate, Period}; +use instant_epp::domain::{DomainCheck, DomainContact, DomainCreate, Period, PeriodLength}; use instant_epp::login::Login; use instant_epp::response::ResultCode; use instant_epp::Error; @@ -232,7 +232,7 @@ async fn dropped() { // remainder of the in-flight request before starting the new one, and succeed. let create = DomainCreate::new( "eppdev-1.com", - Period::years(1).unwrap(), + Period::Years(PeriodLength::new(1).unwrap()), None, Some("eppdev-contact-3"), "epP4uthd#v",