///
/// JNitroVerifyPurchaseWithIapkitResult.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 "NitroVerifyPurchaseWithIapkitResult.hpp"

#include "IapStore.hpp"
#include "IapkitPurchaseState.hpp"
#include "JIapStore.hpp"
#include "JIapkitPurchaseState.hpp"

namespace margelo::nitro::iap {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct NitroVerifyPurchaseWithIapkitResult by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    NitroVerifyPurchaseWithIapkitResult toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldIsValid = clazz->getField<jboolean>("isValid");
      jboolean isValid = this->getFieldValue(fieldIsValid);
      static const auto fieldState = clazz->getField<JIapkitPurchaseState>("state");
      jni::local_ref<JIapkitPurchaseState> state = this->getFieldValue(fieldState);
      static const auto fieldStore = clazz->getField<JIapStore>("store");
      jni::local_ref<JIapStore> store = this->getFieldValue(fieldStore);
      return NitroVerifyPurchaseWithIapkitResult(
        static_cast<bool>(isValid),
        state->toCpp(),
        store->toCpp()
      );
    }

  public:
    /**
     * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
     */
    [[maybe_unused]]
    static jni::local_ref<JNitroVerifyPurchaseWithIapkitResult::javaobject> fromCpp(const NitroVerifyPurchaseWithIapkitResult& value) {
      using JSignature = JNitroVerifyPurchaseWithIapkitResult(jboolean, jni::alias_ref<JIapkitPurchaseState>, jni::alias_ref<JIapStore>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        value.isValid,
        JIapkitPurchaseState::fromCpp(value.state),
        JIapStore::fromCpp(value.store)
      );
    }
  };

} // namespace margelo::nitro::iap
