Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bot API 8.1 #74

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Layers/Generated.php
Original file line number Diff line number Diff line change
Expand Up @@ -2440,7 +2440,7 @@ public function sendInvoice(
* @param LabeledPrice[] $prices Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.). Must contain exactly one item for payments in <a href="https://t.me/BotNews/90">Telegram Stars</a>.
* @param string $business_connection_id Unique identifier of the business connection on behalf of which the link will be created. For payments in <a href="https://t.me/BotNews/90">Telegram Stars</a> only.
* @param string $provider_token Payment provider token, obtained via <a href="https://t.me/botfather">@BotFather</a>. Pass an empty string for payments in <a href="https://t.me/BotNews/90">Telegram Stars</a>.
* @param int $subscription_period The number of seconds the subscription will be active for before the next payment. The currency must be set to “XTR” (Telegram Stars) if the parameter is used. Currently, it must always be 2592000 (30 days) if specified. Any number of subscriptions can be active for a given bot at the same time, including multiple concurrent subscriptions from the same user.
* @param int $subscription_period The number of seconds the subscription will be active for before the next payment. The currency must be set to “XTR” (Telegram Stars) if the parameter is used. Currently, it must always be 2592000 (30 days) if specified. Any number of subscriptions can be active for a given bot at the same time, including multiple concurrent subscriptions from the same user. Subscription price must no exceed 2500 Telegram Stars.
* @param int $max_tip_amount The maximum accepted amount for tips in the <em>smallest units</em> of the currency (integer, not float/double). For example, for a maximum tip of US$ 1.45 pass max_tip_amount = 145. See the <em>exp</em> parameter in <a href="https://core.telegram.org/bots/payments/currencies.json">currencies.json</a>, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0. Not supported for payments in <a href="https://t.me/BotNews/90">Telegram Stars</a>.
* @param int[] $suggested_tip_amounts A JSON-serialized array of suggested amounts of tips in the <em>smallest units</em> 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 <em>max_tip_amount</em>.
* @param string $provider_data JSON-serialized data about the invoice, which will be shared with the payment provider. A detailed description of required fields should be provided by the payment provider.
Expand Down
53 changes: 53 additions & 0 deletions src/Telegram/AffiliateInfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

/**
* This file is auto-generated.
*/

namespace Telepath\Telegram;

use Telepath\Types\Type;

/**
* Contains information about the affiliate that received a commission via this transaction.
*/
class AffiliateInfo extends Type
{
/** The number of Telegram Stars received by the affiliate for each 1000 Telegram Stars received by the bot from referred users */
public int $commission_per_mille;

/** Integer amount of Telegram Stars received by the affiliate from the transaction, rounded to 0; can be negative for refunds */
public int $amount;

/** <em>Optional</em>. The bot or the user that received an affiliate commission if it was received by a bot or a user */
public ?User $affiliate_user = null;

/** <em>Optional</em>. The chat that received an affiliate commission if it was received by a chat */
public ?Chat $affiliate_chat = null;

/** <em>Optional</em>. The number of 1/1000000000 shares of Telegram Stars received by the affiliate; from -999999999 to 999999999; can be negative for refunds */
public ?int $nanostar_amount = null;

/**
* @param int $commission_per_mille The number of Telegram Stars received by the affiliate for each 1000 Telegram Stars received by the bot from referred users
* @param int $amount Integer amount of Telegram Stars received by the affiliate from the transaction, rounded to 0; can be negative for refunds
* @param User $affiliate_user <em>Optional</em>. The bot or the user that received an affiliate commission if it was received by a bot or a user
* @param Chat $affiliate_chat <em>Optional</em>. The chat that received an affiliate commission if it was received by a chat
* @param int $nanostar_amount <em>Optional</em>. The number of 1/1000000000 shares of Telegram Stars received by the affiliate; from -999999999 to 999999999; can be negative for refunds
*/
public static function make(
int $commission_per_mille,
int $amount,
?User $affiliate_user = null,
?Chat $affiliate_chat = null,
?int $nanostar_amount = null,
): static {
return new static([
'commission_per_mille' => $commission_per_mille,
'amount' => $amount,
'affiliate_user' => $affiliate_user,
'affiliate_chat' => $affiliate_chat,
'nanostar_amount' => $nanostar_amount,
]);
}
}
10 changes: 8 additions & 2 deletions src/Telegram/StarTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ class StarTransaction extends Type
/** Unique identifier of the transaction. Coincides with the identifier of the original transaction for refund transactions. Coincides with <em>SuccessfulPayment.telegram_payment_charge_id</em> for successful incoming payments from users. */
public string $id;

/** Number of Telegram Stars transferred by the transaction */
/** Integer amount of Telegram Stars transferred by the transaction */
public int $amount;

/** Date the transaction was created in Unix time */
public int $date;

/** <em>Optional</em>. The number of 1/1000000000 shares of Telegram Stars transferred by the transaction; from 0 to 999999999 */
public ?int $nanostar_amount = null;

/** <em>Optional</em>. 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;

Expand All @@ -30,22 +33,25 @@ class StarTransaction extends Type

/**
* @param string $id Unique identifier of the transaction. Coincides with the identifier of the original transaction for refund transactions. Coincides with <em>SuccessfulPayment.telegram_payment_charge_id</em> for successful incoming payments from users.
* @param int $amount Number of Telegram Stars transferred by the transaction
* @param int $amount Integer amount of Telegram Stars transferred by the transaction
* @param int $date Date the transaction was created in Unix time
* @param int $nanostar_amount <em>Optional</em>. The number of 1/1000000000 shares of Telegram Stars transferred by the transaction; from 0 to 999999999
* @param TransactionPartner $source <em>Optional</em>. 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 <em>Optional</em>. 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,
?int $nanostar_amount = null,
?TransactionPartner $source = null,
?TransactionPartner $receiver = null,
): static {
return new static([
'id' => $id,
'amount' => $amount,
'date' => $date,
'nanostar_amount' => $nanostar_amount,
'source' => $source,
'receiver' => $receiver,
]);
Expand Down
1 change: 1 addition & 0 deletions src/Telegram/TransactionPartner.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public static function factory(array $data, ?Bot $bot = null): self
{
return match ($data['type']) {
'user' => new TransactionPartnerUser($data, $bot),
'affiliate_program' => new TransactionPartnerAffiliateProgram($data, $bot),
'fragment' => new TransactionPartnerFragment($data, $bot),
'telegram_ads' => new TransactionPartnerTelegramAds($data, $bot),
'telegram_api' => new TransactionPartnerTelegramApi($data, $bot),
Expand Down
34 changes: 34 additions & 0 deletions src/Telegram/TransactionPartnerAffiliateProgram.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

/**
* This file is auto-generated.
*/

namespace Telepath\Telegram;

/**
* Describes the affiliate program that issued the affiliate commission received via this transaction.
*/
class TransactionPartnerAffiliateProgram extends TransactionPartner
{
/** Type of the transaction partner, always “affiliate_program” */
public string $type = 'affiliate_program';

/** The number of Telegram Stars received by the bot for each 1000 Telegram Stars received by the affiliate program sponsor from referred users */
public int $commission_per_mille;

/** <em>Optional</em>. Information about the bot that sponsored the affiliate program */
public ?User $sponsor_user = null;

/**
* @param int $commission_per_mille The number of Telegram Stars received by the bot for each 1000 Telegram Stars received by the affiliate program sponsor from referred users
* @param User $sponsor_user <em>Optional</em>. Information about the bot that sponsored the affiliate program
*/
public static function make(int $commission_per_mille, ?User $sponsor_user = null): static
{
return new static([
'commission_per_mille' => $commission_per_mille,
'sponsor_user' => $sponsor_user,
]);
}
}
12 changes: 9 additions & 3 deletions src/Telegram/TransactionPartnerUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ class TransactionPartnerUser extends TransactionPartner
/** Information about the user */
public User $user;

/** <em>Optional</em>. Information about the affiliate that received a commission via this transaction */
public ?AffiliateInfo $affiliate = null;

/** <em>Optional</em>. Bot-specified invoice payload */
public ?string $invoice_payload = null;

Expand All @@ -34,26 +37,29 @@ class TransactionPartnerUser extends TransactionPartner
public ?string $paid_media_payload = null;

/** <em>Optional</em>. The gift sent to the user by the bot */
public ?string $gift = null;
public ?Gift $gift = null;

/**
* @param User $user Information about the user
* @param AffiliateInfo $affiliate <em>Optional</em>. Information about the affiliate that received a commission via this transaction
* @param string $invoice_payload <em>Optional</em>. Bot-specified invoice payload
* @param int $subscription_period <em>Optional</em>. The duration of the paid subscription
* @param PaidMedia[] $paid_media <em>Optional</em>. Information about the paid media bought by the user
* @param string $paid_media_payload <em>Optional</em>. Bot-specified paid media payload
* @param string $gift <em>Optional</em>. The gift sent to the user by the bot
* @param Gift $gift <em>Optional</em>. The gift sent to the user by the bot
*/
public static function make(
User $user,
?AffiliateInfo $affiliate = null,
?string $invoice_payload = null,
?int $subscription_period = null,
?array $paid_media = null,
?string $paid_media_payload = null,
?string $gift = null,
?Gift $gift = null,
): static {
return new static([
'user' => $user,
'affiliate' => $affiliate,
'invoice_payload' => $invoice_payload,
'subscription_period' => $subscription_period,
'paid_media' => $paid_media,
Expand Down
Loading