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

// Forward declaration of `ThemeSettings` to properly resolve imports.
namespace margelo::nitro::taponpagseguro { struct ThemeSettings; }

#include <string>
#include <optional>
#include "ThemeSettings.hpp"

namespace margelo::nitro::taponpagseguro {

  /**
   * A struct which can be represented as a JavaScript object (SettingData).
   */
  struct SettingData final {
  public:
    std::string app_key     SWIFT_PRIVATE;
    std::string app_name     SWIFT_PRIVATE;
    std::string app_version     SWIFT_PRIVATE;
    std::optional<bool> enable_taxpass_through     SWIFT_PRIVATE;
    std::optional<ThemeSettings> theme     SWIFT_PRIVATE;

  public:
    SettingData() = default;
    explicit SettingData(std::string app_key, std::string app_name, std::string app_version, std::optional<bool> enable_taxpass_through, std::optional<ThemeSettings> theme): app_key(app_key), app_name(app_name), app_version(app_version), enable_taxpass_through(enable_taxpass_through), theme(theme) {}

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

} // namespace margelo::nitro::taponpagseguro

namespace margelo::nitro {

  // C++ SettingData <> JS SettingData (object)
  template <>
  struct JSIConverter<margelo::nitro::taponpagseguro::SettingData> final {
    static inline margelo::nitro::taponpagseguro::SettingData fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::taponpagseguro::SettingData(
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "app_key"))),
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "app_name"))),
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "app_version"))),
        JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "enable_taxpass_through"))),
        JSIConverter<std::optional<margelo::nitro::taponpagseguro::ThemeSettings>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "theme")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::taponpagseguro::SettingData& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "app_key"), JSIConverter<std::string>::toJSI(runtime, arg.app_key));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "app_name"), JSIConverter<std::string>::toJSI(runtime, arg.app_name));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "app_version"), JSIConverter<std::string>::toJSI(runtime, arg.app_version));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "enable_taxpass_through"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.enable_taxpass_through));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "theme"), JSIConverter<std::optional<margelo::nitro::taponpagseguro::ThemeSettings>>::toJSI(runtime, arg.theme));
      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, "app_key")))) return false;
      if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "app_name")))) return false;
      if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "app_version")))) return false;
      if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "enable_taxpass_through")))) return false;
      if (!JSIConverter<std::optional<margelo::nitro::taponpagseguro::ThemeSettings>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "theme")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
