Skip to content

Commit 51b2f9e

Browse files
committed
BotAPI 8.1 implementation
1 parent 090d2e4 commit 51b2f9e

File tree

1 file changed

+83
-12
lines changed

1 file changed

+83
-12
lines changed

types.go

Lines changed: 83 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5316,28 +5316,70 @@ type RevenueWithdrawalState struct {
53165316
URL string `json:"url,omitempty"`
53175317
}
53185318

5319+
// AffiliateInfo contains information about the affiliate that
5320+
// received a commission via this transaction.
5321+
type AffiliateInfo struct {
5322+
// AffiliateUser is the bot or the user that received an
5323+
// affiliate commission if it was received by a bot or a user
5324+
//
5325+
// optional
5326+
AffiliateUser *User `json:"affiliate_user,omitempty"`
5327+
// AffiliateChat is the chat that received an affiliate commission
5328+
// if it was received by a chat
5329+
//
5330+
// optional
5331+
AffiliateChat *Chat `json:"affiliate_chat,omitempty"`
5332+
// CommissionPerMile is the number of Telegram Stars received by
5333+
// the affiliate for each 1000 Telegram Stars received by
5334+
// the bot from referred users
5335+
CommissionPerMile int `json:"commission_per_mille"`
5336+
// Amount is the integer amount of Telegram Stars received by
5337+
// the affiliate from the transaction, rounded to 0;
5338+
// can be negative for refunds
5339+
Amount int64 `json:"amount"`
5340+
// NanostarAmount is the number of 1/1000000000 shares of Telegram Stars
5341+
// received by the affiliate; from -999999999 to 999999999;
5342+
// can be negative for refunds
5343+
//
5344+
// optional
5345+
NanostarAmount int64 `json:"nanostar_amount,omitempty"`
5346+
}
5347+
53195348
// TransactionPartner describes the source of a transaction, or its recipient for outgoing transactions. Currently, it can be one of
53205349
// - TransactionPartnerUser
5350+
// - TransactionPartnerAffiliateProgram
53215351
// - TransactionPartnerFragment
53225352
// - TransactionPartnerTelegramAds
53235353
// - TransactionPartnerTelegramApi
53245354
// - TransactionPartnerOther
53255355
type TransactionPartner struct {
53265356
// Type of the transaction partner. Must be one of:
5327-
// - fragment
53285357
// - user
5329-
// - other
5358+
// - affiliate_program
5359+
// - fragment
53305360
// - telegram_ads
53315361
// - telegram_api
5362+
// - other
53325363
Type string `json:"type"`
5333-
// State of the transaction if the transaction is outgoing.
5334-
// Represent only in "fragment" state
5364+
// TransactionPartnerUser payload for "user" type of transaction partner
5365+
TransactionPartnerUser
5366+
// TransactionPartnerAffiliateProgram payload for "affiliate_program" type of transaction partner
5367+
TransactionPartnerAffiliateProgram
5368+
// TransactionPartnerFragment payload for "fragment" type of transaction partner
5369+
TransactionPartnerFragment
5370+
// TransactionPartnerTelegramAPI payload for "telegram_api" type of transaction partner
5371+
TransactionPartnerTelegramAPI
5372+
}
5373+
5374+
type TransactionPartnerUser struct {
5375+
// Information about the user.
5376+
User User `json:"user"`
5377+
// Affiliate is the information about the affiliate that
5378+
// received a commission via this transaction.
5379+
// Can be available only for “invoice_payment” and “paid_media_payment” transactions.
53355380
//
53365381
// optional
5337-
WithdrawalState *RevenueWithdrawalState `json:"withdrawal_state,omitempty"`
5338-
// Information about the user.
5339-
// Represent only in "user" state
5340-
User *User `json:"user,omitempty"`
5382+
Affiliate *AffiliateInfo `json:"affiliate,omitempty"`
53415383
// TransactionPartnerUser only.
53425384
// Bot-specified invoice payload
53435385
//
@@ -5361,12 +5403,35 @@ type TransactionPartner struct {
53615403
//
53625404
// optional
53635405
Gift *Gift `json:"gift,omitempty"`
5364-
// RequestCount is the number of successful requests that
5365-
// exceeded regular limits and were therefore billed
5366-
// Represent only in "telegram_api" state
5406+
}
5407+
5408+
// TransactionPartnerAffiliateProgram describes the affiliate program that
5409+
// issued the affiliate commission received via this transaction.
5410+
type TransactionPartnerAffiliateProgram struct {
5411+
// SponsorUser is the information about the bot that
5412+
// sponsored the affiliate program
53675413
//
53685414
// optional
5369-
RequestCount int `json:"request_count,omitempty"`
5415+
SponsorUser *User `json:"sponsor_user,omitempty"`
5416+
// CommissionPerMile is the number of Telegram Stars received by the bot
5417+
// for each 1000 Telegram Stars received by
5418+
// the affiliate program sponsor from referred users
5419+
CommissionPerMile int `json:"commission_per_mille"`
5420+
}
5421+
5422+
// TransactionPartnerFragment describes a withdrawal transaction with Fragment.
5423+
type TransactionPartnerFragment struct {
5424+
// State of the transaction if the transaction is outgoing.
5425+
//
5426+
// optional
5427+
WithdrawalState *RevenueWithdrawalState `json:"withdrawal_state,omitempty"`
5428+
}
5429+
5430+
// TransactionPartnerTelegramAPI describes a transaction with payment for paid broadcasting.
5431+
type TransactionPartnerTelegramAPI struct {
5432+
// RequestCount is the number of successful requests that
5433+
// exceeded regular limits and were therefore billed
5434+
RequestCount int `json:"request_count"`
53705435
}
53715436

53725437
// StarTransaction describes a Telegram Star transaction.
@@ -5377,6 +5442,12 @@ type StarTransaction struct {
53775442
ID string `json:"id"`
53785443
// Number of Telegram Stars transferred by the transaction
53795444
Amount int64 `json:"amount"`
5445+
// NanostarAmount is the number of 1/1000000000 shares of
5446+
// Telegram Stars transferred by the transaction;
5447+
// from 0 to 999999999
5448+
//
5449+
// optional
5450+
NanostarAmount int64 `json:"nanostar_amount,omitempty"`
53805451
// Date the transaction was created in Unix time
53815452
Date int64 `json:"date"`
53825453
// Source of an incoming transaction (e.g., a user purchasing goods or services, Fragment refunding a failed withdrawal).

0 commit comments

Comments
 (0)