///
/// PTDevice.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 `PTSecurity` to properly resolve imports.
namespace margelo::nitro::espprovtoolkit { enum class PTSecurity; }
// Forward declaration of `PTTransport` to properly resolve imports.
namespace margelo::nitro::espprovtoolkit { enum class PTTransport; }

#include <string>
#include "PTSecurity.hpp"
#include "PTTransport.hpp"
#include <optional>
#include <vector>

namespace margelo::nitro::espprovtoolkit {

  /**
   * A struct which can be represented as a JavaScript object (PTDevice).
   */
  struct PTDevice final {
  public:
    std::string name     SWIFT_PRIVATE;
    PTSecurity security     SWIFT_PRIVATE;
    PTTransport transport     SWIFT_PRIVATE;
    std::optional<bool> connected     SWIFT_PRIVATE;
    std::optional<std::string> username     SWIFT_PRIVATE;
    std::optional<std::string> versionInfo     SWIFT_PRIVATE;
    std::optional<std::vector<std::string>> capabilities     SWIFT_PRIVATE;
    std::optional<std::string> advertisementData     SWIFT_PRIVATE;

  public:
    PTDevice() = default;
    explicit PTDevice(std::string name, PTSecurity security, PTTransport transport, std::optional<bool> connected, std::optional<std::string> username, std::optional<std::string> versionInfo, std::optional<std::vector<std::string>> capabilities, std::optional<std::string> advertisementData): name(name), security(security), transport(transport), connected(connected), username(username), versionInfo(versionInfo), capabilities(capabilities), advertisementData(advertisementData) {}

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

} // namespace margelo::nitro::espprovtoolkit

namespace margelo::nitro {

  // C++ PTDevice <> JS PTDevice (object)
  template <>
  struct JSIConverter<margelo::nitro::espprovtoolkit::PTDevice> final {
    static inline margelo::nitro::espprovtoolkit::PTDevice fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::espprovtoolkit::PTDevice(
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "name"))),
        JSIConverter<margelo::nitro::espprovtoolkit::PTSecurity>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "security"))),
        JSIConverter<margelo::nitro::espprovtoolkit::PTTransport>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "transport"))),
        JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "connected"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "username"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "versionInfo"))),
        JSIConverter<std::optional<std::vector<std::string>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "capabilities"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "advertisementData")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::espprovtoolkit::PTDevice& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "name"), JSIConverter<std::string>::toJSI(runtime, arg.name));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "security"), JSIConverter<margelo::nitro::espprovtoolkit::PTSecurity>::toJSI(runtime, arg.security));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "transport"), JSIConverter<margelo::nitro::espprovtoolkit::PTTransport>::toJSI(runtime, arg.transport));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "connected"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.connected));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "username"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.username));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "versionInfo"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.versionInfo));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "capabilities"), JSIConverter<std::optional<std::vector<std::string>>>::toJSI(runtime, arg.capabilities));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "advertisementData"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.advertisementData));
      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, "name")))) return false;
      if (!JSIConverter<margelo::nitro::espprovtoolkit::PTSecurity>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "security")))) return false;
      if (!JSIConverter<margelo::nitro::espprovtoolkit::PTTransport>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "transport")))) return false;
      if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "connected")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "username")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "versionInfo")))) return false;
      if (!JSIConverter<std::optional<std::vector<std::string>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "capabilities")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "advertisementData")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
