Skip to content

Commit

Permalink
Merge pull request #53 from JerrySmidt/3.1.6.1
Browse files Browse the repository at this point in the history
Bug #41: Fix inconsistent method names
  • Loading branch information
JozefVerhoef authored Jul 7, 2022
2 parents c381a0b + 6473105 commit 979cc19
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions Helper/ApiClientHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function formatSupportedCountriesJs($countries=[])
*/
private function _prepareApiClient(): PostcodeApiClient
{
$isApiReady = $this->isPostCodeApiReady();
$isApiReady = $this->_isPostCodeApiReady();
if ($isApiReady !== true) {
return $isApiReady;
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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.')];
Expand Down
14 changes: 7 additions & 7 deletions Helper/PostcodeApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,23 @@ 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());
}

/**
* @see https://api.postcode.nl/documentation/international/v1/Autocomplete/getDetails
*/
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());
}

/**
* @see https://api.postcode.nl/documentation/international/v1/Autocomplete/getSupportedCountries
*/
public function internationalGetSupportedCountries(): array
{
return $this->performApiCall('international/v1/supported-countries', null);
return $this->_performApiCall('international/v1/supported-countries', null);
}

/**
Expand Down Expand Up @@ -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);
}

/**
Expand All @@ -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);
Expand Down

0 comments on commit 979cc19

Please sign in to comment.