|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Fousky\Component\iDoklad\Functions\CashVoucher; |
|
4
|
|
|
|
|
5
|
|
|
use Fousky\Component\iDoklad\Functions\iDokladAbstractFunction; |
|
6
|
|
|
use Fousky\Component\iDoklad\Model\CashVoucher\CashVoucherApiModel; |
|
7
|
|
|
use Fousky\Component\iDoklad\Model\CashVoucher\CashVoucherApiModelUpdate; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* @see https://app.idoklad.cz/developer/Help/v2/cs/Api?apiId=PUT-api-v2-CashVouchers-id |
|
11
|
|
|
* |
|
12
|
|
|
* @author Lukáš Brzák <[email protected]> |
|
13
|
|
|
*/ |
|
14
|
|
|
class UpdateCashVoucher extends iDokladAbstractFunction |
|
15
|
|
|
{ |
|
16
|
|
|
/** @var string $id */ |
|
17
|
|
|
protected $id; |
|
18
|
|
|
|
|
19
|
|
|
/** @var CashVoucherApiModelUpdate $data */ |
|
20
|
|
|
protected $data; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @param string $voucherId |
|
24
|
|
|
* @param CashVoucherApiModelUpdate $data |
|
25
|
|
|
* |
|
26
|
|
|
* @throws \Fousky\Component\iDoklad\Exception\InvalidModelException |
|
27
|
|
|
*/ |
|
28
|
|
|
public function __construct(string $voucherId, CashVoucherApiModelUpdate $data) |
|
29
|
|
|
{ |
|
30
|
|
|
$this->id = $voucherId; |
|
31
|
|
|
$this->data = $data; |
|
32
|
|
|
|
|
33
|
|
|
$this->validate($data); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Get iDokladModelInterface class. |
|
38
|
|
|
* |
|
39
|
|
|
* @see iDokladModelInterface |
|
40
|
|
|
* |
|
41
|
|
|
* @return string |
|
42
|
|
|
*/ |
|
43
|
|
|
public function getModelClass(): string |
|
44
|
|
|
{ |
|
45
|
|
|
return CashVoucherApiModel::class; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* GET|POST|PUT|DELETE e.g. |
|
50
|
|
|
* |
|
51
|
|
|
* @see iDoklad::request() |
|
52
|
|
|
* |
|
53
|
|
|
* @return string |
|
54
|
|
|
*/ |
|
55
|
|
|
public function getHttpMethod(): string |
|
56
|
|
|
{ |
|
57
|
|
|
return 'PUT'; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Return base URI, e.g. /invoices; /invoice/1/edit and so on. |
|
62
|
|
|
* |
|
63
|
|
|
* @see iDoklad::call() |
|
64
|
|
|
* |
|
65
|
|
|
* @return string |
|
66
|
|
|
*/ |
|
67
|
|
|
public function getUri(): string |
|
68
|
|
|
{ |
|
69
|
|
|
return sprintf('CashVouchers/%s', $this->id); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Vrátí seznam parametrů, které se předají GuzzleHttp\Client. |
|
74
|
|
|
* |
|
75
|
|
|
* @see \GuzzleHttp\Client::request() |
|
76
|
|
|
* @see iDoklad::call() |
|
77
|
|
|
* |
|
78
|
|
|
* @throws \ReflectionException |
|
79
|
|
|
* @throws \InvalidArgumentException |
|
80
|
|
|
* |
|
81
|
|
|
* @return array |
|
82
|
|
|
*/ |
|
83
|
|
|
public function getGuzzleOptions(): array |
|
84
|
|
|
{ |
|
85
|
|
|
return [ |
|
86
|
|
|
'json' => $this->data->toArray(), |
|
87
|
|
|
]; |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|