Skip to content

Commit 77f04fe

Browse files
committed
Add WebAppInfo entity
1 parent fabfd78 commit 77f04fe

2 files changed

Lines changed: 34 additions & 2 deletions

File tree

src/Entities/InlineKeyboardButton.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class InlineKeyboardButton extends Entity
1818
protected $url;
1919
protected $callback_data;
2020
protected $switch_inline_query;
21+
protected $web_app;
2122

2223

2324
/**
@@ -37,8 +38,8 @@ public function __construct($data = array())
3738
$this->url = isset($data['url']) ? $data['url'] : null;
3839
$this->callback_data = isset($data['callback_data']) ? $data['callback_data'] : null;
3940
$this->switch_inline_query = isset($data['switch_inline_query']) ? $data['switch_inline_query'] : null;
40-
41-
if ($this->url === '' && $this->callback_data === '' && $this->switch_inline_query === '') {
41+
$this->web_app = isset($data['web_app']) ? $data['web_app'] : null;
42+
if ($this->url === '' && $this->callback_data === '' && $this->switch_inline_query === '' && $this->web_app === '') {
4243
throw new TelegramException('You must use at least one of these fields: url, callback_data, switch_inline_query!');
4344
}
4445
}

src/Entities/WebAppInfo.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
/**
3+
* This file is part of the TelegramBot package.
4+
*
5+
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
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 WebAppInfo extends Entity
16+
{
17+
protected $url;
18+
19+
/**
20+
* WebAppInfo constructor.
21+
*
22+
* @param array $data
23+
*/
24+
public function __construct($data = array())
25+
{
26+
$this->url = isset($data['url']) ? $data['url'] : null;
27+
if (empty($this->url)) {
28+
throw new TelegramException('url is empty!');
29+
}
30+
}
31+
}

0 commit comments

Comments
 (0)