MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / request

Method request

Telegram/SourceFiles/api/api_premium.cpp:497–547  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

495}
496
497rpl::producer<rpl::no_value, QString> PremiumGiftCodeOptions::request() {
498 return [=](auto consumer) {
499 auto lifetime = rpl::lifetime();
500
501 using TLOption = MTPPremiumGiftCodeOption;
502 _api.request(MTPpayments_GetPremiumGiftCodeOptions(
503 MTP_flags(_peer->isChannel()
504 ? MTPpayments_GetPremiumGiftCodeOptions::Flag::f_boost_peer
505 : MTPpayments_GetPremiumGiftCodeOptions::Flag(0)),
506 _peer->input()
507 )).done([=](const MTPVector<TLOption> &result) {
508 auto tlMapOptions = base::flat_map<Amount, QVector<TLOption>>();
509 for (const auto &tlOption : result.v) {
510 const auto &data = tlOption.data();
511 tlMapOptions[data.vusers().v].push_back(tlOption);
512 if (qs(data.vcurrency()) == Ui::kCreditsCurrency) {
513 continue;
514 }
515
516 const auto token = Token{ data.vusers().v, data.vmonths().v };
517 _stores[token] = Store{
518 .amount = data.vamount().v,
519 .currency = qs(data.vcurrency()),
520 .product = qs(data.vstore_product().value_or_empty()),
521 .quantity = data.vstore_quantity().value_or_empty(),
522 };
523 if (!ranges::contains(_availablePresets, data.vusers().v)) {
524 _availablePresets.push_back(data.vusers().v);
525 }
526 }
527 for (const auto &[amount, tlOptions] : tlMapOptions) {
528 if (amount == 1 && _optionsForOnePerson.currencies.empty()) {
529 for (const auto &option : tlOptions) {
530 _optionsForOnePerson.months.push_back(
531 option.data().vmonths().v);
532 _optionsForOnePerson.totalCosts.push_back(
533 option.data().vamount().v);
534 _optionsForOnePerson.currencies.push_back(
535 qs(option.data().vcurrency()));
536 }
537 }
538 _subscriptionOptions[amount] = GiftCodesFromTL(tlOptions);
539 }
540 consumer.put_done();
541 }).fail([=](const MTP::Error &error) {
542 consumer.put_error_copy(error.type());
543 }).send();
544
545 return lifetime;
546 };
547}
548
549rpl::producer<rpl::no_value, QString> PremiumGiftCodeOptions::applyPrepaid(
550 const Payments::InvoicePremiumGiftCode &invoice,

Callers 12

reloadPromoMethod · 0.45
reloadStickersMethod · 0.45
reloadCloudSetMethod · 0.45
reloadHelloStickersMethod · 0.45
checkGiftCodeMethod · 0.45
applyGiftCodeMethod · 0.45
resolveGiveawayInfoMethod · 0.45
applyPrepaidMethod · 0.45
requestStarGiftsMethod · 0.45
toggledMethod · 0.45
setToggledMethod · 0.45

Calls 12

MTP_flagsFunction · 0.85
qsFunction · 0.85
GiftCodesFromTLFunction · 0.85
isChannelMethod · 0.80
FlagEnum · 0.50
sendMethod · 0.45
failMethod · 0.45
doneMethod · 0.45
inputMethod · 0.45
dataMethod · 0.45
emptyMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected