stripe_form_encodable.h 828 B

123456789101112131415161718192021222324252627282930313233343536373839
  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 <QtCore/QString>
  9. #include <map>
  10. namespace Stripe {
  11. class FormEncodable {
  12. public:
  13. [[nodiscard]] virtual QString rootObjectName() = 0;
  14. [[nodiscard]] virtual std::map<QString, QString> formFieldValues() = 0;
  15. };
  16. template <typename T>
  17. struct MakeEncodable final : FormEncodable {
  18. public:
  19. MakeEncodable(const T &value) : _value(value) {
  20. }
  21. QString rootObjectName() override {
  22. return _value.rootObjectName();
  23. }
  24. std::map<QString, QString> formFieldValues() override {
  25. return _value.formFieldValues();
  26. }
  27. private:
  28. const T &_value;
  29. };
  30. } // namespace Stripe