///
/// JNitroGoogleSSOConfig.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 "NitroGoogleSSOConfig.hpp"

#include <optional>
#include <string>

namespace margelo::nitro::nitrogooglesso {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct NitroGoogleSSOConfig by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    NitroGoogleSSOConfig toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldNonce = clazz->getField<jni::JString>("nonce");
      jni::local_ref<jni::JString> nonce = this->getFieldValue(fieldNonce);
      static const auto fieldIosClientId = clazz->getField<jni::JString>("iosClientId");
      jni::local_ref<jni::JString> iosClientId = this->getFieldValue(fieldIosClientId);
      static const auto fieldWebClientId = clazz->getField<jni::JString>("webClientId");
      jni::local_ref<jni::JString> webClientId = this->getFieldValue(fieldWebClientId);
      static const auto fieldHostedDomain = clazz->getField<jni::JString>("hostedDomain");
      jni::local_ref<jni::JString> hostedDomain = this->getFieldValue(fieldHostedDomain);
      return NitroGoogleSSOConfig(
        nonce != nullptr ? std::make_optional(nonce->toStdString()) : std::nullopt,
        iosClientId->toStdString(),
        webClientId->toStdString(),
        hostedDomain != nullptr ? std::make_optional(hostedDomain->toStdString()) : 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<JNitroGoogleSSOConfig::javaobject> fromCpp(const NitroGoogleSSOConfig& value) {
      using JSignature = JNitroGoogleSSOConfig(jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        value.nonce.has_value() ? jni::make_jstring(value.nonce.value()) : nullptr,
        jni::make_jstring(value.iosClientId),
        jni::make_jstring(value.webClientId),
        value.hostedDomain.has_value() ? jni::make_jstring(value.hostedDomain.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::nitrogooglesso
