diff --git a/src/DDoSX/RecordClient.php b/src/DDoSX/RecordClient.php index e60e9fce..d80d6ff2 100644 --- a/src/DDoSX/RecordClient.php +++ b/src/DDoSX/RecordClient.php @@ -4,6 +4,7 @@ use UKFast\SDK\Client as BaseClient; use UKFast\SDK\DDoSX\Entities\Record; +use UKFast\SDK\SelfResponse; class RecordClient extends BaseClient { @@ -59,4 +60,19 @@ public function getPageByDomainName($domainName, $page = 1, $perPage = 20, $filt return $page; } + + public function create(Record $record) + { + $response = $this->post( + 'v1/domains/' . $record->domainName . '/records', + json_encode($this->friendlyToApi($record, $this->requestMap)) + ); + $body = $this->decodeJson($response->getBody()->getContents()); + + return (new SelfResponse($body)) + ->setClient($this) + ->serializeWith(function ($body) { + return new Record($this->apiToFriendly($body->data, $this->requestMap)); + }); + } }