///
/// TikTokContent.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>

namespace margelo::nitro::tiktokappevents {

  /**
   * A struct which can be represented as a JavaScript object (TikTokContent).
   */
  struct TikTokContent final {
  public:
    std::optional<std::string> contentId     SWIFT_PRIVATE;
    std::optional<std::string> contentCategory     SWIFT_PRIVATE;
    std::optional<std::string> contentName     SWIFT_PRIVATE;
    std::optional<std::string> brand     SWIFT_PRIVATE;
    std::optional<double> price     SWIFT_PRIVATE;
    std::optional<double> quantity     SWIFT_PRIVATE;

  public:
    TikTokContent() = default;
    explicit TikTokContent(std::optional<std::string> contentId, std::optional<std::string> contentCategory, std::optional<std::string> contentName, std::optional<std::string> brand, std::optional<double> price, std::optional<double> quantity): contentId(contentId), contentCategory(contentCategory), contentName(contentName), brand(brand), price(price), quantity(quantity) {}

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

} // namespace margelo::nitro::tiktokappevents

namespace margelo::nitro {

  // C++ TikTokContent <> JS TikTokContent (object)
  template <>
  struct JSIConverter<margelo::nitro::tiktokappevents::TikTokContent> final {
    static inline margelo::nitro::tiktokappevents::TikTokContent fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::tiktokappevents::TikTokContent(
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "contentId"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "contentCategory"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "contentName"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "brand"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "price"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "quantity")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::tiktokappevents::TikTokContent& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "contentId"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.contentId));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "contentCategory"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.contentCategory));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "contentName"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.contentName));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "brand"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.brand));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "price"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.price));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "quantity"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.quantity));
      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, "contentId")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "contentCategory")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "contentName")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "brand")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "price")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "quantity")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
