1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace TgBotApi\BotApiBase\Traits; |
6
|
|
|
|
7
|
|
|
use TgBotApi\BotApiBase\Exception\ResponseException; |
8
|
|
|
use TgBotApi\BotApiBase\Method\Interfaces\AddMethodAliasInterface; |
9
|
|
|
use TgBotApi\BotApiBase\Method\Interfaces\AnswerMethodAliasInterface; |
10
|
|
|
use TgBotApi\BotApiBase\Method\Interfaces\CreateMethodAliasInterface; |
11
|
|
|
use TgBotApi\BotApiBase\Method\Interfaces\DeleteMethodAliasInterface; |
12
|
|
|
use TgBotApi\BotApiBase\Method\Interfaces\EditMethodAliasInterface; |
13
|
|
|
use TgBotApi\BotApiBase\Method\Interfaces\ForwardMethodAliasInterface; |
14
|
|
|
use TgBotApi\BotApiBase\Method\Interfaces\KickMethodAliasInterface; |
15
|
|
|
use TgBotApi\BotApiBase\Method\Interfaces\LeaveMethodAliasInterface; |
16
|
|
|
use TgBotApi\BotApiBase\Method\Interfaces\PinMethodAliasInterface; |
17
|
|
|
use TgBotApi\BotApiBase\Method\Interfaces\PromoteMethodAliasInterface; |
18
|
|
|
use TgBotApi\BotApiBase\Method\Interfaces\RestrictMethodAliasInterface; |
19
|
|
|
use TgBotApi\BotApiBase\Method\Interfaces\SendMethodAliasInterface; |
20
|
|
|
use TgBotApi\BotApiBase\Method\Interfaces\SetMethodAliasInterface; |
21
|
|
|
use TgBotApi\BotApiBase\Method\Interfaces\StopMethodAliasInterface; |
22
|
|
|
use TgBotApi\BotApiBase\Method\Interfaces\UnbanMethodAliasInterface; |
23
|
|
|
use TgBotApi\BotApiBase\Method\Interfaces\UnpinMethodAliasInterface; |
24
|
|
|
use TgBotApi\BotApiBase\Method\Interfaces\UploadMethodAliasInterface; |
25
|
|
|
use TgBotApi\BotApiBase\Type\FileType; |
26
|
|
|
use TgBotApi\BotApiBase\Type\MessageType; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Trait AliasMethodTrait. |
30
|
|
|
*/ |
31
|
|
|
trait AliasMethodTrait |
32
|
|
|
{ |
33
|
|
|
/** |
34
|
|
|
* @param $method |
35
|
|
|
* @param string|null $type |
36
|
|
|
* |
37
|
|
|
* @throws ResponseException |
38
|
|
|
* |
39
|
|
|
* @return mixed |
40
|
|
|
*/ |
41
|
|
|
abstract public function call($method, string $type = null); |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @param AddMethodAliasInterface $method |
45
|
|
|
* |
46
|
|
|
* @throws ResponseException |
47
|
|
|
* |
48
|
|
|
* @return bool |
49
|
|
|
*/ |
50
|
1 |
|
public function add(AddMethodAliasInterface $method): bool |
51
|
|
|
{ |
52
|
1 |
|
return $this->call($method); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @param AnswerMethodAliasInterface $method |
57
|
|
|
* |
58
|
|
|
* @throws ResponseException |
59
|
|
|
* |
60
|
|
|
* @return bool |
61
|
|
|
*/ |
62
|
5 |
|
public function answer(AnswerMethodAliasInterface $method): bool |
63
|
|
|
{ |
64
|
5 |
|
return $this->call($method); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @param CreateMethodAliasInterface $method |
69
|
|
|
* |
70
|
|
|
* @throws ResponseException |
71
|
|
|
* |
72
|
|
|
* @return bool |
73
|
|
|
*/ |
74
|
1 |
|
public function create(CreateMethodAliasInterface $method): bool |
75
|
|
|
{ |
76
|
1 |
|
return $this->call($method); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @param DeleteMethodAliasInterface $method |
81
|
|
|
* |
82
|
|
|
* @throws ResponseException |
83
|
|
|
* |
84
|
|
|
* @return bool |
85
|
|
|
*/ |
86
|
5 |
|
public function delete(DeleteMethodAliasInterface $method): bool |
87
|
|
|
{ |
88
|
5 |
|
return $this->call($method); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @param EditMethodAliasInterface $method |
93
|
|
|
* |
94
|
|
|
* @throws ResponseException |
95
|
|
|
* |
96
|
|
|
* @return bool |
97
|
|
|
*/ |
98
|
12 |
|
public function edit(EditMethodAliasInterface $method): bool |
99
|
|
|
{ |
100
|
12 |
|
return $this->call($method); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @param ForwardMethodAliasInterface $method |
105
|
|
|
* |
106
|
|
|
* @throws ResponseException |
107
|
|
|
* |
108
|
|
|
* @return MessageType |
109
|
|
|
*/ |
110
|
1 |
|
public function forward(ForwardMethodAliasInterface $method): MessageType |
111
|
|
|
{ |
112
|
1 |
|
return $this->call($method, MessageType::class); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* @param KickMethodAliasInterface $method |
117
|
|
|
* |
118
|
|
|
* @throws ResponseException |
119
|
|
|
* |
120
|
|
|
* @return bool |
121
|
|
|
*/ |
122
|
1 |
|
public function kick(KickMethodAliasInterface $method): bool |
123
|
|
|
{ |
124
|
1 |
|
return $this->call($method); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* @param LeaveMethodAliasInterface $method |
129
|
|
|
* |
130
|
|
|
* @throws ResponseException |
131
|
|
|
* |
132
|
|
|
* @return bool |
133
|
|
|
*/ |
134
|
1 |
|
public function leave(LeaveMethodAliasInterface $method): bool |
135
|
|
|
{ |
136
|
1 |
|
return $this->call($method); |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* @param PinMethodAliasInterface $method |
141
|
|
|
* |
142
|
|
|
* @throws ResponseException |
143
|
|
|
* |
144
|
|
|
* @return bool |
145
|
|
|
*/ |
146
|
1 |
|
public function pin(PinMethodAliasInterface $method): bool |
147
|
|
|
{ |
148
|
1 |
|
return $this->call($method); |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* @param PromoteMethodAliasInterface $method |
153
|
|
|
* |
154
|
|
|
* @throws ResponseException |
155
|
|
|
* |
156
|
|
|
* @return bool |
157
|
|
|
*/ |
158
|
1 |
|
public function promote(PromoteMethodAliasInterface $method): bool |
159
|
|
|
{ |
160
|
1 |
|
return $this->call($method); |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* @param RestrictMethodAliasInterface $method |
165
|
|
|
* |
166
|
|
|
* @throws ResponseException |
167
|
|
|
* |
168
|
|
|
* @return bool |
169
|
|
|
*/ |
170
|
1 |
|
public function restrict(RestrictMethodAliasInterface $method): bool |
171
|
|
|
{ |
172
|
1 |
|
return $this->call($method); |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
/** |
176
|
|
|
* @param SendMethodAliasInterface $method |
177
|
|
|
* |
178
|
|
|
* @throws ResponseException |
179
|
|
|
* |
180
|
|
|
* @return MessageType |
181
|
|
|
*/ |
182
|
25 |
|
public function send(SendMethodAliasInterface $method): MessageType |
183
|
|
|
{ |
184
|
25 |
|
return $this->call($method, MessageType::class); |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
/** |
188
|
|
|
* @param SetMethodAliasInterface $method |
189
|
|
|
* |
190
|
|
|
* @throws ResponseException |
191
|
|
|
* |
192
|
|
|
* @return bool |
193
|
|
|
*/ |
194
|
17 |
|
public function set(SetMethodAliasInterface $method): bool |
195
|
|
|
{ |
196
|
17 |
|
return $this->call($method); |
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
/** |
200
|
|
|
* @param StopMethodAliasInterface $method |
201
|
|
|
* |
202
|
|
|
* @throws ResponseException |
203
|
|
|
* |
204
|
|
|
* @return bool |
205
|
|
|
*/ |
206
|
2 |
|
public function stop(StopMethodAliasInterface $method): bool |
207
|
|
|
{ |
208
|
2 |
|
return $this->call($method); |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
/** |
212
|
|
|
* @param UnbanMethodAliasInterface $method |
213
|
|
|
* |
214
|
|
|
* @throws ResponseException |
215
|
|
|
* |
216
|
|
|
* @return bool |
217
|
|
|
*/ |
218
|
1 |
|
public function unban(UnbanMethodAliasInterface $method): bool |
219
|
|
|
{ |
220
|
1 |
|
return $this->call($method); |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
/** |
224
|
|
|
* @param UnpinMethodAliasInterface $method |
225
|
|
|
* |
226
|
|
|
* @throws ResponseException |
227
|
|
|
* |
228
|
|
|
* @return bool |
229
|
|
|
*/ |
230
|
1 |
|
public function unpin(UnpinMethodAliasInterface $method): bool |
231
|
|
|
{ |
232
|
1 |
|
return $this->call($method); |
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
/** |
236
|
|
|
* @param UploadMethodAliasInterface $method |
237
|
|
|
* |
238
|
|
|
* @throws ResponseException |
239
|
|
|
* |
240
|
|
|
* @return FileType |
241
|
|
|
*/ |
242
|
1 |
|
public function upload(UploadMethodAliasInterface $method): FileType |
243
|
|
|
{ |
244
|
1 |
|
return $this->call($method, FileType::class); |
245
|
|
|
} |
246
|
|
|
} |
247
|
|
|
|