///
/// NowPlayingInfo.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 <optional>

namespace margelo::nitro::aviation {

  /**
   * A struct which can be represented as a JavaScript object (NowPlayingInfo).
   */
  struct NowPlayingInfo final {
  public:
    std::optional<std::string> title     SWIFT_PRIVATE;
    std::optional<std::string> artist     SWIFT_PRIVATE;
    std::optional<std::string> album     SWIFT_PRIVATE;
    std::optional<std::string> artworkUri     SWIFT_PRIVATE;
    std::optional<double> durationMs     SWIFT_PRIVATE;
    std::optional<double> currentTimeMs     SWIFT_PRIVATE;
    std::optional<double> rate     SWIFT_PRIVATE;
    std::optional<bool> isLiveStream     SWIFT_PRIVATE;

  public:
    NowPlayingInfo() = default;
    explicit NowPlayingInfo(std::optional<std::string> title, std::optional<std::string> artist, std::optional<std::string> album, std::optional<std::string> artworkUri, std::optional<double> durationMs, std::optional<double> currentTimeMs, std::optional<double> rate, std::optional<bool> isLiveStream): title(title), artist(artist), album(album), artworkUri(artworkUri), durationMs(durationMs), currentTimeMs(currentTimeMs), rate(rate), isLiveStream(isLiveStream) {}

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

} // namespace margelo::nitro::aviation

namespace margelo::nitro {

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

} // namespace margelo::nitro
