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

#include <NitroModules/Null.hpp>
#include "AdvancedCommerceItemDetailsIOS.hpp"
#include <variant>
#include <optional>
#include "AdvancedCommerceRefundIOS.hpp"
#include <vector>

namespace margelo::nitro::iap {

  /**
   * A struct which can be represented as a JavaScript object (AdvancedCommerceItemIOS).
   */
  struct AdvancedCommerceItemIOS final {
  public:
    std::optional<std::variant<nitro::NullType, AdvancedCommerceItemDetailsIOS>> details     SWIFT_PRIVATE;
    std::optional<std::variant<nitro::NullType, std::vector<AdvancedCommerceRefundIOS>>> refunds     SWIFT_PRIVATE;
    std::optional<std::variant<nitro::NullType, double>> revocationDate     SWIFT_PRIVATE;

  public:
    AdvancedCommerceItemIOS() = default;
    explicit AdvancedCommerceItemIOS(std::optional<std::variant<nitro::NullType, AdvancedCommerceItemDetailsIOS>> details, std::optional<std::variant<nitro::NullType, std::vector<AdvancedCommerceRefundIOS>>> refunds, std::optional<std::variant<nitro::NullType, double>> revocationDate): details(details), refunds(refunds), revocationDate(revocationDate) {}

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

} // namespace margelo::nitro::iap

namespace margelo::nitro {

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

} // namespace margelo::nitro
