1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the TelegramBot package. |
4
|
|
|
* |
5
|
|
|
* (c) Avtandil Kikabidze aka LONGMAN <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Longman\TelegramBot\Entities; |
12
|
|
|
|
13
|
|
|
use Longman\TelegramBot\Exception\TelegramException; |
14
|
|
|
|
15
|
|
|
class WebhookInfo extends Entity |
16
|
|
|
{ |
17
|
|
|
protected $url; // String Webhook URL, may be empty if webhook is not set up |
18
|
|
|
protected $has_custom_certificate; // Boolean True, if a custom certificate was provided for webhook certificate checks |
19
|
|
|
protected $pending_update_count; // Integer Number of updates awaiting delivery |
20
|
|
|
protected $last_error_date; // Integer Optional. Unix time for the most recent error that happened when trying to deliver an update via webhook |
21
|
|
|
protected $last_error_message; // String Optional. Error message in human-readable format for the most recent error that happened when trying to deliver an update via webhook |
22
|
|
|
|
23
|
|
|
public function __construct(array $data) |
24
|
|
|
{ |
25
|
|
|
$this->url = isset($data['url']) ? $data['url'] : null; |
26
|
|
|
$this->has_custom_certificate = isset($data['has_custom_certificate']) ? $data['has_custom_certificate'] : null; |
27
|
|
|
$this->pending_update_count = isset($data['pending_update_count']) ? $data['pending_update_count'] : null; |
28
|
|
|
$this->last_error_date = isset($data['last_error_date']) ? $data['last_error_date'] : null; |
29
|
|
|
$this->last_error_message = isset($data['last_error_message']) ? $data['last_error_message'] : null; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Webhook URL, may be empty if webhook is not set up. |
34
|
|
|
* |
35
|
|
|
* @return string |
36
|
|
|
*/ |
37
|
|
|
public function getUrl() |
38
|
|
|
{ |
39
|
|
|
return $this->url; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* True, if a custom certificate was provided for webhook certificate checks. |
44
|
|
|
* |
45
|
|
|
* @return bool |
46
|
|
|
*/ |
47
|
|
|
public function getHasCustomCertificate() |
48
|
|
|
{ |
49
|
|
|
return $this->has_custom_certificate; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Number of updates awaiting delivery. |
54
|
|
|
* |
55
|
|
|
* @return int |
56
|
|
|
*/ |
57
|
|
|
public function getPendingUpdateCount() |
58
|
|
|
{ |
59
|
|
|
return $this->pending_update_count; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Optional. |
64
|
|
|
* Unix time for the most recent error that happened when trying to deliver an update via webhook. |
65
|
|
|
* |
66
|
|
|
* @return int |
67
|
|
|
*/ |
68
|
|
|
public function getLastErrorDate() |
69
|
|
|
{ |
70
|
|
|
return $this->last_error_date; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Optional. |
75
|
|
|
* Error message in human-readable format for the most recent error that happened when trying to deliver an update via webhook. |
76
|
|
|
* |
77
|
|
|
* @return string |
78
|
|
|
*/ |
79
|
|
|
public function getLastErrorMessage() |
80
|
|
|
{ |
81
|
|
|
return $this->last_error_message; |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|