diff --git a/src/Telegram/Animation.php b/src/Telegram/Animation.php index 2b79f41..71cf15d 100644 --- a/src/Telegram/Animation.php +++ b/src/Telegram/Animation.php @@ -27,14 +27,50 @@ class Animation extends \Tii\Telepath\Type public int $duration; /** Optional. Animation thumbnail as defined by sender */ - public ?PhotoSize $thumb; + public ?PhotoSize $thumb = null; /** Optional. Original animation filename as defined by sender */ - public ?string $file_name; + public ?string $file_name = null; /** Optional. MIME type of the file as defined by sender */ - public ?string $mime_type; + public ?string $mime_type = null; /** Optional. File size in bytes */ - public ?int $file_size; + public ?int $file_size = null; + + + /** + * @param string $file_id Identifier for this file, which can be used to download or reuse the file + * @param string $file_unique_id Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. + * @param int $width Video width as defined by sender + * @param int $height Video height as defined by sender + * @param int $duration Duration of the video in seconds as defined by sender + * @param PhotoSize $thumb Optional. Animation thumbnail as defined by sender + * @param string $file_name Optional. Original animation filename as defined by sender + * @param string $mime_type Optional. MIME type of the file as defined by sender + * @param int $file_size Optional. File size in bytes + */ + public static function make( + string $file_id, + string $file_unique_id, + int $width, + int $height, + int $duration, + ?PhotoSize $thumb = null, + ?string $file_name = null, + ?string $mime_type = null, + ?int $file_size = null + ): static { + return new static([ + 'file_id' => $file_id, + 'file_unique_id' => $file_unique_id, + 'width' => $width, + 'height' => $height, + 'duration' => $duration, + 'thumb' => $thumb, + 'file_name' => $file_name, + 'mime_type' => $mime_type, + 'file_size' => $file_size, + ]); + } } diff --git a/src/Telegram/Audio.php b/src/Telegram/Audio.php index 98dc1f1..441c078 100644 --- a/src/Telegram/Audio.php +++ b/src/Telegram/Audio.php @@ -21,20 +21,56 @@ class Audio extends \Tii\Telepath\Type public int $duration; /** Optional. Performer of the audio as defined by sender or by audio tags */ - public ?string $performer; + public ?string $performer = null; /** Optional. Title of the audio as defined by sender or by audio tags */ - public ?string $title; + public ?string $title = null; /** Optional. Original filename as defined by sender */ - public ?string $file_name; + public ?string $file_name = null; /** Optional. MIME type of the file as defined by sender */ - public ?string $mime_type; + public ?string $mime_type = null; /** Optional. File size in bytes */ - public ?int $file_size; + public ?int $file_size = null; /** Optional. Thumbnail of the album cover to which the music file belongs */ - public ?PhotoSize $thumb; + public ?PhotoSize $thumb = null; + + + /** + * @param string $file_id Identifier for this file, which can be used to download or reuse the file + * @param string $file_unique_id Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. + * @param int $duration Duration of the audio in seconds as defined by sender + * @param string $performer Optional. Performer of the audio as defined by sender or by audio tags + * @param string $title Optional. Title of the audio as defined by sender or by audio tags + * @param string $file_name Optional. Original filename as defined by sender + * @param string $mime_type Optional. MIME type of the file as defined by sender + * @param int $file_size Optional. File size in bytes + * @param PhotoSize $thumb Optional. Thumbnail of the album cover to which the music file belongs + */ + public static function make( + string $file_id, + string $file_unique_id, + int $duration, + ?string $performer = null, + ?string $title = null, + ?string $file_name = null, + ?string $mime_type = null, + ?int $file_size = null, + ?PhotoSize $thumb = null + ): static { + return new static([ + 'file_id' => $file_id, + 'file_unique_id' => $file_unique_id, + 'duration' => $duration, + 'performer' => $performer, + 'title' => $title, + 'file_name' => $file_name, + 'mime_type' => $mime_type, + 'file_size' => $file_size, + 'thumb' => $thumb, + ]); + } } diff --git a/src/Telegram/BotCommand.php b/src/Telegram/BotCommand.php index 79b633e..78a0ac1 100644 --- a/src/Telegram/BotCommand.php +++ b/src/Telegram/BotCommand.php @@ -16,4 +16,17 @@ class BotCommand extends \Tii\Telepath\Type /** Description of the command; 1-256 characters. */ public string $description; + + + /** + * @param string $command Text of the command; 1-32 characters. Can contain only lowercase English letters, digits and underscores. + * @param string $description Description of the command; 1-256 characters. + */ + public static function make(string $command, string $description): static + { + return new static([ + 'command' => $command, + 'description' => $description, + ]); + } } diff --git a/src/Telegram/BotCommandScope.php b/src/Telegram/BotCommandScope.php index dcdf1a7..78ec7bf 100644 --- a/src/Telegram/BotCommandScope.php +++ b/src/Telegram/BotCommandScope.php @@ -13,4 +13,15 @@ class BotCommandScope extends \Tii\Telepath\Type { /** Scope type */ public string $type; + + + /** + * @param string $type Scope type + */ + public static function make(string $type): static + { + return new static([ + 'type' => $type, + ]); + } } diff --git a/src/Telegram/BotCommandScopeAllChatAdministrators.php b/src/Telegram/BotCommandScopeAllChatAdministrators.php index 0f6db0c..a7e4f47 100644 --- a/src/Telegram/BotCommandScopeAllChatAdministrators.php +++ b/src/Telegram/BotCommandScopeAllChatAdministrators.php @@ -11,4 +11,9 @@ */ class BotCommandScopeAllChatAdministrators extends BotCommandScope { + public static function make(): static + { + return new static([ + ]); + } } diff --git a/src/Telegram/BotCommandScopeAllGroupChats.php b/src/Telegram/BotCommandScopeAllGroupChats.php index 9019e8a..97689f4 100644 --- a/src/Telegram/BotCommandScopeAllGroupChats.php +++ b/src/Telegram/BotCommandScopeAllGroupChats.php @@ -11,4 +11,9 @@ */ class BotCommandScopeAllGroupChats extends BotCommandScope { + public static function make(): static + { + return new static([ + ]); + } } diff --git a/src/Telegram/BotCommandScopeAllPrivateChats.php b/src/Telegram/BotCommandScopeAllPrivateChats.php index 1ac0ec5..c7d3b74 100644 --- a/src/Telegram/BotCommandScopeAllPrivateChats.php +++ b/src/Telegram/BotCommandScopeAllPrivateChats.php @@ -11,4 +11,9 @@ */ class BotCommandScopeAllPrivateChats extends BotCommandScope { + public static function make(): static + { + return new static([ + ]); + } } diff --git a/src/Telegram/BotCommandScopeChat.php b/src/Telegram/BotCommandScopeChat.php index 1530b21..4c42d8a 100644 --- a/src/Telegram/BotCommandScopeChat.php +++ b/src/Telegram/BotCommandScopeChat.php @@ -13,4 +13,15 @@ class BotCommandScopeChat extends BotCommandScope { /** Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) */ public int|string $chat_id; + + + /** + * @param int|string $chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + */ + public static function make(int|string $chat_id): static + { + return new static([ + 'chat_id' => $chat_id, + ]); + } } diff --git a/src/Telegram/BotCommandScopeChatAdministrators.php b/src/Telegram/BotCommandScopeChatAdministrators.php index ff07163..cbac5af 100644 --- a/src/Telegram/BotCommandScopeChatAdministrators.php +++ b/src/Telegram/BotCommandScopeChatAdministrators.php @@ -13,4 +13,15 @@ class BotCommandScopeChatAdministrators extends BotCommandScope { /** Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) */ public int|string $chat_id; + + + /** + * @param int|string $chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + */ + public static function make(int|string $chat_id): static + { + return new static([ + 'chat_id' => $chat_id, + ]); + } } diff --git a/src/Telegram/BotCommandScopeChatMember.php b/src/Telegram/BotCommandScopeChatMember.php index a8dca98..074c639 100644 --- a/src/Telegram/BotCommandScopeChatMember.php +++ b/src/Telegram/BotCommandScopeChatMember.php @@ -16,4 +16,17 @@ class BotCommandScopeChatMember extends BotCommandScope /** Unique identifier of the target user */ public int $user_id; + + + /** + * @param int|string $chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * @param int $user_id Unique identifier of the target user + */ + public static function make(int|string $chat_id, int $user_id): static + { + return new static([ + 'chat_id' => $chat_id, + 'user_id' => $user_id, + ]); + } } diff --git a/src/Telegram/BotCommandScopeDefault.php b/src/Telegram/BotCommandScopeDefault.php index 8b26f7f..d35193f 100644 --- a/src/Telegram/BotCommandScopeDefault.php +++ b/src/Telegram/BotCommandScopeDefault.php @@ -11,4 +11,9 @@ */ class BotCommandScopeDefault extends BotCommandScope { + public static function make(): static + { + return new static([ + ]); + } } diff --git a/src/Telegram/CallbackQuery.php b/src/Telegram/CallbackQuery.php index 78d7731..631c922 100644 --- a/src/Telegram/CallbackQuery.php +++ b/src/Telegram/CallbackQuery.php @@ -18,17 +18,47 @@ class CallbackQuery extends \Tii\Telepath\Type public User $from; /** Optional. Message with the callback button that originated the query. Note that message content and message date will not be available if the message is too old */ - public ?Message $message; + public ?Message $message = null; /** Optional. Identifier of the message sent via the bot in inline mode, that originated the query. */ - public ?string $inline_message_id; + public ?string $inline_message_id = null; /** Global identifier, uniquely corresponding to the chat to which the message with the callback button was sent. Useful for high scores in games. */ public string $chat_instance; /** Optional. Data associated with the callback button. Be aware that a bad client can send arbitrary data in this field. */ - public ?string $data; + public ?string $data = null; /** Optional. Short name of a Game to be returned, serves as the unique identifier for the game */ - public ?string $game_short_name; + public ?string $game_short_name = null; + + + /** + * @param string $id Unique identifier for this query + * @param User $from Sender + * @param Message $message Optional. Message with the callback button that originated the query. Note that message content and message date will not be available if the message is too old + * @param string $inline_message_id Optional. Identifier of the message sent via the bot in inline mode, that originated the query. + * @param string $chat_instance Global identifier, uniquely corresponding to the chat to which the message with the callback button was sent. Useful for high scores in games. + * @param string $data Optional. Data associated with the callback button. Be aware that a bad client can send arbitrary data in this field. + * @param string $game_short_name Optional. Short name of a Game to be returned, serves as the unique identifier for the game + */ + public static function make( + string $id, + User $from, + ?Message $message = null, + ?string $inline_message_id = null, + string $chat_instance, + ?string $data = null, + ?string $game_short_name = null + ): static { + return new static([ + 'id' => $id, + 'from' => $from, + 'message' => $message, + 'inline_message_id' => $inline_message_id, + 'chat_instance' => $chat_instance, + 'data' => $data, + 'game_short_name' => $game_short_name, + ]); + } } diff --git a/src/Telegram/Chat.php b/src/Telegram/Chat.php index 2eceb0f..bdb884e 100644 --- a/src/Telegram/Chat.php +++ b/src/Telegram/Chat.php @@ -18,56 +18,125 @@ class Chat extends \Tii\Telepath\Type public string $type; /** Optional. Title, for supergroups, channels and group chats */ - public ?string $title; + public ?string $title = null; /** Optional. Username, for private chats, supergroups and channels if available */ - public ?string $username; + public ?string $username = null; /** Optional. First name of the other party in a private chat */ - public ?string $first_name; + public ?string $first_name = null; /** Optional. Last name of the other party in a private chat */ - public ?string $last_name; + public ?string $last_name = null; /** Optional. Chat photo. Returned only in getChat. */ - public ?ChatPhoto $photo; + public ?ChatPhoto $photo = null; /** Optional. Bio of the other party in a private chat. Returned only in getChat. */ - public ?string $bio; + public ?string $bio = null; /** Optional. True, if privacy settings of the other party in the private chat allows to use tg://user?id= links only in chats with the user. Returned only in getChat. */ - public ?bool $has_private_forwards; + public ?bool $has_private_forwards = null; /** Optional. Description, for groups, supergroups and channel chats. Returned only in getChat. */ - public ?string $description; + public ?string $description = null; /** Optional. Primary invite link, for groups, supergroups and channel chats. Returned only in getChat. */ - public ?string $invite_link; + public ?string $invite_link = null; /** Optional. The most recent pinned message (by sending date). Returned only in getChat. */ - public ?Message $pinned_message; + public ?Message $pinned_message = null; /** Optional. Default chat member permissions, for groups and supergroups. Returned only in getChat. */ - public ?ChatPermissions $permissions; + public ?ChatPermissions $permissions = null; /** Optional. For supergroups, the minimum allowed delay between consecutive messages sent by each unpriviledged user; in seconds. Returned only in getChat. */ - public ?int $slow_mode_delay; + public ?int $slow_mode_delay = null; /** Optional. The time after which all messages sent to the chat will be automatically deleted; in seconds. Returned only in getChat. */ - public ?int $message_auto_delete_time; + public ?int $message_auto_delete_time = null; /** Optional. True, if messages from the chat can't be forwarded to other chats. Returned only in getChat. */ - public ?bool $has_protected_content; + public ?bool $has_protected_content = null; /** Optional. For supergroups, name of group sticker set. Returned only in getChat. */ - public ?string $sticker_set_name; + public ?string $sticker_set_name = null; /** Optional. True, if the bot can change the group sticker set. Returned only in getChat. */ - public ?bool $can_set_sticker_set; + public ?bool $can_set_sticker_set = null; /** Optional. Unique identifier for the linked chat, i.e. the discussion group identifier for a channel and vice versa; for supergroups and channel chats. This identifier may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier. Returned only in getChat. */ - public ?int $linked_chat_id; + public ?int $linked_chat_id = null; /** Optional. For supergroups, the location to which the supergroup is connected. Returned only in getChat. */ - public ?ChatLocation $location; + public ?ChatLocation $location = null; + + + /** + * @param int $id Unique identifier for this chat. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier. + * @param string $type Type of chat, can be either “private”, “group”, “supergroup” or “channel” + * @param string $title Optional. Title, for supergroups, channels and group chats + * @param string $username Optional. Username, for private chats, supergroups and channels if available + * @param string $first_name Optional. First name of the other party in a private chat + * @param string $last_name Optional. Last name of the other party in a private chat + * @param ChatPhoto $photo Optional. Chat photo. Returned only in getChat. + * @param string $bio Optional. Bio of the other party in a private chat. Returned only in getChat. + * @param bool $has_private_forwards Optional. True, if privacy settings of the other party in the private chat allows to use tg://user?id= links only in chats with the user. Returned only in getChat. + * @param string $description Optional. Description, for groups, supergroups and channel chats. Returned only in getChat. + * @param string $invite_link Optional. Primary invite link, for groups, supergroups and channel chats. Returned only in getChat. + * @param Message $pinned_message Optional. The most recent pinned message (by sending date). Returned only in getChat. + * @param ChatPermissions $permissions Optional. Default chat member permissions, for groups and supergroups. Returned only in getChat. + * @param int $slow_mode_delay Optional. For supergroups, the minimum allowed delay between consecutive messages sent by each unpriviledged user; in seconds. Returned only in getChat. + * @param int $message_auto_delete_time Optional. The time after which all messages sent to the chat will be automatically deleted; in seconds. Returned only in getChat. + * @param bool $has_protected_content Optional. True, if messages from the chat can't be forwarded to other chats. Returned only in getChat. + * @param string $sticker_set_name Optional. For supergroups, name of group sticker set. Returned only in getChat. + * @param bool $can_set_sticker_set Optional. True, if the bot can change the group sticker set. Returned only in getChat. + * @param int $linked_chat_id Optional. Unique identifier for the linked chat, i.e. the discussion group identifier for a channel and vice versa; for supergroups and channel chats. This identifier may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier. Returned only in getChat. + * @param ChatLocation $location Optional. For supergroups, the location to which the supergroup is connected. Returned only in getChat. + */ + public static function make( + int $id, + string $type, + ?string $title = null, + ?string $username = null, + ?string $first_name = null, + ?string $last_name = null, + ?ChatPhoto $photo = null, + ?string $bio = null, + ?bool $has_private_forwards = null, + ?string $description = null, + ?string $invite_link = null, + ?Message $pinned_message = null, + ?ChatPermissions $permissions = null, + ?int $slow_mode_delay = null, + ?int $message_auto_delete_time = null, + ?bool $has_protected_content = null, + ?string $sticker_set_name = null, + ?bool $can_set_sticker_set = null, + ?int $linked_chat_id = null, + ?ChatLocation $location = null + ): static { + return new static([ + 'id' => $id, + 'type' => $type, + 'title' => $title, + 'username' => $username, + 'first_name' => $first_name, + 'last_name' => $last_name, + 'photo' => $photo, + 'bio' => $bio, + 'has_private_forwards' => $has_private_forwards, + 'description' => $description, + 'invite_link' => $invite_link, + 'pinned_message' => $pinned_message, + 'permissions' => $permissions, + 'slow_mode_delay' => $slow_mode_delay, + 'message_auto_delete_time' => $message_auto_delete_time, + 'has_protected_content' => $has_protected_content, + 'sticker_set_name' => $sticker_set_name, + 'can_set_sticker_set' => $can_set_sticker_set, + 'linked_chat_id' => $linked_chat_id, + 'location' => $location, + ]); + } } diff --git a/src/Telegram/ChatAdministratorRights.php b/src/Telegram/ChatAdministratorRights.php index e0239f3..7a17e1a 100644 --- a/src/Telegram/ChatAdministratorRights.php +++ b/src/Telegram/ChatAdministratorRights.php @@ -36,11 +36,53 @@ class ChatAdministratorRights extends \Tii\Telepath\Type public bool $can_invite_users; /** Optional. True, if the administrator can post in the channel; channels only */ - public ?bool $can_post_messages; + public ?bool $can_post_messages = null; /** Optional. True, if the administrator can edit messages of other users and can pin messages; channels only */ - public ?bool $can_edit_messages; + public ?bool $can_edit_messages = null; /** Optional. True, if the user is allowed to pin messages; groups and supergroups only */ - public ?bool $can_pin_messages; + public ?bool $can_pin_messages = null; + + + /** + * @param bool $is_anonymous True, if the user's presence in the chat is hidden + * @param bool $can_manage_chat True, if the administrator can access the chat event log, chat statistics, message statistics in channels, see channel members, see anonymous administrators in supergroups and ignore slow mode. Implied by any other administrator privilege + * @param bool $can_delete_messages True, if the administrator can delete messages of other users + * @param bool $can_manage_video_chats True, if the administrator can manage video chats + * @param bool $can_restrict_members True, if the administrator can restrict, ban or unban chat members + * @param bool $can_promote_members True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by the user) + * @param bool $can_change_info True, if the user is allowed to change the chat title, photo and other settings + * @param bool $can_invite_users True, if the user is allowed to invite new users to the chat + * @param bool $can_post_messages Optional. True, if the administrator can post in the channel; channels only + * @param bool $can_edit_messages Optional. True, if the administrator can edit messages of other users and can pin messages; channels only + * @param bool $can_pin_messages Optional. True, if the user is allowed to pin messages; groups and supergroups only + */ + public static function make( + bool $is_anonymous, + bool $can_manage_chat, + bool $can_delete_messages, + bool $can_manage_video_chats, + bool $can_restrict_members, + bool $can_promote_members, + bool $can_change_info, + bool $can_invite_users, + ?bool $can_post_messages = null, + ?bool $can_edit_messages = null, + ?bool $can_pin_messages = null + ): static { + return new static([ + 'is_anonymous' => $is_anonymous, + 'can_manage_chat' => $can_manage_chat, + 'can_delete_messages' => $can_delete_messages, + 'can_manage_video_chats' => $can_manage_video_chats, + 'can_restrict_members' => $can_restrict_members, + 'can_promote_members' => $can_promote_members, + 'can_change_info' => $can_change_info, + 'can_invite_users' => $can_invite_users, + 'can_post_messages' => $can_post_messages, + 'can_edit_messages' => $can_edit_messages, + 'can_pin_messages' => $can_pin_messages, + ]); + } } diff --git a/src/Telegram/ChatInviteLink.php b/src/Telegram/ChatInviteLink.php index 7a794d8..802bcdd 100644 --- a/src/Telegram/ChatInviteLink.php +++ b/src/Telegram/ChatInviteLink.php @@ -27,14 +27,50 @@ class ChatInviteLink extends \Tii\Telepath\Type public bool $is_revoked; /** Optional. Invite link name */ - public ?string $name; + public ?string $name = null; /** Optional. Point in time (Unix timestamp) when the link will expire or has been expired */ - public ?int $expire_date; + public ?int $expire_date = null; /** Optional. Maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999 */ - public ?int $member_limit; + public ?int $member_limit = null; /** Optional. Number of pending join requests created using this link */ - public ?int $pending_join_request_count; + public ?int $pending_join_request_count = null; + + + /** + * @param string $invite_link The invite link. If the link was created by another chat administrator, then the second part of the link will be replaced with “…”. + * @param User $creator Creator of the link + * @param bool $creates_join_request True, if users joining the chat via the link need to be approved by chat administrators + * @param bool $is_primary True, if the link is primary + * @param bool $is_revoked True, if the link is revoked + * @param string $name Optional. Invite link name + * @param int $expire_date Optional. Point in time (Unix timestamp) when the link will expire or has been expired + * @param int $member_limit Optional. Maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999 + * @param int $pending_join_request_count Optional. Number of pending join requests created using this link + */ + public static function make( + string $invite_link, + User $creator, + bool $creates_join_request, + bool $is_primary, + bool $is_revoked, + ?string $name = null, + ?int $expire_date = null, + ?int $member_limit = null, + ?int $pending_join_request_count = null + ): static { + return new static([ + 'invite_link' => $invite_link, + 'creator' => $creator, + 'creates_join_request' => $creates_join_request, + 'is_primary' => $is_primary, + 'is_revoked' => $is_revoked, + 'name' => $name, + 'expire_date' => $expire_date, + 'member_limit' => $member_limit, + 'pending_join_request_count' => $pending_join_request_count, + ]); + } } diff --git a/src/Telegram/ChatJoinRequest.php b/src/Telegram/ChatJoinRequest.php index 51545a5..4bd7dc1 100644 --- a/src/Telegram/ChatJoinRequest.php +++ b/src/Telegram/ChatJoinRequest.php @@ -21,8 +21,32 @@ class ChatJoinRequest extends \Tii\Telepath\Type public int $date; /** Optional. Bio of the user. */ - public ?string $bio; + public ?string $bio = null; /** Optional. Chat invite link that was used by the user to send the join request */ - public ?ChatInviteLink $invite_link; + public ?ChatInviteLink $invite_link = null; + + + /** + * @param Chat $chat Chat to which the request was sent + * @param User $from User that sent the join request + * @param int $date Date the request was sent in Unix time + * @param string $bio Optional. Bio of the user. + * @param ChatInviteLink $invite_link Optional. Chat invite link that was used by the user to send the join request + */ + public static function make( + Chat $chat, + User $from, + int $date, + ?string $bio = null, + ?ChatInviteLink $invite_link = null + ): static { + return new static([ + 'chat' => $chat, + 'from' => $from, + 'date' => $date, + 'bio' => $bio, + 'invite_link' => $invite_link, + ]); + } } diff --git a/src/Telegram/ChatLocation.php b/src/Telegram/ChatLocation.php index a9b2b2b..0521a96 100644 --- a/src/Telegram/ChatLocation.php +++ b/src/Telegram/ChatLocation.php @@ -16,4 +16,17 @@ class ChatLocation extends \Tii\Telepath\Type /** Location address; 1-64 characters, as defined by the chat owner */ public string $address; + + + /** + * @param Location $location The location to which the supergroup is connected. Can't be a live location. + * @param string $address Location address; 1-64 characters, as defined by the chat owner + */ + public static function make(Location $location, string $address): static + { + return new static([ + 'location' => $location, + 'address' => $address, + ]); + } } diff --git a/src/Telegram/ChatMember.php b/src/Telegram/ChatMember.php index 259f144..5649ccb 100644 --- a/src/Telegram/ChatMember.php +++ b/src/Telegram/ChatMember.php @@ -16,4 +16,17 @@ class ChatMember extends \Tii\Telepath\Type /** Information about the user */ public User $user; + + + /** + * @param string $status The member's status in the chat + * @param User $user Information about the user + */ + public static function make(string $status, User $user): static + { + return new static([ + 'status' => $status, + 'user' => $user, + ]); + } } diff --git a/src/Telegram/ChatMemberAdministrator.php b/src/Telegram/ChatMemberAdministrator.php index 49d5743..e52b6d8 100644 --- a/src/Telegram/ChatMemberAdministrator.php +++ b/src/Telegram/ChatMemberAdministrator.php @@ -39,14 +39,62 @@ class ChatMemberAdministrator extends ChatMember public bool $can_invite_users; /** Optional. True, if the administrator can post in the channel; channels only */ - public ?bool $can_post_messages; + public ?bool $can_post_messages = null; /** Optional. True, if the administrator can edit messages of other users and can pin messages; channels only */ - public ?bool $can_edit_messages; + public ?bool $can_edit_messages = null; /** Optional. True, if the user is allowed to pin messages; groups and supergroups only */ - public ?bool $can_pin_messages; + public ?bool $can_pin_messages = null; /** Optional. Custom title for this user */ - public ?string $custom_title; + public ?string $custom_title = null; + + + /** + * @param bool $can_be_edited True, if the bot is allowed to edit administrator privileges of that user + * @param bool $is_anonymous True, if the user's presence in the chat is hidden + * @param bool $can_manage_chat True, if the administrator can access the chat event log, chat statistics, message statistics in channels, see channel members, see anonymous administrators in supergroups and ignore slow mode. Implied by any other administrator privilege + * @param bool $can_delete_messages True, if the administrator can delete messages of other users + * @param bool $can_manage_video_chats True, if the administrator can manage video chats + * @param bool $can_restrict_members True, if the administrator can restrict, ban or unban chat members + * @param bool $can_promote_members True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by the user) + * @param bool $can_change_info True, if the user is allowed to change the chat title, photo and other settings + * @param bool $can_invite_users True, if the user is allowed to invite new users to the chat + * @param bool $can_post_messages Optional. True, if the administrator can post in the channel; channels only + * @param bool $can_edit_messages Optional. True, if the administrator can edit messages of other users and can pin messages; channels only + * @param bool $can_pin_messages Optional. True, if the user is allowed to pin messages; groups and supergroups only + * @param string $custom_title Optional. Custom title for this user + */ + public static function make( + bool $can_be_edited, + bool $is_anonymous, + bool $can_manage_chat, + bool $can_delete_messages, + bool $can_manage_video_chats, + bool $can_restrict_members, + bool $can_promote_members, + bool $can_change_info, + bool $can_invite_users, + ?bool $can_post_messages = null, + ?bool $can_edit_messages = null, + ?bool $can_pin_messages = null, + ?string $custom_title = null + ): static { + return new static([ + 'can_be_edited' => $can_be_edited, + 'is_anonymous' => $is_anonymous, + 'can_manage_chat' => $can_manage_chat, + 'can_delete_messages' => $can_delete_messages, + 'can_manage_video_chats' => $can_manage_video_chats, + 'can_restrict_members' => $can_restrict_members, + 'can_promote_members' => $can_promote_members, + 'can_change_info' => $can_change_info, + 'can_invite_users' => $can_invite_users, + 'can_post_messages' => $can_post_messages, + 'can_edit_messages' => $can_edit_messages, + 'can_pin_messages' => $can_pin_messages, + 'custom_title' => $custom_title, + ]); + } } diff --git a/src/Telegram/ChatMemberBanned.php b/src/Telegram/ChatMemberBanned.php index 80ee955..24d2956 100644 --- a/src/Telegram/ChatMemberBanned.php +++ b/src/Telegram/ChatMemberBanned.php @@ -13,4 +13,15 @@ class ChatMemberBanned extends ChatMember { /** Date when restrictions will be lifted for this user; unix time. If 0, then the user is banned forever */ public int $until_date; + + + /** + * @param int $until_date Date when restrictions will be lifted for this user; unix time. If 0, then the user is banned forever + */ + public static function make(int $until_date): static + { + return new static([ + 'until_date' => $until_date, + ]); + } } diff --git a/src/Telegram/ChatMemberLeft.php b/src/Telegram/ChatMemberLeft.php index 1deeaee..2d420aa 100644 --- a/src/Telegram/ChatMemberLeft.php +++ b/src/Telegram/ChatMemberLeft.php @@ -11,4 +11,9 @@ */ class ChatMemberLeft extends ChatMember { + public static function make(): static + { + return new static([ + ]); + } } diff --git a/src/Telegram/ChatMemberMember.php b/src/Telegram/ChatMemberMember.php index 2a5929b..0f6171d 100644 --- a/src/Telegram/ChatMemberMember.php +++ b/src/Telegram/ChatMemberMember.php @@ -11,4 +11,9 @@ */ class ChatMemberMember extends ChatMember { + public static function make(): static + { + return new static([ + ]); + } } diff --git a/src/Telegram/ChatMemberOwner.php b/src/Telegram/ChatMemberOwner.php index b0105ba..7918bed 100644 --- a/src/Telegram/ChatMemberOwner.php +++ b/src/Telegram/ChatMemberOwner.php @@ -15,5 +15,18 @@ class ChatMemberOwner extends ChatMember public bool $is_anonymous; /** Optional. Custom title for this user */ - public ?string $custom_title; + public ?string $custom_title = null; + + + /** + * @param bool $is_anonymous True, if the user's presence in the chat is hidden + * @param string $custom_title Optional. Custom title for this user + */ + public static function make(bool $is_anonymous, ?string $custom_title = null): static + { + return new static([ + 'is_anonymous' => $is_anonymous, + 'custom_title' => $custom_title, + ]); + } } diff --git a/src/Telegram/ChatMemberRestricted.php b/src/Telegram/ChatMemberRestricted.php index 253bbeb..90a466b 100644 --- a/src/Telegram/ChatMemberRestricted.php +++ b/src/Telegram/ChatMemberRestricted.php @@ -40,4 +40,43 @@ class ChatMemberRestricted extends ChatMember /** Date when restrictions will be lifted for this user; unix time. If 0, then the user is restricted forever */ public int $until_date; + + + /** + * @param bool $is_member True, if the user is a member of the chat at the moment of the request + * @param bool $can_change_info True, if the user is allowed to change the chat title, photo and other settings + * @param bool $can_invite_users True, if the user is allowed to invite new users to the chat + * @param bool $can_pin_messages True, if the user is allowed to pin messages + * @param bool $can_send_messages True, if the user is allowed to send text messages, contacts, locations and venues + * @param bool $can_send_media_messages True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes + * @param bool $can_send_polls True, if the user is allowed to send polls + * @param bool $can_send_other_messages True, if the user is allowed to send animations, games, stickers and use inline bots + * @param bool $can_add_web_page_previews True, if the user is allowed to add web page previews to their messages + * @param int $until_date Date when restrictions will be lifted for this user; unix time. If 0, then the user is restricted forever + */ + public static function make( + bool $is_member, + bool $can_change_info, + bool $can_invite_users, + bool $can_pin_messages, + bool $can_send_messages, + bool $can_send_media_messages, + bool $can_send_polls, + bool $can_send_other_messages, + bool $can_add_web_page_previews, + int $until_date + ): static { + return new static([ + 'is_member' => $is_member, + 'can_change_info' => $can_change_info, + 'can_invite_users' => $can_invite_users, + 'can_pin_messages' => $can_pin_messages, + 'can_send_messages' => $can_send_messages, + 'can_send_media_messages' => $can_send_media_messages, + 'can_send_polls' => $can_send_polls, + 'can_send_other_messages' => $can_send_other_messages, + 'can_add_web_page_previews' => $can_add_web_page_previews, + 'until_date' => $until_date, + ]); + } } diff --git a/src/Telegram/ChatMemberUpdated.php b/src/Telegram/ChatMemberUpdated.php index a77a9ad..4408024 100644 --- a/src/Telegram/ChatMemberUpdated.php +++ b/src/Telegram/ChatMemberUpdated.php @@ -27,5 +27,32 @@ class ChatMemberUpdated extends \Tii\Telepath\Type public ChatMember $new_chat_member; /** Optional. Chat invite link, which was used by the user to join the chat; for joining by invite link events only. */ - public ?ChatInviteLink $invite_link; + public ?ChatInviteLink $invite_link = null; + + + /** + * @param Chat $chat Chat the user belongs to + * @param User $from Performer of the action, which resulted in the change + * @param int $date Date the change was done in Unix time + * @param ChatMember $old_chat_member Previous information about the chat member + * @param ChatMember $new_chat_member New information about the chat member + * @param ChatInviteLink $invite_link Optional. Chat invite link, which was used by the user to join the chat; for joining by invite link events only. + */ + public static function make( + Chat $chat, + User $from, + int $date, + ChatMember $old_chat_member, + ChatMember $new_chat_member, + ?ChatInviteLink $invite_link = null + ): static { + return new static([ + 'chat' => $chat, + 'from' => $from, + 'date' => $date, + 'old_chat_member' => $old_chat_member, + 'new_chat_member' => $new_chat_member, + 'invite_link' => $invite_link, + ]); + } } diff --git a/src/Telegram/ChatPermissions.php b/src/Telegram/ChatPermissions.php index dd5c946..8241a03 100644 --- a/src/Telegram/ChatPermissions.php +++ b/src/Telegram/ChatPermissions.php @@ -12,26 +12,59 @@ class ChatPermissions extends \Tii\Telepath\Type { /** Optional. True, if the user is allowed to send text messages, contacts, locations and venues */ - public ?bool $can_send_messages; + public ?bool $can_send_messages = null; /** Optional. True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes, implies can_send_messages */ - public ?bool $can_send_media_messages; + public ?bool $can_send_media_messages = null; /** Optional. True, if the user is allowed to send polls, implies can_send_messages */ - public ?bool $can_send_polls; + public ?bool $can_send_polls = null; /** Optional. True, if the user is allowed to send animations, games, stickers and use inline bots, implies can_send_media_messages */ - public ?bool $can_send_other_messages; + public ?bool $can_send_other_messages = null; /** Optional. True, if the user is allowed to add web page previews to their messages, implies can_send_media_messages */ - public ?bool $can_add_web_page_previews; + public ?bool $can_add_web_page_previews = null; /** Optional. True, if the user is allowed to change the chat title, photo and other settings. Ignored in public supergroups */ - public ?bool $can_change_info; + public ?bool $can_change_info = null; /** Optional. True, if the user is allowed to invite new users to the chat */ - public ?bool $can_invite_users; + public ?bool $can_invite_users = null; /** Optional. True, if the user is allowed to pin messages. Ignored in public supergroups */ - public ?bool $can_pin_messages; + public ?bool $can_pin_messages = null; + + + /** + * @param bool $can_send_messages Optional. True, if the user is allowed to send text messages, contacts, locations and venues + * @param bool $can_send_media_messages Optional. True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes, implies can_send_messages + * @param bool $can_send_polls Optional. True, if the user is allowed to send polls, implies can_send_messages + * @param bool $can_send_other_messages Optional. True, if the user is allowed to send animations, games, stickers and use inline bots, implies can_send_media_messages + * @param bool $can_add_web_page_previews Optional. True, if the user is allowed to add web page previews to their messages, implies can_send_media_messages + * @param bool $can_change_info Optional. True, if the user is allowed to change the chat title, photo and other settings. Ignored in public supergroups + * @param bool $can_invite_users Optional. True, if the user is allowed to invite new users to the chat + * @param bool $can_pin_messages Optional. True, if the user is allowed to pin messages. Ignored in public supergroups + */ + public static function make( + ?bool $can_send_messages = null, + ?bool $can_send_media_messages = null, + ?bool $can_send_polls = null, + ?bool $can_send_other_messages = null, + ?bool $can_add_web_page_previews = null, + ?bool $can_change_info = null, + ?bool $can_invite_users = null, + ?bool $can_pin_messages = null + ): static { + return new static([ + 'can_send_messages' => $can_send_messages, + 'can_send_media_messages' => $can_send_media_messages, + 'can_send_polls' => $can_send_polls, + 'can_send_other_messages' => $can_send_other_messages, + 'can_add_web_page_previews' => $can_add_web_page_previews, + 'can_change_info' => $can_change_info, + 'can_invite_users' => $can_invite_users, + 'can_pin_messages' => $can_pin_messages, + ]); + } } diff --git a/src/Telegram/ChatPhoto.php b/src/Telegram/ChatPhoto.php index f152e59..41c81a1 100644 --- a/src/Telegram/ChatPhoto.php +++ b/src/Telegram/ChatPhoto.php @@ -22,4 +22,25 @@ class ChatPhoto extends \Tii\Telepath\Type /** Unique file identifier of big (640x640) chat photo, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */ public string $big_file_unique_id; + + + /** + * @param string $small_file_id File identifier of small (160x160) chat photo. This file_id can be used only for photo download and only for as long as the photo is not changed. + * @param string $small_file_unique_id Unique file identifier of small (160x160) chat photo, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. + * @param string $big_file_id File identifier of big (640x640) chat photo. This file_id can be used only for photo download and only for as long as the photo is not changed. + * @param string $big_file_unique_id Unique file identifier of big (640x640) chat photo, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. + */ + public static function make( + string $small_file_id, + string $small_file_unique_id, + string $big_file_id, + string $big_file_unique_id + ): static { + return new static([ + 'small_file_id' => $small_file_id, + 'small_file_unique_id' => $small_file_unique_id, + 'big_file_id' => $big_file_id, + 'big_file_unique_id' => $big_file_unique_id, + ]); + } } diff --git a/src/Telegram/ChosenInlineResult.php b/src/Telegram/ChosenInlineResult.php index ead83f6..7beee16 100644 --- a/src/Telegram/ChosenInlineResult.php +++ b/src/Telegram/ChosenInlineResult.php @@ -18,11 +18,35 @@ class ChosenInlineResult extends \Tii\Telepath\Type public User $from; /** Optional. Sender location, only for bots that require user location */ - public ?Location $location; + public ?Location $location = null; /** Optional. Identifier of the sent inline message. Available only if there is an inline keyboard attached to the message. Will be also received in callback queries and can be used to edit the message. */ - public ?string $inline_message_id; + public ?string $inline_message_id = null; /** The query that was used to obtain the result */ public string $query; + + + /** + * @param string $result_id The unique identifier for the result that was chosen + * @param User $from The user that chose the result + * @param Location $location Optional. Sender location, only for bots that require user location + * @param string $inline_message_id Optional. Identifier of the sent inline message. Available only if there is an inline keyboard attached to the message. Will be also received in callback queries and can be used to edit the message. + * @param string $query The query that was used to obtain the result + */ + public static function make( + string $result_id, + User $from, + ?Location $location = null, + ?string $inline_message_id = null, + string $query + ): static { + return new static([ + 'result_id' => $result_id, + 'from' => $from, + 'location' => $location, + 'inline_message_id' => $inline_message_id, + 'query' => $query, + ]); + } } diff --git a/src/Telegram/Contact.php b/src/Telegram/Contact.php index c570402..2f1663d 100644 --- a/src/Telegram/Contact.php +++ b/src/Telegram/Contact.php @@ -18,11 +18,35 @@ class Contact extends \Tii\Telepath\Type public string $first_name; /** Optional. Contact's last name */ - public ?string $last_name; + public ?string $last_name = null; /** Optional. Contact's user identifier in Telegram. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier. */ - public ?int $user_id; + public ?int $user_id = null; /** Optional. Additional data about the contact in the form of a vCard */ - public ?string $vcard; + public ?string $vcard = null; + + + /** + * @param string $phone_number Contact's phone number + * @param string $first_name Contact's first name + * @param string $last_name Optional. Contact's last name + * @param int $user_id Optional. Contact's user identifier in Telegram. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier. + * @param string $vcard Optional. Additional data about the contact in the form of a vCard + */ + public static function make( + string $phone_number, + string $first_name, + ?string $last_name = null, + ?int $user_id = null, + ?string $vcard = null + ): static { + return new static([ + 'phone_number' => $phone_number, + 'first_name' => $first_name, + 'last_name' => $last_name, + 'user_id' => $user_id, + 'vcard' => $vcard, + ]); + } } diff --git a/src/Telegram/Dice.php b/src/Telegram/Dice.php index ff0e630..9332b04 100644 --- a/src/Telegram/Dice.php +++ b/src/Telegram/Dice.php @@ -16,4 +16,17 @@ class Dice extends \Tii\Telepath\Type /** Value of the dice, 1-6 for “🎲”, “🎯” and “🎳” base emoji, 1-5 for “🏀” and “⚽” base emoji, 1-64 for “🎰” base emoji */ public int $value; + + + /** + * @param string $emoji Emoji on which the dice throw animation is based + * @param int $value Value of the dice, 1-6 for “🎲”, “🎯” and “🎳” base emoji, 1-5 for “🏀” and “⚽” base emoji, 1-64 for “🎰” base emoji + */ + public static function make(string $emoji, int $value): static + { + return new static([ + 'emoji' => $emoji, + 'value' => $value, + ]); + } } diff --git a/src/Telegram/Document.php b/src/Telegram/Document.php index 35b9ca7..4c89143 100644 --- a/src/Telegram/Document.php +++ b/src/Telegram/Document.php @@ -18,14 +18,41 @@ class Document extends \Tii\Telepath\Type public string $file_unique_id; /** Optional. Document thumbnail as defined by sender */ - public ?PhotoSize $thumb; + public ?PhotoSize $thumb = null; /** Optional. Original filename as defined by sender */ - public ?string $file_name; + public ?string $file_name = null; /** Optional. MIME type of the file as defined by sender */ - public ?string $mime_type; + public ?string $mime_type = null; /** Optional. File size in bytes */ - public ?int $file_size; + public ?int $file_size = null; + + + /** + * @param string $file_id Identifier for this file, which can be used to download or reuse the file + * @param string $file_unique_id Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. + * @param PhotoSize $thumb Optional. Document thumbnail as defined by sender + * @param string $file_name Optional. Original filename as defined by sender + * @param string $mime_type Optional. MIME type of the file as defined by sender + * @param int $file_size Optional. File size in bytes + */ + public static function make( + string $file_id, + string $file_unique_id, + ?PhotoSize $thumb = null, + ?string $file_name = null, + ?string $mime_type = null, + ?int $file_size = null + ): static { + return new static([ + 'file_id' => $file_id, + 'file_unique_id' => $file_unique_id, + 'thumb' => $thumb, + 'file_name' => $file_name, + 'mime_type' => $mime_type, + 'file_size' => $file_size, + ]); + } } diff --git a/src/Telegram/EncryptedCredentials.php b/src/Telegram/EncryptedCredentials.php index 549e1db..a9ee235 100644 --- a/src/Telegram/EncryptedCredentials.php +++ b/src/Telegram/EncryptedCredentials.php @@ -19,4 +19,19 @@ class EncryptedCredentials extends \Tii\Telepath\Type /** Base64-encoded secret, encrypted with the bot's public RSA key, required for data decryption */ public string $secret; + + + /** + * @param string $data Base64-encoded encrypted JSON-serialized data with unique user's payload, data hashes and secrets required for EncryptedPassportElement decryption and authentication + * @param string $hash Base64-encoded data hash for data authentication + * @param string $secret Base64-encoded secret, encrypted with the bot's public RSA key, required for data decryption + */ + public static function make(string $data, string $hash, string $secret): static + { + return new static([ + 'data' => $data, + 'hash' => $hash, + 'secret' => $secret, + ]); + } } diff --git a/src/Telegram/EncryptedPassportElement.php b/src/Telegram/EncryptedPassportElement.php index 589e92c..4901ca4 100644 --- a/src/Telegram/EncryptedPassportElement.php +++ b/src/Telegram/EncryptedPassportElement.php @@ -15,35 +15,74 @@ class EncryptedPassportElement extends \Tii\Telepath\Type public string $type; /** Optional. Base64-encoded encrypted Telegram Passport element data provided by the user, available for “personal_details”, “passport”, “driver_license”, “identity_card”, “internal_passport” and “address” types. Can be decrypted and verified using the accompanying EncryptedCredentials. */ - public ?string $data; + public ?string $data = null; /** Optional. User's verified phone number, available only for “phone_number” type */ - public ?string $phone_number; + public ?string $phone_number = null; /** Optional. User's verified email address, available only for “email” type */ - public ?string $email; + public ?string $email = null; /** * Optional. Array of encrypted files with documents provided by the user, available for “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration” and “temporary_registration” types. Files can be decrypted and verified using the accompanying EncryptedCredentials. * @var PassportFile[] */ - public ?array $files; + public ?array $files = null; /** Optional. Encrypted file with the front side of the document, provided by the user. Available for “passport”, “driver_license”, “identity_card” and “internal_passport”. The file can be decrypted and verified using the accompanying EncryptedCredentials. */ - public ?PassportFile $front_side; + public ?PassportFile $front_side = null; /** Optional. Encrypted file with the reverse side of the document, provided by the user. Available for “driver_license” and “identity_card”. The file can be decrypted and verified using the accompanying EncryptedCredentials. */ - public ?PassportFile $reverse_side; + public ?PassportFile $reverse_side = null; /** Optional. Encrypted file with the selfie of the user holding a document, provided by the user; available for “passport”, “driver_license”, “identity_card” and “internal_passport”. The file can be decrypted and verified using the accompanying EncryptedCredentials. */ - public ?PassportFile $selfie; + public ?PassportFile $selfie = null; /** * Optional. Array of encrypted files with translated versions of documents provided by the user. Available if requested for “passport”, “driver_license”, “identity_card”, “internal_passport”, “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration” and “temporary_registration” types. Files can be decrypted and verified using the accompanying EncryptedCredentials. * @var PassportFile[] */ - public ?array $translation; + public ?array $translation = null; /** Base64-encoded element hash for using in PassportElementErrorUnspecified */ public string $hash; + + + /** + * @param string $type Element type. One of “personal_details”, “passport”, “driver_license”, “identity_card”, “internal_passport”, “address”, “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration”, “temporary_registration”, “phone_number”, “email”. + * @param string $data Optional. Base64-encoded encrypted Telegram Passport element data provided by the user, available for “personal_details”, “passport”, “driver_license”, “identity_card”, “internal_passport” and “address” types. Can be decrypted and verified using the accompanying EncryptedCredentials. + * @param string $phone_number Optional. User's verified phone number, available only for “phone_number” type + * @param string $email Optional. User's verified email address, available only for “email” type + * @param PassportFile[] $files Optional. Array of encrypted files with documents provided by the user, available for “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration” and “temporary_registration” types. Files can be decrypted and verified using the accompanying EncryptedCredentials. + * @param PassportFile $front_side Optional. Encrypted file with the front side of the document, provided by the user. Available for “passport”, “driver_license”, “identity_card” and “internal_passport”. The file can be decrypted and verified using the accompanying EncryptedCredentials. + * @param PassportFile $reverse_side Optional. Encrypted file with the reverse side of the document, provided by the user. Available for “driver_license” and “identity_card”. The file can be decrypted and verified using the accompanying EncryptedCredentials. + * @param PassportFile $selfie Optional. Encrypted file with the selfie of the user holding a document, provided by the user; available for “passport”, “driver_license”, “identity_card” and “internal_passport”. The file can be decrypted and verified using the accompanying EncryptedCredentials. + * @param PassportFile[] $translation Optional. Array of encrypted files with translated versions of documents provided by the user. Available if requested for “passport”, “driver_license”, “identity_card”, “internal_passport”, “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration” and “temporary_registration” types. Files can be decrypted and verified using the accompanying EncryptedCredentials. + * @param string $hash Base64-encoded element hash for using in PassportElementErrorUnspecified + */ + public static function make( + string $type, + ?string $data = null, + ?string $phone_number = null, + ?string $email = null, + ?array $files = null, + ?PassportFile $front_side = null, + ?PassportFile $reverse_side = null, + ?PassportFile $selfie = null, + ?array $translation = null, + string $hash + ): static { + return new static([ + 'type' => $type, + 'data' => $data, + 'phone_number' => $phone_number, + 'email' => $email, + 'files' => $files, + 'front_side' => $front_side, + 'reverse_side' => $reverse_side, + 'selfie' => $selfie, + 'translation' => $translation, + 'hash' => $hash, + ]); + } } diff --git a/src/Telegram/File.php b/src/Telegram/File.php index 93af096..3b8b213 100644 --- a/src/Telegram/File.php +++ b/src/Telegram/File.php @@ -18,8 +18,29 @@ class File extends \Tii\Telepath\Type public string $file_unique_id; /** Optional. File size in bytes, if known */ - public ?int $file_size; + public ?int $file_size = null; /** Optional. File path. Use https://api.telegram.org/file/bot/ to get the file. */ - public ?string $file_path; + public ?string $file_path = null; + + + /** + * @param string $file_id Identifier for this file, which can be used to download or reuse the file + * @param string $file_unique_id Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. + * @param int $file_size Optional. File size in bytes, if known + * @param string $file_path Optional. File path. Use https://api.telegram.org/file/bot/ to get the file. + */ + public static function make( + string $file_id, + string $file_unique_id, + ?int $file_size = null, + ?string $file_path = null + ): static { + return new static([ + 'file_id' => $file_id, + 'file_unique_id' => $file_unique_id, + 'file_size' => $file_size, + 'file_path' => $file_path, + ]); + } } diff --git a/src/Telegram/ForceReply.php b/src/Telegram/ForceReply.php index 81733e5..98b7941 100644 --- a/src/Telegram/ForceReply.php +++ b/src/Telegram/ForceReply.php @@ -15,8 +15,26 @@ class ForceReply extends \Tii\Telepath\Type public bool $force_reply; /** Optional. The placeholder to be shown in the input field when the reply is active; 1-64 characters */ - public ?string $input_field_placeholder; + public ?string $input_field_placeholder = null; /** Optional. Use this parameter if you want to force reply from specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message. */ - public ?bool $selective; + public ?bool $selective = null; + + + /** + * @param bool $force_reply Shows reply interface to the user, as if they manually selected the bot's message and tapped 'Reply' + * @param string $input_field_placeholder Optional. The placeholder to be shown in the input field when the reply is active; 1-64 characters + * @param bool $selective Optional. Use this parameter if you want to force reply from specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message. + */ + public static function make( + bool $force_reply, + ?string $input_field_placeholder = null, + ?bool $selective = null + ): static { + return new static([ + 'force_reply' => $force_reply, + 'input_field_placeholder' => $input_field_placeholder, + 'selective' => $selective, + ]); + } } diff --git a/src/Telegram/Game.php b/src/Telegram/Game.php index 8f3ea8d..5fb685c 100644 --- a/src/Telegram/Game.php +++ b/src/Telegram/Game.php @@ -24,14 +24,41 @@ class Game extends \Tii\Telepath\Type public array $photo; /** Optional. Brief description of the game or high scores included in the game message. Can be automatically edited to include current high scores for the game when the bot calls setGameScore, or manually edited using editMessageText. 0-4096 characters. */ - public ?string $text; + public ?string $text = null; /** * Optional. Special entities that appear in text, such as usernames, URLs, bot commands, etc. * @var MessageEntity[] */ - public ?array $text_entities; + public ?array $text_entities = null; /** Optional. Animation that will be displayed in the game message in chats. Upload via BotFather */ - public ?Animation $animation; + public ?Animation $animation = null; + + + /** + * @param string $title Title of the game + * @param string $description Description of the game + * @param PhotoSize[] $photo Photo that will be displayed in the game message in chats. + * @param string $text Optional. Brief description of the game or high scores included in the game message. Can be automatically edited to include current high scores for the game when the bot calls setGameScore, or manually edited using editMessageText. 0-4096 characters. + * @param MessageEntity[] $text_entities Optional. Special entities that appear in text, such as usernames, URLs, bot commands, etc. + * @param Animation $animation Optional. Animation that will be displayed in the game message in chats. Upload via BotFather + */ + public static function make( + string $title, + string $description, + array $photo, + ?string $text = null, + ?array $text_entities = null, + ?Animation $animation = null + ): static { + return new static([ + 'title' => $title, + 'description' => $description, + 'photo' => $photo, + 'text' => $text, + 'text_entities' => $text_entities, + 'animation' => $animation, + ]); + } } diff --git a/src/Telegram/GameHighScore.php b/src/Telegram/GameHighScore.php index db95e68..89ae485 100644 --- a/src/Telegram/GameHighScore.php +++ b/src/Telegram/GameHighScore.php @@ -19,4 +19,19 @@ class GameHighScore extends \Tii\Telepath\Type /** Score */ public int $score; + + + /** + * @param int $position Position in high score table for the game + * @param User $user User + * @param int $score Score + */ + public static function make(int $position, User $user, int $score): static + { + return new static([ + 'position' => $position, + 'user' => $user, + 'score' => $score, + ]); + } } diff --git a/src/Telegram/InlineKeyboardButton.php b/src/Telegram/InlineKeyboardButton.php index e7feca8..57f4dce 100644 --- a/src/Telegram/InlineKeyboardButton.php +++ b/src/Telegram/InlineKeyboardButton.php @@ -15,26 +15,62 @@ class InlineKeyboardButton extends \Tii\Telepath\Type public string $text; /** Optional. HTTP or tg:// url to be opened when the button is pressed. Links tg://user?id= can be used to mention a user by their ID without using a username, if this is allowed by their privacy settings. */ - public ?string $url; + public ?string $url = null; /** Optional. Data to be sent in a callback query to the bot when button is pressed, 1-64 bytes */ - public ?string $callback_data; + public ?string $callback_data = null; /** Optional. Description of the Web App that will be launched when the user presses the button. The Web App will be able to send an arbitrary message on behalf of the user using the method answerWebAppQuery. Available only in private chats between a user and the bot. */ - public ?WebAppInfo $web_app; + public ?WebAppInfo $web_app = null; /** Optional. An HTTP URL used to automatically authorize the user. Can be used as a replacement for the Telegram Login Widget. */ - public ?LoginUrl $login_url; + public ?LoginUrl $login_url = null; /** Optional. If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. Can be empty, in which case just the bot's username will be inserted.Note: This offers an easy way for users to start using your bot in inline mode when they are currently in a private chat with it. Especially useful when combined with switch_pm… actions – in this case the user will be automatically returned to the chat they switched from, skipping the chat selection screen. */ - public ?string $switch_inline_query; + public ?string $switch_inline_query = null; /** Optional. If set, pressing the button will insert the bot's username and the specified inline query in the current chat's input field. Can be empty, in which case only the bot's username will be inserted.This offers a quick way for the user to open your bot in inline mode in the same chat – good for selecting something from multiple options. */ - public ?string $switch_inline_query_current_chat; + public ?string $switch_inline_query_current_chat = null; /** Optional. Description of the game that will be launched when the user presses the button.NOTE: This type of button must always be the first button in the first row. */ - public ?CallbackGame $callback_game; + public ?CallbackGame $callback_game = null; /** Optional. Specify True, to send a Pay button.NOTE: This type of button must always be the first button in the first row and can only be used in invoice messages. */ - public ?bool $pay; + public ?bool $pay = null; + + + /** + * @param string $text Label text on the button + * @param string $url Optional. HTTP or tg:// url to be opened when the button is pressed. Links tg://user?id= can be used to mention a user by their ID without using a username, if this is allowed by their privacy settings. + * @param string $callback_data Optional. Data to be sent in a callback query to the bot when button is pressed, 1-64 bytes + * @param WebAppInfo $web_app Optional. Description of the Web App that will be launched when the user presses the button. The Web App will be able to send an arbitrary message on behalf of the user using the method answerWebAppQuery. Available only in private chats between a user and the bot. + * @param LoginUrl $login_url Optional. An HTTP URL used to automatically authorize the user. Can be used as a replacement for the Telegram Login Widget. + * @param string $switch_inline_query Optional. If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. Can be empty, in which case just the bot's username will be inserted.Note: This offers an easy way for users to start using your bot in inline mode when they are currently in a private chat with it. Especially useful when combined with switch_pm… actions – in this case the user will be automatically returned to the chat they switched from, skipping the chat selection screen. + * @param string $switch_inline_query_current_chat Optional. If set, pressing the button will insert the bot's username and the specified inline query in the current chat's input field. Can be empty, in which case only the bot's username will be inserted.This offers a quick way for the user to open your bot in inline mode in the same chat – good for selecting something from multiple options. + * @param CallbackGame $callback_game Optional. Description of the game that will be launched when the user presses the button.NOTE: This type of button must always be the first button in the first row. + * @param bool $pay Optional. Specify True, to send a Pay button.NOTE: This type of button must always be the first button in the first row and can only be used in invoice messages. + */ + public static function make( + string $text, + ?string $url = null, + ?string $callback_data = null, + ?WebAppInfo $web_app = null, + ?LoginUrl $login_url = null, + ?string $switch_inline_query = null, + ?string $switch_inline_query_current_chat = null, + ?CallbackGame $callback_game = null, + ?bool $pay = null + ): static { + return new static([ + 'text' => $text, + 'url' => $url, + 'callback_data' => $callback_data, + 'web_app' => $web_app, + 'login_url' => $login_url, + 'switch_inline_query' => $switch_inline_query, + 'switch_inline_query_current_chat' => $switch_inline_query_current_chat, + 'callback_game' => $callback_game, + 'pay' => $pay, + ]); + } } diff --git a/src/Telegram/InlineKeyboardMarkup.php b/src/Telegram/InlineKeyboardMarkup.php index 41d00ae..cb6a7e3 100644 --- a/src/Telegram/InlineKeyboardMarkup.php +++ b/src/Telegram/InlineKeyboardMarkup.php @@ -16,4 +16,15 @@ class InlineKeyboardMarkup extends \Tii\Telepath\Type * @var InlineKeyboardButton[][] */ public array $inline_keyboard; + + + /** + * @param InlineKeyboardButton[][] $inline_keyboard Array of button rows, each represented by an Array of InlineKeyboardButton objects + */ + public static function make(array $inline_keyboard): static + { + return new static([ + 'inline_keyboard' => $inline_keyboard, + ]); + } } diff --git a/src/Telegram/InlineQuery.php b/src/Telegram/InlineQuery.php index 385479b..70f863c 100644 --- a/src/Telegram/InlineQuery.php +++ b/src/Telegram/InlineQuery.php @@ -24,8 +24,35 @@ class InlineQuery extends \Tii\Telepath\Type public string $offset; /** Optional. Type of the chat, from which the inline query was sent. Can be either “sender” for a private chat with the inline query sender, “private”, “group”, “supergroup”, or “channel”. The chat type should be always known for requests sent from official clients and most third-party clients, unless the request was sent from a secret chat */ - public ?string $chat_type; + public ?string $chat_type = null; /** Optional. Sender location, only for bots that request user location */ - public ?Location $location; + public ?Location $location = null; + + + /** + * @param string $id Unique identifier for this query + * @param User $from Sender + * @param string $query Text of the query (up to 256 characters) + * @param string $offset Offset of the results to be returned, can be controlled by the bot + * @param string $chat_type Optional. Type of the chat, from which the inline query was sent. Can be either “sender” for a private chat with the inline query sender, “private”, “group”, “supergroup”, or “channel”. The chat type should be always known for requests sent from official clients and most third-party clients, unless the request was sent from a secret chat + * @param Location $location Optional. Sender location, only for bots that request user location + */ + public static function make( + string $id, + User $from, + string $query, + string $offset, + ?string $chat_type = null, + ?Location $location = null + ): static { + return new static([ + 'id' => $id, + 'from' => $from, + 'query' => $query, + 'offset' => $offset, + 'chat_type' => $chat_type, + 'location' => $location, + ]); + } } diff --git a/src/Telegram/InlineQueryResult.php b/src/Telegram/InlineQueryResult.php index edaf2f5..80e3a48 100644 --- a/src/Telegram/InlineQueryResult.php +++ b/src/Telegram/InlineQueryResult.php @@ -18,5 +18,20 @@ class InlineQueryResult extends \Tii\Telepath\Type public string $id; /** Optional. Inline keyboard attached to the message */ - public ?InlineKeyboardMarkup $reply_markup; + public ?InlineKeyboardMarkup $reply_markup = null; + + + /** + * @param string $type Type of the result + * @param string $id Unique identifier for this result, 1-64 bytes + * @param InlineKeyboardMarkup $reply_markup Optional. Inline keyboard attached to the message + */ + public static function make(string $type, string $id, ?InlineKeyboardMarkup $reply_markup = null): static + { + return new static([ + 'type' => $type, + 'id' => $id, + 'reply_markup' => $reply_markup, + ]); + } } diff --git a/src/Telegram/InlineQueryResultArticle.php b/src/Telegram/InlineQueryResultArticle.php index 4b47c15..d710dca 100644 --- a/src/Telegram/InlineQueryResultArticle.php +++ b/src/Telegram/InlineQueryResultArticle.php @@ -18,20 +18,53 @@ class InlineQueryResultArticle extends InlineQueryResult public InputMessageContent $input_message_content; /** Optional. URL of the result */ - public ?string $url; + public ?string $url = null; /** Optional. Pass True, if you don't want the URL to be shown in the message */ - public ?bool $hide_url; + public ?bool $hide_url = null; /** Optional. Short description of the result */ - public ?string $description; + public ?string $description = null; /** Optional. Url of the thumbnail for the result */ - public ?string $thumb_url; + public ?string $thumb_url = null; /** Optional. Thumbnail width */ - public ?int $thumb_width; + public ?int $thumb_width = null; /** Optional. Thumbnail height */ - public ?int $thumb_height; + public ?int $thumb_height = null; + + + /** + * @param string $title Title of the result + * @param InputMessageContent $input_message_content Content of the message to be sent + * @param string $url Optional. URL of the result + * @param bool $hide_url Optional. Pass True, if you don't want the URL to be shown in the message + * @param string $description Optional. Short description of the result + * @param string $thumb_url Optional. Url of the thumbnail for the result + * @param int $thumb_width Optional. Thumbnail width + * @param int $thumb_height Optional. Thumbnail height + */ + public static function make( + string $title, + InputMessageContent $input_message_content, + ?string $url = null, + ?bool $hide_url = null, + ?string $description = null, + ?string $thumb_url = null, + ?int $thumb_width = null, + ?int $thumb_height = null + ): static { + return new static([ + 'title' => $title, + 'input_message_content' => $input_message_content, + 'url' => $url, + 'hide_url' => $hide_url, + 'description' => $description, + 'thumb_url' => $thumb_url, + 'thumb_width' => $thumb_width, + 'thumb_height' => $thumb_height, + ]); + } } diff --git a/src/Telegram/InlineQueryResultAudio.php b/src/Telegram/InlineQueryResultAudio.php index b7b0972..37f6a5a 100644 --- a/src/Telegram/InlineQueryResultAudio.php +++ b/src/Telegram/InlineQueryResultAudio.php @@ -18,23 +18,56 @@ class InlineQueryResultAudio extends InlineQueryResult public string $title; /** Optional. Caption, 0-1024 characters after entities parsing */ - public ?string $caption; + public ?string $caption = null; /** Optional. Mode for parsing entities in the audio caption. See formatting options for more details. */ - public ?string $parse_mode; + public ?string $parse_mode = null; /** * Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode * @var MessageEntity[] */ - public ?array $caption_entities; + public ?array $caption_entities = null; /** Optional. Performer */ - public ?string $performer; + public ?string $performer = null; /** Optional. Audio duration in seconds */ - public ?int $audio_duration; + public ?int $audio_duration = null; /** Optional. Content of the message to be sent instead of the audio */ - public ?InputMessageContent $input_message_content; + public ?InputMessageContent $input_message_content = null; + + + /** + * @param string $audio_url A valid URL for the audio file + * @param string $title Title + * @param string $caption Optional. Caption, 0-1024 characters after entities parsing + * @param string $parse_mode Optional. Mode for parsing entities in the audio caption. See formatting options for more details. + * @param MessageEntity[] $caption_entities Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode + * @param string $performer Optional. Performer + * @param int $audio_duration Optional. Audio duration in seconds + * @param InputMessageContent $input_message_content Optional. Content of the message to be sent instead of the audio + */ + public static function make( + string $audio_url, + string $title, + ?string $caption = null, + ?string $parse_mode = null, + ?array $caption_entities = null, + ?string $performer = null, + ?int $audio_duration = null, + ?InputMessageContent $input_message_content = null + ): static { + return new static([ + 'audio_url' => $audio_url, + 'title' => $title, + 'caption' => $caption, + 'parse_mode' => $parse_mode, + 'caption_entities' => $caption_entities, + 'performer' => $performer, + 'audio_duration' => $audio_duration, + 'input_message_content' => $input_message_content, + ]); + } } diff --git a/src/Telegram/InlineQueryResultCachedAudio.php b/src/Telegram/InlineQueryResultCachedAudio.php index c22484f..1600a3d 100644 --- a/src/Telegram/InlineQueryResultCachedAudio.php +++ b/src/Telegram/InlineQueryResultCachedAudio.php @@ -15,17 +15,41 @@ class InlineQueryResultCachedAudio extends InlineQueryResult public string $audio_file_id; /** Optional. Caption, 0-1024 characters after entities parsing */ - public ?string $caption; + public ?string $caption = null; /** Optional. Mode for parsing entities in the audio caption. See formatting options for more details. */ - public ?string $parse_mode; + public ?string $parse_mode = null; /** * Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode * @var MessageEntity[] */ - public ?array $caption_entities; + public ?array $caption_entities = null; /** Optional. Content of the message to be sent instead of the audio */ - public ?InputMessageContent $input_message_content; + public ?InputMessageContent $input_message_content = null; + + + /** + * @param string $audio_file_id A valid file identifier for the audio file + * @param string $caption Optional. Caption, 0-1024 characters after entities parsing + * @param string $parse_mode Optional. Mode for parsing entities in the audio caption. See formatting options for more details. + * @param MessageEntity[] $caption_entities Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode + * @param InputMessageContent $input_message_content Optional. Content of the message to be sent instead of the audio + */ + public static function make( + string $audio_file_id, + ?string $caption = null, + ?string $parse_mode = null, + ?array $caption_entities = null, + ?InputMessageContent $input_message_content = null + ): static { + return new static([ + 'audio_file_id' => $audio_file_id, + 'caption' => $caption, + 'parse_mode' => $parse_mode, + 'caption_entities' => $caption_entities, + 'input_message_content' => $input_message_content, + ]); + } } diff --git a/src/Telegram/InlineQueryResultCachedDocument.php b/src/Telegram/InlineQueryResultCachedDocument.php index 7cdbdec..1bd1ca7 100644 --- a/src/Telegram/InlineQueryResultCachedDocument.php +++ b/src/Telegram/InlineQueryResultCachedDocument.php @@ -18,20 +18,50 @@ class InlineQueryResultCachedDocument extends InlineQueryResult public string $document_file_id; /** Optional. Short description of the result */ - public ?string $description; + public ?string $description = null; /** Optional. Caption of the document to be sent, 0-1024 characters after entities parsing */ - public ?string $caption; + public ?string $caption = null; /** Optional. Mode for parsing entities in the document caption. See formatting options for more details. */ - public ?string $parse_mode; + public ?string $parse_mode = null; /** * Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode * @var MessageEntity[] */ - public ?array $caption_entities; + public ?array $caption_entities = null; /** Optional. Content of the message to be sent instead of the file */ - public ?InputMessageContent $input_message_content; + public ?InputMessageContent $input_message_content = null; + + + /** + * @param string $title Title for the result + * @param string $document_file_id A valid file identifier for the file + * @param string $description Optional. Short description of the result + * @param string $caption Optional. Caption of the document to be sent, 0-1024 characters after entities parsing + * @param string $parse_mode Optional. Mode for parsing entities in the document caption. See formatting options for more details. + * @param MessageEntity[] $caption_entities Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode + * @param InputMessageContent $input_message_content Optional. Content of the message to be sent instead of the file + */ + public static function make( + string $title, + string $document_file_id, + ?string $description = null, + ?string $caption = null, + ?string $parse_mode = null, + ?array $caption_entities = null, + ?InputMessageContent $input_message_content = null + ): static { + return new static([ + 'title' => $title, + 'document_file_id' => $document_file_id, + 'description' => $description, + 'caption' => $caption, + 'parse_mode' => $parse_mode, + 'caption_entities' => $caption_entities, + 'input_message_content' => $input_message_content, + ]); + } } diff --git a/src/Telegram/InlineQueryResultCachedGif.php b/src/Telegram/InlineQueryResultCachedGif.php index 7775efd..60e22d4 100644 --- a/src/Telegram/InlineQueryResultCachedGif.php +++ b/src/Telegram/InlineQueryResultCachedGif.php @@ -15,20 +15,47 @@ class InlineQueryResultCachedGif extends InlineQueryResult public string $gif_file_id; /** Optional. Title for the result */ - public ?string $title; + public ?string $title = null; /** Optional. Caption of the GIF file to be sent, 0-1024 characters after entities parsing */ - public ?string $caption; + public ?string $caption = null; /** Optional. Mode for parsing entities in the caption. See formatting options for more details. */ - public ?string $parse_mode; + public ?string $parse_mode = null; /** * Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode * @var MessageEntity[] */ - public ?array $caption_entities; + public ?array $caption_entities = null; /** Optional. Content of the message to be sent instead of the GIF animation */ - public ?InputMessageContent $input_message_content; + public ?InputMessageContent $input_message_content = null; + + + /** + * @param string $gif_file_id A valid file identifier for the GIF file + * @param string $title Optional. Title for the result + * @param string $caption Optional. Caption of the GIF file to be sent, 0-1024 characters after entities parsing + * @param string $parse_mode Optional. Mode for parsing entities in the caption. See formatting options for more details. + * @param MessageEntity[] $caption_entities Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode + * @param InputMessageContent $input_message_content Optional. Content of the message to be sent instead of the GIF animation + */ + public static function make( + string $gif_file_id, + ?string $title = null, + ?string $caption = null, + ?string $parse_mode = null, + ?array $caption_entities = null, + ?InputMessageContent $input_message_content = null + ): static { + return new static([ + 'gif_file_id' => $gif_file_id, + 'title' => $title, + 'caption' => $caption, + 'parse_mode' => $parse_mode, + 'caption_entities' => $caption_entities, + 'input_message_content' => $input_message_content, + ]); + } } diff --git a/src/Telegram/InlineQueryResultCachedMpeg4Gif.php b/src/Telegram/InlineQueryResultCachedMpeg4Gif.php index 4282426..ee3b4c7 100644 --- a/src/Telegram/InlineQueryResultCachedMpeg4Gif.php +++ b/src/Telegram/InlineQueryResultCachedMpeg4Gif.php @@ -15,20 +15,47 @@ class InlineQueryResultCachedMpeg4Gif extends InlineQueryResult public string $mpeg4_file_id; /** Optional. Title for the result */ - public ?string $title; + public ?string $title = null; /** Optional. Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsing */ - public ?string $caption; + public ?string $caption = null; /** Optional. Mode for parsing entities in the caption. See formatting options for more details. */ - public ?string $parse_mode; + public ?string $parse_mode = null; /** * Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode * @var MessageEntity[] */ - public ?array $caption_entities; + public ?array $caption_entities = null; /** Optional. Content of the message to be sent instead of the video animation */ - public ?InputMessageContent $input_message_content; + public ?InputMessageContent $input_message_content = null; + + + /** + * @param string $mpeg4_file_id A valid file identifier for the MP4 file + * @param string $title Optional. Title for the result + * @param string $caption Optional. Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsing + * @param string $parse_mode Optional. Mode for parsing entities in the caption. See formatting options for more details. + * @param MessageEntity[] $caption_entities Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode + * @param InputMessageContent $input_message_content Optional. Content of the message to be sent instead of the video animation + */ + public static function make( + string $mpeg4_file_id, + ?string $title = null, + ?string $caption = null, + ?string $parse_mode = null, + ?array $caption_entities = null, + ?InputMessageContent $input_message_content = null + ): static { + return new static([ + 'mpeg4_file_id' => $mpeg4_file_id, + 'title' => $title, + 'caption' => $caption, + 'parse_mode' => $parse_mode, + 'caption_entities' => $caption_entities, + 'input_message_content' => $input_message_content, + ]); + } } diff --git a/src/Telegram/InlineQueryResultCachedPhoto.php b/src/Telegram/InlineQueryResultCachedPhoto.php index 20a38ff..0f72f1c 100644 --- a/src/Telegram/InlineQueryResultCachedPhoto.php +++ b/src/Telegram/InlineQueryResultCachedPhoto.php @@ -15,23 +15,53 @@ class InlineQueryResultCachedPhoto extends InlineQueryResult public string $photo_file_id; /** Optional. Title for the result */ - public ?string $title; + public ?string $title = null; /** Optional. Short description of the result */ - public ?string $description; + public ?string $description = null; /** Optional. Caption of the photo to be sent, 0-1024 characters after entities parsing */ - public ?string $caption; + public ?string $caption = null; /** Optional. Mode for parsing entities in the photo caption. See formatting options for more details. */ - public ?string $parse_mode; + public ?string $parse_mode = null; /** * Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode * @var MessageEntity[] */ - public ?array $caption_entities; + public ?array $caption_entities = null; /** Optional. Content of the message to be sent instead of the photo */ - public ?InputMessageContent $input_message_content; + public ?InputMessageContent $input_message_content = null; + + + /** + * @param string $photo_file_id A valid file identifier of the photo + * @param string $title Optional. Title for the result + * @param string $description Optional. Short description of the result + * @param string $caption Optional. Caption of the photo to be sent, 0-1024 characters after entities parsing + * @param string $parse_mode Optional. Mode for parsing entities in the photo caption. See formatting options for more details. + * @param MessageEntity[] $caption_entities Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode + * @param InputMessageContent $input_message_content Optional. Content of the message to be sent instead of the photo + */ + public static function make( + string $photo_file_id, + ?string $title = null, + ?string $description = null, + ?string $caption = null, + ?string $parse_mode = null, + ?array $caption_entities = null, + ?InputMessageContent $input_message_content = null + ): static { + return new static([ + 'photo_file_id' => $photo_file_id, + 'title' => $title, + 'description' => $description, + 'caption' => $caption, + 'parse_mode' => $parse_mode, + 'caption_entities' => $caption_entities, + 'input_message_content' => $input_message_content, + ]); + } } diff --git a/src/Telegram/InlineQueryResultCachedSticker.php b/src/Telegram/InlineQueryResultCachedSticker.php index f473645..68d69ad 100644 --- a/src/Telegram/InlineQueryResultCachedSticker.php +++ b/src/Telegram/InlineQueryResultCachedSticker.php @@ -15,5 +15,18 @@ class InlineQueryResultCachedSticker extends InlineQueryResult public string $sticker_file_id; /** Optional. Content of the message to be sent instead of the sticker */ - public ?InputMessageContent $input_message_content; + public ?InputMessageContent $input_message_content = null; + + + /** + * @param string $sticker_file_id A valid file identifier of the sticker + * @param InputMessageContent $input_message_content Optional. Content of the message to be sent instead of the sticker + */ + public static function make(string $sticker_file_id, ?InputMessageContent $input_message_content = null): static + { + return new static([ + 'sticker_file_id' => $sticker_file_id, + 'input_message_content' => $input_message_content, + ]); + } } diff --git a/src/Telegram/InlineQueryResultCachedVideo.php b/src/Telegram/InlineQueryResultCachedVideo.php index 96663b3..4d31952 100644 --- a/src/Telegram/InlineQueryResultCachedVideo.php +++ b/src/Telegram/InlineQueryResultCachedVideo.php @@ -18,20 +18,50 @@ class InlineQueryResultCachedVideo extends InlineQueryResult public string $title; /** Optional. Short description of the result */ - public ?string $description; + public ?string $description = null; /** Optional. Caption of the video to be sent, 0-1024 characters after entities parsing */ - public ?string $caption; + public ?string $caption = null; /** Optional. Mode for parsing entities in the video caption. See formatting options for more details. */ - public ?string $parse_mode; + public ?string $parse_mode = null; /** * Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode * @var MessageEntity[] */ - public ?array $caption_entities; + public ?array $caption_entities = null; /** Optional. Content of the message to be sent instead of the video */ - public ?InputMessageContent $input_message_content; + public ?InputMessageContent $input_message_content = null; + + + /** + * @param string $video_file_id A valid file identifier for the video file + * @param string $title Title for the result + * @param string $description Optional. Short description of the result + * @param string $caption Optional. Caption of the video to be sent, 0-1024 characters after entities parsing + * @param string $parse_mode Optional. Mode for parsing entities in the video caption. See formatting options for more details. + * @param MessageEntity[] $caption_entities Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode + * @param InputMessageContent $input_message_content Optional. Content of the message to be sent instead of the video + */ + public static function make( + string $video_file_id, + string $title, + ?string $description = null, + ?string $caption = null, + ?string $parse_mode = null, + ?array $caption_entities = null, + ?InputMessageContent $input_message_content = null + ): static { + return new static([ + 'video_file_id' => $video_file_id, + 'title' => $title, + 'description' => $description, + 'caption' => $caption, + 'parse_mode' => $parse_mode, + 'caption_entities' => $caption_entities, + 'input_message_content' => $input_message_content, + ]); + } } diff --git a/src/Telegram/InlineQueryResultCachedVoice.php b/src/Telegram/InlineQueryResultCachedVoice.php index c2c438b..856844c 100644 --- a/src/Telegram/InlineQueryResultCachedVoice.php +++ b/src/Telegram/InlineQueryResultCachedVoice.php @@ -18,17 +18,44 @@ class InlineQueryResultCachedVoice extends InlineQueryResult public string $title; /** Optional. Caption, 0-1024 characters after entities parsing */ - public ?string $caption; + public ?string $caption = null; /** Optional. Mode for parsing entities in the voice message caption. See formatting options for more details. */ - public ?string $parse_mode; + public ?string $parse_mode = null; /** * Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode * @var MessageEntity[] */ - public ?array $caption_entities; + public ?array $caption_entities = null; /** Optional. Content of the message to be sent instead of the voice message */ - public ?InputMessageContent $input_message_content; + public ?InputMessageContent $input_message_content = null; + + + /** + * @param string $voice_file_id A valid file identifier for the voice message + * @param string $title Voice message title + * @param string $caption Optional. Caption, 0-1024 characters after entities parsing + * @param string $parse_mode Optional. Mode for parsing entities in the voice message caption. See formatting options for more details. + * @param MessageEntity[] $caption_entities Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode + * @param InputMessageContent $input_message_content Optional. Content of the message to be sent instead of the voice message + */ + public static function make( + string $voice_file_id, + string $title, + ?string $caption = null, + ?string $parse_mode = null, + ?array $caption_entities = null, + ?InputMessageContent $input_message_content = null + ): static { + return new static([ + 'voice_file_id' => $voice_file_id, + 'title' => $title, + 'caption' => $caption, + 'parse_mode' => $parse_mode, + 'caption_entities' => $caption_entities, + 'input_message_content' => $input_message_content, + ]); + } } diff --git a/src/Telegram/InlineQueryResultContact.php b/src/Telegram/InlineQueryResultContact.php index 44f4268..1fe46b0 100644 --- a/src/Telegram/InlineQueryResultContact.php +++ b/src/Telegram/InlineQueryResultContact.php @@ -18,20 +18,53 @@ class InlineQueryResultContact extends InlineQueryResult public string $first_name; /** Optional. Contact's last name */ - public ?string $last_name; + public ?string $last_name = null; /** Optional. Additional data about the contact in the form of a vCard, 0-2048 bytes */ - public ?string $vcard; + public ?string $vcard = null; /** Optional. Content of the message to be sent instead of the contact */ - public ?InputMessageContent $input_message_content; + public ?InputMessageContent $input_message_content = null; /** Optional. Url of the thumbnail for the result */ - public ?string $thumb_url; + public ?string $thumb_url = null; /** Optional. Thumbnail width */ - public ?int $thumb_width; + public ?int $thumb_width = null; /** Optional. Thumbnail height */ - public ?int $thumb_height; + public ?int $thumb_height = null; + + + /** + * @param string $phone_number Contact's phone number + * @param string $first_name Contact's first name + * @param string $last_name Optional. Contact's last name + * @param string $vcard Optional. Additional data about the contact in the form of a vCard, 0-2048 bytes + * @param InputMessageContent $input_message_content Optional. Content of the message to be sent instead of the contact + * @param string $thumb_url Optional. Url of the thumbnail for the result + * @param int $thumb_width Optional. Thumbnail width + * @param int $thumb_height Optional. Thumbnail height + */ + public static function make( + string $phone_number, + string $first_name, + ?string $last_name = null, + ?string $vcard = null, + ?InputMessageContent $input_message_content = null, + ?string $thumb_url = null, + ?int $thumb_width = null, + ?int $thumb_height = null + ): static { + return new static([ + 'phone_number' => $phone_number, + 'first_name' => $first_name, + 'last_name' => $last_name, + 'vcard' => $vcard, + 'input_message_content' => $input_message_content, + 'thumb_url' => $thumb_url, + 'thumb_width' => $thumb_width, + 'thumb_height' => $thumb_height, + ]); + } } diff --git a/src/Telegram/InlineQueryResultDocument.php b/src/Telegram/InlineQueryResultDocument.php index 68627a7..7a81943 100644 --- a/src/Telegram/InlineQueryResultDocument.php +++ b/src/Telegram/InlineQueryResultDocument.php @@ -15,16 +15,16 @@ class InlineQueryResultDocument extends InlineQueryResult public string $title; /** Optional. Caption of the document to be sent, 0-1024 characters after entities parsing */ - public ?string $caption; + public ?string $caption = null; /** Optional. Mode for parsing entities in the document caption. See formatting options for more details. */ - public ?string $parse_mode; + public ?string $parse_mode = null; /** * Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode * @var MessageEntity[] */ - public ?array $caption_entities; + public ?array $caption_entities = null; /** A valid URL for the file */ public string $document_url; @@ -33,17 +33,59 @@ class InlineQueryResultDocument extends InlineQueryResult public string $mime_type; /** Optional. Short description of the result */ - public ?string $description; + public ?string $description = null; /** Optional. Content of the message to be sent instead of the file */ - public ?InputMessageContent $input_message_content; + public ?InputMessageContent $input_message_content = null; /** Optional. URL of the thumbnail (JPEG only) for the file */ - public ?string $thumb_url; + public ?string $thumb_url = null; /** Optional. Thumbnail width */ - public ?int $thumb_width; + public ?int $thumb_width = null; /** Optional. Thumbnail height */ - public ?int $thumb_height; + public ?int $thumb_height = null; + + + /** + * @param string $title Title for the result + * @param string $caption Optional. Caption of the document to be sent, 0-1024 characters after entities parsing + * @param string $parse_mode Optional. Mode for parsing entities in the document caption. See formatting options for more details. + * @param MessageEntity[] $caption_entities Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode + * @param string $document_url A valid URL for the file + * @param string $mime_type Mime type of the content of the file, either “application/pdf” or “application/zip” + * @param string $description Optional. Short description of the result + * @param InputMessageContent $input_message_content Optional. Content of the message to be sent instead of the file + * @param string $thumb_url Optional. URL of the thumbnail (JPEG only) for the file + * @param int $thumb_width Optional. Thumbnail width + * @param int $thumb_height Optional. Thumbnail height + */ + public static function make( + string $title, + ?string $caption = null, + ?string $parse_mode = null, + ?array $caption_entities = null, + string $document_url, + string $mime_type, + ?string $description = null, + ?InputMessageContent $input_message_content = null, + ?string $thumb_url = null, + ?int $thumb_width = null, + ?int $thumb_height = null + ): static { + return new static([ + 'title' => $title, + 'caption' => $caption, + 'parse_mode' => $parse_mode, + 'caption_entities' => $caption_entities, + 'document_url' => $document_url, + 'mime_type' => $mime_type, + 'description' => $description, + 'input_message_content' => $input_message_content, + 'thumb_url' => $thumb_url, + 'thumb_width' => $thumb_width, + 'thumb_height' => $thumb_height, + ]); + } } diff --git a/src/Telegram/InlineQueryResultGame.php b/src/Telegram/InlineQueryResultGame.php index ace1582..385fe31 100644 --- a/src/Telegram/InlineQueryResultGame.php +++ b/src/Telegram/InlineQueryResultGame.php @@ -13,4 +13,15 @@ class InlineQueryResultGame extends InlineQueryResult { /** Short name of the game */ public string $game_short_name; + + + /** + * @param string $game_short_name Short name of the game + */ + public static function make(string $game_short_name): static + { + return new static([ + 'game_short_name' => $game_short_name, + ]); + } } diff --git a/src/Telegram/InlineQueryResultGif.php b/src/Telegram/InlineQueryResultGif.php index 5b7d955..f6f03d1 100644 --- a/src/Telegram/InlineQueryResultGif.php +++ b/src/Telegram/InlineQueryResultGif.php @@ -15,35 +15,77 @@ class InlineQueryResultGif extends InlineQueryResult public string $gif_url; /** Optional. Width of the GIF */ - public ?int $gif_width; + public ?int $gif_width = null; /** Optional. Height of the GIF */ - public ?int $gif_height; + public ?int $gif_height = null; /** Optional. Duration of the GIF in seconds */ - public ?int $gif_duration; + public ?int $gif_duration = null; /** URL of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result */ public string $thumb_url; /** Optional. MIME type of the thumbnail, must be one of “image/jpeg”, “image/gif”, or “video/mp4”. Defaults to “image/jpeg” */ - public ?string $thumb_mime_type; + public ?string $thumb_mime_type = null; /** Optional. Title for the result */ - public ?string $title; + public ?string $title = null; /** Optional. Caption of the GIF file to be sent, 0-1024 characters after entities parsing */ - public ?string $caption; + public ?string $caption = null; /** Optional. Mode for parsing entities in the caption. See formatting options for more details. */ - public ?string $parse_mode; + public ?string $parse_mode = null; /** * Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode * @var MessageEntity[] */ - public ?array $caption_entities; + public ?array $caption_entities = null; /** Optional. Content of the message to be sent instead of the GIF animation */ - public ?InputMessageContent $input_message_content; + public ?InputMessageContent $input_message_content = null; + + + /** + * @param string $gif_url A valid URL for the GIF file. File size must not exceed 1MB + * @param int $gif_width Optional. Width of the GIF + * @param int $gif_height Optional. Height of the GIF + * @param int $gif_duration Optional. Duration of the GIF in seconds + * @param string $thumb_url URL of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result + * @param string $thumb_mime_type Optional. MIME type of the thumbnail, must be one of “image/jpeg”, “image/gif”, or “video/mp4”. Defaults to “image/jpeg” + * @param string $title Optional. Title for the result + * @param string $caption Optional. Caption of the GIF file to be sent, 0-1024 characters after entities parsing + * @param string $parse_mode Optional. Mode for parsing entities in the caption. See formatting options for more details. + * @param MessageEntity[] $caption_entities Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode + * @param InputMessageContent $input_message_content Optional. Content of the message to be sent instead of the GIF animation + */ + public static function make( + string $gif_url, + ?int $gif_width = null, + ?int $gif_height = null, + ?int $gif_duration = null, + string $thumb_url, + ?string $thumb_mime_type = null, + ?string $title = null, + ?string $caption = null, + ?string $parse_mode = null, + ?array $caption_entities = null, + ?InputMessageContent $input_message_content = null + ): static { + return new static([ + 'gif_url' => $gif_url, + 'gif_width' => $gif_width, + 'gif_height' => $gif_height, + 'gif_duration' => $gif_duration, + 'thumb_url' => $thumb_url, + 'thumb_mime_type' => $thumb_mime_type, + 'title' => $title, + 'caption' => $caption, + 'parse_mode' => $parse_mode, + 'caption_entities' => $caption_entities, + 'input_message_content' => $input_message_content, + ]); + } } diff --git a/src/Telegram/InlineQueryResultLocation.php b/src/Telegram/InlineQueryResultLocation.php index 2758e1c..6a74a01 100644 --- a/src/Telegram/InlineQueryResultLocation.php +++ b/src/Telegram/InlineQueryResultLocation.php @@ -21,26 +21,68 @@ class InlineQueryResultLocation extends InlineQueryResult public string $title; /** Optional. The radius of uncertainty for the location, measured in meters; 0-1500 */ - public ?float $horizontal_accuracy; + public ?float $horizontal_accuracy = null; /** Optional. Period in seconds for which the location can be updated, should be between 60 and 86400. */ - public ?int $live_period; + public ?int $live_period = null; /** Optional. For live locations, a direction in which the user is moving, in degrees. Must be between 1 and 360 if specified. */ - public ?int $heading; + public ?int $heading = null; /** Optional. For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified. */ - public ?int $proximity_alert_radius; + public ?int $proximity_alert_radius = null; /** Optional. Content of the message to be sent instead of the location */ - public ?InputMessageContent $input_message_content; + public ?InputMessageContent $input_message_content = null; /** Optional. Url of the thumbnail for the result */ - public ?string $thumb_url; + public ?string $thumb_url = null; /** Optional. Thumbnail width */ - public ?int $thumb_width; + public ?int $thumb_width = null; /** Optional. Thumbnail height */ - public ?int $thumb_height; + public ?int $thumb_height = null; + + + /** + * @param float $latitude Location latitude in degrees + * @param float $longitude Location longitude in degrees + * @param string $title Location title + * @param float $horizontal_accuracy Optional. The radius of uncertainty for the location, measured in meters; 0-1500 + * @param int $live_period Optional. Period in seconds for which the location can be updated, should be between 60 and 86400. + * @param int $heading Optional. For live locations, a direction in which the user is moving, in degrees. Must be between 1 and 360 if specified. + * @param int $proximity_alert_radius Optional. For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified. + * @param InputMessageContent $input_message_content Optional. Content of the message to be sent instead of the location + * @param string $thumb_url Optional. Url of the thumbnail for the result + * @param int $thumb_width Optional. Thumbnail width + * @param int $thumb_height Optional. Thumbnail height + */ + public static function make( + float $latitude, + float $longitude, + string $title, + ?float $horizontal_accuracy = null, + ?int $live_period = null, + ?int $heading = null, + ?int $proximity_alert_radius = null, + ?InputMessageContent $input_message_content = null, + ?string $thumb_url = null, + ?int $thumb_width = null, + ?int $thumb_height = null + ): static { + return new static([ + 'latitude' => $latitude, + 'longitude' => $longitude, + 'title' => $title, + 'horizontal_accuracy' => $horizontal_accuracy, + 'live_period' => $live_period, + 'heading' => $heading, + 'proximity_alert_radius' => $proximity_alert_radius, + 'input_message_content' => $input_message_content, + 'thumb_url' => $thumb_url, + 'thumb_width' => $thumb_width, + 'thumb_height' => $thumb_height, + ]); + } } diff --git a/src/Telegram/InlineQueryResultMpeg4Gif.php b/src/Telegram/InlineQueryResultMpeg4Gif.php index ae1724c..06e99db 100644 --- a/src/Telegram/InlineQueryResultMpeg4Gif.php +++ b/src/Telegram/InlineQueryResultMpeg4Gif.php @@ -15,35 +15,77 @@ class InlineQueryResultMpeg4Gif extends InlineQueryResult public string $mpeg4_url; /** Optional. Video width */ - public ?int $mpeg4_width; + public ?int $mpeg4_width = null; /** Optional. Video height */ - public ?int $mpeg4_height; + public ?int $mpeg4_height = null; /** Optional. Video duration in seconds */ - public ?int $mpeg4_duration; + public ?int $mpeg4_duration = null; /** URL of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result */ public string $thumb_url; /** Optional. MIME type of the thumbnail, must be one of “image/jpeg”, “image/gif”, or “video/mp4”. Defaults to “image/jpeg” */ - public ?string $thumb_mime_type; + public ?string $thumb_mime_type = null; /** Optional. Title for the result */ - public ?string $title; + public ?string $title = null; /** Optional. Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsing */ - public ?string $caption; + public ?string $caption = null; /** Optional. Mode for parsing entities in the caption. See formatting options for more details. */ - public ?string $parse_mode; + public ?string $parse_mode = null; /** * Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode * @var MessageEntity[] */ - public ?array $caption_entities; + public ?array $caption_entities = null; /** Optional. Content of the message to be sent instead of the video animation */ - public ?InputMessageContent $input_message_content; + public ?InputMessageContent $input_message_content = null; + + + /** + * @param string $mpeg4_url A valid URL for the MP4 file. File size must not exceed 1MB + * @param int $mpeg4_width Optional. Video width + * @param int $mpeg4_height Optional. Video height + * @param int $mpeg4_duration Optional. Video duration in seconds + * @param string $thumb_url URL of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result + * @param string $thumb_mime_type Optional. MIME type of the thumbnail, must be one of “image/jpeg”, “image/gif”, or “video/mp4”. Defaults to “image/jpeg” + * @param string $title Optional. Title for the result + * @param string $caption Optional. Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsing + * @param string $parse_mode Optional. Mode for parsing entities in the caption. See formatting options for more details. + * @param MessageEntity[] $caption_entities Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode + * @param InputMessageContent $input_message_content Optional. Content of the message to be sent instead of the video animation + */ + public static function make( + string $mpeg4_url, + ?int $mpeg4_width = null, + ?int $mpeg4_height = null, + ?int $mpeg4_duration = null, + string $thumb_url, + ?string $thumb_mime_type = null, + ?string $title = null, + ?string $caption = null, + ?string $parse_mode = null, + ?array $caption_entities = null, + ?InputMessageContent $input_message_content = null + ): static { + return new static([ + 'mpeg4_url' => $mpeg4_url, + 'mpeg4_width' => $mpeg4_width, + 'mpeg4_height' => $mpeg4_height, + 'mpeg4_duration' => $mpeg4_duration, + 'thumb_url' => $thumb_url, + 'thumb_mime_type' => $thumb_mime_type, + 'title' => $title, + 'caption' => $caption, + 'parse_mode' => $parse_mode, + 'caption_entities' => $caption_entities, + 'input_message_content' => $input_message_content, + ]); + } } diff --git a/src/Telegram/InlineQueryResultPhoto.php b/src/Telegram/InlineQueryResultPhoto.php index b325a6d..2de8dd3 100644 --- a/src/Telegram/InlineQueryResultPhoto.php +++ b/src/Telegram/InlineQueryResultPhoto.php @@ -18,29 +18,68 @@ class InlineQueryResultPhoto extends InlineQueryResult public string $thumb_url; /** Optional. Width of the photo */ - public ?int $photo_width; + public ?int $photo_width = null; /** Optional. Height of the photo */ - public ?int $photo_height; + public ?int $photo_height = null; /** Optional. Title for the result */ - public ?string $title; + public ?string $title = null; /** Optional. Short description of the result */ - public ?string $description; + public ?string $description = null; /** Optional. Caption of the photo to be sent, 0-1024 characters after entities parsing */ - public ?string $caption; + public ?string $caption = null; /** Optional. Mode for parsing entities in the photo caption. See formatting options for more details. */ - public ?string $parse_mode; + public ?string $parse_mode = null; /** * Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode * @var MessageEntity[] */ - public ?array $caption_entities; + public ?array $caption_entities = null; /** Optional. Content of the message to be sent instead of the photo */ - public ?InputMessageContent $input_message_content; + public ?InputMessageContent $input_message_content = null; + + + /** + * @param string $photo_url A valid URL of the photo. Photo must be in JPEG format. Photo size must not exceed 5MB + * @param string $thumb_url URL of the thumbnail for the photo + * @param int $photo_width Optional. Width of the photo + * @param int $photo_height Optional. Height of the photo + * @param string $title Optional. Title for the result + * @param string $description Optional. Short description of the result + * @param string $caption Optional. Caption of the photo to be sent, 0-1024 characters after entities parsing + * @param string $parse_mode Optional. Mode for parsing entities in the photo caption. See formatting options for more details. + * @param MessageEntity[] $caption_entities Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode + * @param InputMessageContent $input_message_content Optional. Content of the message to be sent instead of the photo + */ + public static function make( + string $photo_url, + string $thumb_url, + ?int $photo_width = null, + ?int $photo_height = null, + ?string $title = null, + ?string $description = null, + ?string $caption = null, + ?string $parse_mode = null, + ?array $caption_entities = null, + ?InputMessageContent $input_message_content = null + ): static { + return new static([ + 'photo_url' => $photo_url, + 'thumb_url' => $thumb_url, + 'photo_width' => $photo_width, + 'photo_height' => $photo_height, + 'title' => $title, + 'description' => $description, + 'caption' => $caption, + 'parse_mode' => $parse_mode, + 'caption_entities' => $caption_entities, + 'input_message_content' => $input_message_content, + ]); + } } diff --git a/src/Telegram/InlineQueryResultVenue.php b/src/Telegram/InlineQueryResultVenue.php index 6b4fd93..9759f5a 100644 --- a/src/Telegram/InlineQueryResultVenue.php +++ b/src/Telegram/InlineQueryResultVenue.php @@ -24,26 +24,71 @@ class InlineQueryResultVenue extends InlineQueryResult public string $address; /** Optional. Foursquare identifier of the venue if known */ - public ?string $foursquare_id; + public ?string $foursquare_id = null; /** Optional. Foursquare type of the venue, if known. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.) */ - public ?string $foursquare_type; + public ?string $foursquare_type = null; /** Optional. Google Places identifier of the venue */ - public ?string $google_place_id; + public ?string $google_place_id = null; /** Optional. Google Places type of the venue. (See supported types.) */ - public ?string $google_place_type; + public ?string $google_place_type = null; /** Optional. Content of the message to be sent instead of the venue */ - public ?InputMessageContent $input_message_content; + public ?InputMessageContent $input_message_content = null; /** Optional. Url of the thumbnail for the result */ - public ?string $thumb_url; + public ?string $thumb_url = null; /** Optional. Thumbnail width */ - public ?int $thumb_width; + public ?int $thumb_width = null; /** Optional. Thumbnail height */ - public ?int $thumb_height; + public ?int $thumb_height = null; + + + /** + * @param float $latitude Latitude of the venue location in degrees + * @param float $longitude Longitude of the venue location in degrees + * @param string $title Title of the venue + * @param string $address Address of the venue + * @param string $foursquare_id Optional. Foursquare identifier of the venue if known + * @param string $foursquare_type Optional. Foursquare type of the venue, if known. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.) + * @param string $google_place_id Optional. Google Places identifier of the venue + * @param string $google_place_type Optional. Google Places type of the venue. (See supported types.) + * @param InputMessageContent $input_message_content Optional. Content of the message to be sent instead of the venue + * @param string $thumb_url Optional. Url of the thumbnail for the result + * @param int $thumb_width Optional. Thumbnail width + * @param int $thumb_height Optional. Thumbnail height + */ + public static function make( + float $latitude, + float $longitude, + string $title, + string $address, + ?string $foursquare_id = null, + ?string $foursquare_type = null, + ?string $google_place_id = null, + ?string $google_place_type = null, + ?InputMessageContent $input_message_content = null, + ?string $thumb_url = null, + ?int $thumb_width = null, + ?int $thumb_height = null + ): static { + return new static([ + 'latitude' => $latitude, + 'longitude' => $longitude, + 'title' => $title, + 'address' => $address, + 'foursquare_id' => $foursquare_id, + 'foursquare_type' => $foursquare_type, + 'google_place_id' => $google_place_id, + 'google_place_type' => $google_place_type, + 'input_message_content' => $input_message_content, + 'thumb_url' => $thumb_url, + 'thumb_width' => $thumb_width, + 'thumb_height' => $thumb_height, + ]); + } } diff --git a/src/Telegram/InlineQueryResultVideo.php b/src/Telegram/InlineQueryResultVideo.php index 893b70f..48a4572 100644 --- a/src/Telegram/InlineQueryResultVideo.php +++ b/src/Telegram/InlineQueryResultVideo.php @@ -24,29 +24,74 @@ class InlineQueryResultVideo extends InlineQueryResult public string $title; /** Optional. Caption of the video to be sent, 0-1024 characters after entities parsing */ - public ?string $caption; + public ?string $caption = null; /** Optional. Mode for parsing entities in the video caption. See formatting options for more details. */ - public ?string $parse_mode; + public ?string $parse_mode = null; /** * Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode * @var MessageEntity[] */ - public ?array $caption_entities; + public ?array $caption_entities = null; /** Optional. Video width */ - public ?int $video_width; + public ?int $video_width = null; /** Optional. Video height */ - public ?int $video_height; + public ?int $video_height = null; /** Optional. Video duration in seconds */ - public ?int $video_duration; + public ?int $video_duration = null; /** Optional. Short description of the result */ - public ?string $description; + public ?string $description = null; /** Optional. Content of the message to be sent instead of the video. This field is required if InlineQueryResultVideo is used to send an HTML-page as a result (e.g., a YouTube video). */ - public ?InputMessageContent $input_message_content; + public ?InputMessageContent $input_message_content = null; + + + /** + * @param string $video_url A valid URL for the embedded video player or video file + * @param string $mime_type Mime type of the content of video url, “text/html” or “video/mp4” + * @param string $thumb_url URL of the thumbnail (JPEG only) for the video + * @param string $title Title for the result + * @param string $caption Optional. Caption of the video to be sent, 0-1024 characters after entities parsing + * @param string $parse_mode Optional. Mode for parsing entities in the video caption. See formatting options for more details. + * @param MessageEntity[] $caption_entities Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode + * @param int $video_width Optional. Video width + * @param int $video_height Optional. Video height + * @param int $video_duration Optional. Video duration in seconds + * @param string $description Optional. Short description of the result + * @param InputMessageContent $input_message_content Optional. Content of the message to be sent instead of the video. This field is required if InlineQueryResultVideo is used to send an HTML-page as a result (e.g., a YouTube video). + */ + public static function make( + string $video_url, + string $mime_type, + string $thumb_url, + string $title, + ?string $caption = null, + ?string $parse_mode = null, + ?array $caption_entities = null, + ?int $video_width = null, + ?int $video_height = null, + ?int $video_duration = null, + ?string $description = null, + ?InputMessageContent $input_message_content = null + ): static { + return new static([ + 'video_url' => $video_url, + 'mime_type' => $mime_type, + 'thumb_url' => $thumb_url, + 'title' => $title, + 'caption' => $caption, + 'parse_mode' => $parse_mode, + 'caption_entities' => $caption_entities, + 'video_width' => $video_width, + 'video_height' => $video_height, + 'video_duration' => $video_duration, + 'description' => $description, + 'input_message_content' => $input_message_content, + ]); + } } diff --git a/src/Telegram/InlineQueryResultVoice.php b/src/Telegram/InlineQueryResultVoice.php index 3381da3..2e1759c 100644 --- a/src/Telegram/InlineQueryResultVoice.php +++ b/src/Telegram/InlineQueryResultVoice.php @@ -18,20 +18,50 @@ class InlineQueryResultVoice extends InlineQueryResult public string $title; /** Optional. Caption, 0-1024 characters after entities parsing */ - public ?string $caption; + public ?string $caption = null; /** Optional. Mode for parsing entities in the voice message caption. See formatting options for more details. */ - public ?string $parse_mode; + public ?string $parse_mode = null; /** * Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode * @var MessageEntity[] */ - public ?array $caption_entities; + public ?array $caption_entities = null; /** Optional. Recording duration in seconds */ - public ?int $voice_duration; + public ?int $voice_duration = null; /** Optional. Content of the message to be sent instead of the voice recording */ - public ?InputMessageContent $input_message_content; + public ?InputMessageContent $input_message_content = null; + + + /** + * @param string $voice_url A valid URL for the voice recording + * @param string $title Recording title + * @param string $caption Optional. Caption, 0-1024 characters after entities parsing + * @param string $parse_mode Optional. Mode for parsing entities in the voice message caption. See formatting options for more details. + * @param MessageEntity[] $caption_entities Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode + * @param int $voice_duration Optional. Recording duration in seconds + * @param InputMessageContent $input_message_content Optional. Content of the message to be sent instead of the voice recording + */ + public static function make( + string $voice_url, + string $title, + ?string $caption = null, + ?string $parse_mode = null, + ?array $caption_entities = null, + ?int $voice_duration = null, + ?InputMessageContent $input_message_content = null + ): static { + return new static([ + 'voice_url' => $voice_url, + 'title' => $title, + 'caption' => $caption, + 'parse_mode' => $parse_mode, + 'caption_entities' => $caption_entities, + 'voice_duration' => $voice_duration, + 'input_message_content' => $input_message_content, + ]); + } } diff --git a/src/Telegram/InputContactMessageContent.php b/src/Telegram/InputContactMessageContent.php index 956de75..3a99f7a 100644 --- a/src/Telegram/InputContactMessageContent.php +++ b/src/Telegram/InputContactMessageContent.php @@ -18,8 +18,29 @@ class InputContactMessageContent extends InputMessageContent public string $first_name; /** Optional. Contact's last name */ - public ?string $last_name; + public ?string $last_name = null; /** Optional. Additional data about the contact in the form of a vCard, 0-2048 bytes */ - public ?string $vcard; + public ?string $vcard = null; + + + /** + * @param string $phone_number Contact's phone number + * @param string $first_name Contact's first name + * @param string $last_name Optional. Contact's last name + * @param string $vcard Optional. Additional data about the contact in the form of a vCard, 0-2048 bytes + */ + public static function make( + string $phone_number, + string $first_name, + ?string $last_name = null, + ?string $vcard = null + ): static { + return new static([ + 'phone_number' => $phone_number, + 'first_name' => $first_name, + 'last_name' => $last_name, + 'vcard' => $vcard, + ]); + } } diff --git a/src/Telegram/InputFile.php b/src/Telegram/InputFile.php index f3e5c36..b23cb98 100644 --- a/src/Telegram/InputFile.php +++ b/src/Telegram/InputFile.php @@ -11,4 +11,9 @@ */ class InputFile extends \Tii\Telepath\Type { + public static function make(): static + { + return new static([ + ]); + } } diff --git a/src/Telegram/InputInvoiceMessageContent.php b/src/Telegram/InputInvoiceMessageContent.php index eecb5af..9b518b7 100644 --- a/src/Telegram/InputInvoiceMessageContent.php +++ b/src/Telegram/InputInvoiceMessageContent.php @@ -33,47 +33,116 @@ class InputInvoiceMessageContent extends InputMessageContent public array $prices; /** Optional. The maximum accepted amount for tips in the smallest units of the currency (integer, not float/double). For example, for a maximum tip of US$ 1.45 pass max_tip_amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0 */ - public ?int $max_tip_amount; + public ?int $max_tip_amount = null; /** * Optional. A JSON-serialized array of suggested amounts of tip in the smallest units of the currency (integer, not float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed max_tip_amount. * @var int[] */ - public ?array $suggested_tip_amounts; + public ?array $suggested_tip_amounts = null; /** Optional. A JSON-serialized object for data about the invoice, which will be shared with the payment provider. A detailed description of the required fields should be provided by the payment provider. */ - public ?string $provider_data; + public ?string $provider_data = null; /** Optional. URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service. People like it better when they see what they are paying for. */ - public ?string $photo_url; + public ?string $photo_url = null; /** Optional. Photo size */ - public ?int $photo_size; + public ?int $photo_size = null; /** Optional. Photo width */ - public ?int $photo_width; + public ?int $photo_width = null; /** Optional. Photo height */ - public ?int $photo_height; + public ?int $photo_height = null; /** Optional. Pass True, if you require the user's full name to complete the order */ - public ?bool $need_name; + public ?bool $need_name = null; /** Optional. Pass True, if you require the user's phone number to complete the order */ - public ?bool $need_phone_number; + public ?bool $need_phone_number = null; /** Optional. Pass True, if you require the user's email address to complete the order */ - public ?bool $need_email; + public ?bool $need_email = null; /** Optional. Pass True, if you require the user's shipping address to complete the order */ - public ?bool $need_shipping_address; + public ?bool $need_shipping_address = null; /** Optional. Pass True, if user's phone number should be sent to provider */ - public ?bool $send_phone_number_to_provider; + public ?bool $send_phone_number_to_provider = null; /** Optional. Pass True, if user's email address should be sent to provider */ - public ?bool $send_email_to_provider; + public ?bool $send_email_to_provider = null; /** Optional. Pass True, if the final price depends on the shipping method */ - public ?bool $is_flexible; + public ?bool $is_flexible = null; + + + /** + * @param string $title Product name, 1-32 characters + * @param string $description Product description, 1-255 characters + * @param string $payload Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes. + * @param string $provider_token Payment provider token, obtained via Botfather + * @param string $currency Three-letter ISO 4217 currency code, see more on currencies + * @param LabeledPrice[] $prices Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.) + * @param int $max_tip_amount Optional. The maximum accepted amount for tips in the smallest units of the currency (integer, not float/double). For example, for a maximum tip of US$ 1.45 pass max_tip_amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0 + * @param int[] $suggested_tip_amounts Optional. A JSON-serialized array of suggested amounts of tip in the smallest units of the currency (integer, not float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed max_tip_amount. + * @param string $provider_data Optional. A JSON-serialized object for data about the invoice, which will be shared with the payment provider. A detailed description of the required fields should be provided by the payment provider. + * @param string $photo_url Optional. URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service. People like it better when they see what they are paying for. + * @param int $photo_size Optional. Photo size + * @param int $photo_width Optional. Photo width + * @param int $photo_height Optional. Photo height + * @param bool $need_name Optional. Pass True, if you require the user's full name to complete the order + * @param bool $need_phone_number Optional. Pass True, if you require the user's phone number to complete the order + * @param bool $need_email Optional. Pass True, if you require the user's email address to complete the order + * @param bool $need_shipping_address Optional. Pass True, if you require the user's shipping address to complete the order + * @param bool $send_phone_number_to_provider Optional. Pass True, if user's phone number should be sent to provider + * @param bool $send_email_to_provider Optional. Pass True, if user's email address should be sent to provider + * @param bool $is_flexible Optional. Pass True, if the final price depends on the shipping method + */ + public static function make( + string $title, + string $description, + string $payload, + string $provider_token, + string $currency, + array $prices, + ?int $max_tip_amount = null, + ?array $suggested_tip_amounts = null, + ?string $provider_data = null, + ?string $photo_url = null, + ?int $photo_size = null, + ?int $photo_width = null, + ?int $photo_height = null, + ?bool $need_name = null, + ?bool $need_phone_number = null, + ?bool $need_email = null, + ?bool $need_shipping_address = null, + ?bool $send_phone_number_to_provider = null, + ?bool $send_email_to_provider = null, + ?bool $is_flexible = null + ): static { + return new static([ + 'title' => $title, + 'description' => $description, + 'payload' => $payload, + 'provider_token' => $provider_token, + 'currency' => $currency, + 'prices' => $prices, + 'max_tip_amount' => $max_tip_amount, + 'suggested_tip_amounts' => $suggested_tip_amounts, + 'provider_data' => $provider_data, + 'photo_url' => $photo_url, + 'photo_size' => $photo_size, + 'photo_width' => $photo_width, + 'photo_height' => $photo_height, + 'need_name' => $need_name, + 'need_phone_number' => $need_phone_number, + 'need_email' => $need_email, + 'need_shipping_address' => $need_shipping_address, + 'send_phone_number_to_provider' => $send_phone_number_to_provider, + 'send_email_to_provider' => $send_email_to_provider, + 'is_flexible' => $is_flexible, + ]); + } } diff --git a/src/Telegram/InputLocationMessageContent.php b/src/Telegram/InputLocationMessageContent.php index 5dfdf00..4ecf594 100644 --- a/src/Telegram/InputLocationMessageContent.php +++ b/src/Telegram/InputLocationMessageContent.php @@ -18,14 +18,41 @@ class InputLocationMessageContent extends InputMessageContent public float $longitude; /** Optional. The radius of uncertainty for the location, measured in meters; 0-1500 */ - public ?float $horizontal_accuracy; + public ?float $horizontal_accuracy = null; /** Optional. Period in seconds for which the location can be updated, should be between 60 and 86400. */ - public ?int $live_period; + public ?int $live_period = null; /** Optional. For live locations, a direction in which the user is moving, in degrees. Must be between 1 and 360 if specified. */ - public ?int $heading; + public ?int $heading = null; /** Optional. For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified. */ - public ?int $proximity_alert_radius; + public ?int $proximity_alert_radius = null; + + + /** + * @param float $latitude Latitude of the location in degrees + * @param float $longitude Longitude of the location in degrees + * @param float $horizontal_accuracy Optional. The radius of uncertainty for the location, measured in meters; 0-1500 + * @param int $live_period Optional. Period in seconds for which the location can be updated, should be between 60 and 86400. + * @param int $heading Optional. For live locations, a direction in which the user is moving, in degrees. Must be between 1 and 360 if specified. + * @param int $proximity_alert_radius Optional. For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified. + */ + public static function make( + float $latitude, + float $longitude, + ?float $horizontal_accuracy = null, + ?int $live_period = null, + ?int $heading = null, + ?int $proximity_alert_radius = null + ): static { + return new static([ + 'latitude' => $latitude, + 'longitude' => $longitude, + 'horizontal_accuracy' => $horizontal_accuracy, + 'live_period' => $live_period, + 'heading' => $heading, + 'proximity_alert_radius' => $proximity_alert_radius, + ]); + } } diff --git a/src/Telegram/InputMedia.php b/src/Telegram/InputMedia.php index 9ebdaf5..fac0bae 100644 --- a/src/Telegram/InputMedia.php +++ b/src/Telegram/InputMedia.php @@ -18,14 +18,38 @@ class InputMedia extends \Tii\Telepath\Type public string $media; /** Optional. Caption of the animation to be sent, 0-1024 characters after entities parsing */ - public ?string $caption; + public ?string $caption = null; /** Optional. Mode for parsing entities in the animation caption. See formatting options for more details. */ - public ?string $parse_mode; + public ?string $parse_mode = null; /** * Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode * @var MessageEntity[] */ - public ?array $caption_entities; + public ?array $caption_entities = null; + + + /** + * @param string $type Type of the result + * @param string $media File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://” to upload a new one using multipart/form-data under name. More info on Sending Files » + * @param string $caption Optional. Caption of the animation to be sent, 0-1024 characters after entities parsing + * @param string $parse_mode Optional. Mode for parsing entities in the animation caption. See formatting options for more details. + * @param MessageEntity[] $caption_entities Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode + */ + public static function make( + string $type, + string $media, + ?string $caption = null, + ?string $parse_mode = null, + ?array $caption_entities = null + ): static { + return new static([ + 'type' => $type, + 'media' => $media, + 'caption' => $caption, + 'parse_mode' => $parse_mode, + 'caption_entities' => $caption_entities, + ]); + } } diff --git a/src/Telegram/InputMediaAnimation.php b/src/Telegram/InputMediaAnimation.php index 05e3af3..759396e 100644 --- a/src/Telegram/InputMediaAnimation.php +++ b/src/Telegram/InputMediaAnimation.php @@ -12,14 +12,35 @@ class InputMediaAnimation extends InputMedia { /** Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . More info on Sending Files » */ - public InputFile|string|null $thumb; + public InputFile|string|null $thumb = null; /** Optional. Animation width */ - public ?int $width; + public ?int $width = null; /** Optional. Animation height */ - public ?int $height; + public ?int $height = null; /** Optional. Animation duration in seconds */ - public ?int $duration; + public ?int $duration = null; + + + /** + * @param InputFile|string $thumb Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . More info on Sending Files » + * @param int $width Optional. Animation width + * @param int $height Optional. Animation height + * @param int $duration Optional. Animation duration in seconds + */ + public static function make( + InputFile|string|null $thumb = null, + ?int $width = null, + ?int $height = null, + ?int $duration = null + ): static { + return new static([ + 'thumb' => $thumb, + 'width' => $width, + 'height' => $height, + 'duration' => $duration, + ]); + } } diff --git a/src/Telegram/InputMediaAudio.php b/src/Telegram/InputMediaAudio.php index 81024f8..fad84f3 100644 --- a/src/Telegram/InputMediaAudio.php +++ b/src/Telegram/InputMediaAudio.php @@ -12,14 +12,35 @@ class InputMediaAudio extends InputMedia { /** Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . More info on Sending Files » */ - public InputFile|string|null $thumb; + public InputFile|string|null $thumb = null; /** Optional. Duration of the audio in seconds */ - public ?int $duration; + public ?int $duration = null; /** Optional. Performer of the audio */ - public ?string $performer; + public ?string $performer = null; /** Optional. Title of the audio */ - public ?string $title; + public ?string $title = null; + + + /** + * @param InputFile|string $thumb Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . More info on Sending Files » + * @param int $duration Optional. Duration of the audio in seconds + * @param string $performer Optional. Performer of the audio + * @param string $title Optional. Title of the audio + */ + public static function make( + InputFile|string|null $thumb = null, + ?int $duration = null, + ?string $performer = null, + ?string $title = null + ): static { + return new static([ + 'thumb' => $thumb, + 'duration' => $duration, + 'performer' => $performer, + 'title' => $title, + ]); + } } diff --git a/src/Telegram/InputMediaDocument.php b/src/Telegram/InputMediaDocument.php index 55793f7..34600d0 100644 --- a/src/Telegram/InputMediaDocument.php +++ b/src/Telegram/InputMediaDocument.php @@ -12,8 +12,21 @@ class InputMediaDocument extends InputMedia { /** Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . More info on Sending Files » */ - public InputFile|string|null $thumb; + public InputFile|string|null $thumb = null; /** Optional. Disables automatic server-side content type detection for files uploaded using multipart/form-data. Always True, if the document is sent as part of an album. */ - public ?bool $disable_content_type_detection; + public ?bool $disable_content_type_detection = null; + + + /** + * @param InputFile|string $thumb Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . More info on Sending Files » + * @param bool $disable_content_type_detection Optional. Disables automatic server-side content type detection for files uploaded using multipart/form-data. Always True, if the document is sent as part of an album. + */ + public static function make(InputFile|string|null $thumb = null, ?bool $disable_content_type_detection = null): static + { + return new static([ + 'thumb' => $thumb, + 'disable_content_type_detection' => $disable_content_type_detection, + ]); + } } diff --git a/src/Telegram/InputMediaPhoto.php b/src/Telegram/InputMediaPhoto.php index 332d75b..689d536 100644 --- a/src/Telegram/InputMediaPhoto.php +++ b/src/Telegram/InputMediaPhoto.php @@ -11,4 +11,9 @@ */ class InputMediaPhoto extends InputMedia { + public static function make(): static + { + return new static([ + ]); + } } diff --git a/src/Telegram/InputMediaVideo.php b/src/Telegram/InputMediaVideo.php index 0222137..de7e5d5 100644 --- a/src/Telegram/InputMediaVideo.php +++ b/src/Telegram/InputMediaVideo.php @@ -12,17 +12,41 @@ class InputMediaVideo extends InputMedia { /** Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . More info on Sending Files » */ - public InputFile|string|null $thumb; + public InputFile|string|null $thumb = null; /** Optional. Video width */ - public ?int $width; + public ?int $width = null; /** Optional. Video height */ - public ?int $height; + public ?int $height = null; /** Optional. Video duration in seconds */ - public ?int $duration; + public ?int $duration = null; /** Optional. Pass True, if the uploaded video is suitable for streaming */ - public ?bool $supports_streaming; + public ?bool $supports_streaming = null; + + + /** + * @param InputFile|string $thumb Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . More info on Sending Files » + * @param int $width Optional. Video width + * @param int $height Optional. Video height + * @param int $duration Optional. Video duration in seconds + * @param bool $supports_streaming Optional. Pass True, if the uploaded video is suitable for streaming + */ + public static function make( + InputFile|string|null $thumb = null, + ?int $width = null, + ?int $height = null, + ?int $duration = null, + ?bool $supports_streaming = null + ): static { + return new static([ + 'thumb' => $thumb, + 'width' => $width, + 'height' => $height, + 'duration' => $duration, + 'supports_streaming' => $supports_streaming, + ]); + } } diff --git a/src/Telegram/InputMessageContent.php b/src/Telegram/InputMessageContent.php index 85af39c..4527d4d 100644 --- a/src/Telegram/InputMessageContent.php +++ b/src/Telegram/InputMessageContent.php @@ -11,4 +11,9 @@ */ class InputMessageContent extends \Tii\Telepath\Type { + public static function make(): static + { + return new static([ + ]); + } } diff --git a/src/Telegram/InputTextMessageContent.php b/src/Telegram/InputTextMessageContent.php index d9f6376..0627322 100644 --- a/src/Telegram/InputTextMessageContent.php +++ b/src/Telegram/InputTextMessageContent.php @@ -15,14 +15,35 @@ class InputTextMessageContent extends InputMessageContent public string $message_text; /** Optional. Mode for parsing entities in the message text. See formatting options for more details. */ - public ?string $parse_mode; + public ?string $parse_mode = null; /** * Optional. List of special entities that appear in message text, which can be specified instead of parse_mode * @var MessageEntity[] */ - public ?array $entities; + public ?array $entities = null; /** Optional. Disables link previews for links in the sent message */ - public ?bool $disable_web_page_preview; + public ?bool $disable_web_page_preview = null; + + + /** + * @param string $message_text Text of the message to be sent, 1-4096 characters + * @param string $parse_mode Optional. Mode for parsing entities in the message text. See formatting options for more details. + * @param MessageEntity[] $entities Optional. List of special entities that appear in message text, which can be specified instead of parse_mode + * @param bool $disable_web_page_preview Optional. Disables link previews for links in the sent message + */ + public static function make( + string $message_text, + ?string $parse_mode = null, + ?array $entities = null, + ?bool $disable_web_page_preview = null + ): static { + return new static([ + 'message_text' => $message_text, + 'parse_mode' => $parse_mode, + 'entities' => $entities, + 'disable_web_page_preview' => $disable_web_page_preview, + ]); + } } diff --git a/src/Telegram/InputVenueMessageContent.php b/src/Telegram/InputVenueMessageContent.php index 447b58a..c04e20c 100644 --- a/src/Telegram/InputVenueMessageContent.php +++ b/src/Telegram/InputVenueMessageContent.php @@ -24,14 +24,47 @@ class InputVenueMessageContent extends InputMessageContent public string $address; /** Optional. Foursquare identifier of the venue, if known */ - public ?string $foursquare_id; + public ?string $foursquare_id = null; /** Optional. Foursquare type of the venue, if known. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.) */ - public ?string $foursquare_type; + public ?string $foursquare_type = null; /** Optional. Google Places identifier of the venue */ - public ?string $google_place_id; + public ?string $google_place_id = null; /** Optional. Google Places type of the venue. (See supported types.) */ - public ?string $google_place_type; + public ?string $google_place_type = null; + + + /** + * @param float $latitude Latitude of the venue in degrees + * @param float $longitude Longitude of the venue in degrees + * @param string $title Name of the venue + * @param string $address Address of the venue + * @param string $foursquare_id Optional. Foursquare identifier of the venue, if known + * @param string $foursquare_type Optional. Foursquare type of the venue, if known. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.) + * @param string $google_place_id Optional. Google Places identifier of the venue + * @param string $google_place_type Optional. Google Places type of the venue. (See supported types.) + */ + public static function make( + float $latitude, + float $longitude, + string $title, + string $address, + ?string $foursquare_id = null, + ?string $foursquare_type = null, + ?string $google_place_id = null, + ?string $google_place_type = null + ): static { + return new static([ + 'latitude' => $latitude, + 'longitude' => $longitude, + 'title' => $title, + 'address' => $address, + 'foursquare_id' => $foursquare_id, + 'foursquare_type' => $foursquare_type, + 'google_place_id' => $google_place_id, + 'google_place_type' => $google_place_type, + ]); + } } diff --git a/src/Telegram/Invoice.php b/src/Telegram/Invoice.php index fa79b69..e17ebdd 100644 --- a/src/Telegram/Invoice.php +++ b/src/Telegram/Invoice.php @@ -25,4 +25,28 @@ class Invoice extends \Tii\Telepath\Type /** Total price in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). */ public int $total_amount; + + + /** + * @param string $title Product name + * @param string $description Product description + * @param string $start_parameter Unique bot deep-linking parameter that can be used to generate this invoice + * @param string $currency Three-letter ISO 4217 currency code + * @param int $total_amount Total price in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). + */ + public static function make( + string $title, + string $description, + string $start_parameter, + string $currency, + int $total_amount + ): static { + return new static([ + 'title' => $title, + 'description' => $description, + 'start_parameter' => $start_parameter, + 'currency' => $currency, + 'total_amount' => $total_amount, + ]); + } } diff --git a/src/Telegram/KeyboardButton.php b/src/Telegram/KeyboardButton.php index 60087d1..defcc4f 100644 --- a/src/Telegram/KeyboardButton.php +++ b/src/Telegram/KeyboardButton.php @@ -15,14 +15,38 @@ class KeyboardButton extends \Tii\Telepath\Type public string $text; /** Optional. If True, the user's phone number will be sent as a contact when the button is pressed. Available in private chats only. */ - public ?bool $request_contact; + public ?bool $request_contact = null; /** Optional. If True, the user's current location will be sent when the button is pressed. Available in private chats only. */ - public ?bool $request_location; + public ?bool $request_location = null; /** Optional. If specified, the user will be asked to create a poll and send it to the bot when the button is pressed. Available in private chats only. */ - public ?KeyboardButtonPollType $request_poll; + public ?KeyboardButtonPollType $request_poll = null; /** Optional. If specified, the described Web App will be launched when the button is pressed. The Web App will be able to send a “web_app_data” service message. Available in private chats only. */ - public ?WebAppInfo $web_app; + public ?WebAppInfo $web_app = null; + + + /** + * @param string $text Text of the button. If none of the optional fields are used, it will be sent as a message when the button is pressed + * @param bool $request_contact Optional. If True, the user's phone number will be sent as a contact when the button is pressed. Available in private chats only. + * @param bool $request_location Optional. If True, the user's current location will be sent when the button is pressed. Available in private chats only. + * @param KeyboardButtonPollType $request_poll Optional. If specified, the user will be asked to create a poll and send it to the bot when the button is pressed. Available in private chats only. + * @param WebAppInfo $web_app Optional. If specified, the described Web App will be launched when the button is pressed. The Web App will be able to send a “web_app_data” service message. Available in private chats only. + */ + public static function make( + string $text, + ?bool $request_contact = null, + ?bool $request_location = null, + ?KeyboardButtonPollType $request_poll = null, + ?WebAppInfo $web_app = null + ): static { + return new static([ + 'text' => $text, + 'request_contact' => $request_contact, + 'request_location' => $request_location, + 'request_poll' => $request_poll, + 'web_app' => $web_app, + ]); + } } diff --git a/src/Telegram/KeyboardButtonPollType.php b/src/Telegram/KeyboardButtonPollType.php index a3f7f17..f107cbf 100644 --- a/src/Telegram/KeyboardButtonPollType.php +++ b/src/Telegram/KeyboardButtonPollType.php @@ -12,5 +12,16 @@ class KeyboardButtonPollType extends \Tii\Telepath\Type { /** Optional. If quiz is passed, the user will be allowed to create only polls in the quiz mode. If regular is passed, only regular polls will be allowed. Otherwise, the user will be allowed to create a poll of any type. */ - public ?string $type; + public ?string $type = null; + + + /** + * @param string $type Optional. If quiz is passed, the user will be allowed to create only polls in the quiz mode. If regular is passed, only regular polls will be allowed. Otherwise, the user will be allowed to create a poll of any type. + */ + public static function make(?string $type = null): static + { + return new static([ + 'type' => $type, + ]); + } } diff --git a/src/Telegram/LabeledPrice.php b/src/Telegram/LabeledPrice.php index bba5350..e7e9284 100644 --- a/src/Telegram/LabeledPrice.php +++ b/src/Telegram/LabeledPrice.php @@ -16,4 +16,17 @@ class LabeledPrice extends \Tii\Telepath\Type /** Price of the product in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). */ public int $amount; + + + /** + * @param string $label Portion label + * @param int $amount Price of the product in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). + */ + public static function make(string $label, int $amount): static + { + return new static([ + 'label' => $label, + 'amount' => $amount, + ]); + } } diff --git a/src/Telegram/Location.php b/src/Telegram/Location.php index 993caf4..6f293b5 100644 --- a/src/Telegram/Location.php +++ b/src/Telegram/Location.php @@ -18,14 +18,41 @@ class Location extends \Tii\Telepath\Type public float $latitude; /** Optional. The radius of uncertainty for the location, measured in meters; 0-1500 */ - public ?float $horizontal_accuracy; + public ?float $horizontal_accuracy = null; /** Optional. Time relative to the message sending date, during which the location can be updated; in seconds. For active live locations only. */ - public ?int $live_period; + public ?int $live_period = null; /** Optional. The direction in which user is moving, in degrees; 1-360. For active live locations only. */ - public ?int $heading; + public ?int $heading = null; /** Optional. Maximum distance for proximity alerts about approaching another chat member, in meters. For sent live locations only. */ - public ?int $proximity_alert_radius; + public ?int $proximity_alert_radius = null; + + + /** + * @param float $longitude Longitude as defined by sender + * @param float $latitude Latitude as defined by sender + * @param float $horizontal_accuracy Optional. The radius of uncertainty for the location, measured in meters; 0-1500 + * @param int $live_period Optional. Time relative to the message sending date, during which the location can be updated; in seconds. For active live locations only. + * @param int $heading Optional. The direction in which user is moving, in degrees; 1-360. For active live locations only. + * @param int $proximity_alert_radius Optional. Maximum distance for proximity alerts about approaching another chat member, in meters. For sent live locations only. + */ + public static function make( + float $longitude, + float $latitude, + ?float $horizontal_accuracy = null, + ?int $live_period = null, + ?int $heading = null, + ?int $proximity_alert_radius = null + ): static { + return new static([ + 'longitude' => $longitude, + 'latitude' => $latitude, + 'horizontal_accuracy' => $horizontal_accuracy, + 'live_period' => $live_period, + 'heading' => $heading, + 'proximity_alert_radius' => $proximity_alert_radius, + ]); + } } diff --git a/src/Telegram/LoginUrl.php b/src/Telegram/LoginUrl.php index 820274b..3b244c9 100644 --- a/src/Telegram/LoginUrl.php +++ b/src/Telegram/LoginUrl.php @@ -15,11 +15,32 @@ class LoginUrl extends \Tii\Telepath\Type public string $url; /** Optional. New text of the button in forwarded messages. */ - public ?string $forward_text; + public ?string $forward_text = null; /** Optional. Username of a bot, which will be used for user authorization. See Setting up a bot for more details. If not specified, the current bot's username will be assumed. The url's domain must be the same as the domain linked with the bot. See Linking your domain to the bot for more details. */ - public ?string $bot_username; + public ?string $bot_username = null; /** Optional. Pass True to request the permission for your bot to send messages to the user. */ - public ?bool $request_write_access; + public ?bool $request_write_access = null; + + + /** + * @param string $url An HTTP URL to be opened with user authorization data added to the query string when the button is pressed. If the user refuses to provide authorization data, the original URL without information about the user will be opened. The data added is the same as described in Receiving authorization data.NOTE: You must always check the hash of the received data to verify the authentication and the integrity of the data as described in Checking authorization. + * @param string $forward_text Optional. New text of the button in forwarded messages. + * @param string $bot_username Optional. Username of a bot, which will be used for user authorization. See Setting up a bot for more details. If not specified, the current bot's username will be assumed. The url's domain must be the same as the domain linked with the bot. See Linking your domain to the bot for more details. + * @param bool $request_write_access Optional. Pass True to request the permission for your bot to send messages to the user. + */ + public static function make( + string $url, + ?string $forward_text = null, + ?string $bot_username = null, + ?bool $request_write_access = null + ): static { + return new static([ + 'url' => $url, + 'forward_text' => $forward_text, + 'bot_username' => $bot_username, + 'request_write_access' => $request_write_access, + ]); + } } diff --git a/src/Telegram/MaskPosition.php b/src/Telegram/MaskPosition.php index 88401ca..d70caaf 100644 --- a/src/Telegram/MaskPosition.php +++ b/src/Telegram/MaskPosition.php @@ -22,4 +22,21 @@ class MaskPosition extends \Tii\Telepath\Type /** Mask scaling coefficient. For example, 2.0 means double size. */ public float $scale; + + + /** + * @param string $point The part of the face relative to which the mask should be placed. One of “forehead”, “eyes”, “mouth”, or “chin”. + * @param float $x_shift Shift by X-axis measured in widths of the mask scaled to the face size, from left to right. For example, choosing -1.0 will place mask just to the left of the default mask position. + * @param float $y_shift Shift by Y-axis measured in heights of the mask scaled to the face size, from top to bottom. For example, 1.0 will place the mask just below the default mask position. + * @param float $scale Mask scaling coefficient. For example, 2.0 means double size. + */ + public static function make(string $point, float $x_shift, float $y_shift, float $scale): static + { + return new static([ + 'point' => $point, + 'x_shift' => $x_shift, + 'y_shift' => $y_shift, + 'scale' => $scale, + ]); + } } diff --git a/src/Telegram/MenuButton.php b/src/Telegram/MenuButton.php index 0290790..04ca120 100644 --- a/src/Telegram/MenuButton.php +++ b/src/Telegram/MenuButton.php @@ -13,4 +13,15 @@ class MenuButton extends \Tii\Telepath\Type { /** Type of the button */ public string $type; + + + /** + * @param string $type Type of the button + */ + public static function make(string $type): static + { + return new static([ + 'type' => $type, + ]); + } } diff --git a/src/Telegram/MenuButtonCommands.php b/src/Telegram/MenuButtonCommands.php index e7c294b..c12ca0e 100644 --- a/src/Telegram/MenuButtonCommands.php +++ b/src/Telegram/MenuButtonCommands.php @@ -11,4 +11,9 @@ */ class MenuButtonCommands extends MenuButton { + public static function make(): static + { + return new static([ + ]); + } } diff --git a/src/Telegram/MenuButtonDefault.php b/src/Telegram/MenuButtonDefault.php index bcc4b4a..008df15 100644 --- a/src/Telegram/MenuButtonDefault.php +++ b/src/Telegram/MenuButtonDefault.php @@ -11,4 +11,9 @@ */ class MenuButtonDefault extends MenuButton { + public static function make(): static + { + return new static([ + ]); + } } diff --git a/src/Telegram/MenuButtonWebApp.php b/src/Telegram/MenuButtonWebApp.php index ff8eb77..a67aba2 100644 --- a/src/Telegram/MenuButtonWebApp.php +++ b/src/Telegram/MenuButtonWebApp.php @@ -16,4 +16,17 @@ class MenuButtonWebApp extends MenuButton /** Description of the Web App that will be launched when the user presses the button. The Web App will be able to send an arbitrary message on behalf of the user using the method answerWebAppQuery. */ public WebAppInfo $web_app; + + + /** + * @param string $text Text on the button + * @param WebAppInfo $web_app Description of the Web App that will be launched when the user presses the button. The Web App will be able to send an arbitrary message on behalf of the user using the method answerWebAppQuery. + */ + public static function make(string $text, WebAppInfo $web_app): static + { + return new static([ + 'text' => $text, + 'web_app' => $web_app, + ]); + } } diff --git a/src/Telegram/Message.php b/src/Telegram/Message.php index d844a6f..6b6297e 100644 --- a/src/Telegram/Message.php +++ b/src/Telegram/Message.php @@ -15,10 +15,10 @@ class Message extends \Tii\Telepath\Type public int $message_id; /** Optional. Sender of the message; empty for messages sent to channels. For backward compatibility, the field contains a fake sender user in non-channel chats, if the message was sent on behalf of a chat. */ - public ?User $from; + public ?User $from = null; /** Optional. Sender of the message, sent on behalf of a chat. For example, the channel itself for channel posts, the supergroup itself for messages from anonymous group administrators, the linked channel for messages automatically forwarded to the discussion group. For backward compatibility, the field from contains a fake sender user in non-channel chats, if the message was sent on behalf of a chat. */ - public ?Chat $sender_chat; + public ?Chat $sender_chat = null; /** Date the message was sent in Unix time */ public int $date; @@ -27,179 +27,365 @@ class Message extends \Tii\Telepath\Type public Chat $chat; /** Optional. For forwarded messages, sender of the original message */ - public ?User $forward_from; + public ?User $forward_from = null; /** Optional. For messages forwarded from channels or from anonymous administrators, information about the original sender chat */ - public ?Chat $forward_from_chat; + public ?Chat $forward_from_chat = null; /** Optional. For messages forwarded from channels, identifier of the original message in the channel */ - public ?int $forward_from_message_id; + public ?int $forward_from_message_id = null; /** Optional. For forwarded messages that were originally sent in channels or by an anonymous chat administrator, signature of the message sender if present */ - public ?string $forward_signature; + public ?string $forward_signature = null; /** Optional. Sender's name for messages forwarded from users who disallow adding a link to their account in forwarded messages */ - public ?string $forward_sender_name; + public ?string $forward_sender_name = null; /** Optional. For forwarded messages, date the original message was sent in Unix time */ - public ?int $forward_date; + public ?int $forward_date = null; /** Optional. True, if the message is a channel post that was automatically forwarded to the connected discussion group */ - public ?bool $is_automatic_forward; + public ?bool $is_automatic_forward = null; /** Optional. For replies, the original message. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply. */ - public ?Message $reply_to_message; + public ?Message $reply_to_message = null; /** Optional. Bot through which the message was sent */ - public ?User $via_bot; + public ?User $via_bot = null; /** Optional. Date the message was last edited in Unix time */ - public ?int $edit_date; + public ?int $edit_date = null; /** Optional. True, if the message can't be forwarded */ - public ?bool $has_protected_content; + public ?bool $has_protected_content = null; /** Optional. The unique identifier of a media message group this message belongs to */ - public ?string $media_group_id; + public ?string $media_group_id = null; /** Optional. Signature of the post author for messages in channels, or the custom title of an anonymous group administrator */ - public ?string $author_signature; + public ?string $author_signature = null; /** Optional. For text messages, the actual UTF-8 text of the message, 0-4096 characters */ - public ?string $text; + public ?string $text = null; /** * Optional. For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text * @var MessageEntity[] */ - public ?array $entities; + public ?array $entities = null; /** Optional. Message is an animation, information about the animation. For backward compatibility, when this field is set, the document field will also be set */ - public ?Animation $animation; + public ?Animation $animation = null; /** Optional. Message is an audio file, information about the file */ - public ?Audio $audio; + public ?Audio $audio = null; /** Optional. Message is a general file, information about the file */ - public ?Document $document; + public ?Document $document = null; /** * Optional. Message is a photo, available sizes of the photo * @var PhotoSize[] */ - public ?array $photo; + public ?array $photo = null; /** Optional. Message is a sticker, information about the sticker */ - public ?Sticker $sticker; + public ?Sticker $sticker = null; /** Optional. Message is a video, information about the video */ - public ?Video $video; + public ?Video $video = null; /** Optional. Message is a video note, information about the video message */ - public ?VideoNote $video_note; + public ?VideoNote $video_note = null; /** Optional. Message is a voice message, information about the file */ - public ?Voice $voice; + public ?Voice $voice = null; /** Optional. Caption for the animation, audio, document, photo, video or voice, 0-1024 characters */ - public ?string $caption; + public ?string $caption = null; /** * Optional. For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption * @var MessageEntity[] */ - public ?array $caption_entities; + public ?array $caption_entities = null; /** Optional. Message is a shared contact, information about the contact */ - public ?Contact $contact; + public ?Contact $contact = null; /** Optional. Message is a dice with random value */ - public ?Dice $dice; + public ?Dice $dice = null; /** Optional. Message is a game, information about the game. More about games » */ - public ?Game $game; + public ?Game $game = null; /** Optional. Message is a native poll, information about the poll */ - public ?Poll $poll; + public ?Poll $poll = null; /** Optional. Message is a venue, information about the venue. For backward compatibility, when this field is set, the location field will also be set */ - public ?Venue $venue; + public ?Venue $venue = null; /** Optional. Message is a shared location, information about the location */ - public ?Location $location; + public ?Location $location = null; /** * Optional. New members that were added to the group or supergroup and information about them (the bot itself may be one of these members) * @var User[] */ - public ?array $new_chat_members; + public ?array $new_chat_members = null; /** Optional. A member was removed from the group, information about them (this member may be the bot itself) */ - public ?User $left_chat_member; + public ?User $left_chat_member = null; /** Optional. A chat title was changed to this value */ - public ?string $new_chat_title; + public ?string $new_chat_title = null; /** * Optional. A chat photo was change to this value * @var PhotoSize[] */ - public ?array $new_chat_photo; + public ?array $new_chat_photo = null; /** Optional. Service message: the chat photo was deleted */ - public ?bool $delete_chat_photo; + public ?bool $delete_chat_photo = null; /** Optional. Service message: the group has been created */ - public ?bool $group_chat_created; + public ?bool $group_chat_created = null; /** Optional. Service message: the supergroup has been created. This field can't be received in a message coming through updates, because bot can't be a member of a supergroup when it is created. It can only be found in reply_to_message if someone replies to a very first message in a directly created supergroup. */ - public ?bool $supergroup_chat_created; + public ?bool $supergroup_chat_created = null; /** Optional. Service message: the channel has been created. This field can't be received in a message coming through updates, because bot can't be a member of a channel when it is created. It can only be found in reply_to_message if someone replies to a very first message in a channel. */ - public ?bool $channel_chat_created; + public ?bool $channel_chat_created = null; /** Optional. Service message: auto-delete timer settings changed in the chat */ - public ?MessageAutoDeleteTimerChanged $message_auto_delete_timer_changed; + public ?MessageAutoDeleteTimerChanged $message_auto_delete_timer_changed = null; /** Optional. The group has been migrated to a supergroup with the specified identifier. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier. */ - public ?int $migrate_to_chat_id; + public ?int $migrate_to_chat_id = null; /** Optional. The supergroup has been migrated from a group with the specified identifier. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier. */ - public ?int $migrate_from_chat_id; + public ?int $migrate_from_chat_id = null; /** Optional. Specified message was pinned. Note that the Message object in this field will not contain further reply_to_message fields even if it is itself a reply. */ - public ?Message $pinned_message; + public ?Message $pinned_message = null; /** Optional. Message is an invoice for a payment, information about the invoice. More about payments » */ - public ?Invoice $invoice; + public ?Invoice $invoice = null; /** Optional. Message is a service message about a successful payment, information about the payment. More about payments » */ - public ?SuccessfulPayment $successful_payment; + public ?SuccessfulPayment $successful_payment = null; /** Optional. The domain name of the website on which the user has logged in. More about Telegram Login » */ - public ?string $connected_website; + public ?string $connected_website = null; /** Optional. Telegram Passport data */ - public ?PassportData $passport_data; + public ?PassportData $passport_data = null; /** Optional. Service message. A user in the chat triggered another user's proximity alert while sharing Live Location. */ - public ?ProximityAlertTriggered $proximity_alert_triggered; + public ?ProximityAlertTriggered $proximity_alert_triggered = null; /** Optional. Service message: video chat scheduled */ - public ?VideoChatScheduled $video_chat_scheduled; + public ?VideoChatScheduled $video_chat_scheduled = null; /** Optional. Service message: video chat started */ - public ?VideoChatStarted $video_chat_started; + public ?VideoChatStarted $video_chat_started = null; /** Optional. Service message: video chat ended */ - public ?VideoChatEnded $video_chat_ended; + public ?VideoChatEnded $video_chat_ended = null; /** Optional. Service message: new participants invited to a video chat */ - public ?VideoChatParticipantsInvited $video_chat_participants_invited; + public ?VideoChatParticipantsInvited $video_chat_participants_invited = null; /** Optional. Service message: data sent by a Web App */ - public ?WebAppData $web_app_data; + public ?WebAppData $web_app_data = null; /** Optional. Inline keyboard attached to the message. login_url buttons are represented as ordinary url buttons. */ - public ?InlineKeyboardMarkup $reply_markup; + public ?InlineKeyboardMarkup $reply_markup = null; + + + /** + * @param int $message_id Unique message identifier inside this chat + * @param User $from Optional. Sender of the message; empty for messages sent to channels. For backward compatibility, the field contains a fake sender user in non-channel chats, if the message was sent on behalf of a chat. + * @param Chat $sender_chat Optional. Sender of the message, sent on behalf of a chat. For example, the channel itself for channel posts, the supergroup itself for messages from anonymous group administrators, the linked channel for messages automatically forwarded to the discussion group. For backward compatibility, the field from contains a fake sender user in non-channel chats, if the message was sent on behalf of a chat. + * @param int $date Date the message was sent in Unix time + * @param Chat $chat Conversation the message belongs to + * @param User $forward_from Optional. For forwarded messages, sender of the original message + * @param Chat $forward_from_chat Optional. For messages forwarded from channels or from anonymous administrators, information about the original sender chat + * @param int $forward_from_message_id Optional. For messages forwarded from channels, identifier of the original message in the channel + * @param string $forward_signature Optional. For forwarded messages that were originally sent in channels or by an anonymous chat administrator, signature of the message sender if present + * @param string $forward_sender_name Optional. Sender's name for messages forwarded from users who disallow adding a link to their account in forwarded messages + * @param int $forward_date Optional. For forwarded messages, date the original message was sent in Unix time + * @param bool $is_automatic_forward Optional. True, if the message is a channel post that was automatically forwarded to the connected discussion group + * @param Message $reply_to_message Optional. For replies, the original message. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply. + * @param User $via_bot Optional. Bot through which the message was sent + * @param int $edit_date Optional. Date the message was last edited in Unix time + * @param bool $has_protected_content Optional. True, if the message can't be forwarded + * @param string $media_group_id Optional. The unique identifier of a media message group this message belongs to + * @param string $author_signature Optional. Signature of the post author for messages in channels, or the custom title of an anonymous group administrator + * @param string $text Optional. For text messages, the actual UTF-8 text of the message, 0-4096 characters + * @param MessageEntity[] $entities Optional. For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text + * @param Animation $animation Optional. Message is an animation, information about the animation. For backward compatibility, when this field is set, the document field will also be set + * @param Audio $audio Optional. Message is an audio file, information about the file + * @param Document $document Optional. Message is a general file, information about the file + * @param PhotoSize[] $photo Optional. Message is a photo, available sizes of the photo + * @param Sticker $sticker Optional. Message is a sticker, information about the sticker + * @param Video $video Optional. Message is a video, information about the video + * @param VideoNote $video_note Optional. Message is a video note, information about the video message + * @param Voice $voice Optional. Message is a voice message, information about the file + * @param string $caption Optional. Caption for the animation, audio, document, photo, video or voice, 0-1024 characters + * @param MessageEntity[] $caption_entities Optional. For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption + * @param Contact $contact Optional. Message is a shared contact, information about the contact + * @param Dice $dice Optional. Message is a dice with random value + * @param Game $game Optional. Message is a game, information about the game. More about games » + * @param Poll $poll Optional. Message is a native poll, information about the poll + * @param Venue $venue Optional. Message is a venue, information about the venue. For backward compatibility, when this field is set, the location field will also be set + * @param Location $location Optional. Message is a shared location, information about the location + * @param User[] $new_chat_members Optional. New members that were added to the group or supergroup and information about them (the bot itself may be one of these members) + * @param User $left_chat_member Optional. A member was removed from the group, information about them (this member may be the bot itself) + * @param string $new_chat_title Optional. A chat title was changed to this value + * @param PhotoSize[] $new_chat_photo Optional. A chat photo was change to this value + * @param bool $delete_chat_photo Optional. Service message: the chat photo was deleted + * @param bool $group_chat_created Optional. Service message: the group has been created + * @param bool $supergroup_chat_created Optional. Service message: the supergroup has been created. This field can't be received in a message coming through updates, because bot can't be a member of a supergroup when it is created. It can only be found in reply_to_message if someone replies to a very first message in a directly created supergroup. + * @param bool $channel_chat_created Optional. Service message: the channel has been created. This field can't be received in a message coming through updates, because bot can't be a member of a channel when it is created. It can only be found in reply_to_message if someone replies to a very first message in a channel. + * @param MessageAutoDeleteTimerChanged $message_auto_delete_timer_changed Optional. Service message: auto-delete timer settings changed in the chat + * @param int $migrate_to_chat_id Optional. The group has been migrated to a supergroup with the specified identifier. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier. + * @param int $migrate_from_chat_id Optional. The supergroup has been migrated from a group with the specified identifier. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier. + * @param Message $pinned_message Optional. Specified message was pinned. Note that the Message object in this field will not contain further reply_to_message fields even if it is itself a reply. + * @param Invoice $invoice Optional. Message is an invoice for a payment, information about the invoice. More about payments » + * @param SuccessfulPayment $successful_payment Optional. Message is a service message about a successful payment, information about the payment. More about payments » + * @param string $connected_website Optional. The domain name of the website on which the user has logged in. More about Telegram Login » + * @param PassportData $passport_data Optional. Telegram Passport data + * @param ProximityAlertTriggered $proximity_alert_triggered Optional. Service message. A user in the chat triggered another user's proximity alert while sharing Live Location. + * @param VideoChatScheduled $video_chat_scheduled Optional. Service message: video chat scheduled + * @param VideoChatStarted $video_chat_started Optional. Service message: video chat started + * @param VideoChatEnded $video_chat_ended Optional. Service message: video chat ended + * @param VideoChatParticipantsInvited $video_chat_participants_invited Optional. Service message: new participants invited to a video chat + * @param WebAppData $web_app_data Optional. Service message: data sent by a Web App + * @param InlineKeyboardMarkup $reply_markup Optional. Inline keyboard attached to the message. login_url buttons are represented as ordinary url buttons. + */ + public static function make( + int $message_id, + ?User $from = null, + ?Chat $sender_chat = null, + int $date, + Chat $chat, + ?User $forward_from = null, + ?Chat $forward_from_chat = null, + ?int $forward_from_message_id = null, + ?string $forward_signature = null, + ?string $forward_sender_name = null, + ?int $forward_date = null, + ?bool $is_automatic_forward = null, + ?Message $reply_to_message = null, + ?User $via_bot = null, + ?int $edit_date = null, + ?bool $has_protected_content = null, + ?string $media_group_id = null, + ?string $author_signature = null, + ?string $text = null, + ?array $entities = null, + ?Animation $animation = null, + ?Audio $audio = null, + ?Document $document = null, + ?array $photo = null, + ?Sticker $sticker = null, + ?Video $video = null, + ?VideoNote $video_note = null, + ?Voice $voice = null, + ?string $caption = null, + ?array $caption_entities = null, + ?Contact $contact = null, + ?Dice $dice = null, + ?Game $game = null, + ?Poll $poll = null, + ?Venue $venue = null, + ?Location $location = null, + ?array $new_chat_members = null, + ?User $left_chat_member = null, + ?string $new_chat_title = null, + ?array $new_chat_photo = null, + ?bool $delete_chat_photo = null, + ?bool $group_chat_created = null, + ?bool $supergroup_chat_created = null, + ?bool $channel_chat_created = null, + ?MessageAutoDeleteTimerChanged $message_auto_delete_timer_changed = null, + ?int $migrate_to_chat_id = null, + ?int $migrate_from_chat_id = null, + ?Message $pinned_message = null, + ?Invoice $invoice = null, + ?SuccessfulPayment $successful_payment = null, + ?string $connected_website = null, + ?PassportData $passport_data = null, + ?ProximityAlertTriggered $proximity_alert_triggered = null, + ?VideoChatScheduled $video_chat_scheduled = null, + ?VideoChatStarted $video_chat_started = null, + ?VideoChatEnded $video_chat_ended = null, + ?VideoChatParticipantsInvited $video_chat_participants_invited = null, + ?WebAppData $web_app_data = null, + ?InlineKeyboardMarkup $reply_markup = null + ): static { + return new static([ + 'message_id' => $message_id, + 'from' => $from, + 'sender_chat' => $sender_chat, + 'date' => $date, + 'chat' => $chat, + 'forward_from' => $forward_from, + 'forward_from_chat' => $forward_from_chat, + 'forward_from_message_id' => $forward_from_message_id, + 'forward_signature' => $forward_signature, + 'forward_sender_name' => $forward_sender_name, + 'forward_date' => $forward_date, + 'is_automatic_forward' => $is_automatic_forward, + 'reply_to_message' => $reply_to_message, + 'via_bot' => $via_bot, + 'edit_date' => $edit_date, + 'has_protected_content' => $has_protected_content, + 'media_group_id' => $media_group_id, + 'author_signature' => $author_signature, + 'text' => $text, + 'entities' => $entities, + 'animation' => $animation, + 'audio' => $audio, + 'document' => $document, + 'photo' => $photo, + 'sticker' => $sticker, + 'video' => $video, + 'video_note' => $video_note, + 'voice' => $voice, + 'caption' => $caption, + 'caption_entities' => $caption_entities, + 'contact' => $contact, + 'dice' => $dice, + 'game' => $game, + 'poll' => $poll, + 'venue' => $venue, + 'location' => $location, + 'new_chat_members' => $new_chat_members, + 'left_chat_member' => $left_chat_member, + 'new_chat_title' => $new_chat_title, + 'new_chat_photo' => $new_chat_photo, + 'delete_chat_photo' => $delete_chat_photo, + 'group_chat_created' => $group_chat_created, + 'supergroup_chat_created' => $supergroup_chat_created, + 'channel_chat_created' => $channel_chat_created, + 'message_auto_delete_timer_changed' => $message_auto_delete_timer_changed, + 'migrate_to_chat_id' => $migrate_to_chat_id, + 'migrate_from_chat_id' => $migrate_from_chat_id, + 'pinned_message' => $pinned_message, + 'invoice' => $invoice, + 'successful_payment' => $successful_payment, + 'connected_website' => $connected_website, + 'passport_data' => $passport_data, + 'proximity_alert_triggered' => $proximity_alert_triggered, + 'video_chat_scheduled' => $video_chat_scheduled, + 'video_chat_started' => $video_chat_started, + 'video_chat_ended' => $video_chat_ended, + 'video_chat_participants_invited' => $video_chat_participants_invited, + 'web_app_data' => $web_app_data, + 'reply_markup' => $reply_markup, + ]); + } } diff --git a/src/Telegram/MessageAutoDeleteTimerChanged.php b/src/Telegram/MessageAutoDeleteTimerChanged.php index 1b46149..9b6c55f 100644 --- a/src/Telegram/MessageAutoDeleteTimerChanged.php +++ b/src/Telegram/MessageAutoDeleteTimerChanged.php @@ -13,4 +13,15 @@ class MessageAutoDeleteTimerChanged extends \Tii\Telepath\Type { /** New auto-delete time for messages in the chat; in seconds */ public int $message_auto_delete_time; + + + /** + * @param int $message_auto_delete_time New auto-delete time for messages in the chat; in seconds + */ + public static function make(int $message_auto_delete_time): static + { + return new static([ + 'message_auto_delete_time' => $message_auto_delete_time, + ]); + } } diff --git a/src/Telegram/MessageEntity.php b/src/Telegram/MessageEntity.php index f7d5721..102a779 100644 --- a/src/Telegram/MessageEntity.php +++ b/src/Telegram/MessageEntity.php @@ -21,11 +21,38 @@ class MessageEntity extends \Tii\Telepath\Type public int $length; /** Optional. For “text_link” only, url that will be opened after user taps on the text */ - public ?string $url; + public ?string $url = null; /** Optional. For “text_mention” only, the mentioned user */ - public ?User $user; + public ?User $user = null; /** Optional. For “pre” only, the programming language of the entity text */ - public ?string $language; + public ?string $language = null; + + + /** + * @param string $type Type of the entity. Currently, can be “mention” (@username), “hashtag” (#hashtag), “cashtag” ($USD), “bot_command” (/start@jobs_bot), “url” (https://telegram.org), “email” (do-not-reply@telegram.org), “phone_number” (+1-212-555-0123), “bold” (bold text), “italic” (italic text), “underline” (underlined text), “strikethrough” (strikethrough text), “spoiler” (spoiler message), “code” (monowidth string), “pre” (monowidth block), “text_link” (for clickable text URLs), “text_mention” (for users without usernames) + * @param int $offset Offset in UTF-16 code units to the start of the entity + * @param int $length Length of the entity in UTF-16 code units + * @param string $url Optional. For “text_link” only, url that will be opened after user taps on the text + * @param User $user Optional. For “text_mention” only, the mentioned user + * @param string $language Optional. For “pre” only, the programming language of the entity text + */ + public static function make( + string $type, + int $offset, + int $length, + ?string $url = null, + ?User $user = null, + ?string $language = null + ): static { + return new static([ + 'type' => $type, + 'offset' => $offset, + 'length' => $length, + 'url' => $url, + 'user' => $user, + 'language' => $language, + ]); + } } diff --git a/src/Telegram/MessageId.php b/src/Telegram/MessageId.php index 7a67e81..a105400 100644 --- a/src/Telegram/MessageId.php +++ b/src/Telegram/MessageId.php @@ -13,4 +13,15 @@ class MessageId extends \Tii\Telepath\Type { /** Unique message identifier */ public int $message_id; + + + /** + * @param int $message_id Unique message identifier + */ + public static function make(int $message_id): static + { + return new static([ + 'message_id' => $message_id, + ]); + } } diff --git a/src/Telegram/OrderInfo.php b/src/Telegram/OrderInfo.php index afb3cc0..2629774 100644 --- a/src/Telegram/OrderInfo.php +++ b/src/Telegram/OrderInfo.php @@ -12,14 +12,35 @@ class OrderInfo extends \Tii\Telepath\Type { /** Optional. User name */ - public ?string $name; + public ?string $name = null; /** Optional. User's phone number */ - public ?string $phone_number; + public ?string $phone_number = null; /** Optional. User email */ - public ?string $email; + public ?string $email = null; /** Optional. User shipping address */ - public ?ShippingAddress $shipping_address; + public ?ShippingAddress $shipping_address = null; + + + /** + * @param string $name Optional. User name + * @param string $phone_number Optional. User's phone number + * @param string $email Optional. User email + * @param ShippingAddress $shipping_address Optional. User shipping address + */ + public static function make( + ?string $name = null, + ?string $phone_number = null, + ?string $email = null, + ?ShippingAddress $shipping_address = null + ): static { + return new static([ + 'name' => $name, + 'phone_number' => $phone_number, + 'email' => $email, + 'shipping_address' => $shipping_address, + ]); + } } diff --git a/src/Telegram/PassportData.php b/src/Telegram/PassportData.php index fc67316..0699b41 100644 --- a/src/Telegram/PassportData.php +++ b/src/Telegram/PassportData.php @@ -19,4 +19,17 @@ class PassportData extends \Tii\Telepath\Type /** Encrypted credentials required to decrypt the data */ public EncryptedCredentials $credentials; + + + /** + * @param EncryptedPassportElement[] $data Array with information about documents and other Telegram Passport elements that was shared with the bot + * @param EncryptedCredentials $credentials Encrypted credentials required to decrypt the data + */ + public static function make(array $data, EncryptedCredentials $credentials): static + { + return new static([ + 'data' => $data, + 'credentials' => $credentials, + ]); + } } diff --git a/src/Telegram/PassportElementError.php b/src/Telegram/PassportElementError.php index 280e055..793ec29 100644 --- a/src/Telegram/PassportElementError.php +++ b/src/Telegram/PassportElementError.php @@ -19,4 +19,19 @@ class PassportElementError extends \Tii\Telepath\Type /** Error message */ public string $message; + + + /** + * @param string $source Error source + * @param string $type The section of the user's Telegram Passport which has the error, one of “personal_details”, “passport”, “driver_license”, “identity_card”, “internal_passport”, “address” + * @param string $message Error message + */ + public static function make(string $source, string $type, string $message): static + { + return new static([ + 'source' => $source, + 'type' => $type, + 'message' => $message, + ]); + } } diff --git a/src/Telegram/PassportElementErrorDataField.php b/src/Telegram/PassportElementErrorDataField.php index bac81fd..6bad623 100644 --- a/src/Telegram/PassportElementErrorDataField.php +++ b/src/Telegram/PassportElementErrorDataField.php @@ -16,4 +16,17 @@ class PassportElementErrorDataField extends PassportElementError /** Base64-encoded data hash */ public string $data_hash; + + + /** + * @param string $field_name Name of the data field which has the error + * @param string $data_hash Base64-encoded data hash + */ + public static function make(string $field_name, string $data_hash): static + { + return new static([ + 'field_name' => $field_name, + 'data_hash' => $data_hash, + ]); + } } diff --git a/src/Telegram/PassportElementErrorFile.php b/src/Telegram/PassportElementErrorFile.php index ac10a2f..159f07b 100644 --- a/src/Telegram/PassportElementErrorFile.php +++ b/src/Telegram/PassportElementErrorFile.php @@ -13,4 +13,15 @@ class PassportElementErrorFile extends PassportElementError { /** Base64-encoded file hash */ public string $file_hash; + + + /** + * @param string $file_hash Base64-encoded file hash + */ + public static function make(string $file_hash): static + { + return new static([ + 'file_hash' => $file_hash, + ]); + } } diff --git a/src/Telegram/PassportElementErrorFiles.php b/src/Telegram/PassportElementErrorFiles.php index c32ab78..45a5f65 100644 --- a/src/Telegram/PassportElementErrorFiles.php +++ b/src/Telegram/PassportElementErrorFiles.php @@ -16,4 +16,15 @@ class PassportElementErrorFiles extends PassportElementError * @var string[] */ public array $file_hashes; + + + /** + * @param string[] $file_hashes List of base64-encoded file hashes + */ + public static function make(array $file_hashes): static + { + return new static([ + 'file_hashes' => $file_hashes, + ]); + } } diff --git a/src/Telegram/PassportElementErrorFrontSide.php b/src/Telegram/PassportElementErrorFrontSide.php index c6d8a40..f6a7cf7 100644 --- a/src/Telegram/PassportElementErrorFrontSide.php +++ b/src/Telegram/PassportElementErrorFrontSide.php @@ -13,4 +13,15 @@ class PassportElementErrorFrontSide extends PassportElementError { /** Base64-encoded hash of the file with the front side of the document */ public string $file_hash; + + + /** + * @param string $file_hash Base64-encoded hash of the file with the front side of the document + */ + public static function make(string $file_hash): static + { + return new static([ + 'file_hash' => $file_hash, + ]); + } } diff --git a/src/Telegram/PassportElementErrorReverseSide.php b/src/Telegram/PassportElementErrorReverseSide.php index e59a067..961bf33 100644 --- a/src/Telegram/PassportElementErrorReverseSide.php +++ b/src/Telegram/PassportElementErrorReverseSide.php @@ -13,4 +13,15 @@ class PassportElementErrorReverseSide extends PassportElementError { /** Base64-encoded hash of the file with the reverse side of the document */ public string $file_hash; + + + /** + * @param string $file_hash Base64-encoded hash of the file with the reverse side of the document + */ + public static function make(string $file_hash): static + { + return new static([ + 'file_hash' => $file_hash, + ]); + } } diff --git a/src/Telegram/PassportElementErrorSelfie.php b/src/Telegram/PassportElementErrorSelfie.php index 7f48f1c..c3f53f9 100644 --- a/src/Telegram/PassportElementErrorSelfie.php +++ b/src/Telegram/PassportElementErrorSelfie.php @@ -13,4 +13,15 @@ class PassportElementErrorSelfie extends PassportElementError { /** Base64-encoded hash of the file with the selfie */ public string $file_hash; + + + /** + * @param string $file_hash Base64-encoded hash of the file with the selfie + */ + public static function make(string $file_hash): static + { + return new static([ + 'file_hash' => $file_hash, + ]); + } } diff --git a/src/Telegram/PassportElementErrorTranslationFile.php b/src/Telegram/PassportElementErrorTranslationFile.php index c2ff3de..d3c71be 100644 --- a/src/Telegram/PassportElementErrorTranslationFile.php +++ b/src/Telegram/PassportElementErrorTranslationFile.php @@ -13,4 +13,15 @@ class PassportElementErrorTranslationFile extends PassportElementError { /** Base64-encoded file hash */ public string $file_hash; + + + /** + * @param string $file_hash Base64-encoded file hash + */ + public static function make(string $file_hash): static + { + return new static([ + 'file_hash' => $file_hash, + ]); + } } diff --git a/src/Telegram/PassportElementErrorTranslationFiles.php b/src/Telegram/PassportElementErrorTranslationFiles.php index 3805180..28edcc1 100644 --- a/src/Telegram/PassportElementErrorTranslationFiles.php +++ b/src/Telegram/PassportElementErrorTranslationFiles.php @@ -16,4 +16,15 @@ class PassportElementErrorTranslationFiles extends PassportElementError * @var string[] */ public array $file_hashes; + + + /** + * @param string[] $file_hashes List of base64-encoded file hashes + */ + public static function make(array $file_hashes): static + { + return new static([ + 'file_hashes' => $file_hashes, + ]); + } } diff --git a/src/Telegram/PassportElementErrorUnspecified.php b/src/Telegram/PassportElementErrorUnspecified.php index 5dd5455..813097b 100644 --- a/src/Telegram/PassportElementErrorUnspecified.php +++ b/src/Telegram/PassportElementErrorUnspecified.php @@ -13,4 +13,15 @@ class PassportElementErrorUnspecified extends PassportElementError { /** Base64-encoded element hash */ public string $element_hash; + + + /** + * @param string $element_hash Base64-encoded element hash + */ + public static function make(string $element_hash): static + { + return new static([ + 'element_hash' => $element_hash, + ]); + } } diff --git a/src/Telegram/PassportFile.php b/src/Telegram/PassportFile.php index 137f2bb..24f9e9a 100644 --- a/src/Telegram/PassportFile.php +++ b/src/Telegram/PassportFile.php @@ -22,4 +22,21 @@ class PassportFile extends \Tii\Telepath\Type /** Unix time when the file was uploaded */ public int $file_date; + + + /** + * @param string $file_id Identifier for this file, which can be used to download or reuse the file + * @param string $file_unique_id Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. + * @param int $file_size File size in bytes + * @param int $file_date Unix time when the file was uploaded + */ + public static function make(string $file_id, string $file_unique_id, int $file_size, int $file_date): static + { + return new static([ + 'file_id' => $file_id, + 'file_unique_id' => $file_unique_id, + 'file_size' => $file_size, + 'file_date' => $file_date, + ]); + } } diff --git a/src/Telegram/PhotoSize.php b/src/Telegram/PhotoSize.php index 72f124d..9234244 100644 --- a/src/Telegram/PhotoSize.php +++ b/src/Telegram/PhotoSize.php @@ -24,5 +24,29 @@ class PhotoSize extends \Tii\Telepath\Type public int $height; /** Optional. File size in bytes */ - public ?int $file_size; + public ?int $file_size = null; + + + /** + * @param string $file_id Identifier for this file, which can be used to download or reuse the file + * @param string $file_unique_id Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. + * @param int $width Photo width + * @param int $height Photo height + * @param int $file_size Optional. File size in bytes + */ + public static function make( + string $file_id, + string $file_unique_id, + int $width, + int $height, + ?int $file_size = null + ): static { + return new static([ + 'file_id' => $file_id, + 'file_unique_id' => $file_unique_id, + 'width' => $width, + 'height' => $height, + 'file_size' => $file_size, + ]); + } } diff --git a/src/Telegram/Poll.php b/src/Telegram/Poll.php index f335c8d..d3fbf42 100644 --- a/src/Telegram/Poll.php +++ b/src/Telegram/Poll.php @@ -39,20 +39,68 @@ class Poll extends \Tii\Telepath\Type public bool $allows_multiple_answers; /** Optional. 0-based identifier of the correct answer option. Available only for polls in the quiz mode, which are closed, or was sent (not forwarded) by the bot or to the private chat with the bot. */ - public ?int $correct_option_id; + public ?int $correct_option_id = null; /** Optional. Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters */ - public ?string $explanation; + public ?string $explanation = null; /** * Optional. Special entities like usernames, URLs, bot commands, etc. that appear in the explanation * @var MessageEntity[] */ - public ?array $explanation_entities; + public ?array $explanation_entities = null; /** Optional. Amount of time in seconds the poll will be active after creation */ - public ?int $open_period; + public ?int $open_period = null; /** Optional. Point in time (Unix timestamp) when the poll will be automatically closed */ - public ?int $close_date; + public ?int $close_date = null; + + + /** + * @param string $id Unique poll identifier + * @param string $question Poll question, 1-300 characters + * @param PollOption[] $options List of poll options + * @param int $total_voter_count Total number of users that voted in the poll + * @param bool $is_closed True, if the poll is closed + * @param bool $is_anonymous True, if the poll is anonymous + * @param string $type Poll type, currently can be “regular” or “quiz” + * @param bool $allows_multiple_answers True, if the poll allows multiple answers + * @param int $correct_option_id Optional. 0-based identifier of the correct answer option. Available only for polls in the quiz mode, which are closed, or was sent (not forwarded) by the bot or to the private chat with the bot. + * @param string $explanation Optional. Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters + * @param MessageEntity[] $explanation_entities Optional. Special entities like usernames, URLs, bot commands, etc. that appear in the explanation + * @param int $open_period Optional. Amount of time in seconds the poll will be active after creation + * @param int $close_date Optional. Point in time (Unix timestamp) when the poll will be automatically closed + */ + public static function make( + string $id, + string $question, + array $options, + int $total_voter_count, + bool $is_closed, + bool $is_anonymous, + string $type, + bool $allows_multiple_answers, + ?int $correct_option_id = null, + ?string $explanation = null, + ?array $explanation_entities = null, + ?int $open_period = null, + ?int $close_date = null + ): static { + return new static([ + 'id' => $id, + 'question' => $question, + 'options' => $options, + 'total_voter_count' => $total_voter_count, + 'is_closed' => $is_closed, + 'is_anonymous' => $is_anonymous, + 'type' => $type, + 'allows_multiple_answers' => $allows_multiple_answers, + 'correct_option_id' => $correct_option_id, + 'explanation' => $explanation, + 'explanation_entities' => $explanation_entities, + 'open_period' => $open_period, + 'close_date' => $close_date, + ]); + } } diff --git a/src/Telegram/PollAnswer.php b/src/Telegram/PollAnswer.php index d909424..58407db 100644 --- a/src/Telegram/PollAnswer.php +++ b/src/Telegram/PollAnswer.php @@ -22,4 +22,19 @@ class PollAnswer extends \Tii\Telepath\Type * @var int[] */ public array $option_ids; + + + /** + * @param string $poll_id Unique poll identifier + * @param User $user The user, who changed the answer to the poll + * @param int[] $option_ids 0-based identifiers of answer options, chosen by the user. May be empty if the user retracted their vote. + */ + public static function make(string $poll_id, User $user, array $option_ids): static + { + return new static([ + 'poll_id' => $poll_id, + 'user' => $user, + 'option_ids' => $option_ids, + ]); + } } diff --git a/src/Telegram/PollOption.php b/src/Telegram/PollOption.php index 0918543..5252783 100644 --- a/src/Telegram/PollOption.php +++ b/src/Telegram/PollOption.php @@ -16,4 +16,17 @@ class PollOption extends \Tii\Telepath\Type /** Number of users that voted for this option */ public int $voter_count; + + + /** + * @param string $text Option text, 1-100 characters + * @param int $voter_count Number of users that voted for this option + */ + public static function make(string $text, int $voter_count): static + { + return new static([ + 'text' => $text, + 'voter_count' => $voter_count, + ]); + } } diff --git a/src/Telegram/PreCheckoutQuery.php b/src/Telegram/PreCheckoutQuery.php index 56efe11..0561d1a 100644 --- a/src/Telegram/PreCheckoutQuery.php +++ b/src/Telegram/PreCheckoutQuery.php @@ -27,8 +27,38 @@ class PreCheckoutQuery extends \Tii\Telepath\Type public string $invoice_payload; /** Optional. Identifier of the shipping option chosen by the user */ - public ?string $shipping_option_id; + public ?string $shipping_option_id = null; /** Optional. Order info provided by the user */ - public ?OrderInfo $order_info; + public ?OrderInfo $order_info = null; + + + /** + * @param string $id Unique query identifier + * @param User $from User who sent the query + * @param string $currency Three-letter ISO 4217 currency code + * @param int $total_amount Total price in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). + * @param string $invoice_payload Bot specified invoice payload + * @param string $shipping_option_id Optional. Identifier of the shipping option chosen by the user + * @param OrderInfo $order_info Optional. Order info provided by the user + */ + public static function make( + string $id, + User $from, + string $currency, + int $total_amount, + string $invoice_payload, + ?string $shipping_option_id = null, + ?OrderInfo $order_info = null + ): static { + return new static([ + 'id' => $id, + 'from' => $from, + 'currency' => $currency, + 'total_amount' => $total_amount, + 'invoice_payload' => $invoice_payload, + 'shipping_option_id' => $shipping_option_id, + 'order_info' => $order_info, + ]); + } } diff --git a/src/Telegram/ProximityAlertTriggered.php b/src/Telegram/ProximityAlertTriggered.php index 63abc50..4091db3 100644 --- a/src/Telegram/ProximityAlertTriggered.php +++ b/src/Telegram/ProximityAlertTriggered.php @@ -19,4 +19,19 @@ class ProximityAlertTriggered extends \Tii\Telepath\Type /** The distance between the users */ public int $distance; + + + /** + * @param User $traveler User that triggered the alert + * @param User $watcher User that set the alert + * @param int $distance The distance between the users + */ + public static function make(User $traveler, User $watcher, int $distance): static + { + return new static([ + 'traveler' => $traveler, + 'watcher' => $watcher, + 'distance' => $distance, + ]); + } } diff --git a/src/Telegram/ReplyKeyboardMarkup.php b/src/Telegram/ReplyKeyboardMarkup.php index beb60f3..de6683c 100644 --- a/src/Telegram/ReplyKeyboardMarkup.php +++ b/src/Telegram/ReplyKeyboardMarkup.php @@ -18,14 +18,38 @@ class ReplyKeyboardMarkup extends \Tii\Telepath\Type public array $keyboard; /** Optional. Requests clients to resize the keyboard vertically for optimal fit (e.g., make the keyboard smaller if there are just two rows of buttons). Defaults to false, in which case the custom keyboard is always of the same height as the app's standard keyboard. */ - public ?bool $resize_keyboard; + public ?bool $resize_keyboard = null; /** Optional. Requests clients to hide the keyboard as soon as it's been used. The keyboard will still be available, but clients will automatically display the usual letter-keyboard in the chat – the user can press a special button in the input field to see the custom keyboard again. Defaults to false. */ - public ?bool $one_time_keyboard; + public ?bool $one_time_keyboard = null; /** Optional. The placeholder to be shown in the input field when the keyboard is active; 1-64 characters */ - public ?string $input_field_placeholder; + public ?string $input_field_placeholder = null; /** Optional. Use this parameter if you want to show the keyboard to specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.Example: A user requests to change the bot's language, bot replies to the request with a keyboard to select the new language. Other users in the group don't see the keyboard. */ - public ?bool $selective; + public ?bool $selective = null; + + + /** + * @param KeyboardButton[][] $keyboard Array of button rows, each represented by an Array of KeyboardButton objects + * @param bool $resize_keyboard Optional. Requests clients to resize the keyboard vertically for optimal fit (e.g., make the keyboard smaller if there are just two rows of buttons). Defaults to false, in which case the custom keyboard is always of the same height as the app's standard keyboard. + * @param bool $one_time_keyboard Optional. Requests clients to hide the keyboard as soon as it's been used. The keyboard will still be available, but clients will automatically display the usual letter-keyboard in the chat – the user can press a special button in the input field to see the custom keyboard again. Defaults to false. + * @param string $input_field_placeholder Optional. The placeholder to be shown in the input field when the keyboard is active; 1-64 characters + * @param bool $selective Optional. Use this parameter if you want to show the keyboard to specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.Example: A user requests to change the bot's language, bot replies to the request with a keyboard to select the new language. Other users in the group don't see the keyboard. + */ + public static function make( + array $keyboard, + ?bool $resize_keyboard = null, + ?bool $one_time_keyboard = null, + ?string $input_field_placeholder = null, + ?bool $selective = null + ): static { + return new static([ + 'keyboard' => $keyboard, + 'resize_keyboard' => $resize_keyboard, + 'one_time_keyboard' => $one_time_keyboard, + 'input_field_placeholder' => $input_field_placeholder, + 'selective' => $selective, + ]); + } } diff --git a/src/Telegram/ReplyKeyboardRemove.php b/src/Telegram/ReplyKeyboardRemove.php index 7a3edfe..d54dab5 100644 --- a/src/Telegram/ReplyKeyboardRemove.php +++ b/src/Telegram/ReplyKeyboardRemove.php @@ -15,5 +15,18 @@ class ReplyKeyboardRemove extends \Tii\Telepath\Type public bool $remove_keyboard; /** Optional. Use this parameter if you want to remove the keyboard for specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.Example: A user votes in a poll, bot returns confirmation message in reply to the vote and removes the keyboard for that user, while still showing the keyboard with poll options to users who haven't voted yet. */ - public ?bool $selective; + public ?bool $selective = null; + + + /** + * @param bool $remove_keyboard Requests clients to remove the custom keyboard (user will not be able to summon this keyboard; if you want to hide the keyboard from sight but keep it accessible, use one_time_keyboard in ReplyKeyboardMarkup) + * @param bool $selective Optional. Use this parameter if you want to remove the keyboard for specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.Example: A user votes in a poll, bot returns confirmation message in reply to the vote and removes the keyboard for that user, while still showing the keyboard with poll options to users who haven't voted yet. + */ + public static function make(bool $remove_keyboard, ?bool $selective = null): static + { + return new static([ + 'remove_keyboard' => $remove_keyboard, + 'selective' => $selective, + ]); + } } diff --git a/src/Telegram/ResponseParameters.php b/src/Telegram/ResponseParameters.php index d824afb..c88ffa5 100644 --- a/src/Telegram/ResponseParameters.php +++ b/src/Telegram/ResponseParameters.php @@ -12,8 +12,21 @@ class ResponseParameters extends \Tii\Telepath\Type { /** Optional. The group has been migrated to a supergroup with the specified identifier. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier. */ - public ?int $migrate_to_chat_id; + public ?int $migrate_to_chat_id = null; /** Optional. In case of exceeding flood control, the number of seconds left to wait before the request can be repeated */ - public ?int $retry_after; + public ?int $retry_after = null; + + + /** + * @param int $migrate_to_chat_id Optional. The group has been migrated to a supergroup with the specified identifier. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier. + * @param int $retry_after Optional. In case of exceeding flood control, the number of seconds left to wait before the request can be repeated + */ + public static function make(?int $migrate_to_chat_id = null, ?int $retry_after = null): static + { + return new static([ + 'migrate_to_chat_id' => $migrate_to_chat_id, + 'retry_after' => $retry_after, + ]); + } } diff --git a/src/Telegram/SentWebAppMessage.php b/src/Telegram/SentWebAppMessage.php index f4d6a75..2ed1e66 100644 --- a/src/Telegram/SentWebAppMessage.php +++ b/src/Telegram/SentWebAppMessage.php @@ -12,5 +12,16 @@ class SentWebAppMessage extends \Tii\Telepath\Type { /** Optional. Identifier of the sent inline message. Available only if there is an inline keyboard attached to the message. */ - public ?string $inline_message_id; + public ?string $inline_message_id = null; + + + /** + * @param string $inline_message_id Optional. Identifier of the sent inline message. Available only if there is an inline keyboard attached to the message. + */ + public static function make(?string $inline_message_id = null): static + { + return new static([ + 'inline_message_id' => $inline_message_id, + ]); + } } diff --git a/src/Telegram/ShippingAddress.php b/src/Telegram/ShippingAddress.php index 0a083c9..a85b297 100644 --- a/src/Telegram/ShippingAddress.php +++ b/src/Telegram/ShippingAddress.php @@ -28,4 +28,31 @@ class ShippingAddress extends \Tii\Telepath\Type /** Address post code */ public string $post_code; + + + /** + * @param string $country_code ISO 3166-1 alpha-2 country code + * @param string $state State, if applicable + * @param string $city City + * @param string $street_line1 First line for the address + * @param string $street_line2 Second line for the address + * @param string $post_code Address post code + */ + public static function make( + string $country_code, + string $state, + string $city, + string $street_line1, + string $street_line2, + string $post_code + ): static { + return new static([ + 'country_code' => $country_code, + 'state' => $state, + 'city' => $city, + 'street_line1' => $street_line1, + 'street_line2' => $street_line2, + 'post_code' => $post_code, + ]); + } } diff --git a/src/Telegram/ShippingOption.php b/src/Telegram/ShippingOption.php index 92d0715..e446ad7 100644 --- a/src/Telegram/ShippingOption.php +++ b/src/Telegram/ShippingOption.php @@ -22,4 +22,19 @@ class ShippingOption extends \Tii\Telepath\Type * @var LabeledPrice[] */ public array $prices; + + + /** + * @param string $id Shipping option identifier + * @param string $title Option title + * @param LabeledPrice[] $prices List of price portions + */ + public static function make(string $id, string $title, array $prices): static + { + return new static([ + 'id' => $id, + 'title' => $title, + 'prices' => $prices, + ]); + } } diff --git a/src/Telegram/ShippingQuery.php b/src/Telegram/ShippingQuery.php index acc477d..430af23 100644 --- a/src/Telegram/ShippingQuery.php +++ b/src/Telegram/ShippingQuery.php @@ -22,4 +22,21 @@ class ShippingQuery extends \Tii\Telepath\Type /** User specified shipping address */ public ShippingAddress $shipping_address; + + + /** + * @param string $id Unique query identifier + * @param User $from User who sent the query + * @param string $invoice_payload Bot specified invoice payload + * @param ShippingAddress $shipping_address User specified shipping address + */ + public static function make(string $id, User $from, string $invoice_payload, ShippingAddress $shipping_address): static + { + return new static([ + 'id' => $id, + 'from' => $from, + 'invoice_payload' => $invoice_payload, + 'shipping_address' => $shipping_address, + ]); + } } diff --git a/src/Telegram/Sticker.php b/src/Telegram/Sticker.php index cdb76ba..89e7c70 100644 --- a/src/Telegram/Sticker.php +++ b/src/Telegram/Sticker.php @@ -30,17 +30,59 @@ class Sticker extends \Tii\Telepath\Type public bool $is_video; /** Optional. Sticker thumbnail in the .WEBP or .JPG format */ - public ?PhotoSize $thumb; + public ?PhotoSize $thumb = null; /** Optional. Emoji associated with the sticker */ - public ?string $emoji; + public ?string $emoji = null; /** Optional. Name of the sticker set to which the sticker belongs */ - public ?string $set_name; + public ?string $set_name = null; /** Optional. For mask stickers, the position where the mask should be placed */ - public ?MaskPosition $mask_position; + public ?MaskPosition $mask_position = null; /** Optional. File size in bytes */ - public ?int $file_size; + public ?int $file_size = null; + + + /** + * @param string $file_id Identifier for this file, which can be used to download or reuse the file + * @param string $file_unique_id Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. + * @param int $width Sticker width + * @param int $height Sticker height + * @param bool $is_animated True, if the sticker is animated + * @param bool $is_video True, if the sticker is a video sticker + * @param PhotoSize $thumb Optional. Sticker thumbnail in the .WEBP or .JPG format + * @param string $emoji Optional. Emoji associated with the sticker + * @param string $set_name Optional. Name of the sticker set to which the sticker belongs + * @param MaskPosition $mask_position Optional. For mask stickers, the position where the mask should be placed + * @param int $file_size Optional. File size in bytes + */ + public static function make( + string $file_id, + string $file_unique_id, + int $width, + int $height, + bool $is_animated, + bool $is_video, + ?PhotoSize $thumb = null, + ?string $emoji = null, + ?string $set_name = null, + ?MaskPosition $mask_position = null, + ?int $file_size = null + ): static { + return new static([ + 'file_id' => $file_id, + 'file_unique_id' => $file_unique_id, + 'width' => $width, + 'height' => $height, + 'is_animated' => $is_animated, + 'is_video' => $is_video, + 'thumb' => $thumb, + 'emoji' => $emoji, + 'set_name' => $set_name, + 'mask_position' => $mask_position, + 'file_size' => $file_size, + ]); + } } diff --git a/src/Telegram/StickerSet.php b/src/Telegram/StickerSet.php index c11fb5e..98e0b6f 100644 --- a/src/Telegram/StickerSet.php +++ b/src/Telegram/StickerSet.php @@ -33,5 +33,35 @@ class StickerSet extends \Tii\Telepath\Type public array $stickers; /** Optional. Sticker set thumbnail in the .WEBP, .TGS, or .WEBM format */ - public ?PhotoSize $thumb; + public ?PhotoSize $thumb = null; + + + /** + * @param string $name Sticker set name + * @param string $title Sticker set title + * @param bool $is_animated True, if the sticker set contains animated stickers + * @param bool $is_video True, if the sticker set contains video stickers + * @param bool $contains_masks True, if the sticker set contains masks + * @param Sticker[] $stickers List of all set stickers + * @param PhotoSize $thumb Optional. Sticker set thumbnail in the .WEBP, .TGS, or .WEBM format + */ + public static function make( + string $name, + string $title, + bool $is_animated, + bool $is_video, + bool $contains_masks, + array $stickers, + ?PhotoSize $thumb = null + ): static { + return new static([ + 'name' => $name, + 'title' => $title, + 'is_animated' => $is_animated, + 'is_video' => $is_video, + 'contains_masks' => $contains_masks, + 'stickers' => $stickers, + 'thumb' => $thumb, + ]); + } } diff --git a/src/Telegram/SuccessfulPayment.php b/src/Telegram/SuccessfulPayment.php index ab59068..54ec70b 100644 --- a/src/Telegram/SuccessfulPayment.php +++ b/src/Telegram/SuccessfulPayment.php @@ -21,14 +21,44 @@ class SuccessfulPayment extends \Tii\Telepath\Type public string $invoice_payload; /** Optional. Identifier of the shipping option chosen by the user */ - public ?string $shipping_option_id; + public ?string $shipping_option_id = null; /** Optional. Order info provided by the user */ - public ?OrderInfo $order_info; + public ?OrderInfo $order_info = null; /** Telegram payment identifier */ public string $telegram_payment_charge_id; /** Provider payment identifier */ public string $provider_payment_charge_id; + + + /** + * @param string $currency Three-letter ISO 4217 currency code + * @param int $total_amount Total price in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). + * @param string $invoice_payload Bot specified invoice payload + * @param string $shipping_option_id Optional. Identifier of the shipping option chosen by the user + * @param OrderInfo $order_info Optional. Order info provided by the user + * @param string $telegram_payment_charge_id Telegram payment identifier + * @param string $provider_payment_charge_id Provider payment identifier + */ + public static function make( + string $currency, + int $total_amount, + string $invoice_payload, + ?string $shipping_option_id = null, + ?OrderInfo $order_info = null, + string $telegram_payment_charge_id, + string $provider_payment_charge_id + ): static { + return new static([ + 'currency' => $currency, + 'total_amount' => $total_amount, + 'invoice_payload' => $invoice_payload, + 'shipping_option_id' => $shipping_option_id, + 'order_info' => $order_info, + 'telegram_payment_charge_id' => $telegram_payment_charge_id, + 'provider_payment_charge_id' => $provider_payment_charge_id, + ]); + } } diff --git a/src/Telegram/Update.php b/src/Telegram/Update.php index d75d08b..d4b2ca8 100644 --- a/src/Telegram/Update.php +++ b/src/Telegram/Update.php @@ -15,44 +15,98 @@ class Update extends \Tii\Telepath\Type public int $update_id; /** Optional. New incoming message of any kind — text, photo, sticker, etc. */ - public ?Message $message; + public ?Message $message = null; /** Optional. New version of a message that is known to the bot and was edited */ - public ?Message $edited_message; + public ?Message $edited_message = null; /** Optional. New incoming channel post of any kind — text, photo, sticker, etc. */ - public ?Message $channel_post; + public ?Message $channel_post = null; /** Optional. New version of a channel post that is known to the bot and was edited */ - public ?Message $edited_channel_post; + public ?Message $edited_channel_post = null; /** Optional. New incoming inline query */ - public ?InlineQuery $inline_query; + public ?InlineQuery $inline_query = null; /** Optional. The result of an inline query that was chosen by a user and sent to their chat partner. Please see our documentation on the feedback collecting for details on how to enable these updates for your bot. */ - public ?ChosenInlineResult $chosen_inline_result; + public ?ChosenInlineResult $chosen_inline_result = null; /** Optional. New incoming callback query */ - public ?CallbackQuery $callback_query; + public ?CallbackQuery $callback_query = null; /** Optional. New incoming shipping query. Only for invoices with flexible price */ - public ?ShippingQuery $shipping_query; + public ?ShippingQuery $shipping_query = null; /** Optional. New incoming pre-checkout query. Contains full information about checkout */ - public ?PreCheckoutQuery $pre_checkout_query; + public ?PreCheckoutQuery $pre_checkout_query = null; /** Optional. New poll state. Bots receive only updates about stopped polls and polls, which are sent by the bot */ - public ?Poll $poll; + public ?Poll $poll = null; /** Optional. A user changed their answer in a non-anonymous poll. Bots receive new votes only in polls that were sent by the bot itself. */ - public ?PollAnswer $poll_answer; + public ?PollAnswer $poll_answer = null; /** Optional. The bot's chat member status was updated in a chat. For private chats, this update is received only when the bot is blocked or unblocked by the user. */ - public ?ChatMemberUpdated $my_chat_member; + public ?ChatMemberUpdated $my_chat_member = null; /** Optional. A chat member's status was updated in a chat. The bot must be an administrator in the chat and must explicitly specify “chat_member” in the list of allowed_updates to receive these updates. */ - public ?ChatMemberUpdated $chat_member; + public ?ChatMemberUpdated $chat_member = null; /** Optional. A request to join the chat has been sent. The bot must have the can_invite_users administrator right in the chat to receive these updates. */ - public ?ChatJoinRequest $chat_join_request; + public ?ChatJoinRequest $chat_join_request = null; + + + /** + * @param int $update_id The update's unique identifier. Update identifiers start from a certain positive number and increase sequentially. This ID becomes especially handy if you're using Webhooks, since it allows you to ignore repeated updates or to restore the correct update sequence, should they get out of order. If there are no new updates for at least a week, then identifier of the next update will be chosen randomly instead of sequentially. + * @param Message $message Optional. New incoming message of any kind — text, photo, sticker, etc. + * @param Message $edited_message Optional. New version of a message that is known to the bot and was edited + * @param Message $channel_post Optional. New incoming channel post of any kind — text, photo, sticker, etc. + * @param Message $edited_channel_post Optional. New version of a channel post that is known to the bot and was edited + * @param InlineQuery $inline_query Optional. New incoming inline query + * @param ChosenInlineResult $chosen_inline_result Optional. The result of an inline query that was chosen by a user and sent to their chat partner. Please see our documentation on the feedback collecting for details on how to enable these updates for your bot. + * @param CallbackQuery $callback_query Optional. New incoming callback query + * @param ShippingQuery $shipping_query Optional. New incoming shipping query. Only for invoices with flexible price + * @param PreCheckoutQuery $pre_checkout_query Optional. New incoming pre-checkout query. Contains full information about checkout + * @param Poll $poll Optional. New poll state. Bots receive only updates about stopped polls and polls, which are sent by the bot + * @param PollAnswer $poll_answer Optional. A user changed their answer in a non-anonymous poll. Bots receive new votes only in polls that were sent by the bot itself. + * @param ChatMemberUpdated $my_chat_member Optional. The bot's chat member status was updated in a chat. For private chats, this update is received only when the bot is blocked or unblocked by the user. + * @param ChatMemberUpdated $chat_member Optional. A chat member's status was updated in a chat. The bot must be an administrator in the chat and must explicitly specify “chat_member” in the list of allowed_updates to receive these updates. + * @param ChatJoinRequest $chat_join_request Optional. A request to join the chat has been sent. The bot must have the can_invite_users administrator right in the chat to receive these updates. + */ + public static function make( + int $update_id, + ?Message $message = null, + ?Message $edited_message = null, + ?Message $channel_post = null, + ?Message $edited_channel_post = null, + ?InlineQuery $inline_query = null, + ?ChosenInlineResult $chosen_inline_result = null, + ?CallbackQuery $callback_query = null, + ?ShippingQuery $shipping_query = null, + ?PreCheckoutQuery $pre_checkout_query = null, + ?Poll $poll = null, + ?PollAnswer $poll_answer = null, + ?ChatMemberUpdated $my_chat_member = null, + ?ChatMemberUpdated $chat_member = null, + ?ChatJoinRequest $chat_join_request = null + ): static { + return new static([ + 'update_id' => $update_id, + 'message' => $message, + 'edited_message' => $edited_message, + 'channel_post' => $channel_post, + 'edited_channel_post' => $edited_channel_post, + 'inline_query' => $inline_query, + 'chosen_inline_result' => $chosen_inline_result, + 'callback_query' => $callback_query, + 'shipping_query' => $shipping_query, + 'pre_checkout_query' => $pre_checkout_query, + 'poll' => $poll, + 'poll_answer' => $poll_answer, + 'my_chat_member' => $my_chat_member, + 'chat_member' => $chat_member, + 'chat_join_request' => $chat_join_request, + ]); + } } diff --git a/src/Telegram/User.php b/src/Telegram/User.php index 7120551..fd13995 100644 --- a/src/Telegram/User.php +++ b/src/Telegram/User.php @@ -21,20 +21,56 @@ class User extends \Tii\Telepath\Type public string $first_name; /** Optional. User's or bot's last name */ - public ?string $last_name; + public ?string $last_name = null; /** Optional. User's or bot's username */ - public ?string $username; + public ?string $username = null; /** Optional. IETF language tag of the user's language */ - public ?string $language_code; + public ?string $language_code = null; /** Optional. True, if the bot can be invited to groups. Returned only in getMe. */ - public ?bool $can_join_groups; + public ?bool $can_join_groups = null; /** Optional. True, if privacy mode is disabled for the bot. Returned only in getMe. */ - public ?bool $can_read_all_group_messages; + public ?bool $can_read_all_group_messages = null; /** Optional. True, if the bot supports inline queries. Returned only in getMe. */ - public ?bool $supports_inline_queries; + public ?bool $supports_inline_queries = null; + + + /** + * @param int $id Unique identifier for this user or bot. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier. + * @param bool $is_bot True, if this user is a bot + * @param string $first_name User's or bot's first name + * @param string $last_name Optional. User's or bot's last name + * @param string $username Optional. User's or bot's username + * @param string $language_code Optional. IETF language tag of the user's language + * @param bool $can_join_groups Optional. True, if the bot can be invited to groups. Returned only in getMe. + * @param bool $can_read_all_group_messages Optional. True, if privacy mode is disabled for the bot. Returned only in getMe. + * @param bool $supports_inline_queries Optional. True, if the bot supports inline queries. Returned only in getMe. + */ + public static function make( + int $id, + bool $is_bot, + string $first_name, + ?string $last_name = null, + ?string $username = null, + ?string $language_code = null, + ?bool $can_join_groups = null, + ?bool $can_read_all_group_messages = null, + ?bool $supports_inline_queries = null + ): static { + return new static([ + 'id' => $id, + 'is_bot' => $is_bot, + 'first_name' => $first_name, + 'last_name' => $last_name, + 'username' => $username, + 'language_code' => $language_code, + 'can_join_groups' => $can_join_groups, + 'can_read_all_group_messages' => $can_read_all_group_messages, + 'supports_inline_queries' => $supports_inline_queries, + ]); + } } diff --git a/src/Telegram/UserProfilePhotos.php b/src/Telegram/UserProfilePhotos.php index 66535b1..b3d0a3c 100644 --- a/src/Telegram/UserProfilePhotos.php +++ b/src/Telegram/UserProfilePhotos.php @@ -19,4 +19,17 @@ class UserProfilePhotos extends \Tii\Telepath\Type * @var PhotoSize[][] */ public array $photos; + + + /** + * @param int $total_count Total number of profile pictures the target user has + * @param PhotoSize[][] $photos Requested profile pictures (in up to 4 sizes each) + */ + public static function make(int $total_count, array $photos): static + { + return new static([ + 'total_count' => $total_count, + 'photos' => $photos, + ]); + } } diff --git a/src/Telegram/Venue.php b/src/Telegram/Venue.php index 352da9a..44a32a1 100644 --- a/src/Telegram/Venue.php +++ b/src/Telegram/Venue.php @@ -21,14 +21,44 @@ class Venue extends \Tii\Telepath\Type public string $address; /** Optional. Foursquare identifier of the venue */ - public ?string $foursquare_id; + public ?string $foursquare_id = null; /** Optional. Foursquare type of the venue. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.) */ - public ?string $foursquare_type; + public ?string $foursquare_type = null; /** Optional. Google Places identifier of the venue */ - public ?string $google_place_id; + public ?string $google_place_id = null; /** Optional. Google Places type of the venue. (See supported types.) */ - public ?string $google_place_type; + public ?string $google_place_type = null; + + + /** + * @param Location $location Venue location. Can't be a live location + * @param string $title Name of the venue + * @param string $address Address of the venue + * @param string $foursquare_id Optional. Foursquare identifier of the venue + * @param string $foursquare_type Optional. Foursquare type of the venue. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.) + * @param string $google_place_id Optional. Google Places identifier of the venue + * @param string $google_place_type Optional. Google Places type of the venue. (See supported types.) + */ + public static function make( + Location $location, + string $title, + string $address, + ?string $foursquare_id = null, + ?string $foursquare_type = null, + ?string $google_place_id = null, + ?string $google_place_type = null + ): static { + return new static([ + 'location' => $location, + 'title' => $title, + 'address' => $address, + 'foursquare_id' => $foursquare_id, + 'foursquare_type' => $foursquare_type, + 'google_place_id' => $google_place_id, + 'google_place_type' => $google_place_type, + ]); + } } diff --git a/src/Telegram/Video.php b/src/Telegram/Video.php index e6f4bc3..e50f801 100644 --- a/src/Telegram/Video.php +++ b/src/Telegram/Video.php @@ -27,14 +27,50 @@ class Video extends \Tii\Telepath\Type public int $duration; /** Optional. Video thumbnail */ - public ?PhotoSize $thumb; + public ?PhotoSize $thumb = null; /** Optional. Original filename as defined by sender */ - public ?string $file_name; + public ?string $file_name = null; /** Optional. Mime type of a file as defined by sender */ - public ?string $mime_type; + public ?string $mime_type = null; /** Optional. File size in bytes */ - public ?int $file_size; + public ?int $file_size = null; + + + /** + * @param string $file_id Identifier for this file, which can be used to download or reuse the file + * @param string $file_unique_id Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. + * @param int $width Video width as defined by sender + * @param int $height Video height as defined by sender + * @param int $duration Duration of the video in seconds as defined by sender + * @param PhotoSize $thumb Optional. Video thumbnail + * @param string $file_name Optional. Original filename as defined by sender + * @param string $mime_type Optional. Mime type of a file as defined by sender + * @param int $file_size Optional. File size in bytes + */ + public static function make( + string $file_id, + string $file_unique_id, + int $width, + int $height, + int $duration, + ?PhotoSize $thumb = null, + ?string $file_name = null, + ?string $mime_type = null, + ?int $file_size = null + ): static { + return new static([ + 'file_id' => $file_id, + 'file_unique_id' => $file_unique_id, + 'width' => $width, + 'height' => $height, + 'duration' => $duration, + 'thumb' => $thumb, + 'file_name' => $file_name, + 'mime_type' => $mime_type, + 'file_size' => $file_size, + ]); + } } diff --git a/src/Telegram/VideoChatEnded.php b/src/Telegram/VideoChatEnded.php index 65b909e..7949475 100644 --- a/src/Telegram/VideoChatEnded.php +++ b/src/Telegram/VideoChatEnded.php @@ -13,4 +13,15 @@ class VideoChatEnded extends \Tii\Telepath\Type { /** Video chat duration in seconds */ public int $duration; + + + /** + * @param int $duration Video chat duration in seconds + */ + public static function make(int $duration): static + { + return new static([ + 'duration' => $duration, + ]); + } } diff --git a/src/Telegram/VideoChatParticipantsInvited.php b/src/Telegram/VideoChatParticipantsInvited.php index 99720a4..dac6513 100644 --- a/src/Telegram/VideoChatParticipantsInvited.php +++ b/src/Telegram/VideoChatParticipantsInvited.php @@ -16,4 +16,15 @@ class VideoChatParticipantsInvited extends \Tii\Telepath\Type * @var User[] */ public array $users; + + + /** + * @param User[] $users New members that were invited to the video chat + */ + public static function make(array $users): static + { + return new static([ + 'users' => $users, + ]); + } } diff --git a/src/Telegram/VideoChatScheduled.php b/src/Telegram/VideoChatScheduled.php index 3335004..2c36eb6 100644 --- a/src/Telegram/VideoChatScheduled.php +++ b/src/Telegram/VideoChatScheduled.php @@ -13,4 +13,15 @@ class VideoChatScheduled extends \Tii\Telepath\Type { /** Point in time (Unix timestamp) when the video chat is supposed to be started by a chat administrator */ public int $start_date; + + + /** + * @param int $start_date Point in time (Unix timestamp) when the video chat is supposed to be started by a chat administrator + */ + public static function make(int $start_date): static + { + return new static([ + 'start_date' => $start_date, + ]); + } } diff --git a/src/Telegram/VideoChatStarted.php b/src/Telegram/VideoChatStarted.php index 36fcdca..c61e421 100644 --- a/src/Telegram/VideoChatStarted.php +++ b/src/Telegram/VideoChatStarted.php @@ -11,4 +11,9 @@ */ class VideoChatStarted extends \Tii\Telepath\Type { + public static function make(): static + { + return new static([ + ]); + } } diff --git a/src/Telegram/VideoNote.php b/src/Telegram/VideoNote.php index b2e3805..f14c1c1 100644 --- a/src/Telegram/VideoNote.php +++ b/src/Telegram/VideoNote.php @@ -24,8 +24,35 @@ class VideoNote extends \Tii\Telepath\Type public int $duration; /** Optional. Video thumbnail */ - public ?PhotoSize $thumb; + public ?PhotoSize $thumb = null; /** Optional. File size in bytes */ - public ?int $file_size; + public ?int $file_size = null; + + + /** + * @param string $file_id Identifier for this file, which can be used to download or reuse the file + * @param string $file_unique_id Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. + * @param int $length Video width and height (diameter of the video message) as defined by sender + * @param int $duration Duration of the video in seconds as defined by sender + * @param PhotoSize $thumb Optional. Video thumbnail + * @param int $file_size Optional. File size in bytes + */ + public static function make( + string $file_id, + string $file_unique_id, + int $length, + int $duration, + ?PhotoSize $thumb = null, + ?int $file_size = null + ): static { + return new static([ + 'file_id' => $file_id, + 'file_unique_id' => $file_unique_id, + 'length' => $length, + 'duration' => $duration, + 'thumb' => $thumb, + 'file_size' => $file_size, + ]); + } } diff --git a/src/Telegram/Voice.php b/src/Telegram/Voice.php index 3898627..8756fd9 100644 --- a/src/Telegram/Voice.php +++ b/src/Telegram/Voice.php @@ -21,8 +21,32 @@ class Voice extends \Tii\Telepath\Type public int $duration; /** Optional. MIME type of the file as defined by sender */ - public ?string $mime_type; + public ?string $mime_type = null; /** Optional. File size in bytes */ - public ?int $file_size; + public ?int $file_size = null; + + + /** + * @param string $file_id Identifier for this file, which can be used to download or reuse the file + * @param string $file_unique_id Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. + * @param int $duration Duration of the audio in seconds as defined by sender + * @param string $mime_type Optional. MIME type of the file as defined by sender + * @param int $file_size Optional. File size in bytes + */ + public static function make( + string $file_id, + string $file_unique_id, + int $duration, + ?string $mime_type = null, + ?int $file_size = null + ): static { + return new static([ + 'file_id' => $file_id, + 'file_unique_id' => $file_unique_id, + 'duration' => $duration, + 'mime_type' => $mime_type, + 'file_size' => $file_size, + ]); + } } diff --git a/src/Telegram/WebAppData.php b/src/Telegram/WebAppData.php index 6b3f6a0..8c5b49e 100644 --- a/src/Telegram/WebAppData.php +++ b/src/Telegram/WebAppData.php @@ -16,4 +16,17 @@ class WebAppData extends \Tii\Telepath\Type /** Text of the web_app keyboard button, from which the Web App was opened. Be aware that a bad client can send arbitrary data in this field. */ public string $button_text; + + + /** + * @param string $data The data. Be aware that a bad client can send arbitrary data in this field. + * @param string $button_text Text of the web_app keyboard button, from which the Web App was opened. Be aware that a bad client can send arbitrary data in this field. + */ + public static function make(string $data, string $button_text): static + { + return new static([ + 'data' => $data, + 'button_text' => $button_text, + ]); + } } diff --git a/src/Telegram/WebAppInfo.php b/src/Telegram/WebAppInfo.php index b8bd897..5f2bda8 100644 --- a/src/Telegram/WebAppInfo.php +++ b/src/Telegram/WebAppInfo.php @@ -13,4 +13,15 @@ class WebAppInfo extends \Tii\Telepath\Type { /** An HTTPS URL of a Web App to be opened with additional data as specified in Initializing Web Apps */ public string $url; + + + /** + * @param string $url An HTTPS URL of a Web App to be opened with additional data as specified in Initializing Web Apps + */ + public static function make(string $url): static + { + return new static([ + 'url' => $url, + ]); + } } diff --git a/src/Telegram/WebhookInfo.php b/src/Telegram/WebhookInfo.php index d08e561..da00809 100644 --- a/src/Telegram/WebhookInfo.php +++ b/src/Telegram/WebhookInfo.php @@ -21,23 +21,59 @@ class WebhookInfo extends \Tii\Telepath\Type public int $pending_update_count; /** Optional. Currently used webhook IP address */ - public ?string $ip_address; + public ?string $ip_address = null; /** Optional. Unix time for the most recent error that happened when trying to deliver an update via webhook */ - public ?int $last_error_date; + public ?int $last_error_date = null; /** Optional. Error message in human-readable format for the most recent error that happened when trying to deliver an update via webhook */ - public ?string $last_error_message; + public ?string $last_error_message = null; /** Optional. Unix time of the most recent error that happened when trying to synchronize available updates with Telegram datacenters */ - public ?int $last_synchronization_error_date; + public ?int $last_synchronization_error_date = null; /** Optional. Maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery */ - public ?int $max_connections; + public ?int $max_connections = null; /** * Optional. A list of update types the bot is subscribed to. Defaults to all update types except chat_member * @var string[] */ - public ?array $allowed_updates; + public ?array $allowed_updates = null; + + + /** + * @param string $url Webhook URL, may be empty if webhook is not set up + * @param bool $has_custom_certificate True, if a custom certificate was provided for webhook certificate checks + * @param int $pending_update_count Number of updates awaiting delivery + * @param string $ip_address Optional. Currently used webhook IP address + * @param int $last_error_date Optional. Unix time for the most recent error that happened when trying to deliver an update via webhook + * @param string $last_error_message Optional. Error message in human-readable format for the most recent error that happened when trying to deliver an update via webhook + * @param int $last_synchronization_error_date Optional. Unix time of the most recent error that happened when trying to synchronize available updates with Telegram datacenters + * @param int $max_connections Optional. Maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery + * @param string[] $allowed_updates Optional. A list of update types the bot is subscribed to. Defaults to all update types except chat_member + */ + public static function make( + string $url, + bool $has_custom_certificate, + int $pending_update_count, + ?string $ip_address = null, + ?int $last_error_date = null, + ?string $last_error_message = null, + ?int $last_synchronization_error_date = null, + ?int $max_connections = null, + ?array $allowed_updates = null + ): static { + return new static([ + 'url' => $url, + 'has_custom_certificate' => $has_custom_certificate, + 'pending_update_count' => $pending_update_count, + 'ip_address' => $ip_address, + 'last_error_date' => $last_error_date, + 'last_error_message' => $last_error_message, + 'last_synchronization_error_date' => $last_synchronization_error_date, + 'max_connections' => $max_connections, + 'allowed_updates' => $allowed_updates, + ]); + } } diff --git a/telepathy b/telepathy index 464a7b1..fc4e87f 100755 Binary files a/telepathy and b/telepathy differ