Skip to content

Commit

Permalink
update SaveContactDetails
Browse files Browse the repository at this point in the history
  • Loading branch information
PlanetHoster-account committed Mar 15, 2019
1 parent 8579602 commit e1502c5
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/Api/Domain.php
Expand Up @@ -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'));
}
Expand All @@ -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);
}
Expand Down

0 comments on commit e1502c5

Please sign in to comment.