///
/// NitroRequestPurchaseAndroid.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 `AndroidSubscriptionOfferInput` to properly resolve imports.
namespace margelo::nitro::iap { struct AndroidSubscriptionOfferInput; }
// Forward declaration of `SubscriptionProductReplacementParamsAndroid` to properly resolve imports.
namespace margelo::nitro::iap { struct SubscriptionProductReplacementParamsAndroid; }

#include <string>
#include <vector>
#include <NitroModules/Null.hpp>
#include <variant>
#include <optional>
#include "AndroidSubscriptionOfferInput.hpp"
#include "SubscriptionProductReplacementParamsAndroid.hpp"

namespace margelo::nitro::iap {

  /**
   * A struct which can be represented as a JavaScript object (NitroRequestPurchaseAndroid).
   */
  struct NitroRequestPurchaseAndroid final {
  public:
    std::vector<std::string> skus     SWIFT_PRIVATE;
    std::optional<std::variant<nitro::NullType, std::string>> obfuscatedAccountId     SWIFT_PRIVATE;
    std::optional<std::variant<nitro::NullType, std::string>> obfuscatedProfileId     SWIFT_PRIVATE;
    std::optional<std::variant<nitro::NullType, bool>> isOfferPersonalized     SWIFT_PRIVATE;
    std::optional<std::variant<nitro::NullType, std::string>> offerToken     SWIFT_PRIVATE;
    std::optional<std::variant<nitro::NullType, std::vector<AndroidSubscriptionOfferInput>>> subscriptionOffers     SWIFT_PRIVATE;
    std::optional<std::variant<nitro::NullType, double>> replacementMode     SWIFT_PRIVATE;
    std::optional<std::variant<nitro::NullType, std::string>> purchaseToken     SWIFT_PRIVATE;
    std::optional<std::variant<nitro::NullType, SubscriptionProductReplacementParamsAndroid>> subscriptionProductReplacementParams     SWIFT_PRIVATE;

  public:
    NitroRequestPurchaseAndroid() = default;
    explicit NitroRequestPurchaseAndroid(std::vector<std::string> skus, std::optional<std::variant<nitro::NullType, std::string>> obfuscatedAccountId, std::optional<std::variant<nitro::NullType, std::string>> obfuscatedProfileId, std::optional<std::variant<nitro::NullType, bool>> isOfferPersonalized, std::optional<std::variant<nitro::NullType, std::string>> offerToken, std::optional<std::variant<nitro::NullType, std::vector<AndroidSubscriptionOfferInput>>> subscriptionOffers, std::optional<std::variant<nitro::NullType, double>> replacementMode, std::optional<std::variant<nitro::NullType, std::string>> purchaseToken, std::optional<std::variant<nitro::NullType, SubscriptionProductReplacementParamsAndroid>> subscriptionProductReplacementParams): skus(skus), obfuscatedAccountId(obfuscatedAccountId), obfuscatedProfileId(obfuscatedProfileId), isOfferPersonalized(isOfferPersonalized), offerToken(offerToken), subscriptionOffers(subscriptionOffers), replacementMode(replacementMode), purchaseToken(purchaseToken), subscriptionProductReplacementParams(subscriptionProductReplacementParams) {}

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

} // namespace margelo::nitro::iap

namespace margelo::nitro {

  // C++ NitroRequestPurchaseAndroid <> JS NitroRequestPurchaseAndroid (object)
  template <>
  struct JSIConverter<margelo::nitro::iap::NitroRequestPurchaseAndroid> final {
    static inline margelo::nitro::iap::NitroRequestPurchaseAndroid fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::iap::NitroRequestPurchaseAndroid(
        JSIConverter<std::vector<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "skus"))),
        JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "obfuscatedAccountId"))),
        JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "obfuscatedProfileId"))),
        JSIConverter<std::optional<std::variant<nitro::NullType, bool>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isOfferPersonalized"))),
        JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "offerToken"))),
        JSIConverter<std::optional<std::variant<nitro::NullType, std::vector<margelo::nitro::iap::AndroidSubscriptionOfferInput>>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "subscriptionOffers"))),
        JSIConverter<std::optional<std::variant<nitro::NullType, double>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "replacementMode"))),
        JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "purchaseToken"))),
        JSIConverter<std::optional<std::variant<nitro::NullType, margelo::nitro::iap::SubscriptionProductReplacementParamsAndroid>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "subscriptionProductReplacementParams")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::iap::NitroRequestPurchaseAndroid& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "skus"), JSIConverter<std::vector<std::string>>::toJSI(runtime, arg.skus));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "obfuscatedAccountId"), JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::toJSI(runtime, arg.obfuscatedAccountId));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "obfuscatedProfileId"), JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::toJSI(runtime, arg.obfuscatedProfileId));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "isOfferPersonalized"), JSIConverter<std::optional<std::variant<nitro::NullType, bool>>>::toJSI(runtime, arg.isOfferPersonalized));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "offerToken"), JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::toJSI(runtime, arg.offerToken));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "subscriptionOffers"), JSIConverter<std::optional<std::variant<nitro::NullType, std::vector<margelo::nitro::iap::AndroidSubscriptionOfferInput>>>>::toJSI(runtime, arg.subscriptionOffers));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "replacementMode"), JSIConverter<std::optional<std::variant<nitro::NullType, double>>>::toJSI(runtime, arg.replacementMode));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "purchaseToken"), JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::toJSI(runtime, arg.purchaseToken));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "subscriptionProductReplacementParams"), JSIConverter<std::optional<std::variant<nitro::NullType, margelo::nitro::iap::SubscriptionProductReplacementParamsAndroid>>>::toJSI(runtime, arg.subscriptionProductReplacementParams));
      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::vector<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "skus")))) return false;
      if (!JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "obfuscatedAccountId")))) return false;
      if (!JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "obfuscatedProfileId")))) return false;
      if (!JSIConverter<std::optional<std::variant<nitro::NullType, bool>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isOfferPersonalized")))) return false;
      if (!JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "offerToken")))) return false;
      if (!JSIConverter<std::optional<std::variant<nitro::NullType, std::vector<margelo::nitro::iap::AndroidSubscriptionOfferInput>>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "subscriptionOffers")))) return false;
      if (!JSIConverter<std::optional<std::variant<nitro::NullType, double>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "replacementMode")))) return false;
      if (!JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "purchaseToken")))) return false;
      if (!JSIConverter<std::optional<std::variant<nitro::NullType, margelo::nitro::iap::SubscriptionProductReplacementParamsAndroid>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "subscriptionProductReplacementParams")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
