Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions src/Types/AcceptedGiftTypes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

namespace TelegramBot\\Api\\Types;

use TelegramBot\\Api\\BaseType;
use TelegramBot\\Api\\TypeInterface;

class AcceptedGiftTypes extends BaseType implements TypeInterface
{
protected static $requiredParams = ['unlimited_gifts', 'limited_gifts', 'unique_gifts', 'premium_subscription'];

protected static $map = [
'unlimited_gifts' => true,
'limited_gifts' => true,
'unique_gifts' => true,
'premium_subscription' => true,
];

protected $unlimitedGifts;
protected $limitedGifts;
protected $uniqueGifts;
protected $premiumSubscription;

public function getUnlimitedGifts()
{
return $this->unlimitedGifts;
}

public function setUnlimitedGifts($unlimitedGifts)
{
$this->unlimitedGifts = $unlimitedGifts;
}

public function getLimitedGifts()
{
return $this->limitedGifts;
}

public function setLimitedGifts($limitedGifts)
{
$this->limitedGifts = $limitedGifts;
}

public function getUniqueGifts()
{
return $this->uniqueGifts;
}

public function setUniqueGifts($uniqueGifts)
{
$this->uniqueGifts = $uniqueGifts;
}

public function getPremiumSubscription()
{
return $this->premiumSubscription;
}

public function setPremiumSubscription($premiumSubscription)
{
$this->premiumSubscription = $premiumSubscription;
}
}
23 changes: 23 additions & 0 deletions src/Types/ArrayOfGift.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace TelegramBot\Api\Types;

use TelegramBot\Api\InvalidArgumentException;

abstract class ArrayOfGift
{
/**
* @param array $data
* @return Gift[]
* @throws InvalidArgumentException
*/
public static function fromResponse($data)
{
$array = [];
foreach ($data as $datum) {
$array[] = Gift::fromResponse($datum);
}

return $array;
}
}
23 changes: 23 additions & 0 deletions src/Types/ArrayOfOwnedGift.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace TelegramBot\Api\Types;

use TelegramBot\Api\InvalidArgumentException;

abstract class ArrayOfOwnedGift
{
/**
* @param array $data
* @return OwnedGift[]
* @throws InvalidArgumentException
*/
public static function fromResponse($data)
{
$array = [];
foreach ($data as $datum) {
$array[] = OwnedGift::fromResponse($datum);
}

return $array;
}
}
51 changes: 51 additions & 0 deletions src/Types/BotCommandScope.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

namespace TelegramBot\\Api\\Types;

use TelegramBot\\Api\\BaseType;
use TelegramBot\\Api\\InvalidArgumentException;
use TelegramBot\\Api\\TypeInterface;

abstract class BotCommandScope extends BaseType implements TypeInterface
{
protected static $requiredParams = ['type'];
protected static $map = ['type' => true];

/**
* @psalm-suppress LessSpecificReturnType,MoreSpecificReturnType
*/
public static function fromResponse($data)
{
self::validate($data);
switch ($data['type']) {
case 'default':
return BotCommandScopeDefault::fromResponse($data);
case 'all_private_chats':
return BotCommandScopeAllPrivateChats::fromResponse($data);
case 'all_group_chats':
return BotCommandScopeAllGroupChats::fromResponse($data);
case 'all_chat_administrators':
return BotCommandScopeAllChatAdministrators::fromResponse($data);
case 'chat':
return BotCommandScopeChat::fromResponse($data);
case 'chat_administrators':
return BotCommandScopeChatAdministrators::fromResponse($data);
case 'chat_member':
return BotCommandScopeChatMember::fromResponse($data);
default:
throw new InvalidArgumentException('Unknown bot command scope type: ' . $data['type']);
}
}

protected $type;

public function getType()
{
return $this->type;
}

public function setType($type)
{
$this->type = $type;
}
}
26 changes: 26 additions & 0 deletions src/Types/BotCommandScopeAllChatAdministrators.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace TelegramBot\\Api\\Types;

/**
* Class BotCommandScopeAllChatAdministrators
* Represents the scope covering all group and supergroup chat administrators.
*/
class BotCommandScopeAllChatAdministrators extends BotCommandScope
{
protected static $requiredParams = ['type'];

protected static $map = [
'type' => true
];

protected $type = 'all_chat_administrators';

public static function fromResponse($data)
{
self::validate($data);
$instance = new static();
$instance->map($data);
return $instance;
}
}
26 changes: 26 additions & 0 deletions src/Types/BotCommandScopeAllGroupChats.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace TelegramBot\\Api\\Types;

/**
* Class BotCommandScopeAllGroupChats
* Represents the scope covering all group and supergroup chats.
*/
class BotCommandScopeAllGroupChats extends BotCommandScope
{
protected static $requiredParams = ['type'];

protected static $map = [
'type' => true
];

protected $type = 'all_group_chats';

public static function fromResponse($data)
{
self::validate($data);
$instance = new static();
$instance->map($data);
return $instance;
}
}
26 changes: 26 additions & 0 deletions src/Types/BotCommandScopeAllPrivateChats.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace TelegramBot\\Api\\Types;

/**
* Class BotCommandScopeAllPrivateChats
* Represents the scope covering all private chats.
*/
class BotCommandScopeAllPrivateChats extends BotCommandScope
{
protected static $requiredParams = ['type'];

protected static $map = [
'type' => true
];

protected $type = 'all_private_chats';

public static function fromResponse($data)
{
self::validate($data);
$instance = new static();
$instance->map($data);
return $instance;
}
}
38 changes: 38 additions & 0 deletions src/Types/BotCommandScopeChat.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace TelegramBot\\Api\\Types;

/**
* Class BotCommandScopeChat
* Represents the scope of bot commands, covering a specific chat.
*/
class BotCommandScopeChat extends BotCommandScope
{
protected static $requiredParams = ['type', 'chat_id'];

protected static $map = [
'type' => true,
'chat_id' => true
];

protected $type = 'chat';
protected $chatId;

public static function fromResponse($data)
{
self::validate($data);
$instance = new static();
$instance->map($data);
return $instance;
}

public function getChatId()
{
return $this->chatId;
}

public function setChatId($chatId)
{
$this->chatId = $chatId;
}
}
38 changes: 38 additions & 0 deletions src/Types/BotCommandScopeChatAdministrators.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace TelegramBot\\Api\\Types;

/**
* Class BotCommandScopeChatAdministrators
* Represents the scope covering all administrators of a specific chat.
*/
class BotCommandScopeChatAdministrators extends BotCommandScope
{
protected static $requiredParams = ['type', 'chat_id'];

protected static $map = [
'type' => true,
'chat_id' => true
];

protected $type = 'chat_administrators';
protected $chatId;

public static function fromResponse($data)
{
self::validate($data);
$instance = new static();
$instance->map($data);
return $instance;
}

public function getChatId()
{
return $this->chatId;
}

public function setChatId($chatId)
{
$this->chatId = $chatId;
}
}
50 changes: 50 additions & 0 deletions src/Types/BotCommandScopeChatMember.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace TelegramBot\\Api\\Types;

/**
* Class BotCommandScopeChatMember
* Represents the scope covering a specific member of a chat.
*/
class BotCommandScopeChatMember extends BotCommandScope
{
protected static $requiredParams = ['type', 'chat_id', 'user_id'];

protected static $map = [
'type' => true,
'chat_id' => true,
'user_id' => true
];

protected $type = 'chat_member';
protected $chatId;
protected $userId;

public static function fromResponse($data)
{
self::validate($data);
$instance = new static();
$instance->map($data);
return $instance;
}

public function getChatId()
{
return $this->chatId;
}

public function setChatId($chatId)
{
$this->chatId = $chatId;
}

public function getUserId()
{
return $this->userId;
}

public function setUserId($userId)
{
$this->userId = $userId;
}
}
Loading
Loading