stripe_token.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 "stripe/stripe_card.h"
  9. #include <QtCore/QDateTime>
  10. class QJsonObject;
  11. namespace Stripe {
  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. Token(QString tokenId, bool livemode, QDateTime created);
  31. QString _tokenId;
  32. bool _livemode = false;
  33. QDateTime _created;
  34. Card _card = Card::Empty();
  35. };
  36. } // namespace Stripe