///
/// JPaymentResult.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 "PaymentResult.hpp"

#include "InstallmentTypes.hpp"
#include "JInstallmentTypes.hpp"
#include "JPaymentTypes.hpp"
#include "PaymentTypes.hpp"
#include <string>

namespace margelo::nitro::taponpagseguro {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct PaymentResult by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    PaymentResult toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldAmount = clazz->getField<double>("amount");
      double amount = this->getFieldValue(fieldAmount);
      static const auto fieldRaw_amount = clazz->getField<double>("raw_amount");
      double raw_amount = this->getFieldValue(fieldRaw_amount);
      static const auto fieldPayment_method = clazz->getField<JPaymentTypes>("payment_method");
      jni::local_ref<JPaymentTypes> payment_method = this->getFieldValue(fieldPayment_method);
      static const auto fieldTransaction_code = clazz->getField<jni::JString>("transaction_code");
      jni::local_ref<jni::JString> transaction_code = this->getFieldValue(fieldTransaction_code);
      static const auto fieldTransaction_date_time = clazz->getField<jni::JString>("transaction_date_time");
      jni::local_ref<jni::JString> transaction_date_time = this->getFieldValue(fieldTransaction_date_time);
      static const auto fieldCard_holder = clazz->getField<jni::JString>("card_holder");
      jni::local_ref<jni::JString> card_holder = this->getFieldValue(fieldCard_holder);
      static const auto fieldCard_brand = clazz->getField<jni::JString>("card_brand");
      jni::local_ref<jni::JString> card_brand = this->getFieldValue(fieldCard_brand);
      static const auto fieldInstallments = clazz->getField<double>("installments");
      double installments = this->getFieldValue(fieldInstallments);
      static const auto fieldInstallment_value = clazz->getField<double>("installment_value");
      double installment_value = this->getFieldValue(fieldInstallment_value);
      static const auto fieldRaw_installment_value = clazz->getField<double>("raw_installment_value");
      double raw_installment_value = this->getFieldValue(fieldRaw_installment_value);
      static const auto fieldInstallment_method = clazz->getField<JInstallmentTypes>("installment_method");
      jni::local_ref<JInstallmentTypes> installment_method = this->getFieldValue(fieldInstallment_method);
      static const auto fieldIs_sale_with_taxpass_through = clazz->getField<jboolean>("is_sale_with_taxpass_through");
      jboolean is_sale_with_taxpass_through = this->getFieldValue(fieldIs_sale_with_taxpass_through);
      return PaymentResult(
        amount,
        raw_amount,
        payment_method->toCpp(),
        transaction_code->toStdString(),
        transaction_date_time->toStdString(),
        card_holder->toStdString(),
        card_brand->toStdString(),
        installments,
        installment_value,
        raw_installment_value,
        installment_method->toCpp(),
        static_cast<bool>(is_sale_with_taxpass_through)
      );
    }

  public:
    /**
     * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
     */
    [[maybe_unused]]
    static jni::local_ref<JPaymentResult::javaobject> fromCpp(const PaymentResult& value) {
      using JSignature = JPaymentResult(double, double, jni::alias_ref<JPaymentTypes>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, double, double, double, jni::alias_ref<JInstallmentTypes>, jboolean);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        value.amount,
        value.raw_amount,
        JPaymentTypes::fromCpp(value.payment_method),
        jni::make_jstring(value.transaction_code),
        jni::make_jstring(value.transaction_date_time),
        jni::make_jstring(value.card_holder),
        jni::make_jstring(value.card_brand),
        value.installments,
        value.installment_value,
        value.raw_installment_value,
        JInstallmentTypes::fromCpp(value.installment_method),
        value.is_sale_with_taxpass_through
      );
    }
  };

} // namespace margelo::nitro::taponpagseguro
