| 547 | } |
| 548 | |
| 549 | rpl::producer<rpl::no_value, QString> PremiumGiftCodeOptions::applyPrepaid( |
| 550 | const Payments::InvoicePremiumGiftCode &invoice, |
| 551 | uint64 prepaidId) { |
| 552 | return [=](auto consumer) { |
| 553 | auto lifetime = rpl::lifetime(); |
| 554 | const auto channel = _peer->asChannel(); |
| 555 | if (!channel) { |
| 556 | return lifetime; |
| 557 | } |
| 558 | |
| 559 | _api.request(MTPpayments_LaunchPrepaidGiveaway( |
| 560 | _peer->input(), |
| 561 | MTP_long(prepaidId), |
| 562 | invoice.giveawayCredits |
| 563 | ? Payments::InvoiceCreditsGiveawayToTL(invoice) |
| 564 | : Payments::InvoicePremiumGiftCodeGiveawayToTL(invoice) |
| 565 | )).done([=](const MTPUpdates &result) { |
| 566 | _peer->session().api().applyUpdates(result); |
| 567 | consumer.put_done(); |
| 568 | }).fail([=](const MTP::Error &error) { |
| 569 | consumer.put_error_copy(error.type()); |
| 570 | }).send(); |
| 571 | |
| 572 | return lifetime; |
| 573 | }; |
| 574 | } |
| 575 | |
| 576 | const std::vector<int> &PremiumGiftCodeOptions::availablePresets() const { |
| 577 | return _availablePresets; |
no test coverage detected