1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace TgBotApi\BotApiBase\Helper; |
6
|
|
|
|
7
|
|
|
use TgBotApi\BotApiBase\Exception\NormalizationException; |
8
|
|
|
use TgBotApi\BotApiBase\Exception\ResponseException; |
9
|
|
|
use TgBotApi\BotApiBase\Method\SendAnimationMethod; |
10
|
|
|
use TgBotApi\BotApiBase\Method\SendAudioMethod; |
11
|
|
|
use TgBotApi\BotApiBase\Method\SendChatActionMethod; |
12
|
|
|
use TgBotApi\BotApiBase\Method\SendContactMethod; |
13
|
|
|
use TgBotApi\BotApiBase\Method\SendDocumentMethod; |
14
|
|
|
use TgBotApi\BotApiBase\Method\SendGameMethod; |
15
|
|
|
use TgBotApi\BotApiBase\Method\SendInvoiceMethod; |
16
|
|
|
use TgBotApi\BotApiBase\Method\SendLocationMethod; |
17
|
|
|
use TgBotApi\BotApiBase\Method\SendMediaGroupMethod; |
18
|
|
|
use TgBotApi\BotApiBase\Method\SendMessageMethod; |
19
|
|
|
use TgBotApi\BotApiBase\Method\SendPhotoMethod; |
20
|
|
|
use TgBotApi\BotApiBase\Method\SendStickerMethod; |
21
|
|
|
use TgBotApi\BotApiBase\Method\SendVenueMethod; |
22
|
|
|
use TgBotApi\BotApiBase\Method\SendVideoMethod; |
23
|
|
|
use TgBotApi\BotApiBase\Method\SendVideoNoteMethod; |
24
|
|
|
use TgBotApi\BotApiBase\Method\SendVoiceMethod; |
25
|
|
|
use TgBotApi\BotApiBase\Type\MessageType; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Trait SendMethodTrait. |
29
|
|
|
*/ |
30
|
|
|
trait SendMethodTrait |
31
|
|
|
{ |
32
|
|
|
/** |
33
|
|
|
* @param $method |
34
|
|
|
* @param $type |
35
|
|
|
* |
36
|
|
|
* @throws ResponseException |
37
|
|
|
* @throws NormalizationException |
38
|
|
|
* |
39
|
|
|
* @return mixed |
40
|
|
|
*/ |
41
|
|
|
abstract public function call($method, $type = null); |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @param SendPhotoMethod $method |
45
|
|
|
* |
46
|
|
|
* @throws ResponseException |
47
|
|
|
* @throws NormalizationException |
48
|
|
|
* |
49
|
|
|
* @return MessageType |
50
|
|
|
*/ |
51
|
6 |
|
public function sendPhoto(SendPhotoMethod $method): MessageType |
52
|
|
|
{ |
53
|
6 |
|
return $this->call($method, MessageType::class); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @param SendAudioMethod $method |
58
|
|
|
* |
59
|
|
|
* @throws ResponseException |
60
|
|
|
* @throws NormalizationException |
61
|
|
|
* |
62
|
|
|
* @return MessageType |
63
|
|
|
*/ |
64
|
6 |
|
public function sendAudio(SendAudioMethod $method): MessageType |
65
|
|
|
{ |
66
|
6 |
|
return $this->call($method, MessageType::class); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @param SendDocumentMethod $method |
71
|
|
|
* |
72
|
|
|
* @throws ResponseException |
73
|
|
|
* @throws NormalizationException |
74
|
|
|
* |
75
|
|
|
* @return MessageType |
76
|
|
|
*/ |
77
|
6 |
|
public function sendDocument(SendDocumentMethod $method): MessageType |
78
|
|
|
{ |
79
|
6 |
|
return $this->call($method, MessageType::class); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @param SendVideoMethod $method |
84
|
|
|
* |
85
|
|
|
* @throws ResponseException |
86
|
|
|
* @throws NormalizationException |
87
|
|
|
* |
88
|
|
|
* @return MessageType |
89
|
|
|
*/ |
90
|
6 |
|
public function sendVideo(SendVideoMethod $method): MessageType |
91
|
|
|
{ |
92
|
6 |
|
return $this->call($method, MessageType::class); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @param SendAnimationMethod $method |
97
|
|
|
* |
98
|
|
|
* @throws ResponseException |
99
|
|
|
* @throws NormalizationException |
100
|
|
|
* |
101
|
|
|
* @return MessageType |
102
|
|
|
*/ |
103
|
6 |
|
public function sendAnimation(SendAnimationMethod $method): MessageType |
104
|
|
|
{ |
105
|
6 |
|
return $this->call($method, MessageType::class); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @param SendVoiceMethod $method |
110
|
|
|
* |
111
|
|
|
* @throws ResponseException |
112
|
|
|
* @throws NormalizationException |
113
|
|
|
* |
114
|
|
|
* @return MessageType |
115
|
|
|
*/ |
116
|
6 |
|
public function sendVoice(SendVoiceMethod $method): MessageType |
117
|
|
|
{ |
118
|
6 |
|
return $this->call($method, MessageType::class); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @param SendVideoNoteMethod $method |
123
|
|
|
* |
124
|
|
|
* @throws ResponseException |
125
|
|
|
* @throws NormalizationException |
126
|
|
|
* |
127
|
|
|
* @return MessageType |
128
|
|
|
*/ |
129
|
6 |
|
public function sendVideoNote(SendVideoNoteMethod $method): MessageType |
130
|
|
|
{ |
131
|
6 |
|
return $this->call($method, MessageType::class); |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* @param SendMediaGroupMethod $method |
136
|
|
|
* |
137
|
|
|
* @throws ResponseException |
138
|
|
|
* @throws NormalizationException |
139
|
|
|
* |
140
|
|
|
* @return MessageType[] |
141
|
|
|
*/ |
142
|
6 |
|
public function sendMediaGroup(SendMediaGroupMethod $method): array |
143
|
|
|
{ |
144
|
6 |
|
return $this->call($method, MessageType::class . '[]'); |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* @param SendChatActionMethod $method |
149
|
|
|
* |
150
|
|
|
* @throws ResponseException |
151
|
|
|
* @throws NormalizationException |
152
|
|
|
* |
153
|
|
|
* @return bool |
154
|
|
|
*/ |
155
|
3 |
|
public function sendChatAction(SendChatActionMethod $method): bool |
156
|
|
|
{ |
157
|
3 |
|
return $this->call($method); |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* @param SendGameMethod $method |
162
|
|
|
* |
163
|
|
|
* @throws ResponseException |
164
|
|
|
* @throws NormalizationException |
165
|
|
|
* |
166
|
|
|
* @return MessageType |
167
|
|
|
*/ |
168
|
3 |
|
public function sendGame(SendGameMethod $method): MessageType |
169
|
|
|
{ |
170
|
3 |
|
return $this->call($method, MessageType::class); |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
/** |
174
|
|
|
* @param SendInvoiceMethod $method |
175
|
|
|
* |
176
|
|
|
* @throws ResponseException |
177
|
|
|
* @throws NormalizationException |
178
|
|
|
* |
179
|
|
|
* @return MessageType |
180
|
|
|
*/ |
181
|
3 |
|
public function sendInvoice(SendInvoiceMethod $method): MessageType |
182
|
|
|
{ |
183
|
3 |
|
return $this->call($method, MessageType::class); |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* @param SendLocationMethod $method |
188
|
|
|
* |
189
|
|
|
* @throws ResponseException |
190
|
|
|
* @throws NormalizationException |
191
|
|
|
* |
192
|
|
|
* @return MessageType |
193
|
|
|
*/ |
194
|
6 |
|
public function sendLocation(SendLocationMethod $method): MessageType |
195
|
|
|
{ |
196
|
6 |
|
return $this->call($method, MessageType::class); |
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
/** |
200
|
|
|
* @param SendVenueMethod $method |
201
|
|
|
* |
202
|
|
|
* @throws ResponseException |
203
|
|
|
* @throws NormalizationException |
204
|
|
|
* |
205
|
|
|
* @return MessageType |
206
|
|
|
*/ |
207
|
6 |
|
public function sendVenue(SendVenueMethod $method): MessageType |
208
|
|
|
{ |
209
|
6 |
|
return $this->call($method, MessageType::class); |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* @param SendContactMethod $method |
214
|
|
|
* |
215
|
|
|
* @throws ResponseException |
216
|
|
|
* @throws NormalizationException |
217
|
|
|
* |
218
|
|
|
* @return MessageType |
219
|
|
|
*/ |
220
|
6 |
|
public function sendContact(SendContactMethod $method): MessageType |
221
|
|
|
{ |
222
|
6 |
|
return $this->call($method, MessageType::class); |
223
|
|
|
} |
224
|
|
|
|
225
|
|
|
/** |
226
|
|
|
* @param SendStickerMethod $method |
227
|
|
|
* |
228
|
|
|
* @throws ResponseException |
229
|
|
|
* @throws NormalizationException |
230
|
|
|
* |
231
|
|
|
* @return MessageType |
232
|
|
|
*/ |
233
|
3 |
|
public function sendSticker(SendStickerMethod $method): MessageType |
234
|
|
|
{ |
235
|
3 |
|
return $this->call($method, MessageType::class); |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
/** |
239
|
|
|
* @param SendMessageMethod $method |
240
|
|
|
* |
241
|
|
|
* @throws ResponseException |
242
|
|
|
* @throws NormalizationException |
243
|
|
|
* |
244
|
|
|
* @return MessageType |
245
|
|
|
*/ |
246
|
6 |
|
public function sendMessage(SendMessageMethod $method): MessageType |
247
|
|
|
{ |
248
|
6 |
|
return $this->call($method, MessageType::class); |
249
|
|
|
} |
250
|
|
|
} |
251
|
|
|
|