///
/// WorkoutSample.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 `WorkoutActivityType` to properly resolve imports.
namespace margelo::nitro::healthkit { enum class WorkoutActivityType; }
// Forward declaration of `Quantity` to properly resolve imports.
namespace margelo::nitro::healthkit { struct Quantity; }
// Forward declaration of `WorkoutEvent` to properly resolve imports.
namespace margelo::nitro::healthkit { struct WorkoutEvent; }
// Forward declaration of `WorkoutActivity` to properly resolve imports.
namespace margelo::nitro::healthkit { struct WorkoutActivity; }
// Forward declaration of `SampleType` to properly resolve imports.
namespace margelo::nitro::healthkit { struct SampleType; }
// Forward declaration of `SourceRevision` to properly resolve imports.
namespace margelo::nitro::healthkit { struct SourceRevision; }
// Forward declaration of `Device` to properly resolve imports.
namespace margelo::nitro::healthkit { struct Device; }

#include "WorkoutActivityType.hpp"
#include "Quantity.hpp"
#include <optional>
#include "WorkoutEvent.hpp"
#include <vector>
#include "WorkoutActivity.hpp"
#include <NitroModules/AnyMap.hpp>
#include "SampleType.hpp"
#include <chrono>
#include <string>
#include "SourceRevision.hpp"
#include "Device.hpp"

namespace margelo::nitro::healthkit {

  /**
   * A struct which can be represented as a JavaScript object (WorkoutSample).
   */
  struct WorkoutSample final {
  public:
    WorkoutActivityType workoutActivityType     SWIFT_PRIVATE;
    Quantity duration     SWIFT_PRIVATE;
    std::optional<Quantity> totalEnergyBurned     SWIFT_PRIVATE;
    std::optional<Quantity> totalDistance     SWIFT_PRIVATE;
    std::optional<Quantity> totalSwimmingStrokeCount     SWIFT_PRIVATE;
    std::optional<Quantity> totalFlightsClimbed     SWIFT_PRIVATE;
    std::optional<std::vector<WorkoutEvent>> events     SWIFT_PRIVATE;
    std::optional<std::vector<WorkoutActivity>> activities     SWIFT_PRIVATE;
    std::shared_ptr<AnyMap> metadata     SWIFT_PRIVATE;
    SampleType sampleType     SWIFT_PRIVATE;
    std::chrono::system_clock::time_point startDate     SWIFT_PRIVATE;
    std::chrono::system_clock::time_point endDate     SWIFT_PRIVATE;
    bool hasUndeterminedDuration     SWIFT_PRIVATE;
    std::string uuid     SWIFT_PRIVATE;
    SourceRevision sourceRevision     SWIFT_PRIVATE;
    std::optional<Device> device     SWIFT_PRIVATE;

  public:
    WorkoutSample() = default;
    explicit WorkoutSample(WorkoutActivityType workoutActivityType, Quantity duration, std::optional<Quantity> totalEnergyBurned, std::optional<Quantity> totalDistance, std::optional<Quantity> totalSwimmingStrokeCount, std::optional<Quantity> totalFlightsClimbed, std::optional<std::vector<WorkoutEvent>> events, std::optional<std::vector<WorkoutActivity>> activities, std::shared_ptr<AnyMap> metadata, SampleType sampleType, std::chrono::system_clock::time_point startDate, std::chrono::system_clock::time_point endDate, bool hasUndeterminedDuration, std::string uuid, SourceRevision sourceRevision, std::optional<Device> device): workoutActivityType(workoutActivityType), duration(duration), totalEnergyBurned(totalEnergyBurned), totalDistance(totalDistance), totalSwimmingStrokeCount(totalSwimmingStrokeCount), totalFlightsClimbed(totalFlightsClimbed), events(events), activities(activities), metadata(metadata), sampleType(sampleType), startDate(startDate), endDate(endDate), hasUndeterminedDuration(hasUndeterminedDuration), uuid(uuid), sourceRevision(sourceRevision), device(device) {}

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

} // namespace margelo::nitro::healthkit

namespace margelo::nitro {

  // C++ WorkoutSample <> JS WorkoutSample (object)
  template <>
  struct JSIConverter<margelo::nitro::healthkit::WorkoutSample> final {
    static inline margelo::nitro::healthkit::WorkoutSample fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::healthkit::WorkoutSample(
        JSIConverter<margelo::nitro::healthkit::WorkoutActivityType>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "workoutActivityType"))),
        JSIConverter<margelo::nitro::healthkit::Quantity>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "duration"))),
        JSIConverter<std::optional<margelo::nitro::healthkit::Quantity>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "totalEnergyBurned"))),
        JSIConverter<std::optional<margelo::nitro::healthkit::Quantity>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "totalDistance"))),
        JSIConverter<std::optional<margelo::nitro::healthkit::Quantity>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "totalSwimmingStrokeCount"))),
        JSIConverter<std::optional<margelo::nitro::healthkit::Quantity>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "totalFlightsClimbed"))),
        JSIConverter<std::optional<std::vector<margelo::nitro::healthkit::WorkoutEvent>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "events"))),
        JSIConverter<std::optional<std::vector<margelo::nitro::healthkit::WorkoutActivity>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "activities"))),
        JSIConverter<std::shared_ptr<AnyMap>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "metadata"))),
        JSIConverter<margelo::nitro::healthkit::SampleType>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "sampleType"))),
        JSIConverter<std::chrono::system_clock::time_point>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "startDate"))),
        JSIConverter<std::chrono::system_clock::time_point>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "endDate"))),
        JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "hasUndeterminedDuration"))),
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "uuid"))),
        JSIConverter<margelo::nitro::healthkit::SourceRevision>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "sourceRevision"))),
        JSIConverter<std::optional<margelo::nitro::healthkit::Device>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "device")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::healthkit::WorkoutSample& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "workoutActivityType"), JSIConverter<margelo::nitro::healthkit::WorkoutActivityType>::toJSI(runtime, arg.workoutActivityType));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "duration"), JSIConverter<margelo::nitro::healthkit::Quantity>::toJSI(runtime, arg.duration));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "totalEnergyBurned"), JSIConverter<std::optional<margelo::nitro::healthkit::Quantity>>::toJSI(runtime, arg.totalEnergyBurned));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "totalDistance"), JSIConverter<std::optional<margelo::nitro::healthkit::Quantity>>::toJSI(runtime, arg.totalDistance));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "totalSwimmingStrokeCount"), JSIConverter<std::optional<margelo::nitro::healthkit::Quantity>>::toJSI(runtime, arg.totalSwimmingStrokeCount));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "totalFlightsClimbed"), JSIConverter<std::optional<margelo::nitro::healthkit::Quantity>>::toJSI(runtime, arg.totalFlightsClimbed));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "events"), JSIConverter<std::optional<std::vector<margelo::nitro::healthkit::WorkoutEvent>>>::toJSI(runtime, arg.events));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "activities"), JSIConverter<std::optional<std::vector<margelo::nitro::healthkit::WorkoutActivity>>>::toJSI(runtime, arg.activities));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "metadata"), JSIConverter<std::shared_ptr<AnyMap>>::toJSI(runtime, arg.metadata));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "sampleType"), JSIConverter<margelo::nitro::healthkit::SampleType>::toJSI(runtime, arg.sampleType));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "startDate"), JSIConverter<std::chrono::system_clock::time_point>::toJSI(runtime, arg.startDate));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "endDate"), JSIConverter<std::chrono::system_clock::time_point>::toJSI(runtime, arg.endDate));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "hasUndeterminedDuration"), JSIConverter<bool>::toJSI(runtime, arg.hasUndeterminedDuration));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "uuid"), JSIConverter<std::string>::toJSI(runtime, arg.uuid));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "sourceRevision"), JSIConverter<margelo::nitro::healthkit::SourceRevision>::toJSI(runtime, arg.sourceRevision));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "device"), JSIConverter<std::optional<margelo::nitro::healthkit::Device>>::toJSI(runtime, arg.device));
      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<margelo::nitro::healthkit::WorkoutActivityType>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "workoutActivityType")))) return false;
      if (!JSIConverter<margelo::nitro::healthkit::Quantity>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "duration")))) return false;
      if (!JSIConverter<std::optional<margelo::nitro::healthkit::Quantity>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "totalEnergyBurned")))) return false;
      if (!JSIConverter<std::optional<margelo::nitro::healthkit::Quantity>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "totalDistance")))) return false;
      if (!JSIConverter<std::optional<margelo::nitro::healthkit::Quantity>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "totalSwimmingStrokeCount")))) return false;
      if (!JSIConverter<std::optional<margelo::nitro::healthkit::Quantity>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "totalFlightsClimbed")))) return false;
      if (!JSIConverter<std::optional<std::vector<margelo::nitro::healthkit::WorkoutEvent>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "events")))) return false;
      if (!JSIConverter<std::optional<std::vector<margelo::nitro::healthkit::WorkoutActivity>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "activities")))) return false;
      if (!JSIConverter<std::shared_ptr<AnyMap>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "metadata")))) return false;
      if (!JSIConverter<margelo::nitro::healthkit::SampleType>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "sampleType")))) return false;
      if (!JSIConverter<std::chrono::system_clock::time_point>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "startDate")))) return false;
      if (!JSIConverter<std::chrono::system_clock::time_point>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "endDate")))) return false;
      if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "hasUndeterminedDuration")))) return false;
      if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "uuid")))) return false;
      if (!JSIConverter<margelo::nitro::healthkit::SourceRevision>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "sourceRevision")))) return false;
      if (!JSIConverter<std::optional<margelo::nitro::healthkit::Device>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "device")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
