From 3f9b21616517b4c01464e2d72e9c8a6e780e4a4b Mon Sep 17 00:00:00 2001
From: TiiFuchs <1958744+TiiFuchs@users.noreply.github.com>
Date: Tue, 18 Jun 2024 10:52:00 +0000
Subject: [PATCH] Update code to reflect latest changes to the Bot API
documentation
---
src/Layers/Generated.php | 43 ++++++++++++---
src/Telegram/InlineKeyboardButton.php | 4 +-
src/Telegram/RevenueWithdrawalState.php | 29 ++++++++++
src/Telegram/RevenueWithdrawalStateFailed.php | 22 ++++++++
.../RevenueWithdrawalStatePending.php | 22 ++++++++
.../RevenueWithdrawalStateSucceeded.php | 34 ++++++++++++
src/Telegram/StarTransaction.php | 53 +++++++++++++++++++
src/Telegram/StarTransactions.php | 32 +++++++++++
src/Telegram/TransactionPartner.php | 29 ++++++++++
src/Telegram/TransactionPartnerFragment.php | 29 ++++++++++
src/Telegram/TransactionPartnerOther.php | 22 ++++++++
src/Telegram/TransactionPartnerUser.php | 29 ++++++++++
12 files changed, 340 insertions(+), 8 deletions(-)
create mode 100644 src/Telegram/RevenueWithdrawalState.php
create mode 100644 src/Telegram/RevenueWithdrawalStateFailed.php
create mode 100644 src/Telegram/RevenueWithdrawalStatePending.php
create mode 100644 src/Telegram/RevenueWithdrawalStateSucceeded.php
create mode 100644 src/Telegram/StarTransaction.php
create mode 100644 src/Telegram/StarTransactions.php
create mode 100644 src/Telegram/TransactionPartner.php
create mode 100644 src/Telegram/TransactionPartnerFragment.php
create mode 100644 src/Telegram/TransactionPartnerOther.php
create mode 100644 src/Telegram/TransactionPartnerUser.php
diff --git a/src/Layers/Generated.php b/src/Layers/Generated.php
index 68f09b6..ba18221 100644
--- a/src/Layers/Generated.php
+++ b/src/Layers/Generated.php
@@ -49,6 +49,7 @@
use Telepath\Telegram\ReplyParameters;
use Telepath\Telegram\SentWebAppMessage;
use Telepath\Telegram\ShippingOption;
+use Telepath\Telegram\StarTransactions;
use Telepath\Telegram\Sticker;
use Telepath\Telegram\StickerSet;
use Telepath\Telegram\Update;
@@ -1702,9 +1703,10 @@ public function getMyDefaultAdministratorRights(?bool $for_channels = null): Cha
}
/**
- * Use this method to edit text and game messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned.
+ * Use this method to edit text and game messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent.
*
* @param string $text New text of the message, 1-4096 characters after entities parsing
+ * @param string $business_connection_id Unique identifier of the business connection on behalf of which the message to be edited was sent
* @param int|string $chat_id Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param int $message_id Required if inline_message_id is not specified. Identifier of the message to edit
* @param string $inline_message_id Required if chat_id and message_id are not specified. Identifier of the inline message
@@ -1717,6 +1719,7 @@ public function getMyDefaultAdministratorRights(?bool $for_channels = null): Cha
*/
public function editMessageText(
string $text,
+ ?string $business_connection_id = null,
int|string|null $chat_id = null,
?int $message_id = null,
?string $inline_message_id = null,
@@ -1729,8 +1732,9 @@ public function editMessageText(
}
/**
- * Use this method to edit captions of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned.
+ * Use this method to edit captions of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent.
*
+ * @param string $business_connection_id Unique identifier of the business connection on behalf of which the message to be edited was sent
* @param int|string $chat_id Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param int $message_id Required if inline_message_id is not specified. Identifier of the message to edit
* @param string $inline_message_id Required if chat_id and message_id are not specified. Identifier of the inline message
@@ -1743,6 +1747,7 @@ public function editMessageText(
* @throws TelegramException
*/
public function editMessageCaption(
+ ?string $business_connection_id = null,
int|string|null $chat_id = null,
?int $message_id = null,
?string $inline_message_id = null,
@@ -1756,9 +1761,10 @@ public function editMessageCaption(
}
/**
- * Use this method to edit animation, audio, document, photo, or video messages. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned.
+ * Use this method to edit animation, audio, document, photo, or video messages. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent.
*
* @param InputMedia $media A JSON-serialized object for a new media content of the message
+ * @param string $business_connection_id Unique identifier of the business connection on behalf of which the message to be edited was sent
* @param int|string $chat_id Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param int $message_id Required if inline_message_id is not specified. Identifier of the message to edit
* @param string $inline_message_id Required if chat_id and message_id are not specified. Identifier of the inline message
@@ -1768,6 +1774,7 @@ public function editMessageCaption(
*/
public function editMessageMedia(
InputMedia $media,
+ ?string $business_connection_id = null,
int|string|null $chat_id = null,
?int $message_id = null,
?string $inline_message_id = null,
@@ -1781,6 +1788,7 @@ public function editMessageMedia(
*
* @param float $latitude Latitude of new location
* @param float $longitude Longitude of new location
+ * @param string $business_connection_id Unique identifier of the business connection on behalf of which the message to be edited was sent
* @param int|string $chat_id Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param int $message_id Required if inline_message_id is not specified. Identifier of the message to edit
* @param string $inline_message_id Required if chat_id and message_id are not specified. Identifier of the inline message
@@ -1795,6 +1803,7 @@ public function editMessageMedia(
public function editMessageLiveLocation(
float $latitude,
float $longitude,
+ ?string $business_connection_id = null,
int|string|null $chat_id = null,
?int $message_id = null,
?string $inline_message_id = null,
@@ -1810,6 +1819,7 @@ public function editMessageLiveLocation(
/**
* Use this method to stop updating a live location message before live_period expires. On success, if the message is not an inline message, the edited Message is returned, otherwise True is returned.
*
+ * @param string $business_connection_id Unique identifier of the business connection on behalf of which the message to be edited was sent
* @param int|string $chat_id Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param int $message_id Required if inline_message_id is not specified. Identifier of the message with live location to stop
* @param string $inline_message_id Required if chat_id and message_id are not specified. Identifier of the inline message
@@ -1818,6 +1828,7 @@ public function editMessageLiveLocation(
* @throws TelegramException
*/
public function stopMessageLiveLocation(
+ ?string $business_connection_id = null,
int|string|null $chat_id = null,
?int $message_id = null,
?string $inline_message_id = null,
@@ -1827,8 +1838,9 @@ public function stopMessageLiveLocation(
}
/**
- * Use this method to edit only the reply markup of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned.
+ * Use this method to edit only the reply markup of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent.
*
+ * @param string $business_connection_id Unique identifier of the business connection on behalf of which the message to be edited was sent
* @param int|string $chat_id Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param int $message_id Required if inline_message_id is not specified. Identifier of the message to edit
* @param string $inline_message_id Required if chat_id and message_id are not specified. Identifier of the inline message
@@ -1837,6 +1849,7 @@ public function stopMessageLiveLocation(
* @throws TelegramException
*/
public function editMessageReplyMarkup(
+ ?string $business_connection_id = null,
int|string|null $chat_id = null,
?int $message_id = null,
?string $inline_message_id = null,
@@ -1850,12 +1863,17 @@ public function editMessageReplyMarkup(
*
* @param int|string $chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param int $message_id Identifier of the original message with the poll
+ * @param string $business_connection_id Unique identifier of the business connection on behalf of which the message to be edited was sent
* @param InlineKeyboardMarkup $reply_markup A JSON-serialized object for a new message inline keyboard.
*
* @throws TelegramException
*/
- public function stopPoll(int|string $chat_id, int $message_id, ?InlineKeyboardMarkup $reply_markup = null): Poll
- {
+ public function stopPoll(
+ int|string $chat_id,
+ int $message_id,
+ ?string $business_connection_id = null,
+ ?InlineKeyboardMarkup $reply_markup = null,
+ ): Poll {
return $this->raw('stopPoll', func_get_args());
}
@@ -2318,6 +2336,19 @@ public function answerPreCheckoutQuery(
return $this->raw('answerPreCheckoutQuery', func_get_args());
}
+ /**
+ * Returns the bot's Telegram Star transactions in chronological order. On success, returns a StarTransactions object.
+ *
+ * @param int $offset Number of transactions to skip in the response
+ * @param int $limit The maximum number of transactions to be retrieved. Values between 1-100 are accepted. Defaults to 100.
+ *
+ * @throws TelegramException
+ */
+ public function getStarTransactions(?int $offset = null, ?int $limit = null): StarTransactions
+ {
+ return $this->raw('getStarTransactions', func_get_args());
+ }
+
/**
* Refunds a successful payment in Telegram Stars. Returns True on success.
*
diff --git a/src/Telegram/InlineKeyboardButton.php b/src/Telegram/InlineKeyboardButton.php
index 7807c8f..dd4e5d7 100644
--- a/src/Telegram/InlineKeyboardButton.php
+++ b/src/Telegram/InlineKeyboardButton.php
@@ -19,7 +19,7 @@ class InlineKeyboardButton extends Type
/** 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 identifier without using a username, if this is allowed by their privacy settings. */
public ?string $url = null;
- /** Optional. Data to be sent in a callback query to the bot when button is pressed, 1-64 bytes. Not supported for messages sent on behalf of a Telegram Business account. */
+ /** Optional. Data to be sent in a callback query to the bot when the button is pressed, 1-64 bytes */
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. Not supported for messages sent on behalf of a Telegram Business account. */
@@ -46,7 +46,7 @@ class InlineKeyboardButton extends Type
/**
* @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 identifier 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. Not supported for messages sent on behalf of a Telegram Business account.
+ * @param string $callback_data Optional. Data to be sent in a callback query to the bot when the 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. Not supported for messages sent on behalf of a Telegram Business account.
* @param LoginUrl $login_url Optional. An HTTPS 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. May be empty, in which case just the bot's username will be inserted. Not supported for messages sent on behalf of a Telegram Business account.
diff --git a/src/Telegram/RevenueWithdrawalState.php b/src/Telegram/RevenueWithdrawalState.php
new file mode 100644
index 0000000..19e4159
--- /dev/null
+++ b/src/Telegram/RevenueWithdrawalState.php
@@ -0,0 +1,29 @@
+ new RevenueWithdrawalStatePending($data, $bot),
+ 'succeeded' => new RevenueWithdrawalStateSucceeded($data, $bot),
+ 'failed' => new RevenueWithdrawalStateFailed($data, $bot),
+ };
+ }
+}
diff --git a/src/Telegram/RevenueWithdrawalStateFailed.php b/src/Telegram/RevenueWithdrawalStateFailed.php
new file mode 100644
index 0000000..b8582ad
--- /dev/null
+++ b/src/Telegram/RevenueWithdrawalStateFailed.php
@@ -0,0 +1,22 @@
+ $date,
+ 'url' => $url,
+ ]);
+ }
+}
diff --git a/src/Telegram/StarTransaction.php b/src/Telegram/StarTransaction.php
new file mode 100644
index 0000000..2ab9b00
--- /dev/null
+++ b/src/Telegram/StarTransaction.php
@@ -0,0 +1,53 @@
+SuccessfulPayment.telegram_payment_charge_id for successful incoming payments from users. */
+ public string $id;
+
+ /** Number of Telegram Stars transferred by the transaction */
+ public int $amount;
+
+ /** Date the transaction was created in Unix time */
+ public int $date;
+
+ /** Optional. Source of an incoming transaction (e.g., a user purchasing goods or services, Fragment refunding a failed withdrawal). Only for incoming transactions */
+ public ?TransactionPartner $source = null;
+
+ /** Optional. Receiver of an outgoing transaction (e.g., a user for a purchase refund, Fragment for a withdrawal). Only for outgoing transactions */
+ public ?TransactionPartner $receiver = null;
+
+ /**
+ * @param string $id Unique identifier of the transaction. Coincides with the identifer of the original transaction for refund transactions. Coincides with SuccessfulPayment.telegram_payment_charge_id for successful incoming payments from users.
+ * @param int $amount Number of Telegram Stars transferred by the transaction
+ * @param int $date Date the transaction was created in Unix time
+ * @param TransactionPartner $source Optional. Source of an incoming transaction (e.g., a user purchasing goods or services, Fragment refunding a failed withdrawal). Only for incoming transactions
+ * @param TransactionPartner $receiver Optional. Receiver of an outgoing transaction (e.g., a user for a purchase refund, Fragment for a withdrawal). Only for outgoing transactions
+ */
+ public static function make(
+ string $id,
+ int $amount,
+ int $date,
+ ?TransactionPartner $source = null,
+ ?TransactionPartner $receiver = null,
+ ): static {
+ return new static([
+ 'id' => $id,
+ 'amount' => $amount,
+ 'date' => $date,
+ 'source' => $source,
+ 'receiver' => $receiver,
+ ]);
+ }
+}
diff --git a/src/Telegram/StarTransactions.php b/src/Telegram/StarTransactions.php
new file mode 100644
index 0000000..d61caec
--- /dev/null
+++ b/src/Telegram/StarTransactions.php
@@ -0,0 +1,32 @@
+ $transactions,
+ ]);
+ }
+}
diff --git a/src/Telegram/TransactionPartner.php b/src/Telegram/TransactionPartner.php
new file mode 100644
index 0000000..ac375c3
--- /dev/null
+++ b/src/Telegram/TransactionPartner.php
@@ -0,0 +1,29 @@
+ new TransactionPartnerFragment($data, $bot),
+ 'user' => new TransactionPartnerUser($data, $bot),
+ 'other' => new TransactionPartnerOther($data, $bot),
+ };
+ }
+}
diff --git a/src/Telegram/TransactionPartnerFragment.php b/src/Telegram/TransactionPartnerFragment.php
new file mode 100644
index 0000000..37e6948
--- /dev/null
+++ b/src/Telegram/TransactionPartnerFragment.php
@@ -0,0 +1,29 @@
+Optional. State of the transaction if the transaction is outgoing */
+ public ?RevenueWithdrawalState $withdrawal_state = null;
+
+ /**
+ * @param RevenueWithdrawalState $withdrawal_state Optional. State of the transaction if the transaction is outgoing
+ */
+ public static function make(?RevenueWithdrawalState $withdrawal_state = null): static
+ {
+ return new static([
+ 'withdrawal_state' => $withdrawal_state,
+ ]);
+ }
+}
diff --git a/src/Telegram/TransactionPartnerOther.php b/src/Telegram/TransactionPartnerOther.php
new file mode 100644
index 0000000..608d528
--- /dev/null
+++ b/src/Telegram/TransactionPartnerOther.php
@@ -0,0 +1,22 @@
+ $user,
+ ]);
+ }
+}