///
/// PTWifiEntry.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



#include <string>
#include <optional>

namespace margelo::nitro::espprovtoolkit {

  /**
   * A struct which can be represented as a JavaScript object (PTWifiEntry).
   */
  struct PTWifiEntry final {
  public:
    std::string ssid     SWIFT_PRIVATE;
    double rssi     SWIFT_PRIVATE;
    double auth     SWIFT_PRIVATE;
    std::optional<std::string> bssid     SWIFT_PRIVATE;
    std::optional<double> channel     SWIFT_PRIVATE;

  public:
    PTWifiEntry() = default;
    explicit PTWifiEntry(std::string ssid, double rssi, double auth, std::optional<std::string> bssid, std::optional<double> channel): ssid(ssid), rssi(rssi), auth(auth), bssid(bssid), channel(channel) {}

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

} // namespace margelo::nitro::espprovtoolkit

namespace margelo::nitro {

  // C++ PTWifiEntry <> JS PTWifiEntry (object)
  template <>
  struct JSIConverter<margelo::nitro::espprovtoolkit::PTWifiEntry> final {
    static inline margelo::nitro::espprovtoolkit::PTWifiEntry fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::espprovtoolkit::PTWifiEntry(
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "ssid"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "rssi"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "auth"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bssid"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "channel")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::espprovtoolkit::PTWifiEntry& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "ssid"), JSIConverter<std::string>::toJSI(runtime, arg.ssid));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "rssi"), JSIConverter<double>::toJSI(runtime, arg.rssi));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "auth"), JSIConverter<double>::toJSI(runtime, arg.auth));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "bssid"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.bssid));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "channel"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.channel));
      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, "ssid")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "rssi")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "auth")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bssid")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "channel")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
