1 | <?php namespace Arcanedev\GeoLocation\Google; |
||
12 | abstract class AbstractWebService |
||
13 | { |
||
14 | /* ----------------------------------------------------------------- |
||
15 | | Properties |
||
16 | | ----------------------------------------------------------------- |
||
17 | */ |
||
18 | |||
19 | /** @var \GuzzleHttp\ClientInterface */ |
||
20 | protected $client; |
||
21 | |||
22 | /** @var string|null */ |
||
23 | protected $key = null; |
||
24 | |||
25 | /* ----------------------------------------------------------------- |
||
26 | | Constructor |
||
27 | | ----------------------------------------------------------------- |
||
28 | */ |
||
29 | |||
30 | /** |
||
31 | * GoogleDistanceMatrix constructor. |
||
32 | * |
||
33 | * @param \GuzzleHttp\ClientInterface $client |
||
34 | */ |
||
35 | 30 | public function __construct(ClientInterface $client) |
|
39 | |||
40 | /* ----------------------------------------------------------------- |
||
41 | | Getters & Setters |
||
42 | | ----------------------------------------------------------------- |
||
43 | */ |
||
44 | |||
45 | /** |
||
46 | * Set the HTTP Client. |
||
47 | * |
||
48 | * @param \GuzzleHttp\ClientInterface $client |
||
49 | * |
||
50 | * @return self |
||
51 | */ |
||
52 | 30 | public function setHttpClient(ClientInterface $client) |
|
58 | |||
59 | /** |
||
60 | * Set the API Key. |
||
61 | * |
||
62 | * @param string $key |
||
63 | * |
||
64 | * @return self |
||
65 | */ |
||
66 | 30 | public function setKey($key) |
|
72 | |||
73 | /* ----------------------------------------------------------------- |
||
74 | | Other Methods |
||
75 | | ----------------------------------------------------------------- |
||
76 | */ |
||
77 | |||
78 | /** |
||
79 | * Prepare the URL query. |
||
80 | * |
||
81 | * @param array $params |
||
82 | * |
||
83 | * @return string |
||
84 | */ |
||
85 | 18 | protected function prepareQuery(array $params) |
|
91 | |||
92 | /** |
||
93 | * Get the default query params. |
||
94 | * |
||
95 | * @return array |
||
96 | */ |
||
97 | abstract protected function getDefaultQueryParams(); |
||
98 | |||
99 | /** |
||
100 | * Parse the position object for the query. |
||
101 | * |
||
102 | * @param \Arcanedev\GeoLocation\Contracts\Entities\Position $position |
||
103 | * |
||
104 | * @return string |
||
105 | */ |
||
106 | 15 | protected function parsePosition(Position $position) |
|
110 | } |
||
111 |