Skip to content

Commit c806649

Browse files
committed
Merge branch 'develop'
2 parents d5f9dab + 18c2bf5 commit c806649

File tree

62 files changed

+1767
-925
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1767
-925
lines changed

Block/Adminhtml/Config/Credentials/Button.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function render(AbstractElement $element)
6464
*/
6565
public function getSignUpLabel()
6666
{
67-
return __('Sign Up For A Paid Account');
67+
return __('No credentials yet? Sign up for a plan');
6868
}
6969

7070
/**

Block/Adminhtml/Config/Support/Tab.php

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
* @copyright Copyright (c) Total Internet Group B.V. https://tig.nl/copyright
3030
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
3131
*/
32+
3233
namespace TIG\Postcode\Block\Adminhtml\Config\Support;
3334

3435
use Magento\Framework\View\Element\Template;
@@ -38,9 +39,9 @@
3839

3940
class Tab extends Template implements RendererInterface
4041
{
41-
const MODULE_NAME = 'TIG_Postcode';
42+
const MODULE_NAME = 'TIG_Postcode';
4243

43-
const EXTENSION_VERSION = '1.6.0';
44+
const EXTENSION_VERSION = '1.7.0';
4445

4546
// @codingStandardsIgnoreLine
4647
protected $_template = 'TIG_Postcode::config/support/tab.phtml';
@@ -81,19 +82,29 @@ public function render(AbstractElement $element)
8182
/**
8283
* Retrieve the version number from the database.
8384
*
84-
* @return bool|false|string
85+
* @return string
8586
*/
86-
public function getVersionNumber()
87+
public function getVersionNumber(): string
8788
{
8889
return static::EXTENSION_VERSION;
8990
}
9091

92+
/**
93+
* Get Postcode Service used API versions
94+
*
95+
* @return array
96+
*/
97+
public function getAPIVersionNumbers(): array
98+
{
99+
return $this->moduleConfiguration->getAPIVersions();
100+
}
101+
91102
/**
92103
* Get supported magento version
93104
*
94105
* @return string
95106
*/
96-
public function getSupportedMagentoVersions()
107+
public function getSupportedMagentoVersions(): string
97108
{
98109
return $this->moduleConfiguration->getSupportedMagentoVersions();
99110
}

Config/CheckoutConfiguration/ActionUrl.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
* @copyright Copyright (c) Total Internet Group B.V. https://tig.nl/copyright
3030
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
3131
*/
32+
3233
namespace TIG\Postcode\Config\CheckoutConfiguration;
3334

3435
use Magento\Framework\UrlInterface;
@@ -52,14 +53,17 @@ public function __construct(
5253
}
5354

5455
/**
55-
* Get value and return NL, Belgium and German postcode URLs
56+
* Get value and return NL, Belgium, German, France postcode URLs
5657
*
5758
* @return array
5859
*/
5960
public function getValue()
6061
{
6162
return [
62-
'postcode_service' => $this->urlBuilder->getUrl('postcode/address/service', ['_secure' => true]),
63+
'postcode_service' => $this->urlBuilder->getUrl(
64+
'postcode/address/service',
65+
['_secure' => true]
66+
),
6367
'postcode_be_getpostcode' => $this->urlBuilder->getUrl(
6468
'postcode/address/service/be/getpostcode',
6569
['_secure' => true]
@@ -75,6 +79,14 @@ public function getValue()
7579
'postcode_de_getstreet' => $this->urlBuilder->getUrl(
7680
'postcode/address/service/de/getstreet',
7781
['_secure' => true]
82+
),
83+
'postcode_fr_getpostcode' => $this->urlBuilder->getUrl(
84+
'postcode/address/service/fr/getpostcode',
85+
['_secure' => true]
86+
),
87+
'postcode_fr_getstreet' => $this->urlBuilder->getUrl(
88+
'postcode/address/service/fr/getstreet',
89+
['_secure' => true]
7890
)
7991
];
8092
}

Config/Provider/ApiConfiguration.php

Lines changed: 44 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@
3434

3535
class ApiConfiguration extends AbstractConfigProvider
3636
{
37-
public const XPATH_API_BASE = 'tig_postcode/api/base';
37+
public const XPATH_API_NL_BASE = 'tig_postcode/api/base';
3838

39-
public const XPATH_API_VERSION = 'tig_postcode/api/version';
39+
public const XPATH_API_NL_POSTCODE_VERSION = 'tig_postcode/api/version';
4040

41-
public const XPATH_API_TYPE = 'tig_postcode/api/type';
41+
public const XPATH_API_NL_TYPE = 'tig_postcode/api/type';
4242

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

@@ -52,6 +52,12 @@ class ApiConfiguration extends AbstractConfigProvider
5252

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

55+
public const XPATH_API_FR_BASE = 'tig_postcode/api_fr/base';
56+
57+
public const XPATH_API_FR_POSTCODE_VERSION = 'tig_postcode/api_fr/postcode_version';
58+
59+
public const XPATH_API_FR_STREET_VERSION = 'tig_postcode/api_fr/street_version';
60+
5561
/**
5662
* Get base Uri
5763
*
@@ -86,6 +92,19 @@ public function getDEBaseUri(string $endpoint): string
8692
return $this->getBase('DE') . '/' . $this->getVersion('DE', $endpoint) . '/';
8793
}
8894

95+
/**
96+
* Get France base Uri
97+
*
98+
* @param string $endpoint
99+
*
100+
* @return string
101+
*/
102+
public function getFRBaseUri(string $endpoint): string
103+
{
104+
return $this->getBase('FR') . '/' . $this->getVersion('FR', $endpoint) . '/';
105+
}
106+
107+
89108
/**
90109
* Get base path via country and store ID
91110
*
@@ -96,15 +115,12 @@ public function getDEBaseUri(string $endpoint): string
96115
*/
97116
public function getBase(string $country = 'NL', int|string $store = null): mixed
98117
{
99-
$xpath = static::XPATH_API_BASE; // NL
100-
101-
if ($country == 'BE') { // BE
102-
$xpath = static::XPATH_API_BE_BASE;
103-
}
104-
105-
if ($country == 'DE') { // DE
106-
$xpath = static::XPATH_API_DE_BASE;
107-
}
118+
$xpath = match ($country) {
119+
'BE' => static::XPATH_API_BE_BASE,
120+
'DE' => static::XPATH_API_DE_BASE,
121+
'FR' => static::XPATH_API_FR_BASE,
122+
default => static::XPATH_API_NL_BASE,
123+
};
108124

109125
return $this->getConfigFromXpath($xpath, $store);
110126
}
@@ -120,29 +136,21 @@ public function getBase(string $country = 'NL', int|string $store = null): mixed
120136
*/
121137
public function getVersion(string $country = 'NL', string $endpoint = null, int|string $store = null): mixed
122138
{
123-
$xpath = static::XPATH_API_VERSION; // NL
124-
125-
if ($country == 'BE') {
126-
switch ($endpoint) {
127-
case 'zipcode-find/':
128-
$xpath = static::XPATH_API_BE_POSTCODE_VERSION;
129-
break;
130-
case 'street-find/':
131-
$xpath = static::XPATH_API_BE_STREET_VERSION;
132-
break;
133-
}
134-
}
135-
136-
if ($country == 'DE') {
137-
switch ($endpoint) {
138-
case 'zipcode-find/':
139-
$xpath = static::XPATH_API_DE_POSTCODE_VERSION;
140-
break;
141-
case 'street-find/':
142-
$xpath = static::XPATH_API_DE_STREET_VERSION;
143-
break;
144-
}
145-
}
139+
$xpath = match ($country) {
140+
'BE' => match ($endpoint) {
141+
'zipcode-find/' => static::XPATH_API_BE_POSTCODE_VERSION,
142+
'street-find/' => static::XPATH_API_BE_STREET_VERSION,
143+
},
144+
'DE' => match ($endpoint) {
145+
'zipcode-find/' => static::XPATH_API_DE_POSTCODE_VERSION,
146+
'street-find/' => static::XPATH_API_DE_STREET_VERSION,
147+
},
148+
'FR' => match ($endpoint) {
149+
'zipcode-find/' => static::XPATH_API_FR_POSTCODE_VERSION,
150+
'street-find/' => static::XPATH_API_FR_STREET_VERSION,
151+
},
152+
default => static::XPATH_API_NL_POSTCODE_VERSION,
153+
};
146154

147155
return $this->getConfigFromXpath($xpath, $store);
148156
}
@@ -156,6 +164,6 @@ public function getVersion(string $country = 'NL', string $endpoint = null, int|
156164
*/
157165
public function getType(int|string $store = null): mixed
158166
{
159-
return $this->getConfigFromXpath(static::XPATH_API_TYPE, $store);
167+
return $this->getConfigFromXpath(static::XPATH_API_NL_TYPE, $store);
160168
}
161169
}

Config/Provider/ModuleConfiguration.php

Lines changed: 48 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,21 @@ class ModuleConfiguration extends AbstractConfigProvider
4242

4343
public const XPATH_SUPPORTED_MAGENTO_VERSION = 'tig_postcode/supported_magento_version';
4444

45-
public const XPATH_NETHERLANDS_CHECK = 'tig_postcode/countries/enable_nl_check';
45+
public const XPATH_NL_ENABLED = 'tig_postcode/countries/enable_nl_check';
4646

47-
public const XPATH_BELGIUM_CHECK = 'tig_postcode/countries/enable_be_check';
47+
public const XPATH_BE_ENABLED = 'tig_postcode/countries/enable_be_check';
4848

49-
public const XPATH_GERMANY_CHECK = 'tig_postcode/countries/enable_de_check';
49+
public const XPATH_DE_ENABLED = 'tig_postcode/countries/enable_de_check';
50+
51+
public const XPATH_FR_ENABLED = 'tig_postcode/countries/enable_fr_check';
52+
53+
public const XPATH_NL_API_VERSION = 'tig_postcode/api/version';
54+
55+
public const XPATH_BE_API_VERSION = 'tig_postcode/api_be/postcode_version';
56+
57+
public const XPATH_DE_API_VERSION = 'tig_postcode/api_de/postcode_version';
58+
59+
public const XPATH_FR_API_VERSION = 'tig_postcode/api_fr/postcode_version';
5060

5161
/**
5262
* Should return on of these values
@@ -140,51 +150,53 @@ public function getSupportedMagentoVersions($store = null)
140150
}
141151

142152
/**
143-
* Get the Checkout compatability via store ID
144-
*
145-
* @param string|int|null $store
146-
*
147-
* @return mixed
148-
* @deprecated
149-
*/
150-
public function getCheckoutCompatibility($store = null)
151-
{
152-
return $this->getConfigFromXpath(static::XPATH_CHECKOUT_COMPATIBILITY, $store);
153-
}
154-
155-
/**
156-
* Check if NL is enabled via store ID
153+
* Check if a country is enabled via store ID
157154
*
155+
* @param string $country
158156
* @param string|int|null $store
159157
*
160158
* @return bool
161159
*/
162-
public function isNLCheckEnabled($store = null): bool
160+
public function isCountryCheckEnabled(string $country, $store = null): bool
163161
{
164-
return (bool) $this->getConfigFromXpath(static::XPATH_NETHERLANDS_CHECK, $store);
162+
$countryXpaths = [
163+
'NL' => static::XPATH_NL_ENABLED,
164+
'BE' => static::XPATH_BE_ENABLED,
165+
'DE' => static::XPATH_DE_ENABLED,
166+
'FR' => static::XPATH_FR_ENABLED,
167+
];
168+
169+
return isset($countryXpaths[$country]) && $this->getConfigFromXpath($countryXpaths[$country], $store);
165170
}
166171

167172
/**
168-
* Check if BE is enabled via store ID
169-
*
170-
* @param string|int|null $store
173+
* Return the specific used Postcode Service API version for each country
171174
*
172-
* @return bool
175+
* @return array
173176
*/
174-
public function isBECheckEnabled($store = null): bool
177+
public function getAPIVersions(): array
175178
{
176-
return (bool) $this->getConfigFromXpath(static::XPATH_BELGIUM_CHECK, $store);
177-
}
179+
$countryXpaths = [
180+
'NL' => static::XPATH_NL_API_VERSION,
181+
'BE' => static::XPATH_BE_API_VERSION,
182+
'DE' => static::XPATH_DE_API_VERSION,
183+
'FR' => static::XPATH_FR_API_VERSION,
184+
];
185+
186+
$countryNames = [
187+
'NL' => 'Netherlands',
188+
'BE' => 'Belgium',
189+
'DE' => 'Germany',
190+
'FR' => 'France',
191+
];
192+
193+
$result = [];
194+
195+
foreach ($countryXpaths as $country => $xpath) {
196+
$countryName = $countryNames[$country] ?? $country;
197+
$result[$countryName] = str_ireplace('v', '', $this->getConfigFromXpath($xpath));
198+
}
178199

179-
/**
180-
* Check if DE is enabled via store ID
181-
*
182-
* @param string|int|null $store
183-
*
184-
* @return bool
185-
*/
186-
public function isDECheckEnabled($store = null): bool
187-
{
188-
return (bool) $this->getConfigFromXpath(static::XPATH_GERMANY_CHECK, $store);
200+
return $result;
189201
}
190202
}

Config/Provider/ParserConfiguration.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,26 @@
2929
* @copyright Copyright (c) Total Internet Group B.V. https://tig.nl/copyright
3030
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
3131
*/
32+
3233
namespace TIG\Postcode\Config\Provider;
3334

3435
class ParserConfiguration extends AbstractConfigProvider
3536
{
3637
public const XPATH_STREETMERGING = 'tig_postcode/configuration/fieldparsing_street';
38+
3739
public const XPATH_HOUSENUMBERMERGING = 'tig_postcode/configuration/fieldparsing_housenumber';
40+
3841
public const XPATH_ADDITIONMERGING = 'tig_postcode/configuration/fieldparsing_addition';
3942

40-
public const DEFAULT_PARSELINE = 1;
43+
public const DEFAULT_PARSELINE = 1;
44+
45+
public const PARSE_TYPE_ONE = 1;
46+
47+
public const PARSE_TYPE_TWO = 2;
48+
49+
public const PARSE_TYPE_THREE = 3;
4150

42-
public const PARSE_TYPE_ONE = 1;
43-
public const PARSE_TYPE_TWO = 2;
44-
public const PARSE_TYPE_THREE = 3;
45-
public const PARSE_TYPE_FOUR = 4;
51+
public const PARSE_TYPE_FOUR = 4;
4652

4753
/**
4854
* @var int[]

0 commit comments

Comments
 (0)