Skip to content

Commit

Permalink
Merge pull request #80 from postcodeservice/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
schldwcht authored Oct 20, 2023
2 parents 82ce8f6 + 26200a6 commit d5f9dab
Show file tree
Hide file tree
Showing 88 changed files with 2,336 additions and 1,123 deletions.
2 changes: 1 addition & 1 deletion .github/issue_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ Issues with outdated version will be rejected.

### TIG support

- Please ask your question in English to ensure that your issue can help other people internationally. Nevertheless we will respond in English.
- Please ask your question in English to ensure that your issue can help other people internationally. Nevertheless, we will respond in English.
6 changes: 3 additions & 3 deletions Block/Adminhtml/Config/Credentials/Button.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Button extends Template implements RendererInterface
{
public const MODULE_NAME = 'TIG_Postcode';

public const CREDENTIALS_URL = 'https://postcodeservice.nl';
public const CREDENTIALS_URL = 'https://postcodeservice.com/#compare-packages';

// @codingStandardsIgnoreLine
protected $_template = 'TIG_Postcode::config/credentials/button.phtml';
Expand All @@ -62,9 +62,9 @@ public function render(AbstractElement $element)
*
* @return \Magento\Framework\Phrase
*/
public function getLabel()
public function getSignUpLabel()
{
return __('Request Credentails');
return __('Sign Up For A Paid Account');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Block/Adminhtml/Config/Support/Tab.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Tab extends Template implements RendererInterface
{
const MODULE_NAME = 'TIG_Postcode';

const EXTENSION_VERSION = '1.5.5';
const EXTENSION_VERSION = '1.6.0';

// @codingStandardsIgnoreLine
protected $_template = 'TIG_Postcode::config/support/tab.phtml';
Expand Down
10 changes: 9 additions & 1 deletion Config/CheckoutConfiguration/ActionUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function __construct(
}

/**
* Get value and return belgium postcode URLs
* Get value and return NL, Belgium and German postcode URLs
*
* @return array
*/
Expand All @@ -67,6 +67,14 @@ public function getValue()
'postcode_be_getstreet' => $this->urlBuilder->getUrl(
'postcode/address/service/be/getstreet',
['_secure' => true]
),
'postcode_de_getpostcode' => $this->urlBuilder->getUrl(
'postcode/address/service/de/getpostcode',
['_secure' => true]
),
'postcode_de_getstreet' => $this->urlBuilder->getUrl(
'postcode/address/service/de/getstreet',
['_secure' => true]
)
];
}
Expand Down
95 changes: 69 additions & 26 deletions Config/Provider/ApiConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,37 @@
* @copyright Copyright (c) Total Internet Group B.V. https://tig.nl/copyright
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
*/

namespace TIG\Postcode\Config\Provider;

class ApiConfiguration extends AbstractConfigProvider
{
public const XPATH_API_BASE = 'tig_postcode/api/base';
public const XPATH_API_VERSION = 'tig_postcode/api/version';
public const XPATH_API_TYPE = 'tig_postcode/api/type';
public const XPATH_API_BASE = 'tig_postcode/api/base';

public const XPATH_API_VERSION = 'tig_postcode/api/version';

public const XPATH_API_TYPE = 'tig_postcode/api/type';

public const XPATH_API_BE_BASE = 'tig_postcode/api_be/base';

public const XPATH_API_BE_POSTCODE_VERSION = 'tig_postcode/api_be/postcode_version';

public const XPATH_API_BE_STREET_VERSION = 'tig_postcode/api_be/street_version';

public const XPATH_API_BE_BASE = 'tig_postcode/api_be/base';
public const XPATH_API_BE_POSTCODE_VERSION = 'tig_postcode/api_be/postcode_version';
public const XPATH_API_BE_STREET_VERSION = 'tig_postcode/api_be/street_version';
public const XPATH_API_DE_BASE = 'tig_postcode/api_de/base';

public const XPATH_API_DE_POSTCODE_VERSION = 'tig_postcode/api_de/postcode_version';

public const XPATH_API_DE_STREET_VERSION = 'tig_postcode/api_de/street_version';

/**
* Get base Uri
*
* @return string
*/
public function getBaseUri()
public function getBaseUri(): string
{
return $this->getBase() . '/' . $this->getVersion() . '/' . $this->getType() . '/';
return $this->getBase() . '/' . $this->getVersion() . '/';
}

/**
Expand All @@ -58,47 +69,79 @@ public function getBaseUri()
*
* @return string
*/
public function getBeBaseUri($endpoint)
public function getBEBaseUri(string $endpoint): string
{
return $this->getBase('BE') . '/' . $this->getVersion('BE', $endpoint) . '/';
}

/**
* Get German base Uri
*
* @param string $endpoint
*
* @return string
*/
public function getDEBaseUri(string $endpoint): string
{
return $this->getBase('DE') . '/' . $this->getVersion('DE', $endpoint) . '/';
}

/**
* Get base path via country and store ID
*
* @param string $country
* @param string|int|null $store
* @param string $country
* @param int|string|null $store
*
* @return mixed
*/
public function getBase($country = 'NL', $store = null)
public function getBase(string $country = 'NL', int|string $store = null): mixed
{
$xpath = static::XPATH_API_BASE;
if ($country == 'BE') {
$xpath = static::XPATH_API_BASE; // NL

if ($country == 'BE') { // BE
$xpath = static::XPATH_API_BE_BASE;
}

if ($country == 'DE') { // DE
$xpath = static::XPATH_API_DE_BASE;
}

return $this->getConfigFromXpath($xpath, $store);
}

/**
* Versioning for BE is not live yet. Implement this function in getBeBaseUri when this goes live.
* Versioning handling for multiple countries
*
* @param string $country
* @param string|null $endpoint
* @param string|int|null $store
* @param string $country
* @param string|null $endpoint
* @param int|string|null $store
*
* @return mixed
*/
public function getVersion($country = 'NL', $endpoint = null, $store = null)
public function getVersion(string $country = 'NL', string $endpoint = null, int|string $store = null): mixed
{
$xpath = static::XPATH_API_VERSION;
if ($country == 'BE' && $endpoint == 'postcode-find/') {
$xpath = static::XPATH_API_BE_POSTCODE_VERSION;
$xpath = static::XPATH_API_VERSION; // NL

if ($country == 'BE') {
switch ($endpoint) {
case 'zipcode-find/':
$xpath = static::XPATH_API_BE_POSTCODE_VERSION;
break;
case 'street-find/':
$xpath = static::XPATH_API_BE_STREET_VERSION;
break;
}
}

if ($country == 'BE' && $endpoint == 'street-find/') {
$xpath = static::XPATH_API_BE_STREET_VERSION;
if ($country == 'DE') {
switch ($endpoint) {
case 'zipcode-find/':
$xpath = static::XPATH_API_DE_POSTCODE_VERSION;
break;
case 'street-find/':
$xpath = static::XPATH_API_DE_STREET_VERSION;
break;
}
}

return $this->getConfigFromXpath($xpath, $store);
Expand All @@ -107,11 +150,11 @@ public function getVersion($country = 'NL', $endpoint = null, $store = null)
/**
* Get type via store ID
*
* @param string|int|null $store
* @param int|string|null $store
*
* @return mixed
*/
public function getType($store = null)
public function getType(int|string $store = null): mixed
{
return $this->getConfigFromXpath(static::XPATH_API_TYPE, $store);
}
Expand Down
2 changes: 1 addition & 1 deletion Config/Provider/ClientConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function getClientId($store = null)
* @return string
* @throws \Exception
*/
public function getApiKey($store = null)
public function getSecureCode($store = null)
{
$modusXpath = $this->getModusXpath(static::XPATH_CONFIGURATION_API_KEY, $store);
$key = $this->getConfigFromXpath($modusXpath, $store);
Expand Down
38 changes: 29 additions & 9 deletions Config/Provider/ModuleConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,25 @@
* @copyright Copyright (c) Total Internet Group B.V. https://tig.nl/copyright
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
*/

namespace TIG\Postcode\Config\Provider;

class ModuleConfiguration extends AbstractConfigProvider
{
public const XPATH_CONFIGURATION_MODUS = 'tig_postcode/configuration/modus';

public const XPATH_CHECKOUT_COMPATIBILITY = 'tig_postcode/configuration/checkout_compatible';

public const XPATH_MODULE_STABILITY = 'tig_postcode/stability';

public const XPATH_SUPPORTED_MAGENTO_VERSION = 'tig_postcode/supported_magento_version';

public const XPATH_NETHERLANDS_CHECK = 'tig_postcode/countries/enable_nl_check';

public const XPATH_BELGIUM_CHECK = 'tig_postcode/countries/enable_be_check';

public const XPATH_GERMANY_CHECK = 'tig_postcode/countries/enable_de_check';

/**
* Should return on of these values
* '1' => live ||
Expand All @@ -50,7 +58,7 @@ class ModuleConfiguration extends AbstractConfigProvider
*
* @return mixed
*/
public function getModus($store = null)
public function getModus(int|string|null $store = null)
{
if (!$this->isModuleOutputEnabled()) {
return '0';
Expand All @@ -66,7 +74,7 @@ public function getModus($store = null)
*
* @return bool
*/
public function isModusLive($store = null)
public function isModusLive(int|string|null $store = null): bool
{
if ($this->getModus($store) == '1') {
return true;
Expand All @@ -78,11 +86,11 @@ public function isModusLive($store = null)
/**
* Checks if the extension is on status test via store ID
*
* @param string|int|null $store
* @param int|string|null $store
*
* @return bool
*/
public function isModusTest($store = null)
public function isModusTest(int|string|null $store = null): bool
{
if ($this->getModus($store) == '2') {
return true;
Expand All @@ -98,9 +106,9 @@ public function isModusTest($store = null)
*
* @return bool
*/
public function isModusOff($store = null)
public function isModusOff(int|string|null $store = null): bool
{
if ($this->getModus($store) == '0' || false == $this->getModus()) {
if ($this->getModus($store) == '0' || empty($this->getModus())) {
return true;
}

Expand All @@ -114,7 +122,7 @@ public function isModusOff($store = null)
*
* @return string
*/
public function getStability($store = null)
public function getStability(int|string|null $store = null)
{
return $this->getConfigFromXpath(static::XPATH_MODULE_STABILITY, $store);
}
Expand Down Expand Up @@ -151,7 +159,7 @@ public function getCheckoutCompatibility($store = null)
*
* @return bool
*/
public function isNLCheckEnabled($store = null)
public function isNLCheckEnabled($store = null): bool
{
return (bool) $this->getConfigFromXpath(static::XPATH_NETHERLANDS_CHECK, $store);
}
Expand All @@ -163,8 +171,20 @@ public function isNLCheckEnabled($store = null)
*
* @return bool
*/
public function isBECheckEnabled($store = null)
public function isBECheckEnabled($store = null): bool
{
return (bool) $this->getConfigFromXpath(static::XPATH_BELGIUM_CHECK, $store);
}

/**
* Check if DE is enabled via store ID
*
* @param string|int|null $store
*
* @return bool
*/
public function isDECheckEnabled($store = null): bool
{
return (bool) $this->getConfigFromXpath(static::XPATH_GERMANY_CHECK, $store);
}
}
2 changes: 1 addition & 1 deletion Config/Source/Modus.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Modus implements ArrayInterface
*
* @return array
*/
public function toOptionArray()
public function toOptionArray(): array
{
// @codingStandardsIgnoreStart
$options = [
Expand Down
2 changes: 1 addition & 1 deletion Config/Source/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Parser implements ArrayInterface
*
* @return array
*/
public function toOptionArray()
public function toOptionArray(): array
{
// @codingStandardsIgnoreStart
$options = [
Expand Down
Loading

0 comments on commit d5f9dab

Please sign in to comment.