///
/// CastLoadRequest.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 <unordered_map>
#include <optional>

namespace margelo::nitro::omni {

  /**
   * A struct which can be represented as a JavaScript object (CastLoadRequest).
   */
  struct CastLoadRequest final {
  public:
    std::string castId     SWIFT_PRIVATE;
    std::optional<std::unordered_map<std::string, std::string>> customData     SWIFT_PRIVATE;
    std::optional<double> startTime     SWIFT_PRIVATE;
    bool autoplay     SWIFT_PRIVATE;

  public:
    CastLoadRequest() = default;
    explicit CastLoadRequest(std::string castId, std::optional<std::unordered_map<std::string, std::string>> customData, std::optional<double> startTime, bool autoplay): castId(castId), customData(customData), startTime(startTime), autoplay(autoplay) {}

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

} // namespace margelo::nitro::omni

namespace margelo::nitro {

  // C++ CastLoadRequest <> JS CastLoadRequest (object)
  template <>
  struct JSIConverter<margelo::nitro::omni::CastLoadRequest> final {
    static inline margelo::nitro::omni::CastLoadRequest fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::omni::CastLoadRequest(
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "castId"))),
        JSIConverter<std::optional<std::unordered_map<std::string, std::string>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "customData"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "startTime"))),
        JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "autoplay")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::omni::CastLoadRequest& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "castId"), JSIConverter<std::string>::toJSI(runtime, arg.castId));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "customData"), JSIConverter<std::optional<std::unordered_map<std::string, std::string>>>::toJSI(runtime, arg.customData));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "startTime"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.startTime));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "autoplay"), JSIConverter<bool>::toJSI(runtime, arg.autoplay));
      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::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "castId")))) return false;
      if (!JSIConverter<std::optional<std::unordered_map<std::string, std::string>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "customData")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "startTime")))) return false;
      if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "autoplay")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
