1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Ivory Google Map package. |
5
|
|
|
* |
6
|
|
|
* (c) Eric GELOEN <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please read the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Ivory\GoogleMap\Service\TimeZone; |
13
|
|
|
|
14
|
|
|
use Http\Client\HttpClient; |
15
|
|
|
use Http\Message\MessageFactory; |
16
|
|
|
use Ivory\GoogleMap\Service\AbstractSerializableService; |
17
|
|
|
use Ivory\GoogleMap\Service\TimeZone\Request\TimeZoneRequestInterface; |
18
|
|
|
use Ivory\GoogleMap\Service\TimeZone\Response\TimeZoneResponse; |
19
|
|
|
use Ivory\Serializer\Context\Context; |
20
|
|
|
use Ivory\Serializer\Naming\SnakeCaseNamingStrategy; |
21
|
|
|
use Ivory\Serializer\SerializerInterface; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @author GeLo <[email protected]> |
25
|
|
|
*/ |
26
|
|
|
class TimeZoneService extends AbstractSerializableService |
27
|
|
|
{ |
28
|
4 |
|
public function __construct( |
29
|
|
|
HttpClient $client, |
30
|
|
|
MessageFactory $messageFactory, |
31
|
|
|
SerializerInterface $serializer = null |
32
|
|
|
) { |
33
|
4 |
|
parent::__construct('https://maps.googleapis.com/maps/api/timezone', $client, $messageFactory, $serializer); |
34
|
4 |
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @return TimeZoneResponse |
38
|
|
|
*/ |
39
|
4 |
|
public function process(TimeZoneRequestInterface $request) |
40
|
|
|
{ |
41
|
4 |
|
$httpRequest = $this->createRequest($request); |
42
|
4 |
|
$httpResponse = $this->getClient()->sendRequest($httpRequest); |
43
|
|
|
|
44
|
4 |
|
$context = new Context(); |
45
|
|
|
|
46
|
4 |
|
if (self::FORMAT_XML === $this->getFormat()) { |
47
|
|
|
$context->setNamingStrategy(new SnakeCaseNamingStrategy()); |
48
|
|
|
} |
49
|
|
|
|
50
|
4 |
|
$response = $this->deserialize($httpResponse, TimeZoneResponse::class, $context); |
51
|
4 |
|
$response->setRequest($request); |
52
|
|
|
|
53
|
4 |
|
return $response; |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|