///
/// JPurchaseOfferIOS.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 "PurchaseOfferIOS.hpp"

#include <string>

namespace margelo::nitro::iap {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct PurchaseOfferIOS by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    PurchaseOfferIOS toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldId = clazz->getField<jni::JString>("id");
      jni::local_ref<jni::JString> id = this->getFieldValue(fieldId);
      static const auto fieldPaymentMode = clazz->getField<jni::JString>("paymentMode");
      jni::local_ref<jni::JString> paymentMode = this->getFieldValue(fieldPaymentMode);
      static const auto fieldType = clazz->getField<jni::JString>("type");
      jni::local_ref<jni::JString> type = this->getFieldValue(fieldType);
      return PurchaseOfferIOS(
        id->toStdString(),
        paymentMode->toStdString(),
        type->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<JPurchaseOfferIOS::javaobject> fromCpp(const PurchaseOfferIOS& value) {
      using JSignature = JPurchaseOfferIOS(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,
        jni::make_jstring(value.id),
        jni::make_jstring(value.paymentMode),
        jni::make_jstring(value.type)
      );
    }
  };

} // namespace margelo::nitro::iap
