///
/// MailHeaderStruct.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 `MailAddressStruct` to properly resolve imports.
namespace margelo::nitro::mailengine { struct MailAddressStruct; }

#include <string>
#include <optional>
#include "MailAddressStruct.hpp"
#include <vector>

namespace margelo::nitro::mailengine {

  /**
   * A struct which can be represented as a JavaScript object (MailHeaderStruct).
   */
  struct MailHeaderStruct final {
  public:
    double uid     SWIFT_PRIVATE;
    std::optional<std::string> messageId     SWIFT_PRIVATE;
    std::optional<std::string> subject     SWIFT_PRIVATE;
    std::vector<MailAddressStruct> from     SWIFT_PRIVATE;
    std::vector<MailAddressStruct> to     SWIFT_PRIVATE;
    std::vector<MailAddressStruct> cc     SWIFT_PRIVATE;
    std::vector<MailAddressStruct> bcc     SWIFT_PRIVATE;
    std::vector<MailAddressStruct> replyTo     SWIFT_PRIVATE;
    std::optional<double> date     SWIFT_PRIVATE;
    std::vector<std::string> flags     SWIFT_PRIVATE;
    std::optional<double> size     SWIFT_PRIVATE;
    bool hasAttachments     SWIFT_PRIVATE;
    std::optional<std::string> inReplyTo     SWIFT_PRIVATE;
    std::vector<std::string> references     SWIFT_PRIVATE;
    std::optional<std::string> preview     SWIFT_PRIVATE;

  public:
    MailHeaderStruct() = default;
    explicit MailHeaderStruct(double uid, std::optional<std::string> messageId, std::optional<std::string> subject, std::vector<MailAddressStruct> from, std::vector<MailAddressStruct> to, std::vector<MailAddressStruct> cc, std::vector<MailAddressStruct> bcc, std::vector<MailAddressStruct> replyTo, std::optional<double> date, std::vector<std::string> flags, std::optional<double> size, bool hasAttachments, std::optional<std::string> inReplyTo, std::vector<std::string> references, std::optional<std::string> preview): uid(uid), messageId(messageId), subject(subject), from(from), to(to), cc(cc), bcc(bcc), replyTo(replyTo), date(date), flags(flags), size(size), hasAttachments(hasAttachments), inReplyTo(inReplyTo), references(references), preview(preview) {}

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

} // namespace margelo::nitro::mailengine

namespace margelo::nitro {

  // C++ MailHeaderStruct <> JS MailHeaderStruct (object)
  template <>
  struct JSIConverter<margelo::nitro::mailengine::MailHeaderStruct> final {
    static inline margelo::nitro::mailengine::MailHeaderStruct fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::mailengine::MailHeaderStruct(
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "uid"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "messageId"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "subject"))),
        JSIConverter<std::vector<margelo::nitro::mailengine::MailAddressStruct>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "from"))),
        JSIConverter<std::vector<margelo::nitro::mailengine::MailAddressStruct>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "to"))),
        JSIConverter<std::vector<margelo::nitro::mailengine::MailAddressStruct>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cc"))),
        JSIConverter<std::vector<margelo::nitro::mailengine::MailAddressStruct>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bcc"))),
        JSIConverter<std::vector<margelo::nitro::mailengine::MailAddressStruct>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "replyTo"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "date"))),
        JSIConverter<std::vector<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "flags"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "size"))),
        JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "hasAttachments"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "inReplyTo"))),
        JSIConverter<std::vector<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "references"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "preview")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::mailengine::MailHeaderStruct& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "uid"), JSIConverter<double>::toJSI(runtime, arg.uid));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "messageId"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.messageId));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "subject"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.subject));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "from"), JSIConverter<std::vector<margelo::nitro::mailengine::MailAddressStruct>>::toJSI(runtime, arg.from));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "to"), JSIConverter<std::vector<margelo::nitro::mailengine::MailAddressStruct>>::toJSI(runtime, arg.to));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "cc"), JSIConverter<std::vector<margelo::nitro::mailengine::MailAddressStruct>>::toJSI(runtime, arg.cc));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "bcc"), JSIConverter<std::vector<margelo::nitro::mailengine::MailAddressStruct>>::toJSI(runtime, arg.bcc));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "replyTo"), JSIConverter<std::vector<margelo::nitro::mailengine::MailAddressStruct>>::toJSI(runtime, arg.replyTo));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "date"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.date));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "flags"), JSIConverter<std::vector<std::string>>::toJSI(runtime, arg.flags));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "size"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.size));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "hasAttachments"), JSIConverter<bool>::toJSI(runtime, arg.hasAttachments));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "inReplyTo"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.inReplyTo));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "references"), JSIConverter<std::vector<std::string>>::toJSI(runtime, arg.references));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "preview"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.preview));
      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<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "uid")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "messageId")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "subject")))) return false;
      if (!JSIConverter<std::vector<margelo::nitro::mailengine::MailAddressStruct>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "from")))) return false;
      if (!JSIConverter<std::vector<margelo::nitro::mailengine::MailAddressStruct>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "to")))) return false;
      if (!JSIConverter<std::vector<margelo::nitro::mailengine::MailAddressStruct>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cc")))) return false;
      if (!JSIConverter<std::vector<margelo::nitro::mailengine::MailAddressStruct>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bcc")))) return false;
      if (!JSIConverter<std::vector<margelo::nitro::mailengine::MailAddressStruct>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "replyTo")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "date")))) return false;
      if (!JSIConverter<std::vector<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "flags")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "size")))) return false;
      if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "hasAttachments")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "inReplyTo")))) return false;
      if (!JSIConverter<std::vector<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "references")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "preview")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
