///
/// LightningPaymentResult.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 `BarkVtxo` to properly resolve imports.
namespace margelo::nitro::nitroark { struct BarkVtxo; }

#include <string>
#include <optional>
#include "BarkVtxo.hpp"
#include <vector>

namespace margelo::nitro::nitroark {

  /**
   * A struct which can be represented as a JavaScript object (LightningPaymentResult).
   */
  struct LightningPaymentResult final {
  public:
    std::string state     SWIFT_PRIVATE;
    std::optional<std::string> invoice     SWIFT_PRIVATE;
    std::string payment_hash     SWIFT_PRIVATE;
    std::optional<double> amount     SWIFT_PRIVATE;
    std::vector<BarkVtxo> htlc_vtxos     SWIFT_PRIVATE;
    std::optional<double> movement_id     SWIFT_PRIVATE;
    std::optional<std::string> preimage     SWIFT_PRIVATE;

  public:
    LightningPaymentResult() = default;
    explicit LightningPaymentResult(std::string state, std::optional<std::string> invoice, std::string payment_hash, std::optional<double> amount, std::vector<BarkVtxo> htlc_vtxos, std::optional<double> movement_id, std::optional<std::string> preimage): state(state), invoice(invoice), payment_hash(payment_hash), amount(amount), htlc_vtxos(htlc_vtxos), movement_id(movement_id), preimage(preimage) {}

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

} // namespace margelo::nitro::nitroark

namespace margelo::nitro {

  // C++ LightningPaymentResult <> JS LightningPaymentResult (object)
  template <>
  struct JSIConverter<margelo::nitro::nitroark::LightningPaymentResult> final {
    static inline margelo::nitro::nitroark::LightningPaymentResult fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::nitroark::LightningPaymentResult(
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "state"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "invoice"))),
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "payment_hash"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "amount"))),
        JSIConverter<std::vector<margelo::nitro::nitroark::BarkVtxo>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "htlc_vtxos"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "movement_id"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "preimage")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitroark::LightningPaymentResult& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "state"), JSIConverter<std::string>::toJSI(runtime, arg.state));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "invoice"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.invoice));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "payment_hash"), JSIConverter<std::string>::toJSI(runtime, arg.payment_hash));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "amount"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.amount));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "htlc_vtxos"), JSIConverter<std::vector<margelo::nitro::nitroark::BarkVtxo>>::toJSI(runtime, arg.htlc_vtxos));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "movement_id"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.movement_id));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "preimage"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.preimage));
      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, "state")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "invoice")))) return false;
      if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "payment_hash")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "amount")))) return false;
      if (!JSIConverter<std::vector<margelo::nitro::nitroark::BarkVtxo>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "htlc_vtxos")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "movement_id")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "preimage")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
