From 6473105f0b5fbd52ad40a4ede1b4e5db035932a8 Mon Sep 17 00:00:00 2001 From: Jerry Smidt Date: Tue, 5 Jul 2022 16:30:22 +0200 Subject: [PATCH] Bug #41: Fix inconsistent method names --- Helper/ApiClientHelper.php | 10 +++++----- Helper/PostcodeApiClient.php | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Helper/ApiClientHelper.php b/Helper/ApiClientHelper.php index a03d861..1d4705a 100644 --- a/Helper/ApiClientHelper.php +++ b/Helper/ApiClientHelper.php @@ -106,7 +106,7 @@ public function formatSupportedCountriesJs($countries=[]) */ private function _prepareApiClient(): PostcodeApiClient { - $isApiReady = $this->isPostCodeApiReady(); + $isApiReady = $this->_isPostCodeApiReady(); if ($isApiReady !== true) { return $isApiReady; } @@ -139,7 +139,7 @@ public function getAddressAutocomplete(string $context, string $term): array $sessionStr = $this->request->getHeader($client::SESSION_HEADER_KEY); if (empty($sessionStr)) { - $sessionStr = $this->generateSessionString(); + $sessionStr = $this->_generateSessionString(); } $response = $client->internationalAutocomplete($context, $term, $sessionStr, $locale); @@ -172,7 +172,7 @@ public function getAddressDetails(string $context, string $dispatchCountry = '') $sessionStr = $this->request->getHeader($client::SESSION_HEADER_KEY); if (empty($sessionStr)) { - $sessionStr = $this->generateSessionString(); + $sessionStr = $this->_generateSessionString(); } $response = $client->internationalGetDetails($context, $sessionStr); @@ -397,12 +397,12 @@ private function _getSecret(): string /** - * isPostCodeApiReady function. + * _isPostCodeApiReady function. * * @access private * @return bool|array */ - private function isPostCodeApiReady() + private function _isPostCodeApiReady() { if (empty($this->getStoreConfig('postcodenl_api/general/enabled'))) { return ['message' => __('Postcode.eu API not enabled.')]; diff --git a/Helper/PostcodeApiClient.php b/Helper/PostcodeApiClient.php index 488d64b..d457192 100644 --- a/Helper/PostcodeApiClient.php +++ b/Helper/PostcodeApiClient.php @@ -75,7 +75,7 @@ public function __construct(string $key, string $secret) */ public function internationalAutocomplete(string $context, string $term, ?string $session = null, $language=""): array { - return $this->performApiCall('international/v1/autocomplete/' . rawurlencode($context) . '/' . rawurlencode($term) . '/' . rawurlencode($language), $session ?? $this->generateSessionString()); + return $this->_performApiCall('international/v1/autocomplete/' . rawurlencode($context) . '/' . rawurlencode($term) . '/' . rawurlencode($language), $session ?? $this->_generateSessionString()); } /** @@ -83,7 +83,7 @@ public function internationalAutocomplete(string $context, string $term, ?string */ public function internationalGetDetails(string $context, ?string $session = null): array { - return $this->performApiCall('international/v1/address/' . rawurlencode($context), $session ?? $this->generateSessionString()); + return $this->_performApiCall('international/v1/address/' . rawurlencode($context), $session ?? $this->_generateSessionString()); } /** @@ -91,7 +91,7 @@ public function internationalGetDetails(string $context, ?string $session = null */ public function internationalGetSupportedCountries(): array { - return $this->performApiCall('international/v1/supported-countries', null); + return $this->_performApiCall('international/v1/supported-countries', null); } /** @@ -123,12 +123,12 @@ public function dutchAddressByPostcode(string $postcode, int $houseNumber, ?stri { $urlParts[] = rawurlencode($houseNumberAddition); } - return $this->performApiCall(implode('/', $urlParts), null); + return $this->_performApiCall(implode('/', $urlParts), null); } public function accountInfo(): array { - return $this->performApiCall('account/v1/info', null); + return $this->_performApiCall('account/v1/info', null); } /** @@ -155,12 +155,12 @@ public function __destruct() curl_close($this->_curlHandler); } - protected function generateSessionString(): string + protected function _generateSessionString(): string { return bin2hex(random_bytes(8)); } - protected function performApiCall(string $path, ?string $session): array + protected function _performApiCall(string $path, ?string $session): array { $url = static::SERVER_URL . $path; curl_setopt($this->_curlHandler, CURLOPT_URL, $url);