///
/// NitroRequestPurchaseIos.hpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © Marc Rousavy @ Margelo
///

#pragma once

#if __has_include(<NitroModules/JSIConverter.hpp>)
#include <NitroModules/JSIConverter.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/NitroDefines.hpp>)
#include <NitroModules/NitroDefines.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/JSIHelpers.hpp>)
#include <NitroModules/JSIHelpers.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
#include <NitroModules/PropNameIDCache.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif

// Forward declaration of `PromotionalOfferJwsInputIOS` to properly resolve imports.
namespace margelo::nitro::iap { struct PromotionalOfferJwsInputIOS; }
// Forward declaration of `WinBackOfferInputIOS` to properly resolve imports.
namespace margelo::nitro::iap { struct WinBackOfferInputIOS; }

#include <string>
#include <NitroModules/Null.hpp>
#include <variant>
#include <optional>
#include <unordered_map>
#include "PromotionalOfferJwsInputIOS.hpp"
#include "WinBackOfferInputIOS.hpp"

namespace margelo::nitro::iap {

  /**
   * A struct which can be represented as a JavaScript object (NitroRequestPurchaseIos).
   */
  struct NitroRequestPurchaseIos final {
  public:
    std::string sku     SWIFT_PRIVATE;
    std::optional<std::variant<nitro::NullType, bool>> andDangerouslyFinishTransactionAutomatically     SWIFT_PRIVATE;
    std::optional<std::variant<nitro::NullType, std::string>> appAccountToken     SWIFT_PRIVATE;
    std::optional<std::variant<nitro::NullType, double>> quantity     SWIFT_PRIVATE;
    std::optional<std::variant<nitro::NullType, std::unordered_map<std::string, std::string>>> withOffer     SWIFT_PRIVATE;
    std::optional<std::variant<nitro::NullType, std::string>> advancedCommerceData     SWIFT_PRIVATE;
    std::optional<std::variant<nitro::NullType, bool>> introductoryOfferEligibility     SWIFT_PRIVATE;
    std::optional<std::variant<nitro::NullType, PromotionalOfferJwsInputIOS>> promotionalOfferJWS     SWIFT_PRIVATE;
    std::optional<std::variant<nitro::NullType, WinBackOfferInputIOS>> winBackOffer     SWIFT_PRIVATE;

  public:
    NitroRequestPurchaseIos() = default;
    explicit NitroRequestPurchaseIos(std::string sku, std::optional<std::variant<nitro::NullType, bool>> andDangerouslyFinishTransactionAutomatically, std::optional<std::variant<nitro::NullType, std::string>> appAccountToken, std::optional<std::variant<nitro::NullType, double>> quantity, std::optional<std::variant<nitro::NullType, std::unordered_map<std::string, std::string>>> withOffer, std::optional<std::variant<nitro::NullType, std::string>> advancedCommerceData, std::optional<std::variant<nitro::NullType, bool>> introductoryOfferEligibility, std::optional<std::variant<nitro::NullType, PromotionalOfferJwsInputIOS>> promotionalOfferJWS, std::optional<std::variant<nitro::NullType, WinBackOfferInputIOS>> winBackOffer): sku(sku), andDangerouslyFinishTransactionAutomatically(andDangerouslyFinishTransactionAutomatically), appAccountToken(appAccountToken), quantity(quantity), withOffer(withOffer), advancedCommerceData(advancedCommerceData), introductoryOfferEligibility(introductoryOfferEligibility), promotionalOfferJWS(promotionalOfferJWS), winBackOffer(winBackOffer) {}

  public:
    friend bool operator==(const NitroRequestPurchaseIos& lhs, const NitroRequestPurchaseIos& rhs) = default;
  };

} // namespace margelo::nitro::iap

namespace margelo::nitro {

  // C++ NitroRequestPurchaseIos <> JS NitroRequestPurchaseIos (object)
  template <>
  struct JSIConverter<margelo::nitro::iap::NitroRequestPurchaseIos> final {
    static inline margelo::nitro::iap::NitroRequestPurchaseIos fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::iap::NitroRequestPurchaseIos(
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "sku"))),
        JSIConverter<std::optional<std::variant<nitro::NullType, bool>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "andDangerouslyFinishTransactionAutomatically"))),
        JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "appAccountToken"))),
        JSIConverter<std::optional<std::variant<nitro::NullType, double>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "quantity"))),
        JSIConverter<std::optional<std::variant<nitro::NullType, std::unordered_map<std::string, std::string>>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "withOffer"))),
        JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "advancedCommerceData"))),
        JSIConverter<std::optional<std::variant<nitro::NullType, bool>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "introductoryOfferEligibility"))),
        JSIConverter<std::optional<std::variant<nitro::NullType, margelo::nitro::iap::PromotionalOfferJwsInputIOS>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "promotionalOfferJWS"))),
        JSIConverter<std::optional<std::variant<nitro::NullType, margelo::nitro::iap::WinBackOfferInputIOS>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "winBackOffer")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::iap::NitroRequestPurchaseIos& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "sku"), JSIConverter<std::string>::toJSI(runtime, arg.sku));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "andDangerouslyFinishTransactionAutomatically"), JSIConverter<std::optional<std::variant<nitro::NullType, bool>>>::toJSI(runtime, arg.andDangerouslyFinishTransactionAutomatically));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "appAccountToken"), JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::toJSI(runtime, arg.appAccountToken));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "quantity"), JSIConverter<std::optional<std::variant<nitro::NullType, double>>>::toJSI(runtime, arg.quantity));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "withOffer"), JSIConverter<std::optional<std::variant<nitro::NullType, std::unordered_map<std::string, std::string>>>>::toJSI(runtime, arg.withOffer));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "advancedCommerceData"), JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::toJSI(runtime, arg.advancedCommerceData));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "introductoryOfferEligibility"), JSIConverter<std::optional<std::variant<nitro::NullType, bool>>>::toJSI(runtime, arg.introductoryOfferEligibility));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "promotionalOfferJWS"), JSIConverter<std::optional<std::variant<nitro::NullType, margelo::nitro::iap::PromotionalOfferJwsInputIOS>>>::toJSI(runtime, arg.promotionalOfferJWS));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "winBackOffer"), JSIConverter<std::optional<std::variant<nitro::NullType, margelo::nitro::iap::WinBackOfferInputIOS>>>::toJSI(runtime, arg.winBackOffer));
      return obj;
    }
    static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
      if (!value.isObject()) {
        return false;
      }
      jsi::Object obj = value.getObject(runtime);
      if (!nitro::isPlainObject(runtime, obj)) {
        return false;
      }
      if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "sku")))) return false;
      if (!JSIConverter<std::optional<std::variant<nitro::NullType, bool>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "andDangerouslyFinishTransactionAutomatically")))) return false;
      if (!JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "appAccountToken")))) return false;
      if (!JSIConverter<std::optional<std::variant<nitro::NullType, double>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "quantity")))) return false;
      if (!JSIConverter<std::optional<std::variant<nitro::NullType, std::unordered_map<std::string, std::string>>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "withOffer")))) return false;
      if (!JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "advancedCommerceData")))) return false;
      if (!JSIConverter<std::optional<std::variant<nitro::NullType, bool>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "introductoryOfferEligibility")))) return false;
      if (!JSIConverter<std::optional<std::variant<nitro::NullType, margelo::nitro::iap::PromotionalOfferJwsInputIOS>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "promotionalOfferJWS")))) return false;
      if (!JSIConverter<std::optional<std::variant<nitro::NullType, margelo::nitro::iap::WinBackOfferInputIOS>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "winBackOffer")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
