Add td_api::getCollectibleItemInfo.
This commit is contained in:
parent
22d2f6a98d
commit
f7ab032976
@ -851,7 +851,7 @@ emojiStatuses custom_emoji_ids:vector<int64> = EmojiStatuses;
|
||||
//@description Describes usernames assigned to a user, a supergroup, or a channel
|
||||
//@active_usernames List of active usernames; the first one must be shown as the primary username. The order of active usernames can be changed with reorderActiveUsernames, reorderBotActiveUsernames or reorderSupergroupActiveUsernames
|
||||
//@disabled_usernames List of currently disabled usernames; the username can be activated with toggleUsernameIsActive, toggleBotUsernameIsActive, or toggleSupergroupUsernameIsActive
|
||||
//@editable_username The active username, which can be changed with setUsername or setSupergroupUsername
|
||||
//@editable_username The active username, which can be changed with setUsername or setSupergroupUsername. Information about other usernames can be received using getCollectibleItemInfo
|
||||
usernames active_usernames:vector<string> disabled_usernames:vector<string> editable_username:string = Usernames;
|
||||
|
||||
|
||||
@ -2356,10 +2356,29 @@ countries countries:vector<countryInfo> = Countries;
|
||||
//@country Information about the country to which the phone number belongs; may be null
|
||||
//@country_calling_code The part of the phone number denoting country calling code or its part
|
||||
//@formatted_phone_number The phone number without country calling code formatted accordingly to local rules. Expected digits are returned as '-', but even more digits might be entered by the user
|
||||
//@is_anonymous True, if the phone number was bought on Fragment and isn't tied to a SIM card
|
||||
//@is_anonymous True, if the phone number was bought at https://fragment.com and isn't tied to a SIM card. Information about the phone number can be received using getCollectibleItemInfo
|
||||
phoneNumberInfo country:countryInfo country_calling_code:string formatted_phone_number:string is_anonymous:Bool = PhoneNumberInfo;
|
||||
|
||||
|
||||
//@class CollectibleItemType @description Describes a collectible item that can be purchased at https://fragment.com
|
||||
|
||||
//@description A username @username The username
|
||||
collectibleItemTypeUsername username:string = CollectibleItemType;
|
||||
|
||||
//@description A phone number @phone_number The phone number
|
||||
collectibleItemTypePhoneNumber phone_number:string = CollectibleItemType;
|
||||
|
||||
|
||||
//@description Contains information about a collectible item and its last purchase
|
||||
//@purchase_date Point in time (Unix timestamp) when the item was purchased
|
||||
//@currency Currency for the paid amount
|
||||
//@amount The paid amount, in the smallest units of the currency
|
||||
//@cryptocurrency Cryptocurrency used to pay for the item
|
||||
//@cryptocurrency_amount The paid amount, in the smallest units of the cryptocurrency
|
||||
//@url Individual URL for the item on https://fragment.com
|
||||
collectibleItemInfo purchase_date:int32 currency:string amount:int53 cryptocurrency:string cryptocurrency_amount:int64 url:string = CollectibleItemInfo;
|
||||
|
||||
|
||||
//@description Describes an action associated with a bank card number @text Action text @url The URL to be opened
|
||||
bankCardActionOpenUrl text:string url:string = BankCardActionOpenUrl;
|
||||
|
||||
@ -2543,7 +2562,7 @@ messageExtendedMediaUnsupported caption:formattedText = MessageExtendedMedia;
|
||||
//@only_new_members True, if only new members of the chats will be eligible for the giveaway
|
||||
//@has_public_winners True, if the list of winners of the giveaway will be available to everyone
|
||||
//@country_codes The list of two-letter ISO 3166-1 alpha-2 codes of countries, users from which will be eligible for the giveaway. If empty, then all users can participate in the giveaway.
|
||||
//-There can be up to getOption("giveaway_country_count_max") chosen countries. Users with phone number that was bought on Fragment can participate in any giveaway and the country code "FT" must not be specified in the list
|
||||
//-There can be up to getOption("giveaway_country_count_max") chosen countries. Users with phone number that was bought at https://fragment.com can participate in any giveaway and the country code "FT" must not be specified in the list
|
||||
//@prize_description Additional description of the giveaway prize; 0-128 characters
|
||||
premiumGiveawayParameters boosted_chat_id:int53 additional_chat_ids:vector<int53> winners_selection_date:int32 only_new_members:Bool has_public_winners:Bool country_codes:vector<string> prize_description:string = PremiumGiveawayParameters;
|
||||
|
||||
@ -5197,7 +5216,7 @@ checkChatUsernameResultUsernameInvalid = CheckChatUsernameResult;
|
||||
//@description The username is occupied
|
||||
checkChatUsernameResultUsernameOccupied = CheckChatUsernameResult;
|
||||
|
||||
//@description The username can be purchased at fragment.com
|
||||
//@description The username can be purchased at https://fragment.com. Information about the username can be received using getCollectibleItemInfo
|
||||
checkChatUsernameResultUsernamePurchasable = CheckChatUsernameResult;
|
||||
|
||||
//@description The user has too many chats with username, one of them must be made private first
|
||||
@ -10265,6 +10284,10 @@ getPhoneNumberInfo phone_number_prefix:string = PhoneNumberInfo;
|
||||
getPhoneNumberInfoSync language_code:string phone_number_prefix:string = PhoneNumberInfo;
|
||||
|
||||
|
||||
//@description Returns information about a given collectible item that was purchased at https://fragment.com @type Type of the collectible item
|
||||
getCollectibleItemInfo type:CollectibleItemType = CollectibleItemInfo;
|
||||
|
||||
|
||||
//@description Returns information about a tg:// deep link. Use "tg://need_update_for_some_feature" or "tg:some_unsupported_feature" for testing. Returns a 404 error for unknown links. Can be called before authorization @link The link
|
||||
getDeepLinkInfo link:string = DeepLinkInfo;
|
||||
|
||||
|
@ -765,6 +765,44 @@ class GetBankCardInfoQuery final : public Td::ResultHandler {
|
||||
}
|
||||
};
|
||||
|
||||
class GetCollectibleInfoQuery final : public Td::ResultHandler {
|
||||
Promise<td_api::object_ptr<td_api::collectibleItemInfo>> promise_;
|
||||
|
||||
public:
|
||||
explicit GetCollectibleInfoQuery(Promise<td_api::object_ptr<td_api::collectibleItemInfo>> &&promise)
|
||||
: promise_(std::move(promise)) {
|
||||
}
|
||||
|
||||
void send(telegram_api::object_ptr<telegram_api::InputCollectible> &&input_collectible) {
|
||||
send_query(
|
||||
G()->net_query_creator().create(telegram_api::fragment_getCollectibleInfo(std::move(input_collectible))));
|
||||
}
|
||||
|
||||
void on_result(BufferSlice packet) final {
|
||||
auto result_ptr = fetch_result<telegram_api::fragment_getCollectibleInfo>(packet);
|
||||
if (result_ptr.is_error()) {
|
||||
return on_error(result_ptr.move_as_error());
|
||||
}
|
||||
|
||||
auto result = result_ptr.move_as_ok();
|
||||
if (result->amount_ <= 0 || !check_currency_amount(result->amount_)) {
|
||||
LOG(ERROR) << "Receive invalid collectible item price " << result->amount_;
|
||||
result->amount_ = 0;
|
||||
}
|
||||
if (result->crypto_currency_.empty() || result->crypto_amount_ <= 0) {
|
||||
LOG(ERROR) << "Receive invalid collectible item cryptocurrency price " << result->crypto_amount_;
|
||||
result->crypto_amount_ = 0;
|
||||
}
|
||||
promise_.set_value(td_api::make_object<td_api::collectibleItemInfo>(result->purchase_date_, result->currency_,
|
||||
result->amount_, result->crypto_currency_,
|
||||
result->crypto_amount_, result->url_));
|
||||
}
|
||||
|
||||
void on_error(Status status) final {
|
||||
promise_.set_error(std::move(status));
|
||||
}
|
||||
};
|
||||
|
||||
void answer_shipping_query(Td *td, int64 shipping_query_id,
|
||||
vector<tl_object_ptr<td_api::shippingOption>> &&shipping_options,
|
||||
const string &error_message, Promise<Unit> &&promise) {
|
||||
@ -958,4 +996,33 @@ void get_bank_card_info(Td *td, const string &bank_card_number,
|
||||
td->create_handler<GetBankCardInfoQuery>(std::move(promise))->send(bank_card_number);
|
||||
}
|
||||
|
||||
void get_collectible_info(Td *td, td_api::object_ptr<td_api::CollectibleItemType> type,
|
||||
Promise<td_api::object_ptr<td_api::collectibleItemInfo>> &&promise) {
|
||||
if (type == nullptr) {
|
||||
return promise.set_error(Status::Error(400, "Item type must be non-empty"));
|
||||
}
|
||||
switch (type->get_id()) {
|
||||
case td_api::collectibleItemTypeUsername::ID: {
|
||||
auto username = td_api::move_object_as<td_api::collectibleItemTypeUsername>(type);
|
||||
if (!clean_input_string(username->username_)) {
|
||||
return promise.set_error(Status::Error(400, "Username must be encoded in UTF-8"));
|
||||
}
|
||||
td->create_handler<GetCollectibleInfoQuery>(std::move(promise))
|
||||
->send(telegram_api::make_object<telegram_api::inputCollectibleUsername>(username->username_));
|
||||
break;
|
||||
}
|
||||
case td_api::collectibleItemTypePhoneNumber::ID: {
|
||||
auto phone_number = td_api::move_object_as<td_api::collectibleItemTypePhoneNumber>(type);
|
||||
if (!clean_input_string(phone_number->phone_number_)) {
|
||||
return promise.set_error(Status::Error(400, "Phone number must be encoded in UTF-8"));
|
||||
}
|
||||
td->create_handler<GetCollectibleInfoQuery>(std::move(promise))
|
||||
->send(telegram_api::make_object<telegram_api::inputCollectiblePhone>(phone_number->phone_number_));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
@ -51,4 +51,7 @@ void export_invoice(Td *td, td_api::object_ptr<td_api::InputMessageContent> &&in
|
||||
void get_bank_card_info(Td *td, const string &bank_card_number,
|
||||
Promise<td_api::object_ptr<td_api::bankCardInfo>> &&promise);
|
||||
|
||||
void get_collectible_info(Td *td, td_api::object_ptr<td_api::CollectibleItemType> type,
|
||||
Promise<td_api::object_ptr<td_api::collectibleItemInfo>> &&promise);
|
||||
|
||||
} // namespace td
|
||||
|
@ -9322,6 +9322,11 @@ void Td::on_request(uint64 id, const td_api::getPhoneNumberInfo &request) {
|
||||
country_info_manager_->get_phone_number_info(request.phone_number_prefix_, std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::getCollectibleItemInfo &request) {
|
||||
CREATE_REQUEST_PROMISE();
|
||||
get_collectible_info(this, std::move(request.type_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::getApplicationDownloadLink &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_REQUEST_PROMISE();
|
||||
|
@ -1794,6 +1794,8 @@ class Td final : public Actor {
|
||||
|
||||
void on_request(uint64 id, const td_api::getPhoneNumberInfo &request);
|
||||
|
||||
void on_request(uint64 id, td_api::getCollectibleItemInfo &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::getApplicationDownloadLink &request);
|
||||
|
||||
void on_request(uint64 id, td_api::getDeepLinkInfo &request);
|
||||
|
@ -3275,6 +3275,12 @@ class CliClient final : public Actor {
|
||||
send_request(td_api::make_object<td_api::getPhoneNumberInfo>(args));
|
||||
} else if (op == "gpnis") {
|
||||
execute(td_api::make_object<td_api::getPhoneNumberInfoSync>(rand_bool() ? "en" : "", args));
|
||||
} else if (op == "gciu") {
|
||||
send_request(td_api::make_object<td_api::getCollectibleItemInfo>(
|
||||
td_api::make_object<td_api::collectibleItemTypeUsername>(args)));
|
||||
} else if (op == "gcipn") {
|
||||
send_request(td_api::make_object<td_api::getCollectibleItemInfo>(
|
||||
td_api::make_object<td_api::collectibleItemTypePhoneNumber>(args)));
|
||||
} else if (op == "gadl") {
|
||||
send_request(td_api::make_object<td_api::getApplicationDownloadLink>());
|
||||
} else if (op == "gprl") {
|
||||
|
Loading…
Reference in New Issue
Block a user