From 3b166cdb2c283cb6f09c6c40f86864581298149e Mon Sep 17 00:00:00 2001 From: Emerson Jair Date: Tue, 2 Mar 2021 19:04:18 +0000 Subject: [PATCH] fix #35: only enforce per_page param for GET --- src/ApiEndpoints/CloudFlareAPI.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ApiEndpoints/CloudFlareAPI.php b/src/ApiEndpoints/CloudFlareAPI.php index da7b44a..19f40cc 100644 --- a/src/ApiEndpoints/CloudFlareAPI.php +++ b/src/ApiEndpoints/CloudFlareAPI.php @@ -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; @@ -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;