/**
 * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
 *
 * Do not edit this file as changes may cause incorrect behavior and will be lost
 * once the code is regenerated.
 *
 * @generated by codegen project: GenerateModuleH.js
 */

#pragma once

#include <ReactCommon/TurboModule.h>
#include <react/bridging/Bridging.h>

namespace facebook {
namespace react {


  
#pragma mark - NativeInAppPurchaseBaseFetchProductInput

template <typename P0, typename P1, typename P2, typename P3>
struct NativeInAppPurchaseBaseFetchProductInput {
  P0 id;
  P1 type;
  P2 planId;
  P3 offerId;
  bool operator==(const NativeInAppPurchaseBaseFetchProductInput &other) const {
    return id == other.id && type == other.type && planId == other.planId && offerId == other.offerId;
  }
};

template <typename P0, typename P1, typename P2, typename P3>
struct NativeInAppPurchaseBaseFetchProductInputBridging {
  static NativeInAppPurchaseBaseFetchProductInput<P0, P1, P2, P3> fromJs(
      jsi::Runtime &rt,
      const jsi::Object &value,
      const std::shared_ptr<CallInvoker> &jsInvoker) {
    NativeInAppPurchaseBaseFetchProductInput<P0, P1, P2, P3> result{
      bridging::fromJs<P0>(rt, value.getProperty(rt, "id"), jsInvoker),
      bridging::fromJs<P1>(rt, value.getProperty(rt, "type"), jsInvoker),
      bridging::fromJs<P2>(rt, value.getProperty(rt, "planId"), jsInvoker),
      bridging::fromJs<P3>(rt, value.getProperty(rt, "offerId"), jsInvoker)};
    return result;
  }

#ifdef DEBUG
  static jsi::String idToJs(jsi::Runtime &rt, P0 value) {
    return bridging::toJs(rt, value);
  }

  static jsi::String typeToJs(jsi::Runtime &rt, P1 value) {
    return bridging::toJs(rt, value);
  }

  static jsi::String planIdToJs(jsi::Runtime &rt, P2 value) {
    return bridging::toJs(rt, value);
  }

  static jsi::String offerIdToJs(jsi::Runtime &rt, P3 value) {
    return bridging::toJs(rt, value);
  }
#endif

  static jsi::Object toJs(
      jsi::Runtime &rt,
      const NativeInAppPurchaseBaseFetchProductInput<P0, P1, P2, P3> &value,
      const std::shared_ptr<CallInvoker> &jsInvoker) {
    auto result = facebook::jsi::Object(rt);
    result.setProperty(rt, "id", bridging::toJs(rt, value.id, jsInvoker));
    if (value.type) {
      result.setProperty(rt, "type", bridging::toJs(rt, value.type.value(), jsInvoker));
    }
    if (value.planId) {
      result.setProperty(rt, "planId", bridging::toJs(rt, value.planId.value(), jsInvoker));
    }
    if (value.offerId) {
      result.setProperty(rt, "offerId", bridging::toJs(rt, value.offerId.value(), jsInvoker));
    }
    return result;
  }
};



#pragma mark - NativeInAppPurchaseBasePurchase

template <typename P0, typename P1, typename P2, typename P3, typename P4>
struct NativeInAppPurchaseBasePurchase {
  P0 productIds;
  P1 transactionId;
  P2 transactionDate;
  P3 receipt;
  P4 purchaseToken;
  bool operator==(const NativeInAppPurchaseBasePurchase &other) const {
    return productIds == other.productIds && transactionId == other.transactionId && transactionDate == other.transactionDate && receipt == other.receipt && purchaseToken == other.purchaseToken;
  }
};

template <typename P0, typename P1, typename P2, typename P3, typename P4>
struct NativeInAppPurchaseBasePurchaseBridging {
  static NativeInAppPurchaseBasePurchase<P0, P1, P2, P3, P4> fromJs(
      jsi::Runtime &rt,
      const jsi::Object &value,
      const std::shared_ptr<CallInvoker> &jsInvoker) {
    NativeInAppPurchaseBasePurchase<P0, P1, P2, P3, P4> result{
      bridging::fromJs<P0>(rt, value.getProperty(rt, "productIds"), jsInvoker),
      bridging::fromJs<P1>(rt, value.getProperty(rt, "transactionId"), jsInvoker),
      bridging::fromJs<P2>(rt, value.getProperty(rt, "transactionDate"), jsInvoker),
      bridging::fromJs<P3>(rt, value.getProperty(rt, "receipt"), jsInvoker),
      bridging::fromJs<P4>(rt, value.getProperty(rt, "purchaseToken"), jsInvoker)};
    return result;
  }

#ifdef DEBUG
  static jsi::Array productIdsToJs(jsi::Runtime &rt, P0 value) {
    return bridging::toJs(rt, value);
  }

  static jsi::String transactionIdToJs(jsi::Runtime &rt, P1 value) {
    return bridging::toJs(rt, value);
  }

  static jsi::String transactionDateToJs(jsi::Runtime &rt, P2 value) {
    return bridging::toJs(rt, value);
  }

  static jsi::String receiptToJs(jsi::Runtime &rt, P3 value) {
    return bridging::toJs(rt, value);
  }

  static jsi::String purchaseTokenToJs(jsi::Runtime &rt, P4 value) {
    return bridging::toJs(rt, value);
  }
#endif

  static jsi::Object toJs(
      jsi::Runtime &rt,
      const NativeInAppPurchaseBasePurchase<P0, P1, P2, P3, P4> &value,
      const std::shared_ptr<CallInvoker> &jsInvoker) {
    auto result = facebook::jsi::Object(rt);
    result.setProperty(rt, "productIds", bridging::toJs(rt, value.productIds, jsInvoker));
    result.setProperty(rt, "transactionId", bridging::toJs(rt, value.transactionId, jsInvoker));
    result.setProperty(rt, "transactionDate", bridging::toJs(rt, value.transactionDate, jsInvoker));
    result.setProperty(rt, "receipt", bridging::toJs(rt, value.receipt, jsInvoker));
    result.setProperty(rt, "purchaseToken", bridging::toJs(rt, value.purchaseToken, jsInvoker));
    return result;
  }
};

class JSI_EXPORT NativeInAppPurchaseModuleCxxSpecJSI : public TurboModule {
protected:
  NativeInAppPurchaseModuleCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker);

public:
  virtual jsi::Object getConstants(jsi::Runtime &rt) = 0;
  virtual jsi::Value configure(jsi::Runtime &rt, std::optional<jsi::Object> config) = 0;
  virtual void fetchProducts(jsi::Runtime &rt, jsi::Array products) = 0;
  virtual jsi::Value flush(jsi::Runtime &rt) = 0;
  virtual void purchase(jsi::Runtime &rt, jsi::String productId, jsi::Object args) = 0;
  virtual jsi::Value finalize(jsi::Runtime &rt, jsi::Object purchase, bool isConsumable) = 0;
  virtual jsi::Value fetchReceipt(jsi::Runtime &rt) = 0;
  virtual void onFetchProducts(jsi::Runtime &rt, jsi::Function listener) = 0;
  virtual void onPurchase(jsi::Runtime &rt, jsi::Function listener) = 0;
  virtual void onAlternativeBillingFlow(jsi::Runtime &rt, jsi::Function listener) = 0;
  virtual void onError(jsi::Runtime &rt, jsi::Function listener) = 0;
  virtual void clear(jsi::Runtime &rt) = 0;

};

template <typename T>
class JSI_EXPORT NativeInAppPurchaseModuleCxxSpec : public TurboModule {
public:
  jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &propName) override {
    return delegate_.get(rt, propName);
  }

  static constexpr std::string_view kModuleName = "NativeInAppPurchase";

protected:
  NativeInAppPurchaseModuleCxxSpec(std::shared_ptr<CallInvoker> jsInvoker)
    : TurboModule(std::string{NativeInAppPurchaseModuleCxxSpec::kModuleName}, jsInvoker),
      delegate_(static_cast<T*>(this), jsInvoker) {}

private:
  class Delegate : public NativeInAppPurchaseModuleCxxSpecJSI {
  public:
    Delegate(T *instance, std::shared_ptr<CallInvoker> jsInvoker) :
      NativeInAppPurchaseModuleCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {}

    jsi::Object getConstants(jsi::Runtime &rt) override {
      static_assert(
          bridging::getParameterCount(&T::getConstants) == 1,
          "Expected getConstants(...) to have 1 parameters");

      return bridging::callFromJs<jsi::Object>(
          rt, &T::getConstants, jsInvoker_, instance_);
    }
    jsi::Value configure(jsi::Runtime &rt, std::optional<jsi::Object> config) override {
      static_assert(
          bridging::getParameterCount(&T::configure) == 2,
          "Expected configure(...) to have 2 parameters");

      return bridging::callFromJs<jsi::Value>(
          rt, &T::configure, jsInvoker_, instance_, std::move(config));
    }
    void fetchProducts(jsi::Runtime &rt, jsi::Array products) override {
      static_assert(
          bridging::getParameterCount(&T::fetchProducts) == 2,
          "Expected fetchProducts(...) to have 2 parameters");

      return bridging::callFromJs<void>(
          rt, &T::fetchProducts, jsInvoker_, instance_, std::move(products));
    }
    jsi::Value flush(jsi::Runtime &rt) override {
      static_assert(
          bridging::getParameterCount(&T::flush) == 1,
          "Expected flush(...) to have 1 parameters");

      return bridging::callFromJs<jsi::Value>(
          rt, &T::flush, jsInvoker_, instance_);
    }
    void purchase(jsi::Runtime &rt, jsi::String productId, jsi::Object args) override {
      static_assert(
          bridging::getParameterCount(&T::purchase) == 3,
          "Expected purchase(...) to have 3 parameters");

      return bridging::callFromJs<void>(
          rt, &T::purchase, jsInvoker_, instance_, std::move(productId), std::move(args));
    }
    jsi::Value finalize(jsi::Runtime &rt, jsi::Object purchase, bool isConsumable) override {
      static_assert(
          bridging::getParameterCount(&T::finalize) == 3,
          "Expected finalize(...) to have 3 parameters");

      return bridging::callFromJs<jsi::Value>(
          rt, &T::finalize, jsInvoker_, instance_, std::move(purchase), std::move(isConsumable));
    }
    jsi::Value fetchReceipt(jsi::Runtime &rt) override {
      static_assert(
          bridging::getParameterCount(&T::fetchReceipt) == 1,
          "Expected fetchReceipt(...) to have 1 parameters");

      return bridging::callFromJs<jsi::Value>(
          rt, &T::fetchReceipt, jsInvoker_, instance_);
    }
    void onFetchProducts(jsi::Runtime &rt, jsi::Function listener) override {
      static_assert(
          bridging::getParameterCount(&T::onFetchProducts) == 2,
          "Expected onFetchProducts(...) to have 2 parameters");

      return bridging::callFromJs<void>(
          rt, &T::onFetchProducts, jsInvoker_, instance_, std::move(listener));
    }
    void onPurchase(jsi::Runtime &rt, jsi::Function listener) override {
      static_assert(
          bridging::getParameterCount(&T::onPurchase) == 2,
          "Expected onPurchase(...) to have 2 parameters");

      return bridging::callFromJs<void>(
          rt, &T::onPurchase, jsInvoker_, instance_, std::move(listener));
    }
    void onAlternativeBillingFlow(jsi::Runtime &rt, jsi::Function listener) override {
      static_assert(
          bridging::getParameterCount(&T::onAlternativeBillingFlow) == 2,
          "Expected onAlternativeBillingFlow(...) to have 2 parameters");

      return bridging::callFromJs<void>(
          rt, &T::onAlternativeBillingFlow, jsInvoker_, instance_, std::move(listener));
    }
    void onError(jsi::Runtime &rt, jsi::Function listener) override {
      static_assert(
          bridging::getParameterCount(&T::onError) == 2,
          "Expected onError(...) to have 2 parameters");

      return bridging::callFromJs<void>(
          rt, &T::onError, jsInvoker_, instance_, std::move(listener));
    }
    void clear(jsi::Runtime &rt) override {
      static_assert(
          bridging::getParameterCount(&T::clear) == 1,
          "Expected clear(...) to have 1 parameters");

      return bridging::callFromJs<void>(
          rt, &T::clear, jsInvoker_, instance_);
    }

  private:
    T *instance_;
  };

  Delegate delegate_;
};

} // namespace react
} // namespace facebook
