1
|
|
|
<?php declare(strict_types = 1); |
2
|
|
|
|
3
|
|
|
namespace SlevomatEET; |
4
|
|
|
|
5
|
|
|
use DateTime; |
6
|
|
|
use DateTimeImmutable; |
7
|
|
|
use stdClass; |
8
|
|
|
|
9
|
|
|
class EvidenceResponse |
10
|
|
|
{ |
11
|
|
|
|
12
|
|
|
/** @var stdClass */ |
13
|
|
|
private $rawData; |
14
|
|
|
|
15
|
|
|
/** @var string|null */ |
16
|
|
|
private $uuid; |
17
|
|
|
|
18
|
|
|
/** @var string|null */ |
19
|
|
|
private $bkp; |
20
|
|
|
|
21
|
|
|
/** @var bool */ |
22
|
|
|
private $test; |
23
|
|
|
|
24
|
|
|
/** @var string|null */ |
25
|
|
|
private $fik; |
26
|
|
|
|
27
|
|
|
/** @var DateTimeImmutable */ |
28
|
|
|
private $responseTime; |
29
|
|
|
|
30
|
|
|
/** @var EvidenceRequest */ |
31
|
|
|
private $evidenceRequest; |
32
|
|
|
|
33
|
2 |
|
public function __construct(stdClass $rawData, EvidenceRequest $evidenceRequest) |
34
|
|
|
{ |
35
|
2 |
|
$this->rawData = $rawData; |
36
|
2 |
|
$this->uuid = $rawData->Hlavicka->uuid_zpravy ?? null; |
37
|
2 |
|
if (isset($rawData->Potvrzeni)) { |
38
|
1 |
|
$this->fik = $rawData->Potvrzeni->fik; |
39
|
|
|
} |
40
|
2 |
|
$this->bkp = $rawData->Hlavicka->bkp ?? null; |
41
|
2 |
|
$this->test = $rawData->Potvrzeni->test ?? $rawData->Chyba->test ?? false; |
42
|
2 |
|
$this->responseTime = DateTimeImmutable::createFromFormat(DateTime::ISO8601, $rawData->Hlavicka->dat_prij ?? $rawData->Hlavicka->dat_odmit); |
43
|
2 |
|
$this->evidenceRequest = $evidenceRequest; |
44
|
2 |
|
} |
45
|
|
|
|
46
|
2 |
|
public function getFik(): string |
47
|
|
|
{ |
48
|
2 |
|
if ($this->fik === null) { |
49
|
1 |
|
throw new InvalidResponseWithoutFikException($this); |
50
|
|
|
} |
51
|
|
|
|
52
|
1 |
|
return $this->fik; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function getRawData(): stdClass |
56
|
|
|
{ |
57
|
|
|
return $this->rawData; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function getUuid(): ?string |
61
|
|
|
{ |
62
|
|
|
return $this->uuid; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function getBkp(): ?string |
66
|
|
|
{ |
67
|
|
|
return $this->bkp; |
68
|
|
|
} |
69
|
|
|
|
70
|
2 |
|
public function isTest(): bool |
71
|
|
|
{ |
72
|
2 |
|
return $this->test; |
73
|
|
|
} |
74
|
|
|
|
75
|
2 |
|
public function isValid(): bool |
76
|
|
|
{ |
77
|
2 |
|
return $this->fik !== null; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
public function getResponseTime(): DateTimeImmutable |
81
|
|
|
{ |
82
|
|
|
return $this->responseTime; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
public function getRequest(): EvidenceRequest |
86
|
|
|
{ |
87
|
|
|
return $this->evidenceRequest; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
} |
91
|
|
|
|