Add getBankCardInfo method.

GitOrigin-RevId: 1c3c6f5dae3bd197c9aa6998836ffada58f8a094
This commit is contained in:
levlam 2020-02-13 19:20:34 +03:00
parent 30eaa49ffd
commit a5aaa4d0f1
7 changed files with 60 additions and 1 deletions

View File

@ -1011,6 +1011,13 @@ webPageInstantView page_blocks:vector<PageBlock> version:int32 url:string is_rtl
webPage url:string display_url:string type:string site_name:string title:string description:string photo:photo embed_url:string embed_type:string embed_width:int32 embed_height:int32 duration:int32 author:string animation:animation audio:audio document:document sticker:sticker video:video video_note:videoNote voice_note:voiceNote instant_view_version:int32 = WebPage;
//@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;
//@description Information about a bank card @title Title of the bank card description @actions Actions that can be done with the bank card number
bankCardInfo title:string actions:vector<bankCardActionOpenUrl> = BankCardInfo;
//@description Describes an address @country_code A two-letter ISO 3166-1 alpha-2 country code @state State, if applicable @city City @street_line1 First line of the address @street_line2 Second line of the address @postal_code Address postal code
address country_code:string state:string city:string street_line1:string street_line2:string postal_code:string = Address;
@ -1466,7 +1473,7 @@ textEntityTypeEmailAddress = TextEntityType;
//@description A phone number
textEntityTypePhoneNumber = TextEntityType;
//@description A bank card number
//@description A bank card number. The getBankCardInfo method can be used to get information about the bank card
textEntityTypeBankCardNumber = TextEntityType;
//@description A bold text
@ -4128,6 +4135,10 @@ getAutoDownloadSettingsPresets = AutoDownloadSettingsPresets;
setAutoDownloadSettings settings:autoDownloadSettings type:NetworkType = Ok;
//@description Returns information about a bank card @bank_card_number The bank card number
getBankCardInfo bank_card_number:string = BankCardInfo;
//@description Returns one of the available Telegram Passport elements @type Telegram Passport element type @password Password of the current user
getPassportElement type:PassportElementType password:string = PassportElement;

Binary file not shown.

View File

@ -486,6 +486,37 @@ class ClearSavedInfoQuery : public Td::ResultHandler {
promise_.set_error(std::move(status));
}
};
class GetBankCardInfoQuery : public Td::ResultHandler {
Promise<td_api::object_ptr<td_api::bankCardInfo>> promise_;
public:
explicit GetBankCardInfoQuery(Promise<td_api::object_ptr<td_api::bankCardInfo>> &&promise)
: promise_(std::move(promise)) {
}
void send(const string &bank_card_number) {
send_query(G()->net_query_creator().create(create_storer(telegram_api::payments_getBankCardData(bank_card_number)),
G()->get_webfile_dc_id()));
}
void on_result(uint64 id, BufferSlice packet) override {
auto result_ptr = fetch_result<telegram_api::payments_getBankCardData>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
}
auto response = result_ptr.move_as_ok();
auto actions = transform(response->open_urls_, [](auto &open_url) {
return td_api::make_object<td_api::bankCardActionOpenUrl>(open_url->name_, open_url->url_);
});
promise_.set_value(td_api::make_object<td_api::bankCardInfo>(response->title_, std::move(actions)));
}
void on_error(uint64 id, Status status) override {
promise_.set_error(std::move(status));
}
};
/*
class SendLiteRequestQuery : public Td::ResultHandler {
Promise<td_api::object_ptr<td_api::tonLiteServerResponse>> promise_;
@ -896,6 +927,10 @@ void delete_saved_order_info(Promise<Unit> &&promise) {
void delete_saved_credentials(Promise<Unit> &&promise) {
G()->td().get_actor_unsafe()->create_handler<ClearSavedInfoQuery>(std::move(promise))->send(true, false);
}
void get_bank_card_info(const string &bank_card_number, Promise<td_api::object_ptr<td_api::bankCardInfo>> &&promise) {
G()->td().get_actor_unsafe()->create_handler<GetBankCardInfoQuery>(std::move(promise))->send(bank_card_number);
}
/*
void send_ton_lite_server_request(Slice request, Promise<td_api::object_ptr<td_api::tonLiteServerResponse>> &&promise) {
G()->td().get_actor_unsafe()->create_handler<SendLiteRequestQuery>(std::move(promise))->send(BufferSlice{request});

View File

@ -154,6 +154,8 @@ void delete_saved_order_info(Promise<Unit> &&promise);
void delete_saved_credentials(Promise<Unit> &&promise);
void get_bank_card_info(const string &bank_card_number, Promise<td_api::object_ptr<td_api::bankCardInfo>> &&promise);
// void send_ton_lite_server_request(Slice request, Promise<td_api::object_ptr<td_api::tonLiteServerResponse>> &&promise);
} // namespace td

View File

@ -7337,6 +7337,13 @@ void Td::on_request(uint64 id, td_api::answerPreCheckoutQuery &request) {
answer_pre_checkout_query(request.pre_checkout_query_id_, request.error_message_, std::move(promise));
}
void Td::on_request(uint64 id, td_api::getBankCardInfo &request) {
CHECK_IS_USER();
CLEAN_INPUT_STRING(request.bank_card_number_);
CREATE_REQUEST_PROMISE();
get_bank_card_info(request.bank_card_number_, std::move(promise));
}
void Td::on_request(uint64 id, const td_api::getPaymentForm &request) {
CHECK_IS_USER();
CREATE_REQUEST(GetPaymentFormRequest, request.chat_id_, request.message_id_);

View File

@ -927,6 +927,8 @@ class Td final : public NetQueryCallback {
void on_request(uint64 id, td_api::answerPreCheckoutQuery &request);
void on_request(uint64 id, td_api::getBankCardInfo &request);
void on_request(uint64 id, const td_api::getPaymentForm &request);
void on_request(uint64 id, td_api::validateOrderInfo &request);

View File

@ -1572,6 +1572,8 @@ class CliClient final : public Actor {
std::tie(secret, other_user_ids_str) = split(args);
send_request(td_api::make_object<td_api::registerDevice>(
td_api::make_object<td_api::deviceTokenWebPush>(endpoint, key, secret), as_user_ids(other_user_ids_str)));
} else if (op == "gbci") {
send_request(td_api::make_object<td_api::getBankCardInfo>(args));
} else if (op == "gpf") {
string chat_id;
string message_id;