1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace VasilDakov\Econt; |
6
|
|
|
|
7
|
|
|
use Fig\Http\Message\RequestMethodInterface; |
8
|
|
|
use Psr\Http\Client\ClientExceptionInterface; |
9
|
|
|
use Psr\Http\Client\ClientInterface; |
10
|
|
|
use Psr\Http\Message\RequestFactoryInterface; |
11
|
|
|
use Psr\Http\Message\RequestInterface; |
12
|
|
|
use VasilDakov\Econt\Request; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Class Econt |
16
|
|
|
* |
17
|
|
|
* @author Vasil Dakov <[email protected]> |
18
|
|
|
*/ |
19
|
|
|
final class Econt implements EcontInterface |
20
|
|
|
{ |
21
|
|
|
public const API_URL = 'https://demo.econt.com'; |
22
|
|
|
|
23
|
10 |
|
public function __construct( |
24
|
|
|
private readonly Configuration $configuration, |
|
|
|
|
25
|
|
|
private readonly ClientInterface $client, |
26
|
|
|
private readonly RequestFactoryInterface $factory |
27
|
|
|
) { |
28
|
10 |
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @throws ClientExceptionInterface |
32
|
|
|
*/ |
33
|
2 |
|
public function getClientProfiles(): string |
34
|
|
|
{ |
35
|
2 |
|
$request = $this->createRequest( |
36
|
2 |
|
RequestMethodInterface::METHOD_POST, |
37
|
2 |
|
self::API_URL . '/ee/services/Profile/ProfileService.getClientProfiles.json', |
38
|
2 |
|
[] |
39
|
2 |
|
); |
40
|
|
|
|
41
|
2 |
|
$response = $this->client->sendRequest($request); |
42
|
|
|
|
43
|
2 |
|
return $response->getBody()->getContents(); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @throws ClientExceptionInterface |
48
|
|
|
*/ |
49
|
4 |
|
public function getCountries(): string |
50
|
|
|
{ |
51
|
4 |
|
$request = $this->createRequest( |
52
|
4 |
|
RequestMethodInterface::METHOD_POST, |
53
|
4 |
|
self::API_URL . '/ee/services/Nomenclatures/NomenclaturesService.getCountries.json', |
54
|
4 |
|
[] |
55
|
4 |
|
); |
56
|
|
|
|
57
|
4 |
|
$response = $this->client->sendRequest($request); |
58
|
|
|
|
59
|
4 |
|
return $response->getBody()->getContents(); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @throws ClientExceptionInterface |
64
|
|
|
*/ |
65
|
2 |
|
public function getCities(Request\GetCitiesRequest $object): string |
|
|
|
|
66
|
|
|
{ |
67
|
2 |
|
$request = $this->createRequest( |
68
|
2 |
|
RequestMethodInterface::METHOD_POST, |
69
|
2 |
|
self::API_URL . '/ee/services/Nomenclatures/NomenclaturesService.getCities.json', |
70
|
2 |
|
$object->toArray() |
71
|
2 |
|
); |
72
|
|
|
|
73
|
2 |
|
$response = $this->client->sendRequest($request); |
74
|
|
|
|
75
|
2 |
|
return $response->getBody()->getContents(); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function getOffices(array $data): string |
79
|
|
|
{ |
80
|
|
|
$request = $this->createRequest( |
81
|
|
|
RequestMethodInterface::METHOD_POST, |
82
|
|
|
self::API_URL . '/ee/services/Nomenclatures/NomenclaturesService.getOffices.json', |
83
|
|
|
[ |
84
|
|
|
Constants::COUNTRY_CODE => $data['countryCode'], |
85
|
|
|
Constants::CITY_ID => $data['cityId'], |
86
|
|
|
] |
87
|
|
|
); |
88
|
|
|
|
89
|
|
|
$response = $this->client->sendRequest($request); |
90
|
|
|
|
91
|
|
|
return $response->getBody()->getContents(); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
|
95
|
|
|
public function getShipmentStatuses(array $data): string |
96
|
|
|
{ |
97
|
|
|
$request = $this->createRequest( |
98
|
|
|
RequestMethodInterface::METHOD_POST, |
99
|
|
|
self::API_URL . '/ee/services/Shipments/ShipmentService.getShipmentStatuses.json', |
100
|
|
|
$data |
101
|
|
|
); |
102
|
|
|
|
103
|
|
|
$response = $this->client->sendRequest($request); |
104
|
|
|
|
105
|
|
|
return $response->getBody()->getContents(); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @param string $method |
111
|
|
|
* @param string $uri |
112
|
|
|
* @param array $data |
113
|
|
|
* @return RequestInterface |
114
|
|
|
*/ |
115
|
8 |
|
private function createRequest(string $method, string $uri, array $data): RequestInterface |
116
|
|
|
{ |
117
|
8 |
|
$request = $this->factory->createRequest($method, $uri); |
118
|
|
|
|
119
|
8 |
|
$request = $request->withAddedHeader('Content-Type', 'application/json'); |
120
|
8 |
|
$request = $request->withAddedHeader( |
121
|
8 |
|
'Authorization', |
122
|
8 |
|
'Basic ' . base64_encode( |
123
|
8 |
|
$this->configuration->username . ":" . $this->configuration->password |
124
|
8 |
|
) |
125
|
8 |
|
); |
126
|
|
|
|
127
|
8 |
|
$request->getBody()->write(json_encode($data)); |
128
|
|
|
|
129
|
8 |
|
return $request; |
|
|
|
|
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
public function getStreets(array $data): string |
133
|
|
|
{ |
134
|
|
|
return ''; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
public function getQuarters(array $data): string |
138
|
|
|
{ |
139
|
|
|
return ''; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
public function createLabel(array $data): string |
143
|
|
|
{ |
144
|
|
|
return ''; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
public function createLabels(array $data): string |
148
|
|
|
{ |
149
|
|
|
return ''; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
public function deleteLabels(array $data): string |
153
|
|
|
{ |
154
|
|
|
return ''; |
155
|
|
|
} |
156
|
|
|
} |
157
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths