From e1502c5dbea74161548e3fca8b1c6d8a0c65b8e9 Mon Sep 17 00:00:00 2001 From: Gabriel P Date: Fri, 15 Mar 2019 12:17:03 -0400 Subject: [PATCH] update SaveContactDetails --- src/Api/Domain.php | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/Api/Domain.php b/src/Api/Domain.php index d84a3e0..34eeaf2 100644 --- a/src/Api/Domain.php +++ b/src/Api/Domain.php @@ -108,17 +108,19 @@ public function GetRegistrarLock($sld, $tld) { * @param DomainContact $tech * @param DomainContact $billing * + * @throws InvalidArgumentException + * * @return stdClass */ - public function SaveContactDetails($sld, $tld, DomainContact $registrant, + public function SaveContactDetails($sld, $tld, + DomainContact $registrant = null, DomainContact $admin = null, DomainContact $tech = null, DomainContact $billing = null) { - $params = [ - 'sld' => $sld, - 'tld' => $tld, - ]; - $params = array_merge($params, $registrant->toArray('registrant')); + $params = []; + if($registrant !== null) { + $params = array_merge($params, $registrant->toArray('registrant')); + } if($admin !== null) { $params = array_merge($params, $admin->toArray('admin')); } @@ -129,6 +131,15 @@ public function SaveContactDetails($sld, $tld, DomainContact $registrant, $params = array_merge($params, $billing->toArray('billing')); } + if(empty($params)) { + throw new InvalidArgumentException('require at least one of: registrant, admin, tech or billing'); + } + + $params = array_merge($params, [ + 'sld' => $sld, + 'tld' => $tld, + ]); + $content = $this->adapter->post($this->uri('save-contact-details'), $params); return json_decode($content); }