///
/// AdServicesAttributionDataResponse.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 `AppleAdsAttributionData` to properly resolve imports.
namespace margelo::nitro::nitroappleadattribution { struct AppleAdsAttributionData; }

#include "AppleAdsAttributionData.hpp"
#include <exception>

namespace margelo::nitro::nitroappleadattribution {

  /**
   * A struct which can be represented as a JavaScript object (AdServicesAttributionDataResponse).
   */
  struct AdServicesAttributionDataResponse {
  public:
    AppleAdsAttributionData data     SWIFT_PRIVATE;
    std::exception_ptr error     SWIFT_PRIVATE;

  public:
    AdServicesAttributionDataResponse() = default;
    explicit AdServicesAttributionDataResponse(AppleAdsAttributionData data, std::exception_ptr error): data(data), error(error) {}
  };

} // namespace margelo::nitro::nitroappleadattribution

namespace margelo::nitro {

  using namespace margelo::nitro::nitroappleadattribution;

  // C++ AdServicesAttributionDataResponse <> JS AdServicesAttributionDataResponse (object)
  template <>
  struct JSIConverter<AdServicesAttributionDataResponse> final {
    static inline AdServicesAttributionDataResponse fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return AdServicesAttributionDataResponse(
        JSIConverter<AppleAdsAttributionData>::fromJSI(runtime, obj.getProperty(runtime, "data")),
        JSIConverter<std::exception_ptr>::fromJSI(runtime, obj.getProperty(runtime, "error"))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const AdServicesAttributionDataResponse& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, "data", JSIConverter<AppleAdsAttributionData>::toJSI(runtime, arg.data));
      obj.setProperty(runtime, "error", JSIConverter<std::exception_ptr>::toJSI(runtime, arg.error));
      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<AppleAdsAttributionData>::canConvert(runtime, obj.getProperty(runtime, "data"))) return false;
      if (!JSIConverter<std::exception_ptr>::canConvert(runtime, obj.getProperty(runtime, "error"))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
