| 495 | } |
| 496 | |
| 497 | rpl::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 | |
| 549 | rpl::producer<rpl::no_value, QString> PremiumGiftCodeOptions::applyPrepaid( |
| 550 | const Payments::InvoicePremiumGiftCode &invoice, |
no test coverage detected