1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the geo-api-library package. |
5
|
|
|
* |
6
|
|
|
* (c) 2020 WEBEWEB |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace WBW\Library\GeoAPI\Provider; |
13
|
|
|
|
14
|
|
|
use GuzzleHttp\Exception\GuzzleException; |
15
|
|
|
use WBW\Library\Core\Exception\ApiException; |
16
|
|
|
use WBW\Library\GeoAPI\Request\Region\CommunesRequest; |
17
|
|
|
use WBW\Library\GeoAPI\Request\Region\DepartementsRequest; |
18
|
|
|
use WBW\Library\GeoAPI\Request\Region\RegionsRequest; |
19
|
|
|
use WBW\Library\GeoAPI\Response\CommunesResponse; |
20
|
|
|
use WBW\Library\GeoAPI\Response\DepartementsResponse; |
21
|
|
|
use WBW\Library\GeoAPI\Response\RegionsResponse; |
22
|
|
|
use WBW\Library\GeoAPI\Serializer\DecoupageAdministratifResponseDeserializer; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Région provider. |
26
|
|
|
* |
27
|
|
|
* @author webeweb <https://github.com/webeweb/> |
28
|
|
|
* @package WBW\Library\GeoAPI\Provider |
29
|
|
|
*/ |
30
|
|
|
class RegionProvider extends DecoupageAdministratifProvider { |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Communes. |
34
|
|
|
* |
35
|
|
|
* @param CommunesRequest $request The communes request. |
36
|
|
|
* @return CommunesResponse Returns the communes response. |
37
|
|
|
* @throws GuzzleException Throws a Guzzle exception if an error occurs. |
38
|
|
|
* @throws ApiException Throws an API exception if an error occurs. |
39
|
|
|
*/ |
40
|
|
|
public function communes(CommunesRequest $request): CommunesResponse { |
41
|
|
|
|
42
|
|
|
$rawResponse = $this->callApi($request, []); |
43
|
|
|
|
44
|
|
|
return DecoupageAdministratifResponseDeserializer::deserializeCommunesResponse($rawResponse); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Départements. |
49
|
|
|
* |
50
|
|
|
* @param DepartementsRequest $request The départements request. |
51
|
|
|
* @return DepartementsResponse Returns the départements response. |
52
|
|
|
* @throws GuzzleException Throws a Guzzle exception if an error occurs. |
53
|
|
|
* @throws ApiException Throws an API exception if an error occurs. |
54
|
|
|
*/ |
55
|
5 |
|
public function departements(DepartementsRequest $request): DepartementsResponse { |
56
|
|
|
|
57
|
5 |
|
$rawResponse = $this->callApi($request, []); |
58
|
|
|
|
59
|
5 |
|
return DecoupageAdministratifResponseDeserializer::deserializeDepartementsResponse($rawResponse); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Régions. |
64
|
|
|
* |
65
|
|
|
* @param RegionsRequest $request The régions request. |
66
|
|
|
* @return RegionsResponse Returns the régions response. |
67
|
|
|
* @throws GuzzleException Throws a Guzzle exception if an error occurs. |
68
|
|
|
* @throws ApiException Throws an API exception if an error occurs. |
69
|
|
|
*/ |
70
|
5 |
|
public function regions(RegionsRequest $request): RegionsResponse { |
71
|
|
|
|
72
|
5 |
|
$rawResponse = $this->callApi($request, []); |
73
|
|
|
|
74
|
5 |
|
return DecoupageAdministratifResponseDeserializer::deserializeRegionsResponse($rawResponse); |
75
|
|
|
} |
76
|
|
|
} |