///
/// JNitroVerifyPurchaseWithIapkitProps.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 "NitroVerifyPurchaseWithIapkitProps.hpp"

#include "JNitroVerifyPurchaseWithIapkitAppleProps.hpp"
#include "JNitroVerifyPurchaseWithIapkitGoogleProps.hpp"
#include "JVariant_NullType_NitroVerifyPurchaseWithIapkitAppleProps.hpp"
#include "JVariant_NullType_NitroVerifyPurchaseWithIapkitGoogleProps.hpp"
#include "JVariant_NullType_String.hpp"
#include "NitroVerifyPurchaseWithIapkitAppleProps.hpp"
#include "NitroVerifyPurchaseWithIapkitGoogleProps.hpp"
#include <NitroModules/JNull.hpp>
#include <NitroModules/Null.hpp>
#include <optional>
#include <string>
#include <variant>

namespace margelo::nitro::iap {

  using namespace facebook;

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

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

} // namespace margelo::nitro::iap
