///
/// LnurlPaymentResult.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 `PaymentTypes` to properly resolve imports.
namespace margelo::nitro::nitroark { enum class PaymentTypes; }

#include <string>
#include "PaymentTypes.hpp"

namespace margelo::nitro::nitroark {

  /**
   * A struct which can be represented as a JavaScript object (LnurlPaymentResult).
   */
  struct LnurlPaymentResult {
  public:
    std::string lnurl     SWIFT_PRIVATE;
    std::string bolt11_invoice     SWIFT_PRIVATE;
    std::string preimage     SWIFT_PRIVATE;
    PaymentTypes payment_type     SWIFT_PRIVATE;

  public:
    LnurlPaymentResult() = default;
    explicit LnurlPaymentResult(std::string lnurl, std::string bolt11_invoice, std::string preimage, PaymentTypes payment_type): lnurl(lnurl), bolt11_invoice(bolt11_invoice), preimage(preimage), payment_type(payment_type) {}
  };

} // namespace margelo::nitro::nitroark

namespace margelo::nitro {

  using namespace margelo::nitro::nitroark;

  // C++ LnurlPaymentResult <> JS LnurlPaymentResult (object)
  template <>
  struct JSIConverter<LnurlPaymentResult> final {
    static inline LnurlPaymentResult fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return LnurlPaymentResult(
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "lnurl")),
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "bolt11_invoice")),
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "preimage")),
        JSIConverter<PaymentTypes>::fromJSI(runtime, obj.getProperty(runtime, "payment_type"))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const LnurlPaymentResult& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, "lnurl", JSIConverter<std::string>::toJSI(runtime, arg.lnurl));
      obj.setProperty(runtime, "bolt11_invoice", JSIConverter<std::string>::toJSI(runtime, arg.bolt11_invoice));
      obj.setProperty(runtime, "preimage", JSIConverter<std::string>::toJSI(runtime, arg.preimage));
      obj.setProperty(runtime, "payment_type", JSIConverter<PaymentTypes>::toJSI(runtime, arg.payment_type));
      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, "lnurl"))) return false;
      if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "bolt11_invoice"))) return false;
      if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "preimage"))) return false;
      if (!JSIConverter<PaymentTypes>::canConvert(runtime, obj.getProperty(runtime, "payment_type"))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
