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

namespace margelo::nitro::aviation {

  /**
   * A struct which can be represented as a JavaScript object (AdInfo).
   */
  struct AdInfo final {
  public:
    std::string adId     SWIFT_PRIVATE;
    std::string title     SWIFT_PRIVATE;
    double durationMs     SWIFT_PRIVATE;
    double currentMs     SWIFT_PRIVATE;
    double adIndexInBreak     SWIFT_PRIVATE;
    double totalAdsInBreak     SWIFT_PRIVATE;
    bool isSkippable     SWIFT_PRIVATE;
    double skipOffsetMs     SWIFT_PRIVATE;

  public:
    AdInfo() = default;
    explicit AdInfo(std::string adId, std::string title, double durationMs, double currentMs, double adIndexInBreak, double totalAdsInBreak, bool isSkippable, double skipOffsetMs): adId(adId), title(title), durationMs(durationMs), currentMs(currentMs), adIndexInBreak(adIndexInBreak), totalAdsInBreak(totalAdsInBreak), isSkippable(isSkippable), skipOffsetMs(skipOffsetMs) {}

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

} // namespace margelo::nitro::aviation

namespace margelo::nitro {

  // C++ AdInfo <> JS AdInfo (object)
  template <>
  struct JSIConverter<margelo::nitro::aviation::AdInfo> final {
    static inline margelo::nitro::aviation::AdInfo fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::aviation::AdInfo(
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "adId"))),
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "title"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "durationMs"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "currentMs"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "adIndexInBreak"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "totalAdsInBreak"))),
        JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isSkippable"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "skipOffsetMs")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::aviation::AdInfo& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "adId"), JSIConverter<std::string>::toJSI(runtime, arg.adId));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "title"), JSIConverter<std::string>::toJSI(runtime, arg.title));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "durationMs"), JSIConverter<double>::toJSI(runtime, arg.durationMs));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "currentMs"), JSIConverter<double>::toJSI(runtime, arg.currentMs));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "adIndexInBreak"), JSIConverter<double>::toJSI(runtime, arg.adIndexInBreak));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "totalAdsInBreak"), JSIConverter<double>::toJSI(runtime, arg.totalAdsInBreak));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "isSkippable"), JSIConverter<bool>::toJSI(runtime, arg.isSkippable));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "skipOffsetMs"), JSIConverter<double>::toJSI(runtime, arg.skipOffsetMs));
      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, "adId")))) return false;
      if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "title")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "durationMs")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "currentMs")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "adIndexInBreak")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "totalAdsInBreak")))) return false;
      if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isSkippable")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "skipOffsetMs")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
