///
/// JFawryLaunchModel.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 "FawryLaunchModel.hpp"

#include "BillItems.hpp"
#include "CustomerInfo.hpp"
#include "FawryLanguages.hpp"
#include "JBillItems.hpp"
#include "JCustomerInfo.hpp"
#include "JFawryLanguages.hpp"
#include "JLaunchApplePayModel.hpp"
#include "JLaunchCheckoutModel.hpp"
#include "JMerchantInfo.hpp"
#include "LaunchApplePayModel.hpp"
#include "LaunchCheckoutModel.hpp"
#include "MerchantInfo.hpp"
#include <optional>
#include <string>
#include <vector>

namespace margelo::nitro::fawrypay_rnfawrypaysdk {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct FawryLaunchModel by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    FawryLaunchModel toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldBaseUrl = clazz->getField<jni::JString>("baseUrl");
      jni::local_ref<jni::JString> baseUrl = this->getFieldValue(fieldBaseUrl);
      static const auto fieldLang = clazz->getField<JFawryLanguages>("lang");
      jni::local_ref<JFawryLanguages> lang = this->getFieldValue(fieldLang);
      static const auto fieldMerchantInfo = clazz->getField<JMerchantInfo>("merchantInfo");
      jni::local_ref<JMerchantInfo> merchantInfo = this->getFieldValue(fieldMerchantInfo);
      static const auto fieldCustomerInfo = clazz->getField<JCustomerInfo>("customerInfo");
      jni::local_ref<JCustomerInfo> customerInfo = this->getFieldValue(fieldCustomerInfo);
      static const auto fieldItems = clazz->getField<jni::JArrayClass<JBillItems>>("items");
      jni::local_ref<jni::JArrayClass<JBillItems>> items = this->getFieldValue(fieldItems);
      static const auto fieldAllow3DPayment = clazz->getField<jboolean>("allow3DPayment");
      jboolean allow3DPayment = this->getFieldValue(fieldAllow3DPayment);
      static const auto fieldSkipReceipt = clazz->getField<jboolean>("skipReceipt");
      jboolean skipReceipt = this->getFieldValue(fieldSkipReceipt);
      static const auto fieldSkipLogin = clazz->getField<jboolean>("skipLogin");
      jboolean skipLogin = this->getFieldValue(fieldSkipLogin);
      static const auto fieldSkipCustomerInput = clazz->getField<jni::JBoolean>("skipCustomerInput");
      jni::local_ref<jni::JBoolean> skipCustomerInput = this->getFieldValue(fieldSkipCustomerInput);
      static const auto fieldPayWithCardToken = clazz->getField<jboolean>("payWithCardToken");
      jboolean payWithCardToken = this->getFieldValue(fieldPayWithCardToken);
      static const auto fieldAuthCaptureMode = clazz->getField<jboolean>("authCaptureMode");
      jboolean authCaptureMode = this->getFieldValue(fieldAuthCaptureMode);
      static const auto fieldAllowVoucher = clazz->getField<jboolean>("allowVoucher");
      jboolean allowVoucher = this->getFieldValue(fieldAllowVoucher);
      static const auto fieldPaymentSignature = clazz->getField<jni::JString>("paymentSignature");
      jni::local_ref<jni::JString> paymentSignature = this->getFieldValue(fieldPaymentSignature);
      static const auto fieldTokenizationSignature = clazz->getField<jni::JString>("tokenizationSignature");
      jni::local_ref<jni::JString> tokenizationSignature = this->getFieldValue(fieldTokenizationSignature);
      static const auto fieldPaymentMethod = clazz->getField<jni::JString>("paymentMethod");
      jni::local_ref<jni::JString> paymentMethod = this->getFieldValue(fieldPaymentMethod);
      static const auto fieldLaunchApplePayModel = clazz->getField<JLaunchApplePayModel>("launchApplePayModel");
      jni::local_ref<JLaunchApplePayModel> launchApplePayModel = this->getFieldValue(fieldLaunchApplePayModel);
      static const auto fieldLaunchCheckoutModel = clazz->getField<JLaunchCheckoutModel>("launchCheckoutModel");
      jni::local_ref<JLaunchCheckoutModel> launchCheckoutModel = this->getFieldValue(fieldLaunchCheckoutModel);
      return FawryLaunchModel(
        baseUrl->toStdString(),
        lang->toCpp(),
        merchantInfo->toCpp(),
        customerInfo->toCpp(),
        [&]() {
          size_t __size = items->size();
          std::vector<BillItems> __vector;
          __vector.reserve(__size);
          for (size_t __i = 0; __i < __size; __i++) {
            auto __element = items->getElement(__i);
            __vector.push_back(__element->toCpp());
          }
          return __vector;
        }(),
        static_cast<bool>(allow3DPayment),
        static_cast<bool>(skipReceipt),
        static_cast<bool>(skipLogin),
        skipCustomerInput != nullptr ? std::make_optional(static_cast<bool>(skipCustomerInput->value())) : std::nullopt,
        static_cast<bool>(payWithCardToken),
        static_cast<bool>(authCaptureMode),
        static_cast<bool>(allowVoucher),
        paymentSignature != nullptr ? std::make_optional(paymentSignature->toStdString()) : std::nullopt,
        tokenizationSignature != nullptr ? std::make_optional(tokenizationSignature->toStdString()) : std::nullopt,
        paymentMethod != nullptr ? std::make_optional(paymentMethod->toStdString()) : std::nullopt,
        launchApplePayModel != nullptr ? std::make_optional(launchApplePayModel->toCpp()) : std::nullopt,
        launchCheckoutModel != nullptr ? std::make_optional(launchCheckoutModel->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<JFawryLaunchModel::javaobject> fromCpp(const FawryLaunchModel& value) {
      return newInstance(
        jni::make_jstring(value.baseUrl),
        JFawryLanguages::fromCpp(value.lang),
        JMerchantInfo::fromCpp(value.merchantInfo),
        JCustomerInfo::fromCpp(value.customerInfo),
        [&]() {
          size_t __size = value.items.size();
          jni::local_ref<jni::JArrayClass<JBillItems>> __array = jni::JArrayClass<JBillItems>::newArray(__size);
          for (size_t __i = 0; __i < __size; __i++) {
            const auto& __element = value.items[__i];
            __array->setElement(__i, *JBillItems::fromCpp(__element));
          }
          return __array;
        }(),
        value.allow3DPayment,
        value.skipReceipt,
        value.skipLogin,
        value.skipCustomerInput.has_value() ? jni::JBoolean::valueOf(value.skipCustomerInput.value()) : nullptr,
        value.payWithCardToken,
        value.authCaptureMode,
        value.allowVoucher,
        value.paymentSignature.has_value() ? jni::make_jstring(value.paymentSignature.value()) : nullptr,
        value.tokenizationSignature.has_value() ? jni::make_jstring(value.tokenizationSignature.value()) : nullptr,
        value.paymentMethod.has_value() ? jni::make_jstring(value.paymentMethod.value()) : nullptr,
        value.launchApplePayModel.has_value() ? JLaunchApplePayModel::fromCpp(value.launchApplePayModel.value()) : nullptr,
        value.launchCheckoutModel.has_value() ? JLaunchCheckoutModel::fromCpp(value.launchCheckoutModel.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::fawrypay_rnfawrypaysdk
