Skip to content

Commit 8b2de92

Browse files
authored
Merge pull request #111 from JerrySmidt/master
3.6.0
2 parents 3331b89 + 64c0d12 commit 8b2de92

31 files changed

+784
-126
lines changed

Api/Data/Autocomplete.php

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,41 @@ class Autocomplete implements AutocompleteInterface
1010
public $matches = [];
1111

1212
/**
13-
* __construct function.
14-
*
15-
* @access public
13+
* @var string|null
14+
*/
15+
public $error;
16+
17+
/**
18+
* @var string|null
19+
*/
20+
public $message;
21+
22+
/**
23+
* @var string|null
24+
*/
25+
public $exception;
26+
27+
/**
28+
* @var MagentoDebugInfoInterface|null
29+
*/
30+
public $magentoDebugInfo = null;
31+
32+
/**
1633
* @param array $response
17-
* @return void
1834
*/
1935
public function __construct(array $response)
2036
{
2137
foreach ($response['matches'] ?? [] as $match) {
2238
$this->matches[] = new Autocomplete\AutocompleteMatch($match);
2339
}
40+
41+
$this->error = $response['error'] ?? null;
42+
$this->message = $response['message'] ?? null;
43+
$this->exception = $response['exception'] ?? null;
44+
45+
if (isset($response['magento_debug_info'])) {
46+
$this->magentoDebugInfo = new MagentoDebugInfo($response['magento_debug_info']);
47+
}
2448
}
2549

2650
/**
@@ -30,4 +54,36 @@ public function getMatches(): array
3054
{
3155
return $this->matches;
3256
}
57+
58+
/**
59+
* @inheritdoc
60+
*/
61+
public function getError(): ?string
62+
{
63+
return $this->error;
64+
}
65+
66+
/**
67+
* @inheritdoc
68+
*/
69+
public function getMessage(): ?string
70+
{
71+
return $this->message;
72+
}
73+
74+
/**
75+
* @inheritdoc
76+
*/
77+
public function getException(): ?string
78+
{
79+
return $this->exception;
80+
}
81+
82+
/**
83+
* @inheritdoc
84+
*/
85+
public function getMagentoDebugInfo(): ?MagentoDebugInfoInterface
86+
{
87+
return $this->magentoDebugInfo;
88+
}
3389
}

Api/Data/AutocompleteInterface.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,24 @@ interface AutocompleteInterface
88
* @return Flekto\Postcode\Api\Data\Autocomplete\MatchInterface[]
99
*/
1010
public function getMatches(): array;
11+
12+
/**
13+
* @return string|null
14+
*/
15+
public function getError(): ?string;
16+
17+
/**
18+
* @return string|null
19+
*/
20+
public function getMessage(): ?string;
21+
22+
/**
23+
* @return string|null
24+
*/
25+
public function getException(): ?string;
26+
27+
/**
28+
* @return Flekto\Postcode\Api\Data\MagentoDebugInfoInterface|null
29+
*/
30+
public function getMagentoDebugInfo(): ?MagentoDebugInfoInterface;
1131
}

Api/Data/MagentoDebugInfo.php

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?php
2+
3+
namespace Flekto\Postcode\Api\Data;
4+
5+
class MagentoDebugInfo implements MagentoDebugInfoInterface
6+
{
7+
protected $moduleVersion;
8+
protected $magentoVersion;
9+
protected $client;
10+
protected $session;
11+
protected $configuration;
12+
protected $modules;
13+
14+
/**
15+
* @param array $data
16+
*/
17+
public function __construct(array $data)
18+
{
19+
$this->moduleVersion = $data['moduleVersion'] ?? '';
20+
$this->magentoVersion = $data['magentoVersion'] ?? '';
21+
$this->client = $data['client'] ?? '';
22+
$this->session = $data['session'] ?? '';
23+
$this->configuration = new MagentoDebugInfo\Configuration($data['configuration'] ?? []);
24+
$this->modules = $data['modules'] ?? [];
25+
}
26+
27+
/**
28+
* @inheritdoc
29+
*/
30+
public function getModuleVersion(): string
31+
{
32+
return $this->moduleVersion;
33+
}
34+
35+
/**
36+
* @inheritdoc
37+
*/
38+
public function getMagentoVersion(): string
39+
{
40+
return $this->magentoVersion;
41+
}
42+
43+
/**
44+
* @inheritdoc
45+
*/
46+
public function getClient(): string
47+
{
48+
return $this->client;
49+
}
50+
51+
/**
52+
* @inheritdoc
53+
*/
54+
public function getSession(): string
55+
{
56+
return $this->session;
57+
}
58+
59+
/**
60+
* @inheritdoc
61+
*/
62+
public function getConfiguration(): MagentoDebugInfo\ConfigurationInterface
63+
{
64+
return $this->configuration;
65+
}
66+
67+
/**
68+
* @inheritdoc
69+
*/
70+
public function getModules(): array
71+
{
72+
return $this->modules;
73+
}
74+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace Flekto\Postcode\Api\Data\MagentoDebugInfo;
4+
5+
class Configuration implements ConfigurationInterface
6+
{
7+
protected $key;
8+
protected $secret;
9+
10+
/**
11+
* @param array $data
12+
*/
13+
public function __construct(array $data)
14+
{
15+
$this->key = $data['key'] ?? '';
16+
$this->secret = $data['secret'] ?? '';
17+
}
18+
19+
/**
20+
* @inheritdoc
21+
*/
22+
public function getKey(): string
23+
{
24+
return $this->key;
25+
}
26+
27+
/**
28+
* @inheritdoc
29+
*/
30+
public function getSecret(): string
31+
{
32+
return $this->secret;
33+
}
34+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace Flekto\Postcode\Api\Data\MagentoDebugInfo;
4+
5+
interface ConfigurationInterface
6+
{
7+
/**
8+
* @return string
9+
*/
10+
public function getKey(): string;
11+
12+
/**
13+
* @return string
14+
*/
15+
public function getSecret(): string;
16+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace Flekto\Postcode\Api\Data\MagentoDebugInfo;
4+
5+
class MagentoModule implements MagentoModuleInterface
6+
{
7+
private string $name;
8+
private string $setupVersion;
9+
10+
/**
11+
* @param array $data
12+
*/
13+
public function __construct(array $data)
14+
{
15+
$this->name = $data['name'] ?? '';
16+
$this->setupVersion = $data['setup_version'] ?? '';
17+
}
18+
19+
/**
20+
* @inheritdoc
21+
*/
22+
public function getName(): string
23+
{
24+
return $this->name;
25+
}
26+
27+
/**
28+
* @inheritdoc
29+
*/
30+
public function getSetupVersion(): string
31+
{
32+
return $this->setupVersion;
33+
}
34+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace Flekto\Postcode\Api\Data\MagentoDebugInfo;
4+
5+
interface MagentoModuleInterface
6+
{
7+
/**
8+
* Get module name
9+
*
10+
* @return string
11+
*/
12+
public function getName(): string;
13+
14+
/**
15+
* Get module setup version
16+
*
17+
* @return string
18+
*/
19+
public function getSetupVersion(): string;
20+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
namespace Flekto\Postcode\Api\Data;
4+
5+
interface MagentoDebugInfoInterface
6+
{
7+
/**
8+
* @return string
9+
*/
10+
public function getModuleVersion(): string;
11+
12+
/**
13+
* @return string
14+
*/
15+
public function getMagentoVersion(): string;
16+
17+
/**
18+
* @return string
19+
*/
20+
public function getClient(): string;
21+
22+
/**
23+
* @return string
24+
*/
25+
public function getSession(): string;
26+
27+
/**
28+
* @return Flekto\Postcode\Api\Data\MagentoDebugInfo\ConfigurationInterface
29+
*/
30+
public function getConfiguration(): MagentoDebugInfo\ConfigurationInterface;
31+
32+
/**
33+
* @return Flekto\Postcode\Api\Data\MagentoDebugInfo\MagentoModuleInterface[]
34+
*/
35+
public function getModules(): array;
36+
}

Api/PostcodeModelInterface.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,25 @@ public function getAddressDetailsCountry(String $context, String $dispatchCountr
3535
* @return string[][]
3636
*/
3737
public function getNlAddress(String $zipCode, String $houseNumber): array;
38+
39+
/**
40+
* @access public
41+
* @param string $country
42+
* @param string|null $postcode
43+
* @param string|null $locality
44+
* @param string|null $street
45+
* @param string|null $building
46+
* @param string|null $region
47+
* @param string|null $streetAndBuilding
48+
* @return string[][]
49+
*/
50+
public function validateAddress(
51+
string $country,
52+
?string $postcode = null,
53+
?string $locality = null,
54+
?string $street = null,
55+
?string $building = null,
56+
?string $region = null,
57+
?string $streetAndBuilding = null
58+
): array;
3859
}

GraphQl/Exception/GraphQlHeaderException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class GraphQlHeaderException extends LocalizedException implements ClientAware
1414
/**
1515
* Describing a category of the error
1616
*/
17-
const EXCEPTION_CATEGORY = 'graphql-header';
17+
public const EXCEPTION_CATEGORY = 'graphql-header';
1818

1919
/**
2020
* @var boolean

0 commit comments

Comments
 (0)