///
/// JNitroVerifyPurchaseWithProviderProps.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 "NitroVerifyPurchaseWithProviderProps.hpp"

#include "JNitroVerifyPurchaseWithIapkitAppleProps.hpp"
#include "JNitroVerifyPurchaseWithIapkitGoogleProps.hpp"
#include "JNitroVerifyPurchaseWithIapkitProps.hpp"
#include "JPurchaseVerificationProvider.hpp"
#include "JVariant_NullType_NitroVerifyPurchaseWithIapkitAppleProps.hpp"
#include "JVariant_NullType_NitroVerifyPurchaseWithIapkitGoogleProps.hpp"
#include "JVariant_NullType_NitroVerifyPurchaseWithIapkitProps.hpp"
#include "JVariant_NullType_String.hpp"
#include "NitroVerifyPurchaseWithIapkitAppleProps.hpp"
#include "NitroVerifyPurchaseWithIapkitGoogleProps.hpp"
#include "NitroVerifyPurchaseWithIapkitProps.hpp"
#include "PurchaseVerificationProvider.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 "NitroVerifyPurchaseWithProviderProps" and the the Kotlin data class "NitroVerifyPurchaseWithProviderProps".
   */
  struct JNitroVerifyPurchaseWithProviderProps final: public jni::JavaClass<JNitroVerifyPurchaseWithProviderProps> {
  public:
    static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/iap/NitroVerifyPurchaseWithProviderProps;";

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct NitroVerifyPurchaseWithProviderProps by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    NitroVerifyPurchaseWithProviderProps toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldIapkit = clazz->getField<JVariant_NullType_NitroVerifyPurchaseWithIapkitProps>("iapkit");
      jni::local_ref<JVariant_NullType_NitroVerifyPurchaseWithIapkitProps> iapkit = this->getFieldValue(fieldIapkit);
      static const auto fieldProvider = clazz->getField<JPurchaseVerificationProvider>("provider");
      jni::local_ref<JPurchaseVerificationProvider> provider = this->getFieldValue(fieldProvider);
      return NitroVerifyPurchaseWithProviderProps(
        iapkit != nullptr ? std::make_optional(iapkit->toCpp()) : std::nullopt,
        provider->toCpp()
      );
    }

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

} // namespace margelo::nitro::iap
