///
/// JNitroRenewalInfoIOS.hpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2025 Marc Rousavy @ Margelo
///

#pragma once

#include <fbjni/fbjni.h>
#include "NitroRenewalInfoIOS.hpp"

#include <optional>
#include <string>

namespace margelo::nitro::iap {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct NitroRenewalInfoIOS by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    NitroRenewalInfoIOS toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldWillAutoRenew = clazz->getField<jboolean>("willAutoRenew");
      jboolean willAutoRenew = this->getFieldValue(fieldWillAutoRenew);
      static const auto fieldAutoRenewPreference = clazz->getField<jni::JString>("autoRenewPreference");
      jni::local_ref<jni::JString> autoRenewPreference = this->getFieldValue(fieldAutoRenewPreference);
      static const auto fieldPendingUpgradeProductId = clazz->getField<jni::JString>("pendingUpgradeProductId");
      jni::local_ref<jni::JString> pendingUpgradeProductId = this->getFieldValue(fieldPendingUpgradeProductId);
      static const auto fieldRenewalDate = clazz->getField<jni::JDouble>("renewalDate");
      jni::local_ref<jni::JDouble> renewalDate = this->getFieldValue(fieldRenewalDate);
      static const auto fieldExpirationReason = clazz->getField<jni::JString>("expirationReason");
      jni::local_ref<jni::JString> expirationReason = this->getFieldValue(fieldExpirationReason);
      static const auto fieldIsInBillingRetry = clazz->getField<jni::JBoolean>("isInBillingRetry");
      jni::local_ref<jni::JBoolean> isInBillingRetry = this->getFieldValue(fieldIsInBillingRetry);
      static const auto fieldGracePeriodExpirationDate = clazz->getField<jni::JDouble>("gracePeriodExpirationDate");
      jni::local_ref<jni::JDouble> gracePeriodExpirationDate = this->getFieldValue(fieldGracePeriodExpirationDate);
      static const auto fieldPriceIncreaseStatus = clazz->getField<jni::JString>("priceIncreaseStatus");
      jni::local_ref<jni::JString> priceIncreaseStatus = this->getFieldValue(fieldPriceIncreaseStatus);
      static const auto fieldRenewalOfferType = clazz->getField<jni::JString>("renewalOfferType");
      jni::local_ref<jni::JString> renewalOfferType = this->getFieldValue(fieldRenewalOfferType);
      static const auto fieldRenewalOfferId = clazz->getField<jni::JString>("renewalOfferId");
      jni::local_ref<jni::JString> renewalOfferId = this->getFieldValue(fieldRenewalOfferId);
      static const auto fieldJsonRepresentation = clazz->getField<jni::JString>("jsonRepresentation");
      jni::local_ref<jni::JString> jsonRepresentation = this->getFieldValue(fieldJsonRepresentation);
      return NitroRenewalInfoIOS(
        static_cast<bool>(willAutoRenew),
        autoRenewPreference != nullptr ? std::make_optional(autoRenewPreference->toStdString()) : std::nullopt,
        pendingUpgradeProductId != nullptr ? std::make_optional(pendingUpgradeProductId->toStdString()) : std::nullopt,
        renewalDate != nullptr ? std::make_optional(renewalDate->value()) : std::nullopt,
        expirationReason != nullptr ? std::make_optional(expirationReason->toStdString()) : std::nullopt,
        isInBillingRetry != nullptr ? std::make_optional(static_cast<bool>(isInBillingRetry->value())) : std::nullopt,
        gracePeriodExpirationDate != nullptr ? std::make_optional(gracePeriodExpirationDate->value()) : std::nullopt,
        priceIncreaseStatus != nullptr ? std::make_optional(priceIncreaseStatus->toStdString()) : std::nullopt,
        renewalOfferType != nullptr ? std::make_optional(renewalOfferType->toStdString()) : std::nullopt,
        renewalOfferId != nullptr ? std::make_optional(renewalOfferId->toStdString()) : std::nullopt,
        jsonRepresentation != nullptr ? std::make_optional(jsonRepresentation->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<JNitroRenewalInfoIOS::javaobject> fromCpp(const NitroRenewalInfoIOS& value) {
      using JSignature = JNitroRenewalInfoIOS(jboolean, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JDouble>, 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.willAutoRenew,
        value.autoRenewPreference.has_value() ? jni::make_jstring(value.autoRenewPreference.value()) : nullptr,
        value.pendingUpgradeProductId.has_value() ? jni::make_jstring(value.pendingUpgradeProductId.value()) : nullptr,
        value.renewalDate.has_value() ? jni::JDouble::valueOf(value.renewalDate.value()) : nullptr,
        value.expirationReason.has_value() ? jni::make_jstring(value.expirationReason.value()) : nullptr,
        value.isInBillingRetry.has_value() ? jni::JBoolean::valueOf(value.isInBillingRetry.value()) : nullptr,
        value.gracePeriodExpirationDate.has_value() ? jni::JDouble::valueOf(value.gracePeriodExpirationDate.value()) : nullptr,
        value.priceIncreaseStatus.has_value() ? jni::make_jstring(value.priceIncreaseStatus.value()) : nullptr,
        value.renewalOfferType.has_value() ? jni::make_jstring(value.renewalOfferType.value()) : nullptr,
        value.renewalOfferId.has_value() ? jni::make_jstring(value.renewalOfferId.value()) : nullptr,
        value.jsonRepresentation.has_value() ? jni::make_jstring(value.jsonRepresentation.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::iap
