Skip to content

Commit

Permalink
fix d8-contrib-modules#35: only enforce per_page param for GET
Browse files Browse the repository at this point in the history
  • Loading branch information
dungahk authored Mar 2, 2021
1 parent 4bd00ba commit 3b166cd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/ApiEndpoints/CloudFlareAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,6 @@ public function __construct($apikey, $email, MockHandler $mock_handler = NULL) {
* Exception at the Http level.
*/
protected function makeRequest($request_type, $api_end_point, $request_params = []) {
// Default the number of pages returned by the API to MAX.
if (!isset($request_params['per_page'])) {
$request_params['per_page'] = self::MAX_ITEMS_PER_PAGE;
}
// This check seems superfluous. However, the Api only returns a http 400
// code. This proactive check gives us more information.
$is_api_key_valid = strlen($this->apikey) == CloudFlareAPI::API_KEY_LENGTH;
Expand All @@ -160,6 +156,10 @@ protected function makeRequest($request_type, $api_end_point, $request_params =
try {
switch ($request_type) {
case self::REQUEST_TYPE_GET:
// Default the number of pages returned by the API to MAX.
if (!isset($request_params['per_page'])) {
$request_params['per_page'] = self::MAX_ITEMS_PER_PAGE;
}
$this->lastHttpResponse = $this->client->get($api_end_point, ['query' => $request_params]);
break;

Expand Down

0 comments on commit 3b166cd

Please sign in to comment.