///
/// NativeContent.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/AnyMap.hpp>

namespace margelo::nitro::one {

  /**
   * A struct which can be represented as a JavaScript object (NativeContent).
   */
  struct NativeContent final {
  public:
    std::optional<std::string> title     SWIFT_PRIVATE;
    std::optional<std::string> subtitle     SWIFT_PRIVATE;
    std::optional<std::string> body     SWIFT_PRIVATE;
    std::shared_ptr<AnyMap> data     SWIFT_PRIVATE;
    bool sound     SWIFT_PRIVATE;
    std::optional<double> badge     SWIFT_PRIVATE;
    std::optional<std::string> categoryIdentifier     SWIFT_PRIVATE;

  public:
    NativeContent() = default;
    explicit NativeContent(std::optional<std::string> title, std::optional<std::string> subtitle, std::optional<std::string> body, std::shared_ptr<AnyMap> data, bool sound, std::optional<double> badge, std::optional<std::string> categoryIdentifier): title(title), subtitle(subtitle), body(body), data(data), sound(sound), badge(badge), categoryIdentifier(categoryIdentifier) {}

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

} // namespace margelo::nitro::one

namespace margelo::nitro {

  // C++ NativeContent <> JS NativeContent (object)
  template <>
  struct JSIConverter<margelo::nitro::one::NativeContent> final {
    static inline margelo::nitro::one::NativeContent fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::one::NativeContent(
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "title"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "subtitle"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "body"))),
        JSIConverter<std::shared_ptr<AnyMap>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "data"))),
        JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "sound"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "badge"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "categoryIdentifier")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::one::NativeContent& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "title"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.title));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "subtitle"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.subtitle));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "body"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.body));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "data"), JSIConverter<std::shared_ptr<AnyMap>>::toJSI(runtime, arg.data));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "sound"), JSIConverter<bool>::toJSI(runtime, arg.sound));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "badge"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.badge));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "categoryIdentifier"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.categoryIdentifier));
      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, "title")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "subtitle")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "body")))) return false;
      if (!JSIConverter<std::shared_ptr<AnyMap>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "data")))) return false;
      if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "sound")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "badge")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "categoryIdentifier")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
