///
/// CategorySampleForSaving.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 `CategoryTypeIdentifier` to properly resolve imports.
namespace margelo::nitro::healthkit { enum class CategoryTypeIdentifier; }
// Forward declaration of `SourceRevision` to properly resolve imports.
namespace margelo::nitro::healthkit { struct SourceRevision; }

#include <chrono>
#include "CategoryTypeIdentifier.hpp"
#include <NitroModules/AnyMap.hpp>
#include "SourceRevision.hpp"
#include <optional>

namespace margelo::nitro::healthkit {

  /**
   * A struct which can be represented as a JavaScript object (CategorySampleForSaving).
   */
  struct CategorySampleForSaving final {
  public:
    std::chrono::system_clock::time_point start     SWIFT_PRIVATE;
    std::chrono::system_clock::time_point end     SWIFT_PRIVATE;
    CategoryTypeIdentifier categoryType     SWIFT_PRIVATE;
    double value     SWIFT_PRIVATE;
    std::shared_ptr<AnyMap> metadata     SWIFT_PRIVATE;
    std::optional<SourceRevision> sourceRevision     SWIFT_PRIVATE;

  public:
    CategorySampleForSaving() = default;
    explicit CategorySampleForSaving(std::chrono::system_clock::time_point start, std::chrono::system_clock::time_point end, CategoryTypeIdentifier categoryType, double value, std::shared_ptr<AnyMap> metadata, std::optional<SourceRevision> sourceRevision): start(start), end(end), categoryType(categoryType), value(value), metadata(metadata), sourceRevision(sourceRevision) {}

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

} // namespace margelo::nitro::healthkit

namespace margelo::nitro {

  // C++ CategorySampleForSaving <> JS CategorySampleForSaving (object)
  template <>
  struct JSIConverter<margelo::nitro::healthkit::CategorySampleForSaving> final {
    static inline margelo::nitro::healthkit::CategorySampleForSaving fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::healthkit::CategorySampleForSaving(
        JSIConverter<std::chrono::system_clock::time_point>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "start"))),
        JSIConverter<std::chrono::system_clock::time_point>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "end"))),
        JSIConverter<margelo::nitro::healthkit::CategoryTypeIdentifier>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "categoryType"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "value"))),
        JSIConverter<std::shared_ptr<AnyMap>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "metadata"))),
        JSIConverter<std::optional<margelo::nitro::healthkit::SourceRevision>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "sourceRevision")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::healthkit::CategorySampleForSaving& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "start"), JSIConverter<std::chrono::system_clock::time_point>::toJSI(runtime, arg.start));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "end"), JSIConverter<std::chrono::system_clock::time_point>::toJSI(runtime, arg.end));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "categoryType"), JSIConverter<margelo::nitro::healthkit::CategoryTypeIdentifier>::toJSI(runtime, arg.categoryType));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "value"), JSIConverter<double>::toJSI(runtime, arg.value));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "metadata"), JSIConverter<std::shared_ptr<AnyMap>>::toJSI(runtime, arg.metadata));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "sourceRevision"), JSIConverter<std::optional<margelo::nitro::healthkit::SourceRevision>>::toJSI(runtime, arg.sourceRevision));
      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::chrono::system_clock::time_point>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "start")))) return false;
      if (!JSIConverter<std::chrono::system_clock::time_point>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "end")))) return false;
      if (!JSIConverter<margelo::nitro::healthkit::CategoryTypeIdentifier>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "categoryType")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "value")))) return false;
      if (!JSIConverter<std::shared_ptr<AnyMap>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "metadata")))) return false;
      if (!JSIConverter<std::optional<margelo::nitro::healthkit::SourceRevision>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "sourceRevision")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
