///
/// WalletSnapshotInfo.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>
#include <optional>

namespace margelo::nitro::nitroark {

  /**
   * A struct which can be represented as a JavaScript object (WalletSnapshotInfo).
   */
  struct WalletSnapshotInfo final {
  public:
    std::string path     SWIFT_PRIVATE;
    double sizeBytes     SWIFT_PRIVATE;
    std::string sha256     SWIFT_PRIVATE;
    std::string network     SWIFT_PRIVATE;
    std::string walletFingerprint     SWIFT_PRIVATE;
    std::optional<std::string> serverPubkey     SWIFT_PRIVATE;
    std::optional<std::string> mailboxPubkey     SWIFT_PRIVATE;
    double schemaVersion     SWIFT_PRIVATE;

  public:
    WalletSnapshotInfo() = default;
    explicit WalletSnapshotInfo(std::string path, double sizeBytes, std::string sha256, std::string network, std::string walletFingerprint, std::optional<std::string> serverPubkey, std::optional<std::string> mailboxPubkey, double schemaVersion): path(path), sizeBytes(sizeBytes), sha256(sha256), network(network), walletFingerprint(walletFingerprint), serverPubkey(serverPubkey), mailboxPubkey(mailboxPubkey), schemaVersion(schemaVersion) {}

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

} // namespace margelo::nitro::nitroark

namespace margelo::nitro {

  // C++ WalletSnapshotInfo <> JS WalletSnapshotInfo (object)
  template <>
  struct JSIConverter<margelo::nitro::nitroark::WalletSnapshotInfo> final {
    static inline margelo::nitro::nitroark::WalletSnapshotInfo fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::nitroark::WalletSnapshotInfo(
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "path"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "sizeBytes"))),
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "sha256"))),
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "network"))),
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "walletFingerprint"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "serverPubkey"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "mailboxPubkey"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "schemaVersion")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitroark::WalletSnapshotInfo& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "path"), JSIConverter<std::string>::toJSI(runtime, arg.path));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "sizeBytes"), JSIConverter<double>::toJSI(runtime, arg.sizeBytes));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "sha256"), JSIConverter<std::string>::toJSI(runtime, arg.sha256));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "network"), JSIConverter<std::string>::toJSI(runtime, arg.network));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "walletFingerprint"), JSIConverter<std::string>::toJSI(runtime, arg.walletFingerprint));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "serverPubkey"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.serverPubkey));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "mailboxPubkey"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.mailboxPubkey));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "schemaVersion"), JSIConverter<double>::toJSI(runtime, arg.schemaVersion));
      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, "path")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "sizeBytes")))) return false;
      if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "sha256")))) return false;
      if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "network")))) return false;
      if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "walletFingerprint")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "serverPubkey")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "mailboxPubkey")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "schemaVersion")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
