Commit 8acc126f authored by Monster3D's avatar Monster3D

Merge remote-tracking branch 'origin/develop' into tests/telegram-bot-api

parents 68b75c1b 3eb15014
...@@ -69,6 +69,9 @@ class ServerResponse extends Entity ...@@ -69,6 +69,9 @@ class ServerResponse extends Entity
} elseif (isset($data['result']['user'])) { } elseif (isset($data['result']['user'])) {
//Response from getChatMember //Response from getChatMember
$this->result = new ChatMember($data['result']); $this->result = new ChatMember($data['result']);
} elseif (isset($data['result']['has_custom_certificate'])) {
//Response from getWebhookInfo
$this->result = new WebhookInfo($data['result']);
} else { } else {
//Response from sendMessage //Response from sendMessage
$this->result = new Message($data['result'], $bot_name); $this->result = new Message($data['result'], $bot_name);
......
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
class WebhookInfo extends Entity
{
protected $url; // String Webhook URL, may be empty if webhook is not set up
protected $has_custom_certificate; // Boolean True, if a custom certificate was provided for webhook certificate checks
protected $pending_update_count; // Integer Number of updates awaiting delivery
protected $last_error_date; // Integer Optional. Unix time for the most recent error that happened when trying to deliver an update via webhook
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
public function __construct(array $data)
{
$this->url = isset($data['url']) ? $data['url'] : null;
$this->has_custom_certificate = isset($data['has_custom_certificate']) ? $data['has_custom_certificate'] : null;
$this->pending_update_count = isset($data['pending_update_count']) ? $data['pending_update_count'] : null;
$this->last_error_date = isset($data['last_error_date']) ? $data['last_error_date'] : null;
$this->last_error_message = isset($data['last_error_message']) ? $data['last_error_message'] : null;
}
/**
* Webhook URL, may be empty if webhook is not set up.
*
* @return string
*/
public function getUrl()
{
return $this->url;
}
/**
* True, if a custom certificate was provided for webhook certificate checks.
*
* @return bool
*/
public function getHasCustomCertificate()
{
return $this->has_custom_certificate;
}
/**
* Number of updates awaiting delivery.
*
* @return int
*/
public function getPendingUpdateCount()
{
return $this->pending_update_count;
}
/**
* Optional.
* Unix time for the most recent error that happened when trying to deliver an update via webhook.
*
* @return int
*/
public function getLastErrorDate()
{
return $this->last_error_date;
}
/**
* Optional.
* Error message in human-readable format for the most recent error that happened when trying to deliver an update via webhook.
*
* @return string
*/
public function getLastErrorMessage()
{
return $this->last_error_message;
}
}
...@@ -81,6 +81,7 @@ class Request ...@@ -81,6 +81,7 @@ class Request
'editMessageText', 'editMessageText',
'editMessageCaption', 'editMessageCaption',
'editMessageReplyMarkup', 'editMessageReplyMarkup',
'getWebhookInfo',
]; ];
/** /**
...@@ -842,4 +843,14 @@ class Request ...@@ -842,4 +843,14 @@ class Request
return $results; return $results;
} }
/**
* Use this method to get current webhook status.
*
* @return Entities\ServerResponse
*/
public static function getWebhookInfo()
{
return self::send('getWebhookInfo', []);
}
} }
...@@ -56,13 +56,13 @@ class AudioTest extends TestCase ...@@ -56,13 +56,13 @@ class AudioTest extends TestCase
} }
/** /**
* Test base stage without duration property * Test base stage without file_id property
* *
* @expectedException Longman\TelegramBot\Exception\TelegramException * @expectedException Longman\TelegramBot\Exception\TelegramException
*/ */
public function testBaseStageWithoutFileId() public function testBaseStageWithoutFileId()
{ {
$this->record['duration'] = null; $this->record['file_id'] = null;
new Audio($this->record); new Audio($this->record);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment