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

Method checkGiftCode

Telegram/SourceFiles/api/api_premium.cpp:297–321  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

295}
296
297void Premium::checkGiftCode(
298 const QString &slug,
299 Fn<void(GiftCode)> done) {
300 if (_giftCodeRequestId) {
301 if (_giftCodeSlug == slug) {
302 return;
303 }
304 _api.request(_giftCodeRequestId).cancel();
305 }
306 _giftCodeSlug = slug;
307 _giftCodeRequestId = _api.request(MTPpayments_CheckGiftCode(
308 MTP_string(slug)
309 )).done([=](const MTPpayments_CheckedGiftCode &result) {
310 _giftCodeRequestId = 0;
311
312 const auto &data = result.data();
313 _session->data().processUsers(data.vusers());
314 _session->data().processChats(data.vchats());
315 done(updateGiftCode(slug, Parse(data)));
316 }).fail([=](const MTP::Error &error) {
317 _giftCodeRequestId = 0;
318
319 done(updateGiftCode(slug, {}));
320 }).send();
321}
322
323GiftCode Premium::updateGiftCode(
324 const QString &slug,

Callers 1

ResolveGiftCodeFunction · 0.80

Calls 10

MTP_stringFunction · 0.85
processUsersMethod · 0.80
processChatsMethod · 0.80
ParseFunction · 0.70
cancelMethod · 0.45
requestMethod · 0.45
sendMethod · 0.45
failMethod · 0.45
doneMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected