|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace unreal4u\TelegramAPI\Telegram\Types; |
| 6 | + |
| 7 | +use unreal4u\TelegramAPI\Abstracts\TelegramTypes; |
| 8 | + |
| 9 | +/** |
| 10 | + * This object represents changes in the status of a chat member. |
| 11 | + * |
| 12 | + * @see https://core.telegram.org/bots/api#chatmemberupdated |
| 13 | + */ |
| 14 | +class ChatMemberUpdated extends TelegramTypes |
| 15 | +{ |
| 16 | + /** |
| 17 | + * Chat the user belongs to |
| 18 | + * @var Chat |
| 19 | + */ |
| 20 | + public $chat; |
| 21 | + |
| 22 | + /** |
| 23 | + * Performer of the action, which resulted in the change |
| 24 | + * @var User |
| 25 | + */ |
| 26 | + public $from; |
| 27 | + |
| 28 | + /** |
| 29 | + * Date the change was done in Unix time |
| 30 | + * @var int |
| 31 | + */ |
| 32 | + public $date; |
| 33 | + |
| 34 | + /** |
| 35 | + * Previous information about the chat member |
| 36 | + * @var ChatMember |
| 37 | + */ |
| 38 | + public $old_chat_member; |
| 39 | + |
| 40 | + /** |
| 41 | + * New information about the chat member |
| 42 | + * @var ChatMember |
| 43 | + */ |
| 44 | + public $new_chat_member; |
| 45 | + |
| 46 | + /** |
| 47 | + * Optional. Chat invite link, which was used by the user to join the chat; for joining by invite link events only. |
| 48 | + * @var ChatInviteLink |
| 49 | + */ |
| 50 | + public $invite_link; |
| 51 | + |
| 52 | + /** |
| 53 | + * Optional. True, if the user joined the chat via a chat folder invite link |
| 54 | + * @var bool |
| 55 | + */ |
| 56 | + public $via_chat_folder_invite_link; |
| 57 | + |
| 58 | + public function mapSubObjects(string $key, array $data): TelegramTypes |
| 59 | + { |
| 60 | + switch ($key) { |
| 61 | + case 'chat': |
| 62 | + return new Chat($data, $this->logger); |
| 63 | + case 'from': |
| 64 | + return new User($data, $this->logger); |
| 65 | + case 'old_chat_member': |
| 66 | + case 'new_chat_member': |
| 67 | + return new ChatMember($data, $this->logger); |
| 68 | + case 'invite_link': |
| 69 | + return new ChatInviteLink($data, $this->logger); |
| 70 | + } |
| 71 | + |
| 72 | + return parent::mapSubObjects($key, $data); |
| 73 | + } |
| 74 | +} |
0 commit comments