diff --git a/src/ApiEndpoints/CloudFlareAPI.php b/src/ApiEndpoints/CloudFlareAPI.php index 484cf0d..da7b44a 100644 --- a/src/ApiEndpoints/CloudFlareAPI.php +++ b/src/ApiEndpoints/CloudFlareAPI.php @@ -262,12 +262,12 @@ protected function makeListingRequest($request_type, $api_end_point, $request_pa /* @var \CloudFlarePhpSdk\ApiTypes\CloudFlareApiResponse $initial_request */ $initial_request = $this->makeRequest($request_type, $api_end_point, $request_params); $responses[] = $initial_request; + $num_pages = $initial_request->getNumPages(); if ($get_all_pages) { - $num_pages = $initial_request->getNumPages(); for ($i = 1; $i < $num_pages; $i++) { - $request_params['page'] = $i; - $current_request = makeRequest($request_type, $api_end_point, $request_params); + $request_params['page'] = $i + 1; + $current_request = $this->makeRequest($request_type, $api_end_point, $request_params); $responses[] = $current_request; } } diff --git a/src/ApiTypes/CloudFlareApiResponse.php b/src/ApiTypes/CloudFlareApiResponse.php index 60fb383..5a96236 100644 --- a/src/ApiTypes/CloudFlareApiResponse.php +++ b/src/ApiTypes/CloudFlareApiResponse.php @@ -160,12 +160,12 @@ public function __construct($json_response) { $this->errors = $response['errors']; $this->messages = $response['messages']; - $has_pagination_date = isset($response['total_count']); - if ($has_pagination_date) { - $this->totalCount = $response['total_count']; + $has_pagination_data = isset($response['result_info']['total_count']); + if ($has_pagination_data) { + $this->totalCount = $response['result_info']['total_count']; $this->page = $response['result_info']['page']; $this->resultsPerPage = $response['result_info']['per_page']; - $this->numPages = $response['result_info']['count']; + $this->numPages = $response['result_info']['total_pages']; } } diff --git a/src/ApiTypes/Zone/Zone.php b/src/ApiTypes/Zone/Zone.php index fc8e93a..c181b16 100644 --- a/src/ApiTypes/Zone/Zone.php +++ b/src/ApiTypes/Zone/Zone.php @@ -39,10 +39,14 @@ public function __construct(array $cloudflare_zone_settings) { $this->paused = $cloudflare_zone_settings['paused']; $this->type = $cloudflare_zone_settings['type']; $this->developmentMode = $cloudflare_zone_settings['development_mode']; - $this->nameServers = $cloudflare_zone_settings['name_servers']; - $this->originalNameServers = $cloudflare_zone_settings['original_name_servers']; - $this->originalRegistrar = $cloudflare_zone_settings['original_registrar']; - $this->originalDnshost = $cloudflare_zone_settings['original_dnshost']; + + if (isset($cloudflare_zone_settings['name_servers'])) { + $this->nameServers = $cloudflare_zone_settings['name_servers']; + $this->originalNameServers = $cloudflare_zone_settings['original_name_servers']; + $this->originalRegistrar = $cloudflare_zone_settings['original_registrar']; + $this->originalDnshost = $cloudflare_zone_settings['original_dnshost']; + } + $this->modifiedOn = $cloudflare_zone_settings['modified_on']; $this->createdOn = $cloudflare_zone_settings['created_on']; $this->owner = $cloudflare_zone_settings['owner']; diff --git a/tests/ApiEndpoints/ZoneApiTest.php b/tests/ApiEndpoints/ZoneApiTest.php index f46a260..181803e 100644 --- a/tests/ApiEndpoints/ZoneApiTest.php +++ b/tests/ApiEndpoints/ZoneApiTest.php @@ -148,7 +148,8 @@ public function getZoneDataListing(){ "page": 1, "per_page": 20, "count": 1, - "total_count": 2000 + "total_count": 5, + "total_pages": 1 } }'; return [[$json]]; diff --git a/tests/ApiEndpoints/ZoneSettingsApiTest.php b/tests/ApiEndpoints/ZoneSettingsApiTest.php index d8503e0..62e20de 100644 --- a/tests/ApiEndpoints/ZoneSettingsApiTest.php +++ b/tests/ApiEndpoints/ZoneSettingsApiTest.php @@ -216,7 +216,8 @@ public function zoneSettingsInfoResponse($success, $errors, $messages){ "page": 1, "per_page": 20, "count": 1, - "total_count": 2000 + "total_count": 2000, + "total_pages": 100 } }'; @@ -260,7 +261,8 @@ public function zoneSettingsResponse(){ "page": 1, "per_page": 20, "count": 1, - "total_count": 2000 + "total_count": 2000, + "total_pages": 100 } }'; return [[$json]]; @@ -296,7 +298,8 @@ public function editZoneResponse(){ "page": 1, "per_page": 20, "count": 1, - "total_count": 2000 + "total_count": 2000, + "total_pages": 100 } }';