///
/// MailMailboxInfo.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 <vector>
#include <optional>

namespace margelo::nitro::mailengine {

  /**
   * A struct which can be represented as a JavaScript object (MailMailboxInfo).
   */
  struct MailMailboxInfo final {
  public:
    std::string name     SWIFT_PRIVATE;
    std::string path     SWIFT_PRIVATE;
    std::string delimiter     SWIFT_PRIVATE;
    std::vector<std::string> flags     SWIFT_PRIVATE;
    bool selectable     SWIFT_PRIVATE;
    std::optional<double> exists     SWIFT_PRIVATE;
    std::optional<double> unseen     SWIFT_PRIVATE;

  public:
    MailMailboxInfo() = default;
    explicit MailMailboxInfo(std::string name, std::string path, std::string delimiter, std::vector<std::string> flags, bool selectable, std::optional<double> exists, std::optional<double> unseen): name(name), path(path), delimiter(delimiter), flags(flags), selectable(selectable), exists(exists), unseen(unseen) {}

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

} // namespace margelo::nitro::mailengine

namespace margelo::nitro {

  // C++ MailMailboxInfo <> JS MailMailboxInfo (object)
  template <>
  struct JSIConverter<margelo::nitro::mailengine::MailMailboxInfo> final {
    static inline margelo::nitro::mailengine::MailMailboxInfo fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::mailengine::MailMailboxInfo(
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "name"))),
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "path"))),
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "delimiter"))),
        JSIConverter<std::vector<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "flags"))),
        JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "selectable"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "exists"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "unseen")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::mailengine::MailMailboxInfo& 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, "path"), JSIConverter<std::string>::toJSI(runtime, arg.path));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "delimiter"), JSIConverter<std::string>::toJSI(runtime, arg.delimiter));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "flags"), JSIConverter<std::vector<std::string>>::toJSI(runtime, arg.flags));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "selectable"), JSIConverter<bool>::toJSI(runtime, arg.selectable));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "exists"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.exists));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "unseen"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.unseen));
      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<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "path")))) return false;
      if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "delimiter")))) return false;
      if (!JSIConverter<std::vector<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "flags")))) return false;
      if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "selectable")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "exists")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "unseen")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
