smartglocal_token.cpp 975 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #include "smartglocal/smartglocal_token.h"
  8. namespace SmartGlocal {
  9. QString Token::tokenId() const {
  10. return _tokenId;
  11. }
  12. Card Token::card() const {
  13. return _card;
  14. }
  15. Token Token::Empty() {
  16. return Token(QString());
  17. }
  18. Token Token::DecodedObjectFromAPIResponse(QJsonObject object) {
  19. const auto tokenId = object.value("token").toString();
  20. if (tokenId.isEmpty()) {
  21. return Token::Empty();
  22. }
  23. auto result = Token(tokenId);
  24. const auto card = object.value("info");
  25. if (card.isObject()) {
  26. result._card = Card::DecodedObjectFromAPIResponse(card.toObject());
  27. }
  28. return result;
  29. }
  30. bool Token::empty() const {
  31. return _tokenId.isEmpty();
  32. }
  33. Token::Token(QString tokenId)
  34. : _tokenId(std::move(tokenId)) {
  35. }
  36. } // namespace SmartGlocal