///
/// MailAttachmentStruct.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 (MailAttachmentStruct).
   */
  struct MailAttachmentStruct final {
  public:
    std::optional<std::string> partId     SWIFT_PRIVATE;
    std::optional<std::string> filename     SWIFT_PRIVATE;
    std::string mimeType     SWIFT_PRIVATE;
    double size     SWIFT_PRIVATE;
    std::optional<std::string> contentId     SWIFT_PRIVATE;
    bool isInline     SWIFT_PRIVATE;
    std::optional<std::shared_ptr<ArrayBuffer>> data     SWIFT_PRIVATE;

  public:
    MailAttachmentStruct() = default;
    explicit MailAttachmentStruct(std::optional<std::string> partId, std::optional<std::string> filename, std::string mimeType, double size, std::optional<std::string> contentId, bool isInline, std::optional<std::shared_ptr<ArrayBuffer>> data): partId(partId), filename(filename), mimeType(mimeType), size(size), contentId(contentId), isInline(isInline), data(data) {}

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

} // namespace margelo::nitro::mailengine

namespace margelo::nitro {

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

} // namespace margelo::nitro
