///
/// DfuOptions.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 `DfuFirmwareType` to properly resolve imports.
namespace margelo::nitro::co::zyke::dfu { enum class DfuFirmwareType; }

#include <string>
#include "DfuFirmwareType.hpp"
#include <optional>

namespace margelo::nitro::co::zyke::dfu {

  /**
   * A struct which can be represented as a JavaScript object (DfuOptions).
   */
  struct DfuOptions final {
  public:
    std::string deviceId     SWIFT_PRIVATE;
    std::string filePath     SWIFT_PRIVATE;
    std::optional<DfuFirmwareType> firmwareType     SWIFT_PRIVATE;
    std::optional<double> packetReceiptNotificationParameter     SWIFT_PRIVATE;
    std::optional<bool> forceDfu     SWIFT_PRIVATE;
    std::optional<bool> enableUnsafeExperimentalButtonlessDfu     SWIFT_PRIVATE;
    std::optional<bool> forceScanningForNewAddressInLegacyDfu     SWIFT_PRIVATE;
    std::optional<double> numberOfRetries     SWIFT_PRIVATE;
    std::optional<double> connectionTimeout     SWIFT_PRIVATE;
    std::optional<double> dataObjectPreparationDelay     SWIFT_PRIVATE;
    std::optional<bool> alternativeAdvertisingNameEnabled     SWIFT_PRIVATE;
    std::optional<bool> disableResume     SWIFT_PRIVATE;

  public:
    DfuOptions() = default;
    explicit DfuOptions(std::string deviceId, std::string filePath, std::optional<DfuFirmwareType> firmwareType, std::optional<double> packetReceiptNotificationParameter, std::optional<bool> forceDfu, std::optional<bool> enableUnsafeExperimentalButtonlessDfu, std::optional<bool> forceScanningForNewAddressInLegacyDfu, std::optional<double> numberOfRetries, std::optional<double> connectionTimeout, std::optional<double> dataObjectPreparationDelay, std::optional<bool> alternativeAdvertisingNameEnabled, std::optional<bool> disableResume): deviceId(deviceId), filePath(filePath), firmwareType(firmwareType), packetReceiptNotificationParameter(packetReceiptNotificationParameter), forceDfu(forceDfu), enableUnsafeExperimentalButtonlessDfu(enableUnsafeExperimentalButtonlessDfu), forceScanningForNewAddressInLegacyDfu(forceScanningForNewAddressInLegacyDfu), numberOfRetries(numberOfRetries), connectionTimeout(connectionTimeout), dataObjectPreparationDelay(dataObjectPreparationDelay), alternativeAdvertisingNameEnabled(alternativeAdvertisingNameEnabled), disableResume(disableResume) {}

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

} // namespace margelo::nitro::co::zyke::dfu

namespace margelo::nitro {

  // C++ DfuOptions <> JS DfuOptions (object)
  template <>
  struct JSIConverter<margelo::nitro::co::zyke::dfu::DfuOptions> final {
    static inline margelo::nitro::co::zyke::dfu::DfuOptions fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::co::zyke::dfu::DfuOptions(
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "deviceId"))),
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "filePath"))),
        JSIConverter<std::optional<margelo::nitro::co::zyke::dfu::DfuFirmwareType>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "firmwareType"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "packetReceiptNotificationParameter"))),
        JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "forceDfu"))),
        JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "enableUnsafeExperimentalButtonlessDfu"))),
        JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "forceScanningForNewAddressInLegacyDfu"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "numberOfRetries"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "connectionTimeout"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "dataObjectPreparationDelay"))),
        JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "alternativeAdvertisingNameEnabled"))),
        JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "disableResume")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::co::zyke::dfu::DfuOptions& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "deviceId"), JSIConverter<std::string>::toJSI(runtime, arg.deviceId));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "filePath"), JSIConverter<std::string>::toJSI(runtime, arg.filePath));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "firmwareType"), JSIConverter<std::optional<margelo::nitro::co::zyke::dfu::DfuFirmwareType>>::toJSI(runtime, arg.firmwareType));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "packetReceiptNotificationParameter"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.packetReceiptNotificationParameter));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "forceDfu"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.forceDfu));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "enableUnsafeExperimentalButtonlessDfu"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.enableUnsafeExperimentalButtonlessDfu));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "forceScanningForNewAddressInLegacyDfu"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.forceScanningForNewAddressInLegacyDfu));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "numberOfRetries"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.numberOfRetries));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "connectionTimeout"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.connectionTimeout));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "dataObjectPreparationDelay"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.dataObjectPreparationDelay));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "alternativeAdvertisingNameEnabled"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.alternativeAdvertisingNameEnabled));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "disableResume"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.disableResume));
      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, "deviceId")))) return false;
      if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "filePath")))) return false;
      if (!JSIConverter<std::optional<margelo::nitro::co::zyke::dfu::DfuFirmwareType>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "firmwareType")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "packetReceiptNotificationParameter")))) return false;
      if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "forceDfu")))) return false;
      if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "enableUnsafeExperimentalButtonlessDfu")))) return false;
      if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "forceScanningForNewAddressInLegacyDfu")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "numberOfRetries")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "connectionTimeout")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "dataObjectPreparationDelay")))) return false;
      if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "alternativeAdvertisingNameEnabled")))) return false;
      if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "disableResume")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
