1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is a part of nekland places api package |
5
|
|
|
* |
6
|
|
|
* (c) Nekland <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full license, take a look to the LICENSE file |
9
|
|
|
* on the root directory of this project |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Nekland\PlacesApi; |
13
|
|
|
|
14
|
|
|
use Nekland\BaseApi\ApiFactory; |
15
|
|
|
use Nekland\BaseApi\Http\Auth\AuthFactory; |
16
|
|
|
use Nekland\BaseApi\Http\HttpClientFactory; |
17
|
|
|
use Nekland\BaseApi\Transformer\TransformerInterface; |
18
|
|
|
use Symfony\Component\EventDispatcher\EventDispatcher; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Class Places |
22
|
|
|
* |
23
|
|
|
* @method \Nekland\PlacesApi\Api\Search getSearchApi() |
24
|
|
|
* @method \Nekland\PlacesApi\Api\Autocomplete getAutocompleteApi() |
25
|
|
|
* @method \Nekland\PlacesApi\Api\Places getPlacesApi() |
26
|
|
|
*/ |
27
|
|
|
class Places extends ApiFactory |
28
|
|
|
{ |
29
|
|
|
/** |
30
|
|
|
* @var array |
31
|
|
|
*/ |
32
|
|
|
private $options = [ |
33
|
|
|
'base_url' => 'https://maps.googleapis.com/maps/api/place/', |
34
|
|
|
'user_agent' => 'php-places-api (https://github.com/Nekland/PlacesApi)' |
35
|
|
|
]; |
36
|
|
|
|
37
|
|
|
|
38
|
|
|
public function __construct( |
39
|
|
|
array $options = [], |
40
|
|
|
HttpClientFactory $httpClientFactory = null, |
41
|
|
|
EventDispatcher $dispatcher = null, |
42
|
|
|
TransformerInterface $transformer = null, |
43
|
|
|
AuthFactory $authFactory = null |
44
|
|
|
) { |
45
|
|
|
$this->options = array_merge($this->options, $options); |
46
|
|
|
parent::__construct(new HttpClientFactory($this->options)); |
47
|
|
|
$this->getAuthFactory()->addNamespace('Nekland\PlacesApi\Http\Auth'); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Return array of namespaces where AbstractApi instance are localized |
52
|
|
|
* |
53
|
|
|
* |
54
|
|
|
* @return string[] Example: ['Nekland\BaseApi\Api'] |
55
|
|
|
*/ |
56
|
|
|
protected function getApiNamespaces() |
57
|
|
|
{ |
58
|
|
|
return ['Nekland\PlacesApi\Api']; |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|