///
/// JOneTapAuthorizationResult.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 "OneTapAuthorizationResult.hpp"

#include "JVariant_NullType_String.hpp"
#include <NitroModules/JNull.hpp>
#include <NitroModules/Null.hpp>
#include <optional>
#include <string>
#include <variant>

namespace margelo::nitro::nitrogooglesignin {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct OneTapAuthorizationResult by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    OneTapAuthorizationResult toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldAccessToken = clazz->getField<JVariant_NullType_String>("accessToken");
      jni::local_ref<JVariant_NullType_String> accessToken = this->getFieldValue(fieldAccessToken);
      static const auto fieldServerAuthCode = clazz->getField<JVariant_NullType_String>("serverAuthCode");
      jni::local_ref<JVariant_NullType_String> serverAuthCode = this->getFieldValue(fieldServerAuthCode);
      return OneTapAuthorizationResult(
        accessToken != nullptr ? std::make_optional(accessToken->toCpp()) : std::nullopt,
        serverAuthCode != nullptr ? std::make_optional(serverAuthCode->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<JOneTapAuthorizationResult::javaobject> fromCpp(const OneTapAuthorizationResult& value) {
      using JSignature = JOneTapAuthorizationResult(jni::alias_ref<JVariant_NullType_String>, jni::alias_ref<JVariant_NullType_String>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        value.accessToken.has_value() ? JVariant_NullType_String::fromCpp(value.accessToken.value()) : nullptr,
        value.serverAuthCode.has_value() ? JVariant_NullType_String::fromCpp(value.serverAuthCode.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::nitrogooglesignin
