///
/// MailOutgoingMessage.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; }
// Forward declaration of `MailOutgoingAttachment` to properly resolve imports.
namespace margelo::nitro::mailengine { struct MailOutgoingAttachment; }

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

namespace margelo::nitro::mailengine {

  /**
   * A struct which can be represented as a JavaScript object (MailOutgoingMessage).
   */
  struct MailOutgoingMessage final {
  public:
    std::optional<MailAddressStruct> from     SWIFT_PRIVATE;
    std::vector<MailAddressStruct> to     SWIFT_PRIVATE;
    std::optional<std::vector<MailAddressStruct>> cc     SWIFT_PRIVATE;
    std::optional<std::vector<MailAddressStruct>> bcc     SWIFT_PRIVATE;
    std::optional<std::vector<MailAddressStruct>> replyTo     SWIFT_PRIVATE;
    std::string subject     SWIFT_PRIVATE;
    std::optional<std::string> text     SWIFT_PRIVATE;
    std::optional<std::string> html     SWIFT_PRIVATE;
    std::optional<std::vector<MailOutgoingAttachment>> attachments     SWIFT_PRIVATE;
    std::optional<std::unordered_map<std::string, std::string>> headers     SWIFT_PRIVATE;
    std::optional<std::string> inReplyTo     SWIFT_PRIVATE;
    std::optional<std::vector<std::string>> references     SWIFT_PRIVATE;

  public:
    MailOutgoingMessage() = default;
    explicit MailOutgoingMessage(std::optional<MailAddressStruct> from, std::vector<MailAddressStruct> to, std::optional<std::vector<MailAddressStruct>> cc, std::optional<std::vector<MailAddressStruct>> bcc, std::optional<std::vector<MailAddressStruct>> replyTo, std::string subject, std::optional<std::string> text, std::optional<std::string> html, std::optional<std::vector<MailOutgoingAttachment>> attachments, std::optional<std::unordered_map<std::string, std::string>> headers, std::optional<std::string> inReplyTo, std::optional<std::vector<std::string>> references): from(from), to(to), cc(cc), bcc(bcc), replyTo(replyTo), subject(subject), text(text), html(html), attachments(attachments), headers(headers), inReplyTo(inReplyTo), references(references) {}

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

} // namespace margelo::nitro::mailengine

namespace margelo::nitro {

  // C++ MailOutgoingMessage <> JS MailOutgoingMessage (object)
  template <>
  struct JSIConverter<margelo::nitro::mailengine::MailOutgoingMessage> final {
    static inline margelo::nitro::mailengine::MailOutgoingMessage fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::mailengine::MailOutgoingMessage(
        JSIConverter<std::optional<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::optional<std::vector<margelo::nitro::mailengine::MailAddressStruct>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cc"))),
        JSIConverter<std::optional<std::vector<margelo::nitro::mailengine::MailAddressStruct>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bcc"))),
        JSIConverter<std::optional<std::vector<margelo::nitro::mailengine::MailAddressStruct>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "replyTo"))),
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "subject"))),
        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, "html"))),
        JSIConverter<std::optional<std::vector<margelo::nitro::mailengine::MailOutgoingAttachment>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "attachments"))),
        JSIConverter<std::optional<std::unordered_map<std::string, std::string>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "headers"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "inReplyTo"))),
        JSIConverter<std::optional<std::vector<std::string>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "references")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::mailengine::MailOutgoingMessage& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "from"), JSIConverter<std::optional<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::optional<std::vector<margelo::nitro::mailengine::MailAddressStruct>>>::toJSI(runtime, arg.cc));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "bcc"), JSIConverter<std::optional<std::vector<margelo::nitro::mailengine::MailAddressStruct>>>::toJSI(runtime, arg.bcc));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "replyTo"), JSIConverter<std::optional<std::vector<margelo::nitro::mailengine::MailAddressStruct>>>::toJSI(runtime, arg.replyTo));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "subject"), JSIConverter<std::string>::toJSI(runtime, arg.subject));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "text"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.text));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "html"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.html));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "attachments"), JSIConverter<std::optional<std::vector<margelo::nitro::mailengine::MailOutgoingAttachment>>>::toJSI(runtime, arg.attachments));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "headers"), JSIConverter<std::optional<std::unordered_map<std::string, std::string>>>::toJSI(runtime, arg.headers));
      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::optional<std::vector<std::string>>>::toJSI(runtime, arg.references));
      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<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::optional<std::vector<margelo::nitro::mailengine::MailAddressStruct>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cc")))) return false;
      if (!JSIConverter<std::optional<std::vector<margelo::nitro::mailengine::MailAddressStruct>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bcc")))) return false;
      if (!JSIConverter<std::optional<std::vector<margelo::nitro::mailengine::MailAddressStruct>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "replyTo")))) return false;
      if (!JSIConverter<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, "text")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "html")))) return false;
      if (!JSIConverter<std::optional<std::vector<margelo::nitro::mailengine::MailOutgoingAttachment>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "attachments")))) return false;
      if (!JSIConverter<std::optional<std::unordered_map<std::string, std::string>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "headers")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "inReplyTo")))) return false;
      if (!JSIConverter<std::optional<std::vector<std::string>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "references")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
