///
/// MailSearchCriteria.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::mailengine {

  /**
   * A struct which can be represented as a JavaScript object (MailSearchCriteria).
   */
  struct MailSearchCriteria final {
  public:
    std::optional<std::string> text     SWIFT_PRIVATE;
    std::optional<std::string> from     SWIFT_PRIVATE;
    std::optional<std::string> to     SWIFT_PRIVATE;
    std::optional<std::string> subject     SWIFT_PRIVATE;
    std::optional<std::string> body     SWIFT_PRIVATE;
    std::optional<bool> seen     SWIFT_PRIVATE;
    std::optional<bool> flagged     SWIFT_PRIVATE;
    std::optional<bool> answered     SWIFT_PRIVATE;
    std::optional<double> sinceDateMs     SWIFT_PRIVATE;
    std::optional<double> beforeDateMs     SWIFT_PRIVATE;
    std::optional<double> uidRangeStart     SWIFT_PRIVATE;
    std::optional<double> uidRangeEnd     SWIFT_PRIVATE;

  public:
    MailSearchCriteria() = default;
    explicit MailSearchCriteria(std::optional<std::string> text, std::optional<std::string> from, std::optional<std::string> to, std::optional<std::string> subject, std::optional<std::string> body, std::optional<bool> seen, std::optional<bool> flagged, std::optional<bool> answered, std::optional<double> sinceDateMs, std::optional<double> beforeDateMs, std::optional<double> uidRangeStart, std::optional<double> uidRangeEnd): text(text), from(from), to(to), subject(subject), body(body), seen(seen), flagged(flagged), answered(answered), sinceDateMs(sinceDateMs), beforeDateMs(beforeDateMs), uidRangeStart(uidRangeStart), uidRangeEnd(uidRangeEnd) {}

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

} // namespace margelo::nitro::mailengine

namespace margelo::nitro {

  // C++ MailSearchCriteria <> JS MailSearchCriteria (object)
  template <>
  struct JSIConverter<margelo::nitro::mailengine::MailSearchCriteria> final {
    static inline margelo::nitro::mailengine::MailSearchCriteria fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::mailengine::MailSearchCriteria(
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "text"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "from"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "to"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "subject"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "body"))),
        JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "seen"))),
        JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "flagged"))),
        JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "answered"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "sinceDateMs"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "beforeDateMs"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "uidRangeStart"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "uidRangeEnd")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::mailengine::MailSearchCriteria& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "text"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.text));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "from"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.from));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "to"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.to));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "subject"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.subject));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "body"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.body));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "seen"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.seen));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "flagged"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.flagged));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "answered"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.answered));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "sinceDateMs"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.sinceDateMs));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "beforeDateMs"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.beforeDateMs));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "uidRangeStart"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.uidRangeStart));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "uidRangeEnd"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.uidRangeEnd));
      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::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "text")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "from")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "to")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "subject")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "body")))) return false;
      if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "seen")))) return false;
      if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "flagged")))) return false;
      if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "answered")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "sinceDateMs")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "beforeDateMs")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "uidRangeStart")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "uidRangeEnd")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
