///
/// JOneTapResponse.hpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © Marc Rousavy @ Margelo
///

#pragma once

#include <fbjni/fbjni.h>
#include "OneTapResponse.hpp"

#include "JOneTapResponseType.hpp"
#include "JOneTapSuccessData.hpp"
#include "JOneTapUser.hpp"
#include "JVariant_NullType_OneTapSuccessData.hpp"
#include "JVariant_NullType_String.hpp"
#include "OneTapResponseType.hpp"
#include "OneTapSuccessData.hpp"
#include "OneTapUser.hpp"
#include <NitroModules/JNull.hpp>
#include <NitroModules/Null.hpp>
#include <optional>
#include <string>
#include <variant>
#include <vector>

namespace margelo::nitro::nitrogooglesignin {

  using namespace facebook;

  /**
   * The C++ JNI bridge between the C++ struct "OneTapResponse" and the Kotlin data class "OneTapResponse".
   */
  struct JOneTapResponse final: public jni::JavaClass<JOneTapResponse> {
  public:
    static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitrogooglesignin/OneTapResponse;";

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct OneTapResponse by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    OneTapResponse toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldType = clazz->getField<JOneTapResponseType>("type");
      jni::local_ref<JOneTapResponseType> type = this->getFieldValue(fieldType);
      static const auto fieldData = clazz->getField<JVariant_NullType_OneTapSuccessData>("data");
      jni::local_ref<JVariant_NullType_OneTapSuccessData> data = this->getFieldValue(fieldData);
      return OneTapResponse(
        type->toCpp(),
        data != nullptr ? std::make_optional(data->toCpp()) : std::nullopt
      );
    }

  public:
    /**
     * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
     */
    [[maybe_unused]]
    static jni::local_ref<JOneTapResponse::javaobject> fromCpp(const OneTapResponse& value) {
      using JSignature = JOneTapResponse(jni::alias_ref<JOneTapResponseType>, jni::alias_ref<JVariant_NullType_OneTapSuccessData>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        JOneTapResponseType::fromCpp(value.type),
        value.data.has_value() ? JVariant_NullType_OneTapSuccessData::fromCpp(value.data.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::nitrogooglesignin
