///
/// NitroReceiptValidationResultAndroid.hpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © Marc Rousavy @ Margelo
///

#pragma once

#if __has_include(<NitroModules/JSIConverter.hpp>)
#include <NitroModules/JSIConverter.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/NitroDefines.hpp>)
#include <NitroModules/NitroDefines.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/JSIHelpers.hpp>)
#include <NitroModules/JSIHelpers.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
#include <NitroModules/PropNameIDCache.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif



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

namespace margelo::nitro::iap {

  /**
   * A struct which can be represented as a JavaScript object (NitroReceiptValidationResultAndroid).
   */
  struct NitroReceiptValidationResultAndroid final {
  public:
    bool autoRenewing     SWIFT_PRIVATE;
    bool betaProduct     SWIFT_PRIVATE;
    std::optional<std::variant<nitro::NullType, double>> cancelDate     SWIFT_PRIVATE;
    std::optional<std::variant<nitro::NullType, std::string>> cancelReason     SWIFT_PRIVATE;
    std::optional<std::variant<nitro::NullType, double>> deferredDate     SWIFT_PRIVATE;
    std::optional<std::variant<nitro::NullType, std::string>> deferredSku     SWIFT_PRIVATE;
    double freeTrialEndDate     SWIFT_PRIVATE;
    double gracePeriodEndDate     SWIFT_PRIVATE;
    std::string parentProductId     SWIFT_PRIVATE;
    std::string productId     SWIFT_PRIVATE;
    std::string productType     SWIFT_PRIVATE;
    double purchaseDate     SWIFT_PRIVATE;
    double quantity     SWIFT_PRIVATE;
    std::string receiptId     SWIFT_PRIVATE;
    double renewalDate     SWIFT_PRIVATE;
    std::string term     SWIFT_PRIVATE;
    std::string termSku     SWIFT_PRIVATE;
    bool testTransaction     SWIFT_PRIVATE;

  public:
    NitroReceiptValidationResultAndroid() = default;
    explicit NitroReceiptValidationResultAndroid(bool autoRenewing, bool betaProduct, std::optional<std::variant<nitro::NullType, double>> cancelDate, std::optional<std::variant<nitro::NullType, std::string>> cancelReason, std::optional<std::variant<nitro::NullType, double>> deferredDate, std::optional<std::variant<nitro::NullType, std::string>> deferredSku, double freeTrialEndDate, double gracePeriodEndDate, std::string parentProductId, std::string productId, std::string productType, double purchaseDate, double quantity, std::string receiptId, double renewalDate, std::string term, std::string termSku, bool testTransaction): autoRenewing(autoRenewing), betaProduct(betaProduct), cancelDate(cancelDate), cancelReason(cancelReason), deferredDate(deferredDate), deferredSku(deferredSku), freeTrialEndDate(freeTrialEndDate), gracePeriodEndDate(gracePeriodEndDate), parentProductId(parentProductId), productId(productId), productType(productType), purchaseDate(purchaseDate), quantity(quantity), receiptId(receiptId), renewalDate(renewalDate), term(term), termSku(termSku), testTransaction(testTransaction) {}

  public:
    friend bool operator==(const NitroReceiptValidationResultAndroid& lhs, const NitroReceiptValidationResultAndroid& rhs) = default;
  };

} // namespace margelo::nitro::iap

namespace margelo::nitro {

  // C++ NitroReceiptValidationResultAndroid <> JS NitroReceiptValidationResultAndroid (object)
  template <>
  struct JSIConverter<margelo::nitro::iap::NitroReceiptValidationResultAndroid> final {
    static inline margelo::nitro::iap::NitroReceiptValidationResultAndroid fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::iap::NitroReceiptValidationResultAndroid(
        JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "autoRenewing"))),
        JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "betaProduct"))),
        JSIConverter<std::optional<std::variant<nitro::NullType, double>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cancelDate"))),
        JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cancelReason"))),
        JSIConverter<std::optional<std::variant<nitro::NullType, double>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "deferredDate"))),
        JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "deferredSku"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "freeTrialEndDate"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "gracePeriodEndDate"))),
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "parentProductId"))),
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "productId"))),
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "productType"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "purchaseDate"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "quantity"))),
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "receiptId"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "renewalDate"))),
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "term"))),
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "termSku"))),
        JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "testTransaction")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::iap::NitroReceiptValidationResultAndroid& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "autoRenewing"), JSIConverter<bool>::toJSI(runtime, arg.autoRenewing));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "betaProduct"), JSIConverter<bool>::toJSI(runtime, arg.betaProduct));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "cancelDate"), JSIConverter<std::optional<std::variant<nitro::NullType, double>>>::toJSI(runtime, arg.cancelDate));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "cancelReason"), JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::toJSI(runtime, arg.cancelReason));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "deferredDate"), JSIConverter<std::optional<std::variant<nitro::NullType, double>>>::toJSI(runtime, arg.deferredDate));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "deferredSku"), JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::toJSI(runtime, arg.deferredSku));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "freeTrialEndDate"), JSIConverter<double>::toJSI(runtime, arg.freeTrialEndDate));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "gracePeriodEndDate"), JSIConverter<double>::toJSI(runtime, arg.gracePeriodEndDate));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "parentProductId"), JSIConverter<std::string>::toJSI(runtime, arg.parentProductId));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "productId"), JSIConverter<std::string>::toJSI(runtime, arg.productId));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "productType"), JSIConverter<std::string>::toJSI(runtime, arg.productType));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "purchaseDate"), JSIConverter<double>::toJSI(runtime, arg.purchaseDate));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "quantity"), JSIConverter<double>::toJSI(runtime, arg.quantity));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "receiptId"), JSIConverter<std::string>::toJSI(runtime, arg.receiptId));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "renewalDate"), JSIConverter<double>::toJSI(runtime, arg.renewalDate));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "term"), JSIConverter<std::string>::toJSI(runtime, arg.term));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "termSku"), JSIConverter<std::string>::toJSI(runtime, arg.termSku));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "testTransaction"), JSIConverter<bool>::toJSI(runtime, arg.testTransaction));
      return obj;
    }
    static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
      if (!value.isObject()) {
        return false;
      }
      jsi::Object obj = value.getObject(runtime);
      if (!nitro::isPlainObject(runtime, obj)) {
        return false;
      }
      if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "autoRenewing")))) return false;
      if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "betaProduct")))) return false;
      if (!JSIConverter<std::optional<std::variant<nitro::NullType, double>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cancelDate")))) return false;
      if (!JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cancelReason")))) return false;
      if (!JSIConverter<std::optional<std::variant<nitro::NullType, double>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "deferredDate")))) return false;
      if (!JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "deferredSku")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "freeTrialEndDate")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "gracePeriodEndDate")))) return false;
      if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "parentProductId")))) return false;
      if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "productId")))) return false;
      if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "productType")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "purchaseDate")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "quantity")))) return false;
      if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "receiptId")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "renewalDate")))) return false;
      if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "term")))) return false;
      if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "termSku")))) return false;
      if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "testTransaction")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
