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

// Forward declaration of `HttpHeader` to properly resolve imports.
namespace margelo::nitro::nitrofetch { struct HttpHeader; }

#include <string>
#include <unordered_map>
#include "HttpHeader.hpp"
#include <vector>

namespace margelo::nitro::nitrofetch {

  /**
   * A struct which can be represented as a JavaScript object (UrlResponseInfo).
   */
  struct UrlResponseInfo final {
  public:
    std::string url     SWIFT_PRIVATE;
    double httpStatusCode     SWIFT_PRIVATE;
    std::string httpStatusText     SWIFT_PRIVATE;
    std::unordered_map<std::string, std::string> allHeaders     SWIFT_PRIVATE;
    std::vector<HttpHeader> allHeadersAsList     SWIFT_PRIVATE;
    std::vector<std::string> urlChain     SWIFT_PRIVATE;
    std::string negotiatedProtocol     SWIFT_PRIVATE;
    std::string proxyServer     SWIFT_PRIVATE;
    double receivedByteCount     SWIFT_PRIVATE;
    bool wasCached     SWIFT_PRIVATE;

  public:
    UrlResponseInfo() = default;
    explicit UrlResponseInfo(std::string url, double httpStatusCode, std::string httpStatusText, std::unordered_map<std::string, std::string> allHeaders, std::vector<HttpHeader> allHeadersAsList, std::vector<std::string> urlChain, std::string negotiatedProtocol, std::string proxyServer, double receivedByteCount, bool wasCached): url(url), httpStatusCode(httpStatusCode), httpStatusText(httpStatusText), allHeaders(allHeaders), allHeadersAsList(allHeadersAsList), urlChain(urlChain), negotiatedProtocol(negotiatedProtocol), proxyServer(proxyServer), receivedByteCount(receivedByteCount), wasCached(wasCached) {}

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

} // namespace margelo::nitro::nitrofetch

namespace margelo::nitro {

  // C++ UrlResponseInfo <> JS UrlResponseInfo (object)
  template <>
  struct JSIConverter<margelo::nitro::nitrofetch::UrlResponseInfo> final {
    static inline margelo::nitro::nitrofetch::UrlResponseInfo fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::nitrofetch::UrlResponseInfo(
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "url"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "httpStatusCode"))),
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "httpStatusText"))),
        JSIConverter<std::unordered_map<std::string, std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "allHeaders"))),
        JSIConverter<std::vector<margelo::nitro::nitrofetch::HttpHeader>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "allHeadersAsList"))),
        JSIConverter<std::vector<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "urlChain"))),
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "negotiatedProtocol"))),
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "proxyServer"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "receivedByteCount"))),
        JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "wasCached")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitrofetch::UrlResponseInfo& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "url"), JSIConverter<std::string>::toJSI(runtime, arg.url));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "httpStatusCode"), JSIConverter<double>::toJSI(runtime, arg.httpStatusCode));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "httpStatusText"), JSIConverter<std::string>::toJSI(runtime, arg.httpStatusText));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "allHeaders"), JSIConverter<std::unordered_map<std::string, std::string>>::toJSI(runtime, arg.allHeaders));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "allHeadersAsList"), JSIConverter<std::vector<margelo::nitro::nitrofetch::HttpHeader>>::toJSI(runtime, arg.allHeadersAsList));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "urlChain"), JSIConverter<std::vector<std::string>>::toJSI(runtime, arg.urlChain));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "negotiatedProtocol"), JSIConverter<std::string>::toJSI(runtime, arg.negotiatedProtocol));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "proxyServer"), JSIConverter<std::string>::toJSI(runtime, arg.proxyServer));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "receivedByteCount"), JSIConverter<double>::toJSI(runtime, arg.receivedByteCount));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "wasCached"), JSIConverter<bool>::toJSI(runtime, arg.wasCached));
      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, "url")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "httpStatusCode")))) return false;
      if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "httpStatusText")))) return false;
      if (!JSIConverter<std::unordered_map<std::string, std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "allHeaders")))) return false;
      if (!JSIConverter<std::vector<margelo::nitro::nitrofetch::HttpHeader>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "allHeadersAsList")))) return false;
      if (!JSIConverter<std::vector<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "urlChain")))) return false;
      if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "negotiatedProtocol")))) return false;
      if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "proxyServer")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "receivedByteCount")))) return false;
      if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "wasCached")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
