Skip to content

Commit

Permalink
Merge pull request #200 from BenjiHartley/add-record-client-create
Browse files Browse the repository at this point in the history
Add record client create
  • Loading branch information
phily245 authored Jan 29, 2020
2 parents f31392c + 7eac316 commit 652389b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/DDoSX/RecordClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use UKFast\SDK\Client as BaseClient;
use UKFast\SDK\DDoSX\Entities\Record;
use UKFast\SDK\SelfResponse;

class RecordClient extends BaseClient
{
Expand Down Expand Up @@ -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));
});
}
}

0 comments on commit 652389b

Please sign in to comment.