-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathSendInvoice.php
More file actions
107 lines (88 loc) · 2.48 KB
/
Copy pathSendInvoice.php
File metadata and controls
107 lines (88 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
namespace Formapro\TelegramBot;
use function Formapro\Values\add_object;
use function Formapro\Values\get_value;
use function Formapro\Values\get_values;
use function Formapro\Values\set_object;
use function Formapro\Values\set_objects;
use function Formapro\Values\set_value;
class SendInvoice
{
private $values = [];
private $objects = [];
public function __construct(
int $chatId,
string $title,
string $description,
string $payload,
string $providerToken,
string $startParameter,
string $currency,
array $prices
) {
set_value($this, 'chat_id', $chatId);
set_value($this, 'title', $title);
set_value($this, 'description', $description);
set_value($this, 'payload', $payload);
set_value($this, 'provider_token', $providerToken);
set_value($this, 'start_parameter', $startParameter);
set_value($this, 'currency', $currency);
if (empty($prices)) {
throw new \InvalidArgumentException('Prices must be filled');
}
foreach ($prices as $price) {
$this->addPrice($price);
}
}
public function getChatId(): int
{
return get_value($this, 'chat_id');
}
public function getTitle(): string
{
return get_value($this, 'title');
}
public function getDescription(): string
{
return get_value($this, 'description');
}
public function getPayload(): string
{
return get_value($this, 'payload');
}
public function getProviderToken(): string
{
return get_value($this, 'provider_token');
}
public function getStartParameter(): string
{
return get_value($this, 'start_parameter');
}
public function getCurrency(): string
{
return get_value($this, 'currency');
}
/**
* @return LabeledPrice[]
*/
public function getPrices(): array
{
return get_value($this, 'prices');
}
private function addPrice(LabeledPrice $price): void
{
add_object($this, 'prices', $price);
}
public function setParseMode(string $parseMode): void
{
set_value($this, 'parse_mode', $parseMode);
}
public function getParseMode(): ?string
{
return get_value($this, 'parse_mode');
}
public function setReplyMarkup(ReplyMarkup $replyMarkup): void
{
set_value($this, 'reply_markup', json_encode(get_values($replyMarkup)));
}
}