///
/// SubscriptionReplacementModeAndroid.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/NitroHash.hpp>)
#include <NitroModules/NitroHash.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#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

namespace margelo::nitro::iap {

  /**
   * An enum which can be represented as a JavaScript union (SubscriptionReplacementModeAndroid).
   */
  enum class SubscriptionReplacementModeAndroid {
    UNKNOWN_REPLACEMENT_MODE      SWIFT_NAME(unknownReplacementMode) = 0,
    WITH_TIME_PRORATION      SWIFT_NAME(withTimeProration) = 1,
    CHARGE_PRORATED_PRICE      SWIFT_NAME(chargeProratedPrice) = 2,
    CHARGE_FULL_PRICE      SWIFT_NAME(chargeFullPrice) = 3,
    WITHOUT_PRORATION      SWIFT_NAME(withoutProration) = 4,
    DEFERRED      SWIFT_NAME(deferred) = 5,
    KEEP_EXISTING      SWIFT_NAME(keepExisting) = 6,
  } CLOSED_ENUM;

} // namespace margelo::nitro::iap

namespace margelo::nitro {

  // C++ SubscriptionReplacementModeAndroid <> JS SubscriptionReplacementModeAndroid (union)
  template <>
  struct JSIConverter<margelo::nitro::iap::SubscriptionReplacementModeAndroid> final {
    static inline margelo::nitro::iap::SubscriptionReplacementModeAndroid fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
      switch (hashString(unionValue.c_str(), unionValue.size())) {
        case hashString("unknown-replacement-mode"): return margelo::nitro::iap::SubscriptionReplacementModeAndroid::UNKNOWN_REPLACEMENT_MODE;
        case hashString("with-time-proration"): return margelo::nitro::iap::SubscriptionReplacementModeAndroid::WITH_TIME_PRORATION;
        case hashString("charge-prorated-price"): return margelo::nitro::iap::SubscriptionReplacementModeAndroid::CHARGE_PRORATED_PRICE;
        case hashString("charge-full-price"): return margelo::nitro::iap::SubscriptionReplacementModeAndroid::CHARGE_FULL_PRICE;
        case hashString("without-proration"): return margelo::nitro::iap::SubscriptionReplacementModeAndroid::WITHOUT_PRORATION;
        case hashString("deferred"): return margelo::nitro::iap::SubscriptionReplacementModeAndroid::DEFERRED;
        case hashString("keep-existing"): return margelo::nitro::iap::SubscriptionReplacementModeAndroid::KEEP_EXISTING;
        default: [[unlikely]]
          throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum SubscriptionReplacementModeAndroid - invalid value!");
      }
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::iap::SubscriptionReplacementModeAndroid arg) {
      switch (arg) {
        case margelo::nitro::iap::SubscriptionReplacementModeAndroid::UNKNOWN_REPLACEMENT_MODE: return JSIConverter<std::string>::toJSI(runtime, "unknown-replacement-mode");
        case margelo::nitro::iap::SubscriptionReplacementModeAndroid::WITH_TIME_PRORATION: return JSIConverter<std::string>::toJSI(runtime, "with-time-proration");
        case margelo::nitro::iap::SubscriptionReplacementModeAndroid::CHARGE_PRORATED_PRICE: return JSIConverter<std::string>::toJSI(runtime, "charge-prorated-price");
        case margelo::nitro::iap::SubscriptionReplacementModeAndroid::CHARGE_FULL_PRICE: return JSIConverter<std::string>::toJSI(runtime, "charge-full-price");
        case margelo::nitro::iap::SubscriptionReplacementModeAndroid::WITHOUT_PRORATION: return JSIConverter<std::string>::toJSI(runtime, "without-proration");
        case margelo::nitro::iap::SubscriptionReplacementModeAndroid::DEFERRED: return JSIConverter<std::string>::toJSI(runtime, "deferred");
        case margelo::nitro::iap::SubscriptionReplacementModeAndroid::KEEP_EXISTING: return JSIConverter<std::string>::toJSI(runtime, "keep-existing");
        default: [[unlikely]]
          throw std::invalid_argument("Cannot convert SubscriptionReplacementModeAndroid to JS - invalid value: "
                                    + std::to_string(static_cast<int>(arg)) + "!");
      }
    }
    static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
      if (!value.isString()) {
        return false;
      }
      std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
      switch (hashString(unionValue.c_str(), unionValue.size())) {
        case hashString("unknown-replacement-mode"):
        case hashString("with-time-proration"):
        case hashString("charge-prorated-price"):
        case hashString("charge-full-price"):
        case hashString("without-proration"):
        case hashString("deferred"):
        case hashString("keep-existing"):
          return true;
        default:
          return false;
      }
    }
  };

} // namespace margelo::nitro
