Allow transfer request without period

This commit is contained in:
Nicholas Rempel 2021-12-02 15:41:31 -08:00 committed by masalachai
parent 26579600d0
commit fe47e27c99
2 changed files with 9 additions and 4 deletions

View File

@ -122,7 +122,7 @@ impl<E: EppExtension> EppRequest<E> for DomainTransferQuery<E> {
///
/// // Create an DomainTransferRequest instance
/// let domain_transfer_request = DomainTransferRequest::<NoExtension>::new(
/// "eppdev-100.net", 1, "epP4uthd#v"
/// "eppdev-100.net", None, "epP4uthd#v"
/// );
///
/// // send it to the registry and receive a response of type DomainTransferRequestResponse
@ -135,14 +135,18 @@ impl<E: EppExtension> EppRequest<E> for DomainTransferQuery<E> {
/// }
/// ```
impl<E: EppExtension> DomainTransferRequest<E> {
pub fn new(name: &str, years: u16, auth_password: &str) -> DomainTransferRequest<NoExtension> {
pub fn new(
name: &str,
years: Option<u16>,
auth_password: &str,
) -> DomainTransferRequest<NoExtension> {
DomainTransferRequest {
request: DomainTransferReq {
operation: "request".to_string(),
domain: DomainTransferReqData {
xmlns: XMLNS.to_string(),
name: name.into(),
period: Some(Period::new(years)),
period: years.map(Period::new),
auth_info: Some(DomainAuthInfo::new(auth_password)),
},
},

View File

@ -369,7 +369,8 @@ mod request {
fn domain_transfer_request() {
let xml = get_xml("request/domain/transfer_request.xml").unwrap();
let object = DomainTransferRequest::<NoExtension>::new("testing.com", 1, "epP4uthd#v");
let object =
DomainTransferRequest::<NoExtension>::new("testing.com", Some(1), "epP4uthd#v");
let serialized = object.serialize_request(CLTRID).unwrap();