1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace DH\NavigationBundle\Provider\Here; |
4
|
|
|
|
5
|
|
|
use DH\NavigationBundle\Contract\DistanceMatrix\DistanceMatrixQueryInterface; |
6
|
|
|
use DH\NavigationBundle\Contract\Routing\RoutingQueryInterface; |
7
|
|
|
use DH\NavigationBundle\Provider\AbstractProvider; |
8
|
|
|
use DH\NavigationBundle\Provider\Here\DistanceMatrix\DistanceMatrixQuery; |
9
|
|
|
use DH\NavigationBundle\Provider\Here\Routing\RoutingQuery; |
10
|
|
|
use GuzzleHttp\ClientInterface; |
11
|
|
|
|
12
|
|
|
class Here extends AbstractProvider |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* @var string |
16
|
|
|
*/ |
17
|
|
|
private $app_id; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @var string |
21
|
|
|
*/ |
22
|
|
|
private $app_code; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var bool |
26
|
|
|
*/ |
27
|
|
|
private $useCIT; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Here constructor. |
31
|
|
|
* |
32
|
|
|
* @param ClientInterface $client |
33
|
|
|
* @param string $appId an App ID |
34
|
|
|
* @param string $appCode an App code |
35
|
|
|
* @param bool $useCIT use Customer Integration Testing environment (CIT) instead of production |
36
|
|
|
*/ |
37
|
|
|
public function __construct(ClientInterface $client, string $appId, string $appCode, bool $useCIT = false) |
38
|
|
|
{ |
39
|
|
|
parent::__construct($client); |
40
|
|
|
|
41
|
|
|
$this->app_id = $appId; |
42
|
|
|
$this->app_code = $appCode; |
43
|
|
|
$this->useCIT = $useCIT; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @return string |
48
|
|
|
*/ |
49
|
|
|
public function getName(): string |
50
|
|
|
{ |
51
|
|
|
return 'here'; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @return string |
56
|
|
|
*/ |
57
|
|
|
public function getAppId(): string |
58
|
|
|
{ |
59
|
|
|
return $this->app_id; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @return string |
64
|
|
|
*/ |
65
|
|
|
public function getAppCode(): string |
66
|
|
|
{ |
67
|
|
|
return $this->app_code; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @return bool |
72
|
|
|
*/ |
73
|
|
|
public function isCitEnabled(): bool |
74
|
|
|
{ |
75
|
|
|
return $this->useCIT; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @return array |
80
|
|
|
*/ |
81
|
|
|
public function getCredentials(): array |
82
|
|
|
{ |
83
|
|
|
return [ |
84
|
|
|
'app_id' => $this->getAppId(), |
85
|
|
|
'app_code' => $this->getAppCode(), |
86
|
|
|
]; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @return DistanceMatrixQueryInterface |
91
|
|
|
*/ |
92
|
|
|
public function createDistanceMatrixQuery(): DistanceMatrixQueryInterface |
93
|
|
|
{ |
94
|
|
|
return new DistanceMatrixQuery($this); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @return RoutingQueryInterface |
99
|
|
|
*/ |
100
|
|
|
public function createRoutingQuery(): RoutingQueryInterface |
101
|
|
|
{ |
102
|
|
|
return new RoutingQuery($this); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @return string |
107
|
|
|
*/ |
108
|
|
|
public function __toString() |
109
|
|
|
{ |
110
|
|
|
return $this->getName(); |
111
|
|
|
} |
112
|
|
|
} |
113
|
|
|
|