mirror of
https://github.com/tdlight-team/tdlight-telegram-bot-api.git
synced 2024-12-25 12:15:51 +01:00
Add affiliate info to relevant Star transactions.
This commit is contained in:
parent
26f945f2b0
commit
cc2c3678a9
@ -4230,6 +4230,32 @@ class Client::JsonRevenueWithdrawalState final : public td::Jsonable {
|
||||
const td_api::RevenueWithdrawalState *state_;
|
||||
};
|
||||
|
||||
class Client::JsonAffiliateInfo final : public td::Jsonable {
|
||||
public:
|
||||
JsonAffiliateInfo(const td_api::affiliateInfo *affiliate_info, const Client *client)
|
||||
: affiliate_info_(affiliate_info), client_(client) {
|
||||
}
|
||||
void store(td::JsonValueScope *scope) const {
|
||||
auto object = scope->enter_object();
|
||||
auto chat_info = client_->get_chat(affiliate_info_->affiliate_chat_id_);
|
||||
CHECK(chat_info != nullptr);
|
||||
if (chat_info->type == ChatInfo::Type::Private) {
|
||||
object("affiliate_user", JsonUser(chat_info->user_id, client_));
|
||||
} else {
|
||||
object("affiliate_chat", JsonChat(affiliate_info_->affiliate_chat_id_, client_));
|
||||
}
|
||||
object("commission_per_mille", affiliate_info_->commission_per_mille_);
|
||||
object("amount", affiliate_info_->star_amount_->star_count_);
|
||||
if (affiliate_info_->star_amount_->nanostar_count_ != 0) {
|
||||
object("nanostar_amount", affiliate_info_->star_amount_->nanostar_count_);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
const td_api::affiliateInfo *affiliate_info_;
|
||||
const Client *client_;
|
||||
};
|
||||
|
||||
class Client::JsonStarTransactionType final : public td::Jsonable {
|
||||
public:
|
||||
JsonStarTransactionType(const td_api::StarTransactionType *type, const Client *client)
|
||||
@ -4260,6 +4286,9 @@ class Client::JsonStarTransactionType final : public td::Jsonable {
|
||||
if (!type->payload_.empty()) {
|
||||
object("paid_media_payload", type->payload_);
|
||||
}
|
||||
if (type->affiliate_ != nullptr) {
|
||||
object("affiliate", JsonAffiliateInfo(type->affiliate_.get(), client_));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case td_api::starTransactionTypeBotInvoiceSale::ID: {
|
||||
@ -4274,6 +4303,9 @@ class Client::JsonStarTransactionType final : public td::Jsonable {
|
||||
object("invoice_payload", type->invoice_payload_);
|
||||
}
|
||||
}
|
||||
if (type->affiliate_ != nullptr) {
|
||||
object("affiliate", JsonAffiliateInfo(type->affiliate_.get(), client_));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case td_api::starTransactionTypeBotSubscriptionSale::ID: {
|
||||
@ -4291,6 +4323,9 @@ class Client::JsonStarTransactionType final : public td::Jsonable {
|
||||
if (type->subscription_period_ > 0) {
|
||||
object("subscription_period", type->subscription_period_);
|
||||
}
|
||||
if (type->affiliate_ != nullptr) {
|
||||
object("affiliate", JsonAffiliateInfo(type->affiliate_.get(), client_));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case td_api::starTransactionTypeTelegramAdsWithdrawal::ID:
|
||||
|
@ -204,6 +204,7 @@ class Client final : public WebhookActor::Callback {
|
||||
class JsonGiveawayCompleted;
|
||||
class JsonChatBoostAdded;
|
||||
class JsonRevenueWithdrawalState;
|
||||
class JsonAffiliateInfo;
|
||||
class JsonStarTransactionType;
|
||||
class JsonStarTransaction;
|
||||
class JsonStarTransactions;
|
||||
|
Loading…
Reference in New Issue
Block a user