///
/// JNitroPurchaseRequest.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 "NitroPurchaseRequest.hpp"

#include "AndroidSubscriptionOfferInput.hpp"
#include "JAndroidSubscriptionOfferInput.hpp"
#include "JNitroRequestPurchaseAndroid.hpp"
#include "JNitroRequestPurchaseIos.hpp"
#include "JPromotionalOfferJwsInputIOS.hpp"
#include "JSubscriptionProductReplacementParamsAndroid.hpp"
#include "JSubscriptionReplacementModeAndroid.hpp"
#include "JVariant_NullType_Array_AndroidSubscriptionOfferInput_.hpp"
#include "JVariant_NullType_Boolean.hpp"
#include "JVariant_NullType_Double.hpp"
#include "JVariant_NullType_Map_String__String_.hpp"
#include "JVariant_NullType_NitroRequestPurchaseAndroid.hpp"
#include "JVariant_NullType_NitroRequestPurchaseIos.hpp"
#include "JVariant_NullType_PromotionalOfferJwsInputIOS.hpp"
#include "JVariant_NullType_String.hpp"
#include "JVariant_NullType_SubscriptionProductReplacementParamsAndroid.hpp"
#include "JVariant_NullType_WinBackOfferInputIOS.hpp"
#include "JWinBackOfferInputIOS.hpp"
#include "NitroRequestPurchaseAndroid.hpp"
#include "NitroRequestPurchaseIos.hpp"
#include "PromotionalOfferJwsInputIOS.hpp"
#include "SubscriptionProductReplacementParamsAndroid.hpp"
#include "SubscriptionReplacementModeAndroid.hpp"
#include "WinBackOfferInputIOS.hpp"
#include <NitroModules/JNull.hpp>
#include <NitroModules/Null.hpp>
#include <optional>
#include <string>
#include <unordered_map>
#include <variant>
#include <vector>

namespace margelo::nitro::iap {

  using namespace facebook;

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

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

} // namespace margelo::nitro::iap
