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

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

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

namespace margelo::nitro::rncandle {

  /**
   * A struct which can be represented as a JavaScript object (MerchantCounterparty).
   */
  struct MerchantCounterparty {
  public:
    std::string kind     SWIFT_PRIVATE;
    std::string name     SWIFT_PRIVATE;
    std::string logoURL     SWIFT_PRIVATE;
    std::optional<MerchantLocation> location     SWIFT_PRIVATE;

  public:
    MerchantCounterparty() = default;
    explicit MerchantCounterparty(std::string kind, std::string name, std::string logoURL, std::optional<MerchantLocation> location): kind(kind), name(name), logoURL(logoURL), location(location) {}
  };

} // namespace margelo::nitro::rncandle

namespace margelo::nitro {

  // C++ MerchantCounterparty <> JS MerchantCounterparty (object)
  template <>
  struct JSIConverter<margelo::nitro::rncandle::MerchantCounterparty> final {
    static inline margelo::nitro::rncandle::MerchantCounterparty fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::rncandle::MerchantCounterparty(
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "kind")),
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "name")),
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "logoURL")),
        JSIConverter<std::optional<margelo::nitro::rncandle::MerchantLocation>>::fromJSI(runtime, obj.getProperty(runtime, "location"))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::rncandle::MerchantCounterparty& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, "kind", JSIConverter<std::string>::toJSI(runtime, arg.kind));
      obj.setProperty(runtime, "name", JSIConverter<std::string>::toJSI(runtime, arg.name));
      obj.setProperty(runtime, "logoURL", JSIConverter<std::string>::toJSI(runtime, arg.logoURL));
      obj.setProperty(runtime, "location", JSIConverter<std::optional<margelo::nitro::rncandle::MerchantLocation>>::toJSI(runtime, arg.location));
      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, "kind"))) return false;
      if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "name"))) return false;
      if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "logoURL"))) return false;
      if (!JSIConverter<std::optional<margelo::nitro::rncandle::MerchantLocation>>::canConvert(runtime, obj.getProperty(runtime, "location"))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
