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