///
/// TradeQuote.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 `TradeAsset` to properly resolve imports.
namespace margelo::nitro::rncandle { struct TradeAsset; }
// Forward declaration of `Counterparty` to properly resolve imports.
namespace margelo::nitro::rncandle { struct Counterparty; }

#include "TradeAsset.hpp"
#include "Counterparty.hpp"
#include <string>

namespace margelo::nitro::rncandle {

  /**
   * A struct which can be represented as a JavaScript object (TradeQuote).
   */
  struct TradeQuote {
  public:
    TradeAsset lost     SWIFT_PRIVATE;
    TradeAsset gained     SWIFT_PRIVATE;
    Counterparty counterparty     SWIFT_PRIVATE;
    std::string context     SWIFT_PRIVATE;
    std::string expirationDateTime     SWIFT_PRIVATE;

  public:
    TradeQuote() = default;
    explicit TradeQuote(TradeAsset lost, TradeAsset gained, Counterparty counterparty, std::string context, std::string expirationDateTime): lost(lost), gained(gained), counterparty(counterparty), context(context), expirationDateTime(expirationDateTime) {}
  };

} // namespace margelo::nitro::rncandle

namespace margelo::nitro {

  // C++ TradeQuote <> JS TradeQuote (object)
  template <>
  struct JSIConverter<margelo::nitro::rncandle::TradeQuote> final {
    static inline margelo::nitro::rncandle::TradeQuote fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::rncandle::TradeQuote(
        JSIConverter<margelo::nitro::rncandle::TradeAsset>::fromJSI(runtime, obj.getProperty(runtime, "lost")),
        JSIConverter<margelo::nitro::rncandle::TradeAsset>::fromJSI(runtime, obj.getProperty(runtime, "gained")),
        JSIConverter<margelo::nitro::rncandle::Counterparty>::fromJSI(runtime, obj.getProperty(runtime, "counterparty")),
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "context")),
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "expirationDateTime"))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::rncandle::TradeQuote& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, "lost", JSIConverter<margelo::nitro::rncandle::TradeAsset>::toJSI(runtime, arg.lost));
      obj.setProperty(runtime, "gained", JSIConverter<margelo::nitro::rncandle::TradeAsset>::toJSI(runtime, arg.gained));
      obj.setProperty(runtime, "counterparty", JSIConverter<margelo::nitro::rncandle::Counterparty>::toJSI(runtime, arg.counterparty));
      obj.setProperty(runtime, "context", JSIConverter<std::string>::toJSI(runtime, arg.context));
      obj.setProperty(runtime, "expirationDateTime", JSIConverter<std::string>::toJSI(runtime, arg.expirationDateTime));
      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<margelo::nitro::rncandle::TradeAsset>::canConvert(runtime, obj.getProperty(runtime, "lost"))) return false;
      if (!JSIConverter<margelo::nitro::rncandle::TradeAsset>::canConvert(runtime, obj.getProperty(runtime, "gained"))) return false;
      if (!JSIConverter<margelo::nitro::rncandle::Counterparty>::canConvert(runtime, obj.getProperty(runtime, "counterparty"))) return false;
      if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "context"))) return false;
      if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "expirationDateTime"))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
