Skip to content

Commit 98d247e

Browse files
committed
Update code to reflect latest changes to the Bot API documentation
1 parent dc9425e commit 98d247e

6 files changed

Lines changed: 106 additions & 6 deletions

File tree

src/Layers/Generated.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2440,7 +2440,7 @@ public function sendInvoice(
24402440
* @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>.
24412441
* @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.
24422442
* @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>.
2443-
* @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.
2443+
* @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.
24442444
* @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>.
24452445
* @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>.
24462446
* @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.

src/Telegram/AffiliateInfo.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
/**
4+
* This file is auto-generated.
5+
*/
6+
7+
namespace Telepath\Telegram;
8+
9+
use Telepath\Types\Type;
10+
11+
/**
12+
* Contains information about the affiliate that received a commission via this transaction.
13+
*/
14+
class AffiliateInfo extends Type
15+
{
16+
/** The number of Telegram Stars received by the affiliate for each 1000 Telegram Stars received by the bot from referred users */
17+
public int $commission_per_mille;
18+
19+
/** Integer amount of Telegram Stars received by the affiliate from the transaction, rounded to 0; can be negative for refunds */
20+
public int $amount;
21+
22+
/** <em>Optional</em>. The bot or the user that received an affiliate commission if it was received by a bot or a user */
23+
public ?User $affiliate_user = null;
24+
25+
/** <em>Optional</em>. The chat that received an affiliate commission if it was received by a chat */
26+
public ?Chat $affiliate_chat = null;
27+
28+
/** <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 */
29+
public ?int $nanostar_amount = null;
30+
31+
/**
32+
* @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
33+
* @param int $amount Integer amount of Telegram Stars received by the affiliate from the transaction, rounded to 0; can be negative for refunds
34+
* @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
35+
* @param Chat $affiliate_chat <em>Optional</em>. The chat that received an affiliate commission if it was received by a chat
36+
* @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
37+
*/
38+
public static function make(
39+
int $commission_per_mille,
40+
int $amount,
41+
?User $affiliate_user = null,
42+
?Chat $affiliate_chat = null,
43+
?int $nanostar_amount = null,
44+
): static {
45+
return new static([
46+
'commission_per_mille' => $commission_per_mille,
47+
'amount' => $amount,
48+
'affiliate_user' => $affiliate_user,
49+
'affiliate_chat' => $affiliate_chat,
50+
'nanostar_amount' => $nanostar_amount,
51+
]);
52+
}
53+
}

src/Telegram/StarTransaction.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@ class StarTransaction extends Type
1616
/** 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. */
1717
public string $id;
1818

19-
/** Number of Telegram Stars transferred by the transaction */
19+
/** Integer amount of Telegram Stars transferred by the transaction */
2020
public int $amount;
2121

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

25+
/** <em>Optional</em>. The number of 1/1000000000 shares of Telegram Stars transferred by the transaction; from 0 to 999999999 */
26+
public ?int $nanostar_amount = null;
27+
2528
/** <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 */
2629
public ?TransactionPartner $source = null;
2730

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

3134
/**
3235
* @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.
33-
* @param int $amount Number of Telegram Stars transferred by the transaction
36+
* @param int $amount Integer amount of Telegram Stars transferred by the transaction
3437
* @param int $date Date the transaction was created in Unix time
38+
* @param int $nanostar_amount <em>Optional</em>. The number of 1/1000000000 shares of Telegram Stars transferred by the transaction; from 0 to 999999999
3539
* @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
3640
* @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
3741
*/
3842
public static function make(
3943
string $id,
4044
int $amount,
4145
int $date,
46+
?int $nanostar_amount = null,
4247
?TransactionPartner $source = null,
4348
?TransactionPartner $receiver = null,
4449
): static {
4550
return new static([
4651
'id' => $id,
4752
'amount' => $amount,
4853
'date' => $date,
54+
'nanostar_amount' => $nanostar_amount,
4955
'source' => $source,
5056
'receiver' => $receiver,
5157
]);

src/Telegram/TransactionPartner.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public static function factory(array $data, ?Bot $bot = null): self
2222
{
2323
return match ($data['type']) {
2424
'user' => new TransactionPartnerUser($data, $bot),
25+
'affiliate_program' => new TransactionPartnerAffiliateProgram($data, $bot),
2526
'fragment' => new TransactionPartnerFragment($data, $bot),
2627
'telegram_ads' => new TransactionPartnerTelegramAds($data, $bot),
2728
'telegram_api' => new TransactionPartnerTelegramApi($data, $bot),
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
/**
4+
* This file is auto-generated.
5+
*/
6+
7+
namespace Telepath\Telegram;
8+
9+
/**
10+
* Describes the affiliate program that issued the affiliate commission received via this transaction.
11+
*/
12+
class TransactionPartnerAffiliateProgram extends TransactionPartner
13+
{
14+
/** Type of the transaction partner, always “affiliate_program” */
15+
public string $type = 'affiliate_program';
16+
17+
/** The number of Telegram Stars received by the bot for each 1000 Telegram Stars received by the affiliate program sponsor from referred users */
18+
public int $commission_per_mille;
19+
20+
/** <em>Optional</em>. Information about the bot that sponsored the affiliate program */
21+
public ?User $sponsor_user = null;
22+
23+
/**
24+
* @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
25+
* @param User $sponsor_user <em>Optional</em>. Information about the bot that sponsored the affiliate program
26+
*/
27+
public static function make(int $commission_per_mille, ?User $sponsor_user = null): static
28+
{
29+
return new static([
30+
'commission_per_mille' => $commission_per_mille,
31+
'sponsor_user' => $sponsor_user,
32+
]);
33+
}
34+
}

src/Telegram/TransactionPartnerUser.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ class TransactionPartnerUser extends TransactionPartner
1717
/** Information about the user */
1818
public User $user;
1919

20+
/** <em>Optional</em>. Information about the affiliate that received a commission via this transaction */
21+
public ?AffiliateInfo $affiliate = null;
22+
2023
/** <em>Optional</em>. Bot-specified invoice payload */
2124
public ?string $invoice_payload = null;
2225

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

3639
/** <em>Optional</em>. The gift sent to the user by the bot */
37-
public ?string $gift = null;
40+
public ?Gift $gift = null;
3841

3942
/**
4043
* @param User $user Information about the user
44+
* @param AffiliateInfo $affiliate <em>Optional</em>. Information about the affiliate that received a commission via this transaction
4145
* @param string $invoice_payload <em>Optional</em>. Bot-specified invoice payload
4246
* @param int $subscription_period <em>Optional</em>. The duration of the paid subscription
4347
* @param PaidMedia[] $paid_media <em>Optional</em>. Information about the paid media bought by the user
4448
* @param string $paid_media_payload <em>Optional</em>. Bot-specified paid media payload
45-
* @param string $gift <em>Optional</em>. The gift sent to the user by the bot
49+
* @param Gift $gift <em>Optional</em>. The gift sent to the user by the bot
4650
*/
4751
public static function make(
4852
User $user,
53+
?AffiliateInfo $affiliate = null,
4954
?string $invoice_payload = null,
5055
?int $subscription_period = null,
5156
?array $paid_media = null,
5257
?string $paid_media_payload = null,
53-
?string $gift = null,
58+
?Gift $gift = null,
5459
): static {
5560
return new static([
5661
'user' => $user,
62+
'affiliate' => $affiliate,
5763
'invoice_payload' => $invoice_payload,
5864
'subscription_period' => $subscription_period,
5965
'paid_media' => $paid_media,

0 commit comments

Comments
 (0)