///
/// NitroVerifyPurchaseWithProviderResult.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 `NitroVerifyPurchaseWithIapkitResult` to properly resolve imports.
namespace margelo::nitro::iap { struct NitroVerifyPurchaseWithIapkitResult; }
// Forward declaration of `NitroVerifyPurchaseWithProviderError` to properly resolve imports.
namespace margelo::nitro::iap { struct NitroVerifyPurchaseWithProviderError; }
// Forward declaration of `PurchaseVerificationProvider` to properly resolve imports.
namespace margelo::nitro::iap { enum class PurchaseVerificationProvider; }

#include <NitroModules/Null.hpp>
#include "NitroVerifyPurchaseWithIapkitResult.hpp"
#include <variant>
#include <optional>
#include "NitroVerifyPurchaseWithProviderError.hpp"
#include <vector>
#include "PurchaseVerificationProvider.hpp"

namespace margelo::nitro::iap {

  /**
   * A struct which can be represented as a JavaScript object (NitroVerifyPurchaseWithProviderResult).
   */
  struct NitroVerifyPurchaseWithProviderResult final {
  public:
    std::optional<std::variant<nitro::NullType, NitroVerifyPurchaseWithIapkitResult>> iapkit     SWIFT_PRIVATE;
    std::optional<std::variant<nitro::NullType, std::vector<NitroVerifyPurchaseWithProviderError>>> errors     SWIFT_PRIVATE;
    PurchaseVerificationProvider provider     SWIFT_PRIVATE;

  public:
    NitroVerifyPurchaseWithProviderResult() = default;
    explicit NitroVerifyPurchaseWithProviderResult(std::optional<std::variant<nitro::NullType, NitroVerifyPurchaseWithIapkitResult>> iapkit, std::optional<std::variant<nitro::NullType, std::vector<NitroVerifyPurchaseWithProviderError>>> errors, PurchaseVerificationProvider provider): iapkit(iapkit), errors(errors), provider(provider) {}

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

} // namespace margelo::nitro::iap

namespace margelo::nitro {

  // C++ NitroVerifyPurchaseWithProviderResult <> JS NitroVerifyPurchaseWithProviderResult (object)
  template <>
  struct JSIConverter<margelo::nitro::iap::NitroVerifyPurchaseWithProviderResult> final {
    static inline margelo::nitro::iap::NitroVerifyPurchaseWithProviderResult fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::iap::NitroVerifyPurchaseWithProviderResult(
        JSIConverter<std::optional<std::variant<nitro::NullType, margelo::nitro::iap::NitroVerifyPurchaseWithIapkitResult>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "iapkit"))),
        JSIConverter<std::optional<std::variant<nitro::NullType, std::vector<margelo::nitro::iap::NitroVerifyPurchaseWithProviderError>>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "errors"))),
        JSIConverter<margelo::nitro::iap::PurchaseVerificationProvider>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "provider")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::iap::NitroVerifyPurchaseWithProviderResult& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "iapkit"), JSIConverter<std::optional<std::variant<nitro::NullType, margelo::nitro::iap::NitroVerifyPurchaseWithIapkitResult>>>::toJSI(runtime, arg.iapkit));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "errors"), JSIConverter<std::optional<std::variant<nitro::NullType, std::vector<margelo::nitro::iap::NitroVerifyPurchaseWithProviderError>>>>::toJSI(runtime, arg.errors));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "provider"), JSIConverter<margelo::nitro::iap::PurchaseVerificationProvider>::toJSI(runtime, arg.provider));
      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::optional<std::variant<nitro::NullType, margelo::nitro::iap::NitroVerifyPurchaseWithIapkitResult>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "iapkit")))) return false;
      if (!JSIConverter<std::optional<std::variant<nitro::NullType, std::vector<margelo::nitro::iap::NitroVerifyPurchaseWithProviderError>>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "errors")))) return false;
      if (!JSIConverter<margelo::nitro::iap::PurchaseVerificationProvider>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "provider")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
