Add td_api::getStarTransactions.
This commit is contained in:
parent
3987f69202
commit
31194a7591
@ -833,6 +833,27 @@ starPaymentOption currency:string amount:int53 star_count:int53 store_product_id
|
||||
starPaymentOptions options:vector<starPaymentOption> = StarPaymentOptions;
|
||||
|
||||
|
||||
//@class StarTransactionDirection @description Describes direction of a transaction with Telegram stars
|
||||
|
||||
//@description The transaction is incoming and increases the number of owned Telegram stars
|
||||
starTransactionDirectionIncoming = StarTransactionDirection;
|
||||
|
||||
//@description The transaction is outgoing and decreases the number of owned Telegram stars
|
||||
starTransactionDirectionOutgoing = StarTransactionDirection;
|
||||
|
||||
|
||||
//@description Represents a transaction changing the amount of owned Telegram stars
|
||||
//@id Unique identifier of the transaction
|
||||
//@star_count The amount of added owned Telegram stars; negative for outgoing transactions
|
||||
//@date Point in time (Unix timestamp) when the transaction was completed
|
||||
starTransaction id:string star_count:int53 date:int32 = StarTransaction;
|
||||
|
||||
//@description Represents a list of Telegram star transactions
|
||||
//@star_count The amount of owned Telegram stars
|
||||
//@transactions List of transactions with Telegram stars
|
||||
//@next_offset The offset for the next request. If empty, then there are no more results
|
||||
starTransactions star_count:int53 transactions:vector<starTransaction> next_offset:string = StarTransactions;
|
||||
|
||||
|
||||
//@class PremiumGiveawayParticipantStatus @description Contains information about status of a user in a Telegram Premium giveaway
|
||||
|
||||
@ -10756,6 +10777,11 @@ getPremiumGiveawayInfo chat_id:int53 message_id:int53 = PremiumGiveawayInfo;
|
||||
//@description Returns available options for Telegram stars purchase
|
||||
getStarPaymentOptions = StarPaymentOptions;
|
||||
|
||||
//@description Returns the list of Telegram star transactions for the current user
|
||||
//@offset Offset of the first transaction to return as received from the previous request; use empty string to get the first chunk of results
|
||||
//@direction Direction of the transactions to receive; pass null to get all transactions
|
||||
getStarTransactions offset:string direction:StarTransactionDirection = StarTransactions;
|
||||
|
||||
//@description Checks whether an in-store purchase is possible. Must be called before any in-store purchase @purpose Transaction purpose
|
||||
canPurchaseFromStore purpose:StorePaymentPurpose = Ok;
|
||||
|
||||
|
@ -640,6 +640,58 @@ class GetStarsTopupOptionsQuery final : public Td::ResultHandler {
|
||||
}
|
||||
};
|
||||
|
||||
class GetStarsTransactionsQuery final : public Td::ResultHandler {
|
||||
Promise<td_api::object_ptr<td_api::starTransactions>> promise_;
|
||||
|
||||
public:
|
||||
explicit GetStarsTransactionsQuery(Promise<td_api::object_ptr<td_api::starTransactions>> &&promise)
|
||||
: promise_(std::move(promise)) {
|
||||
}
|
||||
|
||||
void send(const string &offset, td_api::object_ptr<td_api::StarTransactionDirection> &&direction) {
|
||||
int32 flags = 0;
|
||||
if (direction != nullptr) {
|
||||
switch (direction->get_id()) {
|
||||
case td_api::starTransactionDirectionIncoming::ID:
|
||||
flags |= telegram_api::payments_getStarsTransactions::INBOUND_MASK;
|
||||
break;
|
||||
case td_api::starTransactionDirectionOutgoing::ID:
|
||||
flags |= telegram_api::payments_getStarsTransactions::OUTBOUND_MASK;
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
send_query(G()->net_query_creator().create(
|
||||
telegram_api::payments_getStarsTransactions(flags, false /*ignored*/, false /*ignored*/,
|
||||
telegram_api::make_object<telegram_api::inputPeerSelf>(), offset)));
|
||||
}
|
||||
|
||||
void on_result(BufferSlice packet) final {
|
||||
auto result_ptr = fetch_result<telegram_api::payments_getStarsTransactions>(packet);
|
||||
if (result_ptr.is_error()) {
|
||||
return on_error(result_ptr.move_as_error());
|
||||
}
|
||||
|
||||
auto result = result_ptr.move_as_ok();
|
||||
td_->user_manager_->on_get_users(std::move(result->users_), "GetStarsTransactionsQuery");
|
||||
td_->chat_manager_->on_get_chats(std::move(result->chats_), "GetStarsTransactionsQuery");
|
||||
|
||||
vector<td_api::object_ptr<td_api::starTransaction>> transactions;
|
||||
for (auto &transaction : result->history_) {
|
||||
transactions.push_back(
|
||||
td_api::make_object<td_api::starTransaction>(transaction->id_, transaction->stars_, transaction->date_));
|
||||
}
|
||||
|
||||
promise_.set_value(
|
||||
td_api::make_object<td_api::starTransactions>(result->balance_, std::move(transactions), result->next_offset_));
|
||||
}
|
||||
|
||||
void on_error(Status status) final {
|
||||
promise_.set_error(std::move(status));
|
||||
}
|
||||
};
|
||||
|
||||
class CanPurchasePremiumQuery final : public Td::ResultHandler {
|
||||
Promise<Unit> promise_;
|
||||
|
||||
@ -1196,6 +1248,12 @@ void get_star_payment_options(Td *td, Promise<td_api::object_ptr<td_api::starPay
|
||||
td->create_handler<GetStarsTopupOptionsQuery>(std::move(promise))->send();
|
||||
}
|
||||
|
||||
void get_star_transactions(Td *td, const string &offset,
|
||||
td_api::object_ptr<td_api::StarTransactionDirection> &&direction,
|
||||
Promise<td_api::object_ptr<td_api::starTransactions>> &&promise) {
|
||||
td->create_handler<GetStarsTransactionsQuery>(std::move(promise))->send(offset, std::move(direction));
|
||||
}
|
||||
|
||||
void can_purchase_premium(Td *td, td_api::object_ptr<td_api::StorePaymentPurpose> &&purpose, Promise<Unit> &&promise) {
|
||||
td->create_handler<CanPurchasePremiumQuery>(std::move(promise))->send(std::move(purpose));
|
||||
}
|
||||
|
@ -56,6 +56,10 @@ void get_premium_giveaway_info(Td *td, MessageFullId message_full_id,
|
||||
|
||||
void get_star_payment_options(Td *td, Promise<td_api::object_ptr<td_api::starPaymentOptions>> &&promise);
|
||||
|
||||
void get_star_transactions(Td *td, const string &offset,
|
||||
td_api::object_ptr<td_api::StarTransactionDirection> &&direction,
|
||||
Promise<td_api::object_ptr<td_api::starTransactions>> &&promise);
|
||||
|
||||
void can_purchase_premium(Td *td, td_api::object_ptr<td_api::StorePaymentPurpose> &&purpose, Promise<Unit> &&promise);
|
||||
|
||||
void assign_app_store_transaction(Td *td, const string &receipt,
|
||||
|
@ -9394,6 +9394,13 @@ void Td::on_request(uint64 id, const td_api::getStarPaymentOptions &request) {
|
||||
get_star_payment_options(this, std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::getStarTransactions &request) {
|
||||
CHECK_IS_USER();
|
||||
CLEAN_INPUT_STRING(request.offset_);
|
||||
CREATE_REQUEST_PROMISE();
|
||||
get_star_transactions(this, request.offset_, std::move(request.direction_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::canPurchaseFromStore &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
|
@ -1835,6 +1835,8 @@ class Td final : public Actor {
|
||||
|
||||
void on_request(uint64 id, const td_api::getStarPaymentOptions &request);
|
||||
|
||||
void on_request(uint64 id, td_api::getStarTransactions &request);
|
||||
|
||||
void on_request(uint64 id, td_api::canPurchaseFromStore &request);
|
||||
|
||||
void on_request(uint64 id, td_api::assignAppStoreTransaction &request);
|
||||
|
@ -3382,6 +3382,14 @@ class CliClient final : public Actor {
|
||||
send_request(td_api::make_object<td_api::getPremiumGiveawayInfo>(chat_id, message_id));
|
||||
} else if (op == "gspo") {
|
||||
send_request(td_api::make_object<td_api::getStarPaymentOptions>());
|
||||
} else if (op == "gsta" || op == "gsti" || op == "gsto") {
|
||||
td_api::object_ptr<td_api::StarTransactionDirection> direction;
|
||||
if (op == "gsti") {
|
||||
direction = td_api::make_object<td_api::starTransactionDirectionIncoming>();
|
||||
} else if (op == "gsto") {
|
||||
direction = td_api::make_object<td_api::starTransactionDirectionOutgoing>();
|
||||
}
|
||||
send_request(td_api::make_object<td_api::getStarTransactions>(args, std::move(direction)));
|
||||
} else if (op == "cpfs" || op == "cpfsb") {
|
||||
UserId user_id;
|
||||
string currency;
|
||||
|
Loading…
Reference in New Issue
Block a user