mirror of
https://github.com/tdlight-team/tdlight-telegram-bot-api.git
synced 2025-01-12 13:06:00 +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_;
|
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 {
|
class Client::JsonStarTransactionType final : public td::Jsonable {
|
||||||
public:
|
public:
|
||||||
JsonStarTransactionType(const td_api::StarTransactionType *type, const Client *client)
|
JsonStarTransactionType(const td_api::StarTransactionType *type, const Client *client)
|
||||||
@ -4260,6 +4286,9 @@ class Client::JsonStarTransactionType final : public td::Jsonable {
|
|||||||
if (!type->payload_.empty()) {
|
if (!type->payload_.empty()) {
|
||||||
object("paid_media_payload", type->payload_);
|
object("paid_media_payload", type->payload_);
|
||||||
}
|
}
|
||||||
|
if (type->affiliate_ != nullptr) {
|
||||||
|
object("affiliate", JsonAffiliateInfo(type->affiliate_.get(), client_));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case td_api::starTransactionTypeBotInvoiceSale::ID: {
|
case td_api::starTransactionTypeBotInvoiceSale::ID: {
|
||||||
@ -4274,6 +4303,9 @@ class Client::JsonStarTransactionType final : public td::Jsonable {
|
|||||||
object("invoice_payload", type->invoice_payload_);
|
object("invoice_payload", type->invoice_payload_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (type->affiliate_ != nullptr) {
|
||||||
|
object("affiliate", JsonAffiliateInfo(type->affiliate_.get(), client_));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case td_api::starTransactionTypeBotSubscriptionSale::ID: {
|
case td_api::starTransactionTypeBotSubscriptionSale::ID: {
|
||||||
@ -4291,6 +4323,9 @@ class Client::JsonStarTransactionType final : public td::Jsonable {
|
|||||||
if (type->subscription_period_ > 0) {
|
if (type->subscription_period_ > 0) {
|
||||||
object("subscription_period", type->subscription_period_);
|
object("subscription_period", type->subscription_period_);
|
||||||
}
|
}
|
||||||
|
if (type->affiliate_ != nullptr) {
|
||||||
|
object("affiliate", JsonAffiliateInfo(type->affiliate_.get(), client_));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case td_api::starTransactionTypeTelegramAdsWithdrawal::ID:
|
case td_api::starTransactionTypeTelegramAdsWithdrawal::ID:
|
||||||
|
@ -204,6 +204,7 @@ class Client final : public WebhookActor::Callback {
|
|||||||
class JsonGiveawayCompleted;
|
class JsonGiveawayCompleted;
|
||||||
class JsonChatBoostAdded;
|
class JsonChatBoostAdded;
|
||||||
class JsonRevenueWithdrawalState;
|
class JsonRevenueWithdrawalState;
|
||||||
|
class JsonAffiliateInfo;
|
||||||
class JsonStarTransactionType;
|
class JsonStarTransactionType;
|
||||||
class JsonStarTransaction;
|
class JsonStarTransaction;
|
||||||
class JsonStarTransactions;
|
class JsonStarTransactions;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user