From b0ca4bccdbfd237a4fa71827a238b2fe67b500ec Mon Sep 17 00:00:00 2001 From: Martin Shaw Date: Mon, 20 Jan 2020 15:39:04 +0000 Subject: [PATCH 1/9] Add required Record client methods --- src/DDoSX/Entities/Record.php | 19 ++++++++++++ src/DDoSX/RecordClient.php | 55 +++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 src/DDoSX/Entities/Record.php create mode 100644 src/DDoSX/RecordClient.php diff --git a/src/DDoSX/Entities/Record.php b/src/DDoSX/Entities/Record.php new file mode 100644 index 00000000..2d05e5ce --- /dev/null +++ b/src/DDoSX/Entities/Record.php @@ -0,0 +1,19 @@ +paginatedRequest('v1/domains/' . $domainName . '/records', $page, $perPage, $filters); + $page->serializeWith(function ($item) { + return new Record($item); + }); + + return $page; + } + + /** + * @param $domainName + * @param $recordId + * @return UKFast\SDK\DDoSX\Entities\Record + */ + public function getById($domainName, $recordId) + { + $response = $this->request("GET", 'v1/domains/' . $domainName . '/records/' . $recordId); + $body = $this->decodeJson($response->getBody()->getContents()); + + return new Record($body->data); + } + + /** + * Delete a record + * + * @param Record $record + * @return bool + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function destroy(Record $record) + { + $response = $this->delete("v1/domains/".$record->domainName."/records/".$record->id); + + return $response->getStatusCode() == 204; + } +} \ No newline at end of file From 4645c68c4a69277ec3fb1ee87723f9ed5dafcc34 Mon Sep 17 00:00:00 2001 From: Martin Shaw Date: Mon, 20 Jan 2020 15:54:20 +0000 Subject: [PATCH 2/9] Fix case of property name domain_name in record entity --- src/DDoSX/RecordClient.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DDoSX/RecordClient.php b/src/DDoSX/RecordClient.php index b7b35571..e280b446 100644 --- a/src/DDoSX/RecordClient.php +++ b/src/DDoSX/RecordClient.php @@ -48,7 +48,7 @@ public function getById($domainName, $recordId) */ public function destroy(Record $record) { - $response = $this->delete("v1/domains/".$record->domainName."/records/".$record->id); + $response = $this->delete("v1/domains/".$record->domain_name."/records/".$record->id); return $response->getStatusCode() == 204; } From a574966dbad259d9d0dde35ce94f5d7a5c3c7a85 Mon Sep 17 00:00:00 2001 From: Martin Shaw Date: Mon, 20 Jan 2020 16:15:31 +0000 Subject: [PATCH 3/9] Add new lines --- src/DDoSX/Entities/Record.php | 2 +- src/DDoSX/RecordClient.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DDoSX/Entities/Record.php b/src/DDoSX/Entities/Record.php index 2d05e5ce..dd5cd9a3 100644 --- a/src/DDoSX/Entities/Record.php +++ b/src/DDoSX/Entities/Record.php @@ -16,4 +16,4 @@ class Record extends Entity { // -} \ No newline at end of file +} diff --git a/src/DDoSX/RecordClient.php b/src/DDoSX/RecordClient.php index e280b446..252a444b 100644 --- a/src/DDoSX/RecordClient.php +++ b/src/DDoSX/RecordClient.php @@ -52,4 +52,4 @@ public function destroy(Record $record) return $response->getStatusCode() == 204; } -} \ No newline at end of file +} From fe9e6788a668441a2d81af3e794157b30d1416ac Mon Sep 17 00:00:00 2001 From: Martin Shaw Date: Mon, 20 Jan 2020 16:31:50 +0000 Subject: [PATCH 4/9] Use BaseClient class aliasing to fix bug --- src/SSL/CertificateClient.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SSL/CertificateClient.php b/src/SSL/CertificateClient.php index ec4d6ed1..e7f10e62 100644 --- a/src/SSL/CertificateClient.php +++ b/src/SSL/CertificateClient.php @@ -2,12 +2,12 @@ namespace UKFast\SDK\SSL; -use UKFast\SDK\Client; +use UKFast\SDK\Client as BaseClient; use UKFast\SDK\Page; use UKFast\SDK\SSL\Entities\Certificate; use UKFast\SDK\SSL\Entities\CertificatePEM; -class CertificateClient extends Client +class CertificateClient extends BaseClient { protected $basePath = 'ssl/'; From 26dd595a3063282ba8276ab30431b5ad76d02227 Mon Sep 17 00:00:00 2001 From: Martin Shaw Date: Mon, 20 Jan 2020 16:36:08 +0000 Subject: [PATCH 5/9] Remove redundant changes to SSL CertificateClient --- src/SSL/CertificateClient.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SSL/CertificateClient.php b/src/SSL/CertificateClient.php index e7f10e62..ec4d6ed1 100644 --- a/src/SSL/CertificateClient.php +++ b/src/SSL/CertificateClient.php @@ -2,12 +2,12 @@ namespace UKFast\SDK\SSL; -use UKFast\SDK\Client as BaseClient; +use UKFast\SDK\Client; use UKFast\SDK\Page; use UKFast\SDK\SSL\Entities\Certificate; use UKFast\SDK\SSL\Entities\CertificatePEM; -class CertificateClient extends BaseClient +class CertificateClient extends Client { protected $basePath = 'ssl/'; From 4b7773585f7b824636b665bb68c367a0fa264572 Mon Sep 17 00:00:00 2001 From: Martin Shaw Date: Tue, 21 Jan 2020 15:54:02 +0000 Subject: [PATCH 6/9] Improve doc block comments --- src/DDoSX/RecordClient.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/DDoSX/RecordClient.php b/src/DDoSX/RecordClient.php index 97d76fb2..d87b541e 100644 --- a/src/DDoSX/RecordClient.php +++ b/src/DDoSX/RecordClient.php @@ -22,12 +22,12 @@ class RecordClient extends BaseClient ]; /** - * @param string $domainName - * @param int $page - * @param int $perPage + * Get paginated response of records + * + * @param int $page + * @param int $perPage * @param array $filters * @return int|\UKFast\SDK\Page - * @throws \GuzzleHttp\Exception\GuzzleException */ public function getPage($page = 1, $perPage = 20, $filters = []) { @@ -41,6 +41,8 @@ public function getPage($page = 1, $perPage = 20, $filters = []) } /** + * Get singular records by its Id + * * @param $domainName * @param $recordId * @return UKFast\SDK\DDoSX\Entities\Record @@ -68,6 +70,8 @@ public function destroy(Record $record) } /** + * Get paginated response of records associated with a domain name + * * @param $domainName * @param int $page * @param int $perPage From e92e9302947b72faed64633d443dd92364eed627 Mon Sep 17 00:00:00 2001 From: Martin Shaw Date: Tue, 21 Jan 2020 15:59:38 +0000 Subject: [PATCH 7/9] Add apiToFriendly field conversion to getById method in RecordClient --- src/DDoSX/RecordClient.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DDoSX/RecordClient.php b/src/DDoSX/RecordClient.php index d87b541e..0df2c2f0 100644 --- a/src/DDoSX/RecordClient.php +++ b/src/DDoSX/RecordClient.php @@ -45,14 +45,14 @@ public function getPage($page = 1, $perPage = 20, $filters = []) * * @param $domainName * @param $recordId - * @return UKFast\SDK\DDoSX\Entities\Record + * @return Record */ public function getById($domainName, $recordId) { $response = $this->request("GET", 'v1/domains/' . $domainName . '/records/' . $recordId); $body = $this->decodeJson($response->getBody()->getContents()); - return new Record($body->data); + return new Record($this->apiToFriendly($body, $this->requestMap)); } /** From ff6313e3ae6a3ef93685e826ca9a5618ed9df97e Mon Sep 17 00:00:00 2001 From: Martin Shaw Date: Tue, 21 Jan 2020 16:04:56 +0000 Subject: [PATCH 8/9] Revert unmerged changes from current master branch --- src/DDoSX/RecordClient.php | 39 ++++---------------------------------- 1 file changed, 4 insertions(+), 35 deletions(-) diff --git a/src/DDoSX/RecordClient.php b/src/DDoSX/RecordClient.php index 0df2c2f0..e60e9fce 100644 --- a/src/DDoSX/RecordClient.php +++ b/src/DDoSX/RecordClient.php @@ -22,16 +22,16 @@ class RecordClient extends BaseClient ]; /** - * Get paginated response of records - * - * @param int $page - * @param int $perPage + * @param int $page + * @param int $perPage * @param array $filters * @return int|\UKFast\SDK\Page + * @throws \GuzzleHttp\Exception\GuzzleException */ public function getPage($page = 1, $perPage = 20, $filters = []) { $filters = $this->friendlyToApi($filters, $this->requestMap); + $page = $this->paginatedRequest('v1/records', $page, $perPage, $filters); $page->serializeWith(function ($item) { return new Record($this->apiToFriendly($item, $this->requestMap)); @@ -41,37 +41,6 @@ public function getPage($page = 1, $perPage = 20, $filters = []) } /** - * Get singular records by its Id - * - * @param $domainName - * @param $recordId - * @return Record - */ - public function getById($domainName, $recordId) - { - $response = $this->request("GET", 'v1/domains/' . $domainName . '/records/' . $recordId); - $body = $this->decodeJson($response->getBody()->getContents()); - - return new Record($this->apiToFriendly($body, $this->requestMap)); - } - - /** - * Delete a record - * - * @param Record $record - * @return bool - * @throws \GuzzleHttp\Exception\GuzzleException - */ - public function destroy(Record $record) - { - $response = $this->delete("v1/domains/".$record->domain_name."/records/".$record->id); - - return $response->getStatusCode() == 204; - } - - /** - * Get paginated response of records associated with a domain name - * * @param $domainName * @param int $page * @param int $perPage From 26f6c3e4aaec9884229ee02909ceabcfc70fe528 Mon Sep 17 00:00:00 2001 From: Martin Shaw Date: Tue, 21 Jan 2020 16:06:21 +0000 Subject: [PATCH 9/9] Add class aliasing --- src/SafeDNS/ZoneClient.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SafeDNS/ZoneClient.php b/src/SafeDNS/ZoneClient.php index 873ba87d..8303885f 100644 --- a/src/SafeDNS/ZoneClient.php +++ b/src/SafeDNS/ZoneClient.php @@ -2,13 +2,13 @@ namespace UKFast\SDK\SafeDNS; -use UKFast\SDK\Client; +use UKFast\SDK\Client as BaseClient; use UKFast\SDK\Entities\ClientEntityInterface; use UKFast\SDK\Exception\UKFastException; use UKFast\SDK\Page; use UKFast\SDK\SafeDNS\Entities\Zone; -class ZoneClient extends Client implements ClientEntityInterface +class ZoneClient extends BaseClient implements ClientEntityInterface { protected $basePath = 'safedns/';