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

namespace margelo::nitro::nitroark {

  /**
   * A struct which can be represented as a JavaScript object (ExitTransactionPackageResult).
   */
  struct ExitTransactionPackageResult final {
  public:
    std::string exit_txid     SWIFT_PRIVATE;
    std::string exit_tx_hex     SWIFT_PRIVATE;
    std::string child_txid     SWIFT_PRIVATE;
    std::string child_tx_hex     SWIFT_PRIVATE;
    std::string child_origin     SWIFT_PRIVATE;
    bool has_child     SWIFT_PRIVATE;

  public:
    ExitTransactionPackageResult() = default;
    explicit ExitTransactionPackageResult(std::string exit_txid, std::string exit_tx_hex, std::string child_txid, std::string child_tx_hex, std::string child_origin, bool has_child): exit_txid(exit_txid), exit_tx_hex(exit_tx_hex), child_txid(child_txid), child_tx_hex(child_tx_hex), child_origin(child_origin), has_child(has_child) {}

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

} // namespace margelo::nitro::nitroark

namespace margelo::nitro {

  // C++ ExitTransactionPackageResult <> JS ExitTransactionPackageResult (object)
  template <>
  struct JSIConverter<margelo::nitro::nitroark::ExitTransactionPackageResult> final {
    static inline margelo::nitro::nitroark::ExitTransactionPackageResult fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::nitroark::ExitTransactionPackageResult(
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "exit_txid"))),
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "exit_tx_hex"))),
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "child_txid"))),
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "child_tx_hex"))),
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "child_origin"))),
        JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "has_child")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitroark::ExitTransactionPackageResult& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "exit_txid"), JSIConverter<std::string>::toJSI(runtime, arg.exit_txid));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "exit_tx_hex"), JSIConverter<std::string>::toJSI(runtime, arg.exit_tx_hex));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "child_txid"), JSIConverter<std::string>::toJSI(runtime, arg.child_txid));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "child_tx_hex"), JSIConverter<std::string>::toJSI(runtime, arg.child_tx_hex));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "child_origin"), JSIConverter<std::string>::toJSI(runtime, arg.child_origin));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "has_child"), JSIConverter<bool>::toJSI(runtime, arg.has_child));
      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, "exit_txid")))) return false;
      if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "exit_tx_hex")))) return false;
      if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "child_txid")))) return false;
      if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "child_tx_hex")))) return false;
      if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "child_origin")))) return false;
      if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "has_child")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
