///
/// MailOutgoingAttachment.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>
#include <NitroModules/ArrayBuffer.hpp>

namespace margelo::nitro::mailengine {

  /**
   * A struct which can be represented as a JavaScript object (MailOutgoingAttachment).
   */
  struct MailOutgoingAttachment final {
  public:
    std::string filename     SWIFT_PRIVATE;
    std::optional<std::string> mimeType     SWIFT_PRIVATE;
    std::optional<std::string> path     SWIFT_PRIVATE;
    std::optional<std::shared_ptr<ArrayBuffer>> data     SWIFT_PRIVATE;
    std::optional<std::string> contentId     SWIFT_PRIVATE;
    std::optional<bool> inline     SWIFT_PRIVATE;

  public:
    MailOutgoingAttachment() = default;
    explicit MailOutgoingAttachment(std::string filename, std::optional<std::string> mimeType, std::optional<std::string> path, std::optional<std::shared_ptr<ArrayBuffer>> data, std::optional<std::string> contentId, std::optional<bool> inline): filename(filename), mimeType(mimeType), path(path), data(data), contentId(contentId), inline(inline) {}

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

} // namespace margelo::nitro::mailengine

namespace margelo::nitro {

  // C++ MailOutgoingAttachment <> JS MailOutgoingAttachment (object)
  template <>
  struct JSIConverter<margelo::nitro::mailengine::MailOutgoingAttachment> final {
    static inline margelo::nitro::mailengine::MailOutgoingAttachment fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::mailengine::MailOutgoingAttachment(
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "filename"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "mimeType"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "path"))),
        JSIConverter<std::optional<std::shared_ptr<ArrayBuffer>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "data"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "contentId"))),
        JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "inline")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::mailengine::MailOutgoingAttachment& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "filename"), JSIConverter<std::string>::toJSI(runtime, arg.filename));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "mimeType"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.mimeType));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "path"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.path));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "data"), JSIConverter<std::optional<std::shared_ptr<ArrayBuffer>>>::toJSI(runtime, arg.data));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "contentId"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.contentId));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "inline"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.inline));
      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, "filename")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "mimeType")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "path")))) return false;
      if (!JSIConverter<std::optional<std::shared_ptr<ArrayBuffer>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "data")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "contentId")))) return false;
      if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "inline")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
