1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* User: boshurik |
4
|
|
|
* Date: 10.06.2020 |
5
|
|
|
* Time: 19:43 |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace TelegramBot\Api\Types; |
9
|
|
|
|
10
|
|
|
use TelegramBot\Api\BaseType; |
11
|
|
|
use TelegramBot\Api\TypeInterface; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Contains information about the current status of a webhook. |
15
|
|
|
* |
16
|
|
|
* @package TelegramBot\Api\Types |
17
|
|
|
*/ |
18
|
|
|
class WebhookInfo extends BaseType implements TypeInterface |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* {@inheritdoc} |
22
|
|
|
* |
23
|
|
|
* @var array |
24
|
|
|
*/ |
25
|
|
|
static protected $requiredParams = ['url', 'has_custom_certificate', 'pending_update_count']; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* {@inheritdoc} |
29
|
|
|
* |
30
|
|
|
* @var array |
31
|
|
|
*/ |
32
|
|
|
static protected $map = [ |
33
|
|
|
'url' => true, |
34
|
|
|
'has_custom_certificate' => true, |
35
|
|
|
'pending_update_count' => true, |
36
|
|
|
'last_error_date' => true, |
37
|
|
|
'last_error_message' => true, |
38
|
|
|
'max_connections' => true, |
39
|
|
|
'allowed_updates' => true |
40
|
|
|
]; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Webhook URL, may be empty if webhook is not set up |
44
|
|
|
* |
45
|
|
|
* @var string |
46
|
|
|
*/ |
47
|
|
|
protected $url; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* True, if a custom certificate was provided for webhook certificate checks |
51
|
|
|
* |
52
|
|
|
* @var bool |
53
|
|
|
*/ |
54
|
|
|
protected $hasCustomCertificate; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Number of updates awaiting delivery |
58
|
|
|
* |
59
|
|
|
* @var int |
60
|
|
|
*/ |
61
|
|
|
protected $pendingUpdateCount; |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Optional. Unix time for the most recent error that happened when trying to deliver an update via webhook |
65
|
|
|
* |
66
|
|
|
* @var int |
67
|
|
|
*/ |
68
|
|
|
protected $lastErrorDate; |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Optional. Error message in human-readable format for the most recent error that happened when trying to deliver |
72
|
|
|
* an update via webhook |
73
|
|
|
* |
74
|
|
|
* @var string |
75
|
|
|
*/ |
76
|
|
|
protected $lastErrorMessage; |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Optional. Maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery |
80
|
|
|
* |
81
|
|
|
* @var int |
82
|
|
|
*/ |
83
|
|
|
protected $maxConnections; |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Optional. A list of update types the bot is subscribed to. Defaults to all update types |
87
|
|
|
* |
88
|
|
|
* @var array |
89
|
|
|
*/ |
90
|
|
|
protected $allowedUpdates; |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @return string |
94
|
|
|
*/ |
95
|
1 |
|
public function getUrl() |
96
|
|
|
{ |
97
|
1 |
|
return $this->url; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @param string $url |
102
|
|
|
*/ |
103
|
1 |
|
public function setUrl($url) |
104
|
|
|
{ |
105
|
1 |
|
$this->url = $url; |
106
|
1 |
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @return bool |
110
|
|
|
*/ |
111
|
1 |
|
public function hasCustomCertificate() |
112
|
|
|
{ |
113
|
1 |
|
return $this->hasCustomCertificate; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @param bool $hasCustomCertificate |
118
|
|
|
*/ |
119
|
1 |
|
public function setHasCustomCertificate($hasCustomCertificate) |
120
|
|
|
{ |
121
|
1 |
|
$this->hasCustomCertificate = $hasCustomCertificate; |
122
|
1 |
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* @return int |
126
|
|
|
*/ |
127
|
1 |
|
public function getPendingUpdateCount() |
128
|
|
|
{ |
129
|
1 |
|
return $this->pendingUpdateCount; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* @param int $pendingUpdateCount |
134
|
|
|
*/ |
135
|
1 |
|
public function setPendingUpdateCount($pendingUpdateCount) |
136
|
|
|
{ |
137
|
1 |
|
$this->pendingUpdateCount = $pendingUpdateCount; |
138
|
1 |
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* @return int |
142
|
|
|
*/ |
143
|
1 |
|
public function getLastErrorDate() |
144
|
|
|
{ |
145
|
1 |
|
return $this->lastErrorDate; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* @param int $lastErrorDate |
150
|
|
|
*/ |
151
|
|
|
public function setLastErrorDate($lastErrorDate) |
152
|
|
|
{ |
153
|
|
|
$this->lastErrorDate = $lastErrorDate; |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* @return string |
158
|
|
|
*/ |
159
|
1 |
|
public function getLastErrorMessage() |
160
|
|
|
{ |
161
|
1 |
|
return $this->lastErrorMessage; |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* @param string $lastErrorMessage |
166
|
|
|
*/ |
167
|
|
|
public function setLastErrorMessage($lastErrorMessage) |
168
|
|
|
{ |
169
|
|
|
$this->lastErrorMessage = $lastErrorMessage; |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* @return int |
174
|
|
|
*/ |
175
|
1 |
|
public function getMaxConnections() |
176
|
|
|
{ |
177
|
1 |
|
return $this->maxConnections; |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* @param int $maxConnections |
182
|
|
|
*/ |
183
|
1 |
|
public function setMaxConnections($maxConnections) |
184
|
|
|
{ |
185
|
1 |
|
$this->maxConnections = $maxConnections; |
186
|
1 |
|
} |
187
|
|
|
|
188
|
|
|
/** |
189
|
|
|
* @return array |
190
|
|
|
*/ |
191
|
1 |
|
public function getAllowedUpdates() |
192
|
|
|
{ |
193
|
1 |
|
return $this->allowedUpdates; |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
/** |
197
|
|
|
* @param array $allowedUpdates |
198
|
|
|
*/ |
199
|
|
|
public function setAllowedUpdates($allowedUpdates) |
200
|
|
|
{ |
201
|
|
|
$this->allowedUpdates = $allowedUpdates; |
202
|
|
|
} |
203
|
|
|
} |
204
|
|
|
|