///
/// BLEDevice.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 `ManufacturerData` to properly resolve imports.
namespace margelo::nitro::co::zyke::ble { struct ManufacturerData; }
// Forward declaration of `ServiceData` to properly resolve imports.
namespace margelo::nitro::co::zyke::ble { struct ServiceData; }

#include <string>
#include "ManufacturerData.hpp"
#include "ServiceData.hpp"
#include <vector>

namespace margelo::nitro::co::zyke::ble {

  /**
   * A struct which can be represented as a JavaScript object (BLEDevice).
   */
  struct BLEDevice final {
  public:
    std::string id     SWIFT_PRIVATE;
    std::string name     SWIFT_PRIVATE;
    double rssi     SWIFT_PRIVATE;
    ManufacturerData manufacturerData     SWIFT_PRIVATE;
    ServiceData serviceData     SWIFT_PRIVATE;
    std::vector<std::string> serviceUUIDs     SWIFT_PRIVATE;
    bool isConnectable     SWIFT_PRIVATE;
    bool isConnected     SWIFT_PRIVATE;

  public:
    BLEDevice() = default;
    explicit BLEDevice(std::string id, std::string name, double rssi, ManufacturerData manufacturerData, ServiceData serviceData, std::vector<std::string> serviceUUIDs, bool isConnectable, bool isConnected): id(id), name(name), rssi(rssi), manufacturerData(manufacturerData), serviceData(serviceData), serviceUUIDs(serviceUUIDs), isConnectable(isConnectable), isConnected(isConnected) {}

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

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

namespace margelo::nitro {

  // C++ BLEDevice <> JS BLEDevice (object)
  template <>
  struct JSIConverter<margelo::nitro::co::zyke::ble::BLEDevice> final {
    static inline margelo::nitro::co::zyke::ble::BLEDevice fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::co::zyke::ble::BLEDevice(
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "id"))),
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "name"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "rssi"))),
        JSIConverter<margelo::nitro::co::zyke::ble::ManufacturerData>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "manufacturerData"))),
        JSIConverter<margelo::nitro::co::zyke::ble::ServiceData>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "serviceData"))),
        JSIConverter<std::vector<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "serviceUUIDs"))),
        JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isConnectable"))),
        JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isConnected")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::co::zyke::ble::BLEDevice& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "id"), JSIConverter<std::string>::toJSI(runtime, arg.id));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "name"), JSIConverter<std::string>::toJSI(runtime, arg.name));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "rssi"), JSIConverter<double>::toJSI(runtime, arg.rssi));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "manufacturerData"), JSIConverter<margelo::nitro::co::zyke::ble::ManufacturerData>::toJSI(runtime, arg.manufacturerData));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "serviceData"), JSIConverter<margelo::nitro::co::zyke::ble::ServiceData>::toJSI(runtime, arg.serviceData));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "serviceUUIDs"), JSIConverter<std::vector<std::string>>::toJSI(runtime, arg.serviceUUIDs));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "isConnectable"), JSIConverter<bool>::toJSI(runtime, arg.isConnectable));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "isConnected"), JSIConverter<bool>::toJSI(runtime, arg.isConnected));
      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, "id")))) return false;
      if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "name")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "rssi")))) return false;
      if (!JSIConverter<margelo::nitro::co::zyke::ble::ManufacturerData>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "manufacturerData")))) return false;
      if (!JSIConverter<margelo::nitro::co::zyke::ble::ServiceData>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "serviceData")))) return false;
      if (!JSIConverter<std::vector<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "serviceUUIDs")))) return false;
      if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isConnectable")))) return false;
      if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isConnected")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
