///
/// LDP_PriceData.hpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2025 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



#include <string>
#include <optional>

namespace margelo::nitro::lunardatepicker {

  /**
   * A struct which can be represented as a JavaScript object (LDP_PriceData).
   */
  struct LDP_PriceData {
  public:
    std::string date     SWIFT_PRIVATE;
    double price     SWIFT_PRIVATE;
    std::optional<bool> isCheapest     SWIFT_PRIVATE;

  public:
    LDP_PriceData() = default;
    explicit LDP_PriceData(std::string date, double price, std::optional<bool> isCheapest): date(date), price(price), isCheapest(isCheapest) {}
  };

} // namespace margelo::nitro::lunardatepicker

namespace margelo::nitro {

  using namespace margelo::nitro::lunardatepicker;

  // C++ LDP_PriceData <> JS LDP_PriceData (object)
  template <>
  struct JSIConverter<LDP_PriceData> final {
    static inline LDP_PriceData fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return LDP_PriceData(
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "date")),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "price")),
        JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, "isCheapest"))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const LDP_PriceData& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, "date", JSIConverter<std::string>::toJSI(runtime, arg.date));
      obj.setProperty(runtime, "price", JSIConverter<double>::toJSI(runtime, arg.price));
      obj.setProperty(runtime, "isCheapest", JSIConverter<std::optional<bool>>::toJSI(runtime, arg.isCheapest));
      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 (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "date"))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "price"))) return false;
      if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, "isCheapest"))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
