Skip to content

Commit 5e33e0b

Browse files
committed
RC2
1 parent 418c2a8 commit 5e33e0b

Some content is hidden

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

43 files changed

+992
-128
lines changed

Config/CheckoutConfiguration/ActionUrl.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function __construct(
5252
}
5353

5454
/**
55-
* Get value and return belgium postcode URLs
55+
* Get value and return NL, Belgium and German postcode URLs
5656
*
5757
* @return array
5858
*/
@@ -67,6 +67,14 @@ public function getValue()
6767
'postcode_be_getstreet' => $this->urlBuilder->getUrl(
6868
'postcode/address/service/be/getstreet',
6969
['_secure' => true]
70+
),
71+
'postcode_de_getpostcode' => $this->urlBuilder->getUrl(
72+
'postcode/address/service/de/getpostcode',
73+
['_secure' => true]
74+
),
75+
'postcode_de_getstreet' => $this->urlBuilder->getUrl(
76+
'postcode/address/service/de/getstreet',
77+
['_secure' => true]
7078
)
7179
];
7280
}

Config/Provider/ApiConfiguration.php

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ class ApiConfiguration extends AbstractConfigProvider
4646

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

49+
public const XPATH_API_DE_BASE = 'tig_postcode/api_de/base';
50+
51+
public const XPATH_API_DE_POSTCODE_VERSION = 'tig_postcode/api_de/postcode_version';
52+
53+
public const XPATH_API_DE_STREET_VERSION = 'tig_postcode/api_de/street_version';
54+
4955
/**
5056
* Get base Uri
5157
*
@@ -68,6 +74,18 @@ public function getBEBaseUri(string $endpoint): string
6874
return $this->getBase('BE') . '/' . $this->getVersion('BE', $endpoint) . '/';
6975
}
7076

77+
/**
78+
* Get German base Uri
79+
*
80+
* @param string $endpoint
81+
*
82+
* @return string
83+
*/
84+
public function getDEBaseUri(string $endpoint): string
85+
{
86+
return $this->getBase('DE') . '/' . $this->getVersion('DE', $endpoint) . '/';
87+
}
88+
7189
/**
7290
* Get base path via country and store ID
7391
*
@@ -78,11 +96,16 @@ public function getBEBaseUri(string $endpoint): string
7896
*/
7997
public function getBase(string $country = 'NL', int|string $store = null): mixed
8098
{
81-
$xpath = static::XPATH_API_BASE;
82-
if ($country == 'BE') {
99+
$xpath = static::XPATH_API_BASE; // NL
100+
101+
if ($country == 'BE') { // BE
83102
$xpath = static::XPATH_API_BE_BASE;
84103
}
85104

105+
if ($country == 'DE') { // DE
106+
$xpath = static::XPATH_API_DE_BASE;
107+
}
108+
86109
return $this->getConfigFromXpath($xpath, $store);
87110
}
88111

@@ -97,7 +120,7 @@ public function getBase(string $country = 'NL', int|string $store = null): mixed
97120
*/
98121
public function getVersion(string $country = 'NL', string $endpoint = null, int|string $store = null): mixed
99122
{
100-
$xpath = static::XPATH_API_VERSION;
123+
$xpath = static::XPATH_API_VERSION; // NL
101124

102125
if ($country == 'BE') {
103126
switch ($endpoint) {
@@ -110,6 +133,17 @@ public function getVersion(string $country = 'NL', string $endpoint = null, int|
110133
}
111134
}
112135

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+
}
146+
113147
return $this->getConfigFromXpath($xpath, $store);
114148
}
115149

Config/Provider/ModuleConfiguration.php

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,25 @@
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 ModuleConfiguration extends AbstractConfigProvider
3536
{
3637
public const XPATH_CONFIGURATION_MODUS = 'tig_postcode/configuration/modus';
38+
3739
public const XPATH_CHECKOUT_COMPATIBILITY = 'tig_postcode/configuration/checkout_compatible';
40+
3841
public const XPATH_MODULE_STABILITY = 'tig_postcode/stability';
42+
3943
public const XPATH_SUPPORTED_MAGENTO_VERSION = 'tig_postcode/supported_magento_version';
44+
4045
public const XPATH_NETHERLANDS_CHECK = 'tig_postcode/countries/enable_nl_check';
46+
4147
public const XPATH_BELGIUM_CHECK = 'tig_postcode/countries/enable_be_check';
4248

49+
public const XPATH_GERMANY_CHECK = 'tig_postcode/countries/enable_de_check';
50+
4351
/**
4452
* Should return on of these values
4553
* '1' => live ||
@@ -50,7 +58,7 @@ class ModuleConfiguration extends AbstractConfigProvider
5058
*
5159
* @return mixed
5260
*/
53-
public function getModus($store = null)
61+
public function getModus(int|string|null $store = null)
5462
{
5563
if (!$this->isModuleOutputEnabled()) {
5664
return '0';
@@ -66,7 +74,7 @@ public function getModus($store = null)
6674
*
6775
* @return bool
6876
*/
69-
public function isModusLive($store = null)
77+
public function isModusLive(int|string|null $store = null): bool
7078
{
7179
if ($this->getModus($store) == '1') {
7280
return true;
@@ -78,11 +86,11 @@ public function isModusLive($store = null)
7886
/**
7987
* Checks if the extension is on status test via store ID
8088
*
81-
* @param string|int|null $store
89+
* @param int|string|null $store
8290
*
8391
* @return bool
8492
*/
85-
public function isModusTest($store = null)
93+
public function isModusTest(int|string|null $store = null): bool
8694
{
8795
if ($this->getModus($store) == '2') {
8896
return true;
@@ -98,9 +106,9 @@ public function isModusTest($store = null)
98106
*
99107
* @return bool
100108
*/
101-
public function isModusOff($store = null)
109+
public function isModusOff(int|string|null $store = null): bool
102110
{
103-
if ($this->getModus($store) == '0' || false == $this->getModus()) {
111+
if ($this->getModus($store) == '0' || empty($this->getModus())) {
104112
return true;
105113
}
106114

@@ -114,7 +122,7 @@ public function isModusOff($store = null)
114122
*
115123
* @return string
116124
*/
117-
public function getStability($store = null)
125+
public function getStability(int|string|null $store = null)
118126
{
119127
return $this->getConfigFromXpath(static::XPATH_MODULE_STABILITY, $store);
120128
}
@@ -151,7 +159,7 @@ public function getCheckoutCompatibility($store = null)
151159
*
152160
* @return bool
153161
*/
154-
public function isNLCheckEnabled($store = null)
162+
public function isNLCheckEnabled($store = null): bool
155163
{
156164
return (bool) $this->getConfigFromXpath(static::XPATH_NETHERLANDS_CHECK, $store);
157165
}
@@ -163,8 +171,20 @@ public function isNLCheckEnabled($store = null)
163171
*
164172
* @return bool
165173
*/
166-
public function isBECheckEnabled($store = null)
174+
public function isBECheckEnabled($store = null): bool
167175
{
168176
return (bool) $this->getConfigFromXpath(static::XPATH_BELGIUM_CHECK, $store);
169177
}
178+
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);
189+
}
170190
}

Controller/Address/Service.php

Lines changed: 54 additions & 22 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\Controller\Address;
3334

3435
use Magento\Framework\App\Action\Context;
@@ -37,6 +38,8 @@
3738
use TIG\Postcode\Webservices\Endpoints\GetAddress;
3839
use TIG\Postcode\Webservices\Endpoints\GetBePostcode;
3940
use TIG\Postcode\Webservices\Endpoints\GetBeStreet;
41+
use TIG\Postcode\Webservices\Endpoints\GetDePostcode;
42+
use TIG\Postcode\Webservices\Endpoints\GetDeStreet;
4043
use TIG\Postcode\Services\Converter\Factory;
4144

4245
class Service extends Action
@@ -52,45 +55,61 @@ class Service extends Action
5255
private $converter;
5356

5457
/**
55-
* @var GetAddress
58+
* @var GetAddress // NL
5659
*/
5760
private $getAddress;
5861

5962
/**
60-
* @var GetBePostcode
63+
* @var GetBePostcode // BE
6164
*/
6265
private $getBePostcode;
6366

6467
/**
65-
* @var GetBeStreet
68+
* @var GetBeStreet // BE
6669
*/
6770
private $getBeStreet;
6871

72+
/**
73+
* @var GetDePostcode // DE
74+
*/
75+
private $getDePostcode;
76+
77+
/**
78+
* @var GetDeStreet // DE
79+
*/
80+
private $getDeStreet;
81+
6982
/**
7083
* Service constructor.
7184
*
72-
* @param Context $context
73-
* @param JsonFactory $jsonFactory
74-
* @param Factory $converterFactory
75-
* @param GetAddress $getAddress
76-
* @param GetBePostcode $getBePostcode
77-
* @param GetBeStreet $getBeStreet
85+
* @param Context $context
86+
* @param JsonFactory $jsonFactory
87+
* @param Factory $converterFactory
88+
* @param GetAddress $getAddress
89+
* @param GetBePostcode $getBePostcode
90+
* @param GetBeStreet $getBeStreet
91+
* @param GetDePostcode $getDePostcode
92+
* @param GetDeStreet $getDeStreet
7893
*/
7994
public function __construct(
8095
Context $context,
8196
JsonFactory $jsonFactory,
8297
Factory $converterFactory,
8398
GetAddress $getAddress,
8499
GetBePostcode $getBePostcode,
85-
GetBeStreet $getBeStreet
100+
GetBeStreet $getBeStreet,
101+
GetDePostcode $getDePostcode,
102+
GetDeStreet $getDeStreet
86103
) {
87104
parent::__construct($context);
88105

89-
$this->jsonFactory = $jsonFactory;
90-
$this->converter = $converterFactory;
91-
$this->getAddress = $getAddress;
92-
$this->getBePostcode = $getBePostcode;
93-
$this->getBeStreet = $getBeStreet;
106+
$this->jsonFactory = $jsonFactory;
107+
$this->converter = $converterFactory;
108+
$this->getAddress = $getAddress;
109+
$this->getBePostcode = $getBePostcode;
110+
$this->getBeStreet = $getBeStreet;
111+
$this->getDePostcode = $getDePostcode;
112+
$this->getDeStreet = $getDeStreet;
94113
}
95114

96115
/**
@@ -103,10 +122,10 @@ public function execute()
103122
$params = $this->getRequest()->getParams();
104123

105124
$country = $this->getCountry($params);
106-
$method = $this->getMethod($params, $country);
125+
$method = $this->getMethod($params, $country);
107126

108127
$endpoint = $this->getEndpoint($country, $method);
109-
$params = $this->converter->convert('request', $params, $endpoint->getRequestKeys());
128+
$params = $this->converter->convert('request', $params, $endpoint->getRequestKeys());
110129
if (!$params) {
111130
return $this->returnFailure(__('Request validation failed'));
112131
}
@@ -146,7 +165,11 @@ private function getMethod($params, $country)
146165
*/
147166
private function getCountry($params): string
148167
{
149-
if (key($params) == 'be') {
168+
if (key($params) == 'be') { // BE
169+
return key($params);
170+
}
171+
172+
if (key($params) == 'de') { // DE
150173
return key($params);
151174
}
152175

@@ -178,6 +201,7 @@ private function returnFailure($error)
178201
private function returnJson($data)
179202
{
180203
$response = $this->jsonFactory->create();
204+
181205
return $response->setData($data);
182206
}
183207

@@ -187,18 +211,26 @@ private function returnJson($data)
187211
* @param string $country
188212
* @param string $method
189213
*
190-
* @return GetAddress|GetBePostcode|GetBeStreet
214+
* @return GetAddress|GetBePostcode|GetBeStreet|GetDePostcode|GetDeStreet
191215
*/
192216
private function getEndpoint($country, $method)
193217
{
194-
if ($country == 'be' && $method == 'getpostcode') {
218+
if ($country == 'be' && $method == 'getpostcode') { // BE
195219
return $this->getBePostcode;
196220
}
197221

198-
if ($country == 'be' && $method == 'getstreet') {
222+
if ($country == 'be' && $method == 'getstreet') { // BE
199223
return $this->getBeStreet;
200224
}
201225

202-
return $this->getAddress;
226+
if ($country == 'de' && $method == 'getpostcode') { // DE
227+
return $this->getDePostcode;
228+
}
229+
230+
if ($country == 'de' && $method == 'getstreet') { // DE
231+
return $this->getDeStreet;
232+
}
233+
234+
return $this->getAddress; // NL
203235
}
204236
}

NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ if (data.error_code) {
9292
- Revised and updated the Magento User manual to ensure it matches the latest changes.
9393
- Updated `SECURITY.md` with GitHub’s private reporting option, providing a secure channel for issue
9494
reporting.
95-
- Successfully tested the extension with the new Magento 2.4.7-beta1, confirming compatibility and
95+
- Successfully tested the extension with the new Magento 2.4.7-beta1, Magento 2.4.7-beta2, confirming compatibility and
9696
performance.
9797

9898
## UX/UC improvements

0 commit comments

Comments
 (0)