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

#include "LinkedAccountStatusRef.hpp"
#include <vector>
#include "Trade.hpp"

namespace margelo::nitro::rncandle {

  /**
   * A struct which can be represented as a JavaScript object (TradesResponse).
   */
  struct TradesResponse {
  public:
    std::vector<LinkedAccountStatusRef> linkedAccounts     SWIFT_PRIVATE;
    std::vector<Trade> trades     SWIFT_PRIVATE;

  public:
    TradesResponse() = default;
    explicit TradesResponse(std::vector<LinkedAccountStatusRef> linkedAccounts, std::vector<Trade> trades): linkedAccounts(linkedAccounts), trades(trades) {}
  };

} // namespace margelo::nitro::rncandle

namespace margelo::nitro {

  // C++ TradesResponse <> JS TradesResponse (object)
  template <>
  struct JSIConverter<margelo::nitro::rncandle::TradesResponse> final {
    static inline margelo::nitro::rncandle::TradesResponse fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::rncandle::TradesResponse(
        JSIConverter<std::vector<margelo::nitro::rncandle::LinkedAccountStatusRef>>::fromJSI(runtime, obj.getProperty(runtime, "linkedAccounts")),
        JSIConverter<std::vector<margelo::nitro::rncandle::Trade>>::fromJSI(runtime, obj.getProperty(runtime, "trades"))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::rncandle::TradesResponse& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, "linkedAccounts", JSIConverter<std::vector<margelo::nitro::rncandle::LinkedAccountStatusRef>>::toJSI(runtime, arg.linkedAccounts));
      obj.setProperty(runtime, "trades", JSIConverter<std::vector<margelo::nitro::rncandle::Trade>>::toJSI(runtime, arg.trades));
      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::vector<margelo::nitro::rncandle::LinkedAccountStatusRef>>::canConvert(runtime, obj.getProperty(runtime, "linkedAccounts"))) return false;
      if (!JSIConverter<std::vector<margelo::nitro::rncandle::Trade>>::canConvert(runtime, obj.getProperty(runtime, "trades"))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
