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

#include "JHybridRnFawryPaySdkSpec.hpp"

// Forward declaration of `FawryLaunchModel` to properly resolve imports.
namespace margelo::nitro::fawrypay_rnfawrypaysdk { struct FawryLaunchModel; }
// Forward declaration of `FawryLanguages` to properly resolve imports.
namespace margelo::nitro::fawrypay_rnfawrypaysdk { enum class FawryLanguages; }
// Forward declaration of `MerchantInfo` to properly resolve imports.
namespace margelo::nitro::fawrypay_rnfawrypaysdk { struct MerchantInfo; }
// Forward declaration of `CustomerInfo` to properly resolve imports.
namespace margelo::nitro::fawrypay_rnfawrypaysdk { struct CustomerInfo; }
// Forward declaration of `BillItems` to properly resolve imports.
namespace margelo::nitro::fawrypay_rnfawrypaysdk { struct BillItems; }
// Forward declaration of `LaunchApplePayModel` to properly resolve imports.
namespace margelo::nitro::fawrypay_rnfawrypaysdk { struct LaunchApplePayModel; }
// Forward declaration of `LaunchCheckoutModel` to properly resolve imports.
namespace margelo::nitro::fawrypay_rnfawrypaysdk { struct LaunchCheckoutModel; }

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

namespace margelo::nitro::fawrypay_rnfawrypaysdk {

  jni::local_ref<JHybridRnFawryPaySdkSpec::jhybriddata> JHybridRnFawryPaySdkSpec::initHybrid(jni::alias_ref<jhybridobject> jThis) {
    return makeCxxInstance(jThis);
  }

  void JHybridRnFawryPaySdkSpec::registerNatives() {
    registerHybrid({
      makeNativeMethod("initHybrid", JHybridRnFawryPaySdkSpec::initHybrid),
    });
  }

  size_t JHybridRnFawryPaySdkSpec::getExternalMemorySize() noexcept {
    static const auto method = javaClassStatic()->getMethod<jlong()>("getMemorySize");
    return method(_javaPart);
  }

  // Properties
  

  // Methods
  double JHybridRnFawryPaySdkSpec::multiply(double a, double b) {
    static const auto method = javaClassStatic()->getMethod<double(double /* a */, double /* b */)>("multiply");
    auto __result = method(_javaPart, a, b);
    return __result;
  }
  void JHybridRnFawryPaySdkSpec::startPayment(const FawryLaunchModel& model) {
    static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFawryLaunchModel> /* model */)>("startPayment");
    method(_javaPart, JFawryLaunchModel::fromCpp(model));
  }
  void JHybridRnFawryPaySdkSpec::openCardsManager(const std::string& baseUrl, FawryLanguages lang, const MerchantInfo& merchantInfo, const CustomerInfo& customerInfo, const std::optional<std::string>& tokenizationSignature) {
    static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* baseUrl */, jni::alias_ref<JFawryLanguages> /* lang */, jni::alias_ref<JMerchantInfo> /* merchantInfo */, jni::alias_ref<JCustomerInfo> /* customerInfo */, jni::alias_ref<jni::JString> /* tokenizationSignature */)>("openCardsManager");
    method(_javaPart, jni::make_jstring(baseUrl), JFawryLanguages::fromCpp(lang), JMerchantInfo::fromCpp(merchantInfo), JCustomerInfo::fromCpp(customerInfo), tokenizationSignature.has_value() ? jni::make_jstring(tokenizationSignature.value()) : nullptr);
  }
  std::function<void()> JHybridRnFawryPaySdkSpec::addListener(const std::function<void(const std::string& /* eventName */, const std::string& /* payload */)>& listener) {
    static const auto method = javaClassStatic()->getMethod<jni::local_ref<JFunc_void::javaobject>(jni::alias_ref<JFunc_void_std__string_std__string::javaobject> /* listener */)>("addListener_cxx");
    auto __result = method(_javaPart, JFunc_void_std__string_std__string_cxx::fromCpp(listener));
    return [&]() -> std::function<void()> {
      if (__result->isInstanceOf(JFunc_void_cxx::javaClassStatic())) [[likely]] {
        auto downcast = jni::static_ref_cast<JFunc_void_cxx::javaobject>(__result);
        return downcast->cthis()->getFunction();
      } else {
        auto __resultRef = jni::make_global(__result);
        return [__resultRef]() -> void {
          return __resultRef->invoke();
        };
      }
    }();
  }

} // namespace margelo::nitro::fawrypay_rnfawrypaysdk
