///
/// JExternalPurchaseCustomLinkNoticeResultIOS.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 "ExternalPurchaseCustomLinkNoticeResultIOS.hpp"

#include "JVariant_NullType_String.hpp"
#include <NitroModules/JNull.hpp>
#include <NitroModules/Null.hpp>
#include <optional>
#include <string>
#include <variant>

namespace margelo::nitro::iap {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct ExternalPurchaseCustomLinkNoticeResultIOS by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    ExternalPurchaseCustomLinkNoticeResultIOS toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldContinued = clazz->getField<jboolean>("continued");
      jboolean continued = this->getFieldValue(fieldContinued);
      static const auto fieldError = clazz->getField<JVariant_NullType_String>("error");
      jni::local_ref<JVariant_NullType_String> error = this->getFieldValue(fieldError);
      return ExternalPurchaseCustomLinkNoticeResultIOS(
        static_cast<bool>(continued),
        error != nullptr ? std::make_optional(error->toCpp()) : std::nullopt
      );
    }

  public:
    /**
     * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
     */
    [[maybe_unused]]
    static jni::local_ref<JExternalPurchaseCustomLinkNoticeResultIOS::javaobject> fromCpp(const ExternalPurchaseCustomLinkNoticeResultIOS& value) {
      using JSignature = JExternalPurchaseCustomLinkNoticeResultIOS(jboolean, jni::alias_ref<JVariant_NullType_String>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        value.continued,
        value.error.has_value() ? JVariant_NullType_String::fromCpp(value.error.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::iap
