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\Departement\CommunesRequest; |
17
|
|
|
use WBW\Library\GeoAPI\Request\Departement\DepartementsRequest; |
18
|
|
|
use WBW\Library\GeoAPI\Response\CommunesResponse; |
19
|
|
|
use WBW\Library\GeoAPI\Response\DepartementsResponse; |
20
|
|
|
use WBW\Library\GeoAPI\Serializer\DecoupageAdministratifResponseDeserializer; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Département provider. |
24
|
|
|
* |
25
|
|
|
* @author webeweb <https://github.com/webeweb/> |
26
|
|
|
* @package WBW\Library\GeoAPI\Provider |
27
|
|
|
*/ |
28
|
|
|
class DepartementProvider extends DecoupageAdministratifProvider { |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Communes. |
32
|
|
|
* |
33
|
|
|
* @param CommunesRequest $request The communes request. |
34
|
|
|
* @return CommunesResponse Returns the communes response. |
35
|
|
|
* @throws GuzzleException Throws a Guzzle exception if an error occurs. |
36
|
|
|
* @throws ApiException Throws an API exception if an error occurs. |
37
|
|
|
*/ |
38
|
5 |
|
public function communes(CommunesRequest $request): CommunesResponse { |
39
|
|
|
|
40
|
5 |
|
$rawResponse = $this->callApi($request, []); |
41
|
|
|
|
42
|
5 |
|
return DecoupageAdministratifResponseDeserializer::deserializeCommunesResponse($rawResponse); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Départements. |
47
|
|
|
* |
48
|
|
|
* @param DepartementsRequest $request The départements request. |
49
|
|
|
* @return DepartementsResponse Returns the départements response. |
50
|
|
|
* @throws GuzzleException Throws a Guzzle exception if an error occurs. |
51
|
|
|
* @throws ApiException Throws an API exception if an error occurs. |
52
|
|
|
*/ |
53
|
5 |
|
public function departements(DepartementsRequest $request): DepartementsResponse { |
54
|
|
|
|
55
|
5 |
|
$rawResponse = $this->callApi($request, []); |
56
|
|
|
|
57
|
5 |
|
return DecoupageAdministratifResponseDeserializer::deserializeDepartementsResponse($rawResponse); |
58
|
|
|
} |
59
|
|
|
} |