1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace LauLamanApps\NestApi\Client\Factory\Device; |
6
|
|
|
|
7
|
|
|
use DateTimeImmutable; |
8
|
|
|
use LauLamanApps\NestApi\Client\__shared\AbstractFactory; |
9
|
|
|
use LauLamanApps\NestApi\Client\Device\Camera; |
10
|
|
|
use LauLamanApps\NestApi\Client\Factory\Device\Camera\EventFactoryInterface; |
11
|
|
|
use LauLamanApps\NestApi\NestClient; |
12
|
|
|
|
13
|
|
|
final class CameraFactory extends AbstractFactory implements CameraFactoryInterface |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* @var EventFactoryInterface |
17
|
|
|
*/ |
18
|
|
|
private $eventFactory; |
19
|
|
|
|
20
|
2 |
|
public function __construct(EventFactoryInterface $eventFactory) |
21
|
|
|
{ |
22
|
2 |
|
$this->eventFactory = $eventFactory; |
23
|
2 |
|
} |
24
|
|
|
|
25
|
2 |
|
public function fromData(array $data): Camera |
26
|
|
|
{ |
27
|
2 |
|
return new Camera( |
28
|
2 |
|
$this->extractString('device_id', $data), |
29
|
2 |
|
$this->extractString('structure_id', $data), |
30
|
2 |
|
$this->extractString('where_id', $data), |
31
|
2 |
|
$this->extractString('name', $data), |
32
|
2 |
|
$this->extractString('name_long', $data), |
33
|
2 |
|
$this->extractString('software_version', $data), |
34
|
2 |
|
$this->extractBoolean('is_online', $data), |
35
|
2 |
|
$this->extractBoolean('is_streaming', $data), |
36
|
2 |
|
$this->extractBoolean('is_audio_input_enabled', $data), |
37
|
2 |
|
new DateTimeImmutable($this->extractString('last_is_online_change', $data)), |
38
|
2 |
|
$this->extractBoolean('is_video_history_enabled', $data), |
39
|
2 |
|
$this->eventFactory->fromData($this->extractArrayOrNull('last_event', $data)), |
40
|
2 |
|
$this->extractString('web_url', $data), |
41
|
2 |
|
$this->extractString('app_url', $data) |
42
|
|
|
); |
43
|
|
|
} |
44
|
|
|
} |
45
|
|
|
|