Skip to content

Commit 7b5783a

Browse files
committed
Add additional API types
1 parent 36085b2 commit 7b5783a

File tree

73 files changed

+3654
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+3654
-0
lines changed

src/Types/AcceptedGiftTypes.php

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
3+
namespace TelegramBot\\Api\\Types;
4+
5+
use TelegramBot\\Api\\BaseType;
6+
use TelegramBot\\Api\\TypeInterface;
7+
8+
class AcceptedGiftTypes extends BaseType implements TypeInterface
9+
{
10+
protected static $requiredParams = ['unlimited_gifts', 'limited_gifts', 'unique_gifts', 'premium_subscription'];
11+
12+
protected static $map = [
13+
'unlimited_gifts' => true,
14+
'limited_gifts' => true,
15+
'unique_gifts' => true,
16+
'premium_subscription' => true,
17+
];
18+
19+
protected $unlimitedGifts;
20+
protected $limitedGifts;
21+
protected $uniqueGifts;
22+
protected $premiumSubscription;
23+
24+
public function getUnlimitedGifts()
25+
{
26+
return $this->unlimitedGifts;
27+
}
28+
29+
public function setUnlimitedGifts($unlimitedGifts)
30+
{
31+
$this->unlimitedGifts = $unlimitedGifts;
32+
}
33+
34+
public function getLimitedGifts()
35+
{
36+
return $this->limitedGifts;
37+
}
38+
39+
public function setLimitedGifts($limitedGifts)
40+
{
41+
$this->limitedGifts = $limitedGifts;
42+
}
43+
44+
public function getUniqueGifts()
45+
{
46+
return $this->uniqueGifts;
47+
}
48+
49+
public function setUniqueGifts($uniqueGifts)
50+
{
51+
$this->uniqueGifts = $uniqueGifts;
52+
}
53+
54+
public function getPremiumSubscription()
55+
{
56+
return $this->premiumSubscription;
57+
}
58+
59+
public function setPremiumSubscription($premiumSubscription)
60+
{
61+
$this->premiumSubscription = $premiumSubscription;
62+
}
63+
}

src/Types/ArrayOfGift.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace TelegramBot\Api\Types;
4+
5+
use TelegramBot\Api\InvalidArgumentException;
6+
7+
abstract class ArrayOfGift
8+
{
9+
/**
10+
* @param array $data
11+
* @return Gift[]
12+
* @throws InvalidArgumentException
13+
*/
14+
public static function fromResponse($data)
15+
{
16+
$array = [];
17+
foreach ($data as $datum) {
18+
$array[] = Gift::fromResponse($datum);
19+
}
20+
21+
return $array;
22+
}
23+
}

src/Types/ArrayOfOwnedGift.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace TelegramBot\Api\Types;
4+
5+
use TelegramBot\Api\InvalidArgumentException;
6+
7+
abstract class ArrayOfOwnedGift
8+
{
9+
/**
10+
* @param array $data
11+
* @return OwnedGift[]
12+
* @throws InvalidArgumentException
13+
*/
14+
public static function fromResponse($data)
15+
{
16+
$array = [];
17+
foreach ($data as $datum) {
18+
$array[] = OwnedGift::fromResponse($datum);
19+
}
20+
21+
return $array;
22+
}
23+
}

src/Types/BotCommandScope.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
namespace TelegramBot\\Api\\Types;
4+
5+
use TelegramBot\\Api\\BaseType;
6+
use TelegramBot\\Api\\InvalidArgumentException;
7+
use TelegramBot\\Api\\TypeInterface;
8+
9+
abstract class BotCommandScope extends BaseType implements TypeInterface
10+
{
11+
protected static $requiredParams = ['type'];
12+
protected static $map = ['type' => true];
13+
14+
/**
15+
* @psalm-suppress LessSpecificReturnType,MoreSpecificReturnType
16+
*/
17+
public static function fromResponse($data)
18+
{
19+
self::validate($data);
20+
switch ($data['type']) {
21+
case 'default':
22+
return BotCommandScopeDefault::fromResponse($data);
23+
case 'all_private_chats':
24+
return BotCommandScopeAllPrivateChats::fromResponse($data);
25+
case 'all_group_chats':
26+
return BotCommandScopeAllGroupChats::fromResponse($data);
27+
case 'all_chat_administrators':
28+
return BotCommandScopeAllChatAdministrators::fromResponse($data);
29+
case 'chat':
30+
return BotCommandScopeChat::fromResponse($data);
31+
case 'chat_administrators':
32+
return BotCommandScopeChatAdministrators::fromResponse($data);
33+
case 'chat_member':
34+
return BotCommandScopeChatMember::fromResponse($data);
35+
default:
36+
throw new InvalidArgumentException('Unknown bot command scope type: ' . $data['type']);
37+
}
38+
}
39+
40+
protected $type;
41+
42+
public function getType()
43+
{
44+
return $this->type;
45+
}
46+
47+
public function setType($type)
48+
{
49+
$this->type = $type;
50+
}
51+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace TelegramBot\\Api\\Types;
4+
5+
/**
6+
* Class BotCommandScopeAllChatAdministrators
7+
* Represents the scope covering all group and supergroup chat administrators.
8+
*/
9+
class BotCommandScopeAllChatAdministrators extends BotCommandScope
10+
{
11+
protected static $requiredParams = ['type'];
12+
13+
protected static $map = [
14+
'type' => true
15+
];
16+
17+
protected $type = 'all_chat_administrators';
18+
19+
public static function fromResponse($data)
20+
{
21+
self::validate($data);
22+
$instance = new static();
23+
$instance->map($data);
24+
return $instance;
25+
}
26+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace TelegramBot\\Api\\Types;
4+
5+
/**
6+
* Class BotCommandScopeAllGroupChats
7+
* Represents the scope covering all group and supergroup chats.
8+
*/
9+
class BotCommandScopeAllGroupChats extends BotCommandScope
10+
{
11+
protected static $requiredParams = ['type'];
12+
13+
protected static $map = [
14+
'type' => true
15+
];
16+
17+
protected $type = 'all_group_chats';
18+
19+
public static function fromResponse($data)
20+
{
21+
self::validate($data);
22+
$instance = new static();
23+
$instance->map($data);
24+
return $instance;
25+
}
26+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace TelegramBot\\Api\\Types;
4+
5+
/**
6+
* Class BotCommandScopeAllPrivateChats
7+
* Represents the scope covering all private chats.
8+
*/
9+
class BotCommandScopeAllPrivateChats extends BotCommandScope
10+
{
11+
protected static $requiredParams = ['type'];
12+
13+
protected static $map = [
14+
'type' => true
15+
];
16+
17+
protected $type = 'all_private_chats';
18+
19+
public static function fromResponse($data)
20+
{
21+
self::validate($data);
22+
$instance = new static();
23+
$instance->map($data);
24+
return $instance;
25+
}
26+
}

src/Types/BotCommandScopeChat.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
namespace TelegramBot\\Api\\Types;
4+
5+
/**
6+
* Class BotCommandScopeChat
7+
* Represents the scope of bot commands, covering a specific chat.
8+
*/
9+
class BotCommandScopeChat extends BotCommandScope
10+
{
11+
protected static $requiredParams = ['type', 'chat_id'];
12+
13+
protected static $map = [
14+
'type' => true,
15+
'chat_id' => true
16+
];
17+
18+
protected $type = 'chat';
19+
protected $chatId;
20+
21+
public static function fromResponse($data)
22+
{
23+
self::validate($data);
24+
$instance = new static();
25+
$instance->map($data);
26+
return $instance;
27+
}
28+
29+
public function getChatId()
30+
{
31+
return $this->chatId;
32+
}
33+
34+
public function setChatId($chatId)
35+
{
36+
$this->chatId = $chatId;
37+
}
38+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
namespace TelegramBot\\Api\\Types;
4+
5+
/**
6+
* Class BotCommandScopeChatAdministrators
7+
* Represents the scope covering all administrators of a specific chat.
8+
*/
9+
class BotCommandScopeChatAdministrators extends BotCommandScope
10+
{
11+
protected static $requiredParams = ['type', 'chat_id'];
12+
13+
protected static $map = [
14+
'type' => true,
15+
'chat_id' => true
16+
];
17+
18+
protected $type = 'chat_administrators';
19+
protected $chatId;
20+
21+
public static function fromResponse($data)
22+
{
23+
self::validate($data);
24+
$instance = new static();
25+
$instance->map($data);
26+
return $instance;
27+
}
28+
29+
public function getChatId()
30+
{
31+
return $this->chatId;
32+
}
33+
34+
public function setChatId($chatId)
35+
{
36+
$this->chatId = $chatId;
37+
}
38+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
namespace TelegramBot\\Api\\Types;
4+
5+
/**
6+
* Class BotCommandScopeChatMember
7+
* Represents the scope covering a specific member of a chat.
8+
*/
9+
class BotCommandScopeChatMember extends BotCommandScope
10+
{
11+
protected static $requiredParams = ['type', 'chat_id', 'user_id'];
12+
13+
protected static $map = [
14+
'type' => true,
15+
'chat_id' => true,
16+
'user_id' => true
17+
];
18+
19+
protected $type = 'chat_member';
20+
protected $chatId;
21+
protected $userId;
22+
23+
public static function fromResponse($data)
24+
{
25+
self::validate($data);
26+
$instance = new static();
27+
$instance->map($data);
28+
return $instance;
29+
}
30+
31+
public function getChatId()
32+
{
33+
return $this->chatId;
34+
}
35+
36+
public function setChatId($chatId)
37+
{
38+
$this->chatId = $chatId;
39+
}
40+
41+
public function getUserId()
42+
{
43+
return $this->userId;
44+
}
45+
46+
public function setUserId($userId)
47+
{
48+
$this->userId = $userId;
49+
}
50+
}

0 commit comments

Comments
 (0)