///
/// JNitroRequestPurchaseIos.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 "NitroRequestPurchaseIos.hpp"

#include "JPromotionalOfferJwsInputIOS.hpp"
#include "JVariant_NullType_Boolean.hpp"
#include "JVariant_NullType_Double.hpp"
#include "JVariant_NullType_Map_String__String_.hpp"
#include "JVariant_NullType_PromotionalOfferJwsInputIOS.hpp"
#include "JVariant_NullType_String.hpp"
#include "JVariant_NullType_WinBackOfferInputIOS.hpp"
#include "JWinBackOfferInputIOS.hpp"
#include "PromotionalOfferJwsInputIOS.hpp"
#include "WinBackOfferInputIOS.hpp"
#include <NitroModules/JNull.hpp>
#include <NitroModules/Null.hpp>
#include <optional>
#include <string>
#include <unordered_map>
#include <variant>

namespace margelo::nitro::iap {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct NitroRequestPurchaseIos by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    NitroRequestPurchaseIos toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldSku = clazz->getField<jni::JString>("sku");
      jni::local_ref<jni::JString> sku = this->getFieldValue(fieldSku);
      static const auto fieldAndDangerouslyFinishTransactionAutomatically = clazz->getField<JVariant_NullType_Boolean>("andDangerouslyFinishTransactionAutomatically");
      jni::local_ref<JVariant_NullType_Boolean> andDangerouslyFinishTransactionAutomatically = this->getFieldValue(fieldAndDangerouslyFinishTransactionAutomatically);
      static const auto fieldAppAccountToken = clazz->getField<JVariant_NullType_String>("appAccountToken");
      jni::local_ref<JVariant_NullType_String> appAccountToken = this->getFieldValue(fieldAppAccountToken);
      static const auto fieldQuantity = clazz->getField<JVariant_NullType_Double>("quantity");
      jni::local_ref<JVariant_NullType_Double> quantity = this->getFieldValue(fieldQuantity);
      static const auto fieldWithOffer = clazz->getField<JVariant_NullType_Map_String__String_>("withOffer");
      jni::local_ref<JVariant_NullType_Map_String__String_> withOffer = this->getFieldValue(fieldWithOffer);
      static const auto fieldAdvancedCommerceData = clazz->getField<JVariant_NullType_String>("advancedCommerceData");
      jni::local_ref<JVariant_NullType_String> advancedCommerceData = this->getFieldValue(fieldAdvancedCommerceData);
      static const auto fieldIntroductoryOfferEligibility = clazz->getField<JVariant_NullType_Boolean>("introductoryOfferEligibility");
      jni::local_ref<JVariant_NullType_Boolean> introductoryOfferEligibility = this->getFieldValue(fieldIntroductoryOfferEligibility);
      static const auto fieldPromotionalOfferJWS = clazz->getField<JVariant_NullType_PromotionalOfferJwsInputIOS>("promotionalOfferJWS");
      jni::local_ref<JVariant_NullType_PromotionalOfferJwsInputIOS> promotionalOfferJWS = this->getFieldValue(fieldPromotionalOfferJWS);
      static const auto fieldWinBackOffer = clazz->getField<JVariant_NullType_WinBackOfferInputIOS>("winBackOffer");
      jni::local_ref<JVariant_NullType_WinBackOfferInputIOS> winBackOffer = this->getFieldValue(fieldWinBackOffer);
      return NitroRequestPurchaseIos(
        sku->toStdString(),
        andDangerouslyFinishTransactionAutomatically != nullptr ? std::make_optional(andDangerouslyFinishTransactionAutomatically->toCpp()) : std::nullopt,
        appAccountToken != nullptr ? std::make_optional(appAccountToken->toCpp()) : std::nullopt,
        quantity != nullptr ? std::make_optional(quantity->toCpp()) : std::nullopt,
        withOffer != nullptr ? std::make_optional(withOffer->toCpp()) : std::nullopt,
        advancedCommerceData != nullptr ? std::make_optional(advancedCommerceData->toCpp()) : std::nullopt,
        introductoryOfferEligibility != nullptr ? std::make_optional(introductoryOfferEligibility->toCpp()) : std::nullopt,
        promotionalOfferJWS != nullptr ? std::make_optional(promotionalOfferJWS->toCpp()) : std::nullopt,
        winBackOffer != nullptr ? std::make_optional(winBackOffer->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<JNitroRequestPurchaseIos::javaobject> fromCpp(const NitroRequestPurchaseIos& value) {
      using JSignature = JNitroRequestPurchaseIos(jni::alias_ref<jni::JString>, jni::alias_ref<JVariant_NullType_Boolean>, jni::alias_ref<JVariant_NullType_String>, jni::alias_ref<JVariant_NullType_Double>, jni::alias_ref<JVariant_NullType_Map_String__String_>, jni::alias_ref<JVariant_NullType_String>, jni::alias_ref<JVariant_NullType_Boolean>, jni::alias_ref<JVariant_NullType_PromotionalOfferJwsInputIOS>, jni::alias_ref<JVariant_NullType_WinBackOfferInputIOS>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        jni::make_jstring(value.sku),
        value.andDangerouslyFinishTransactionAutomatically.has_value() ? JVariant_NullType_Boolean::fromCpp(value.andDangerouslyFinishTransactionAutomatically.value()) : nullptr,
        value.appAccountToken.has_value() ? JVariant_NullType_String::fromCpp(value.appAccountToken.value()) : nullptr,
        value.quantity.has_value() ? JVariant_NullType_Double::fromCpp(value.quantity.value()) : nullptr,
        value.withOffer.has_value() ? JVariant_NullType_Map_String__String_::fromCpp(value.withOffer.value()) : nullptr,
        value.advancedCommerceData.has_value() ? JVariant_NullType_String::fromCpp(value.advancedCommerceData.value()) : nullptr,
        value.introductoryOfferEligibility.has_value() ? JVariant_NullType_Boolean::fromCpp(value.introductoryOfferEligibility.value()) : nullptr,
        value.promotionalOfferJWS.has_value() ? JVariant_NullType_PromotionalOfferJwsInputIOS::fromCpp(value.promotionalOfferJWS.value()) : nullptr,
        value.winBackOffer.has_value() ? JVariant_NullType_WinBackOfferInputIOS::fromCpp(value.winBackOffer.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::iap
