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





namespace margelo::nitro::one {

  /**
   * A struct which can be represented as a JavaScript object (LocationPosition).
   */
  struct LocationPosition final {
  public:
    double latitude     SWIFT_PRIVATE;
    double longitude     SWIFT_PRIVATE;
    double accuracy     SWIFT_PRIVATE;
    double altitude     SWIFT_PRIVATE;
    double altitudeAccuracy     SWIFT_PRIVATE;
    double course     SWIFT_PRIVATE;
    double speed     SWIFT_PRIVATE;
    double timestamp     SWIFT_PRIVATE;

  public:
    LocationPosition() = default;
    explicit LocationPosition(double latitude, double longitude, double accuracy, double altitude, double altitudeAccuracy, double course, double speed, double timestamp): latitude(latitude), longitude(longitude), accuracy(accuracy), altitude(altitude), altitudeAccuracy(altitudeAccuracy), course(course), speed(speed), timestamp(timestamp) {}

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

} // namespace margelo::nitro::one

namespace margelo::nitro {

  // C++ LocationPosition <> JS LocationPosition (object)
  template <>
  struct JSIConverter<margelo::nitro::one::LocationPosition> final {
    static inline margelo::nitro::one::LocationPosition fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::one::LocationPosition(
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "latitude"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "longitude"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "accuracy"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "altitude"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "altitudeAccuracy"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "course"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "speed"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "timestamp")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::one::LocationPosition& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "latitude"), JSIConverter<double>::toJSI(runtime, arg.latitude));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "longitude"), JSIConverter<double>::toJSI(runtime, arg.longitude));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "accuracy"), JSIConverter<double>::toJSI(runtime, arg.accuracy));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "altitude"), JSIConverter<double>::toJSI(runtime, arg.altitude));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "altitudeAccuracy"), JSIConverter<double>::toJSI(runtime, arg.altitudeAccuracy));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "course"), JSIConverter<double>::toJSI(runtime, arg.course));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "speed"), JSIConverter<double>::toJSI(runtime, arg.speed));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "timestamp"), JSIConverter<double>::toJSI(runtime, arg.timestamp));
      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<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "latitude")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "longitude")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "accuracy")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "altitude")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "altitudeAccuracy")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "course")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "speed")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "timestamp")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
