///
/// JNitroDiscountAmountAndroid.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 "NitroDiscountAmountAndroid.hpp"

#include <string>

namespace margelo::nitro::iap {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct NitroDiscountAmountAndroid by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    NitroDiscountAmountAndroid toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldDiscountAmountMicros = clazz->getField<jni::JString>("discountAmountMicros");
      jni::local_ref<jni::JString> discountAmountMicros = this->getFieldValue(fieldDiscountAmountMicros);
      static const auto fieldFormattedDiscountAmount = clazz->getField<jni::JString>("formattedDiscountAmount");
      jni::local_ref<jni::JString> formattedDiscountAmount = this->getFieldValue(fieldFormattedDiscountAmount);
      return NitroDiscountAmountAndroid(
        discountAmountMicros->toStdString(),
        formattedDiscountAmount->toStdString()
      );
    }

  public:
    /**
     * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
     */
    [[maybe_unused]]
    static jni::local_ref<JNitroDiscountAmountAndroid::javaobject> fromCpp(const NitroDiscountAmountAndroid& value) {
      using JSignature = JNitroDiscountAmountAndroid(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,
        jni::make_jstring(value.discountAmountMicros),
        jni::make_jstring(value.formattedDiscountAmount)
      );
    }
  };

} // namespace margelo::nitro::iap
