Skip to content

Commit

Permalink
Merge pull request #25 from aweingarten/50pluszones
Browse files Browse the repository at this point in the history
Minor fixes for 50+ zones listing
  • Loading branch information
aweingarten authored Nov 1, 2016
2 parents d0e0ccf + 9e31b2a commit 4bd00ba
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 15 deletions.
6 changes: 3 additions & 3 deletions src/ApiEndpoints/CloudFlareAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/ApiTypes/CloudFlareApiResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
}
}

Expand Down
12 changes: 8 additions & 4 deletions src/ApiTypes/Zone/Zone.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down
3 changes: 2 additions & 1 deletion tests/ApiEndpoints/ZoneApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]];
Expand Down
9 changes: 6 additions & 3 deletions tests/ApiEndpoints/ZoneSettingsApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}';

Expand Down Expand Up @@ -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]];
Expand Down Expand Up @@ -296,7 +298,8 @@ public function editZoneResponse(){
"page": 1,
"per_page": 20,
"count": 1,
"total_count": 2000
"total_count": 2000,
"total_pages": 100
}
}';

Expand Down

0 comments on commit 4bd00ba

Please sign in to comment.