Skip to content

Commit a58d8db

Browse files
committed
DEV-7942
Signed-off-by: Christian Pleintinger <christian.pleintinger@intranetx.com>
1 parent 25eaa7c commit a58d8db

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "internetx/php-domainrobot-sdk",
3-
"version": "0.9.17",
3+
"version": "0.9.18",
44
"description": "A php package for easy integration of the domainrobot API powered by InterNetX GmbH.",
55
"type": "library",
66
"license": "MIT",

src/Service/ZoneService.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Domainrobot\Model\Zone;
1111
use Domainrobot\Model\ZoneStream;
1212
use Domainrobot\Model\Query;
13+
use Domainrobot\Model\ZoneBasePatchRequest;
1314
use Domainrobot\Service\DomainrobotService;
1415

1516
class ZoneService extends DomainrobotService
@@ -164,6 +165,7 @@ public function list(Query $body = null)
164165
$z = new Zone($d);
165166
array_push($zones, $z);
166167
}
168+
167169
return $zones;
168170
}
169171

@@ -201,6 +203,7 @@ public function listAsync(Query $body = null)
201203
if ($body != null) {
202204
$data = $body->toArray();
203205
}
206+
204207
return new DomainrobotPromise($this->sendRequest(
205208
$this->domainrobotConfig->getUrl() . "/zone/_search",
206209
'POST',
@@ -301,15 +304,60 @@ public function updateAsync(Zone $body)
301304
} else {
302305
$name = $body->getOrigin();
303306
}
307+
304308
if ($body->getVirtualNameServer() === null) {
305309
throw new \InvalidArgumentException("Field Zone.virtualNameServer is missing.");
306310
} else {
307311
$systemNameServer = $body->getVirtualNameServer();
308312
}
313+
309314
return $this->sendRequest(
310315
$this->domainrobotConfig->getUrl() . "/zone/$name/$systemNameServer",
311316
'PUT',
312317
["json" => $body->toArray()]
313318
);
314319
}
320+
321+
/**
322+
* Sends a zone patch request.
323+
*
324+
* @param ZoneBasePatchRequest $body
325+
* @return Zone
326+
*/
327+
public function patch(ZoneBasePatchRequest $body)
328+
{
329+
$domainrobotPromise = $this->patchAsync($body);
330+
$domainrobotResult = $domainrobotPromise->wait();
331+
332+
Domainrobot::setLastDomainrobotResult($domainrobotResult);
333+
334+
return new Zone(ArrayHelper::getValueFromArray($domainrobotResult->getResult(), 'data.0', []));
335+
}
336+
337+
/**
338+
* Sends a zone update request.
339+
*
340+
* @param ZoneBasePatchRequest $body
341+
* @return DomainrobotPromise
342+
*/
343+
public function patchAsync(ZoneBasePatchRequest $body)
344+
{
345+
if ($body->getOrigin() === null) {
346+
throw new \InvalidArgumentException("Field Zone.origin is missing.");
347+
} else {
348+
$name = $body->getOrigin();
349+
}
350+
351+
if ($body->getVirtualNameServer() === null) {
352+
throw new \InvalidArgumentException("Field Zone.virtualNameServer is missing.");
353+
} else {
354+
$systemNameServer = $body->getVirtualNameServer();
355+
}
356+
357+
return $this->sendRequest(
358+
$this->domainrobotConfig->getUrl() . "/zone/$name/$systemNameServer",
359+
'PATCH',
360+
["json" => $body->toArray()]
361+
);
362+
}
315363
}

0 commit comments

Comments
 (0)