smartglocal_token.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. #pragma once
  8. #include "smartglocal/smartglocal_card.h"
  9. #include <QtCore/QDateTime>
  10. class QJsonObject;
  11. namespace SmartGlocal {
  12. class Token {
  13. public:
  14. Token(const Token &other) = default;
  15. Token &operator=(const Token &other) = default;
  16. Token(Token &&other) = default;
  17. Token &operator=(Token &&other) = default;
  18. ~Token() = default;
  19. [[nodiscard]] QString tokenId() const;
  20. [[nodiscard]] bool livemode() const;
  21. [[nodiscard]] Card card() const;
  22. [[nodiscard]] static Token Empty();
  23. [[nodiscard]] static Token DecodedObjectFromAPIResponse(
  24. QJsonObject object);
  25. [[nodiscard]] bool empty() const;
  26. [[nodiscard]] explicit operator bool() const {
  27. return !empty();
  28. }
  29. private:
  30. explicit Token(QString tokenId);
  31. QString _tokenId;
  32. Card _card = Card::Empty();
  33. };
  34. } // namespace SmartGlocal