///
/// BarkVtxo.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 (BarkVtxo).
   */
  struct BarkVtxo final {
  public:
    std::string id     SWIFT_PRIVATE;
    double amount     SWIFT_PRIVATE;
    double expiry_height     SWIFT_PRIVATE;
    std::string server_pubkey     SWIFT_PRIVATE;
    double exit_delta     SWIFT_PRIVATE;
    std::string anchor_point     SWIFT_PRIVATE;
    std::string point     SWIFT_PRIVATE;
    std::string state     SWIFT_PRIVATE;

  public:
    BarkVtxo() = default;
    explicit BarkVtxo(std::string id, double amount, double expiry_height, std::string server_pubkey, double exit_delta, std::string anchor_point, std::string point, std::string state): id(id), amount(amount), expiry_height(expiry_height), server_pubkey(server_pubkey), exit_delta(exit_delta), anchor_point(anchor_point), point(point), state(state) {}

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

} // namespace margelo::nitro::nitroark

namespace margelo::nitro {

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

} // namespace margelo::nitro
