/// /// RequestPurchaseResult.kt /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © 2025 Marc Rousavy @ Margelo /// package com.margelo.nitro.iap import com.facebook.proguard.annotations.DoNotStrip /** * Represents the TypeScript variant "PurchaseAndroid | PurchaseIOS | Array". */ @Suppress("ClassName") @DoNotStrip sealed class RequestPurchaseResult { @DoNotStrip data class First(@DoNotStrip val value: PurchaseAndroid): RequestPurchaseResult() @DoNotStrip data class Second(@DoNotStrip val value: PurchaseIOS): RequestPurchaseResult() @DoNotStrip data class Third(@DoNotStrip val value: Array): RequestPurchaseResult() @Deprecated("getAs() is not type-safe. Use fold/asFirstOrNull/asSecondOrNull instead.", level = DeprecationLevel.ERROR) inline fun getAs(): T? = when (this) { is First -> value as? T is Second -> value as? T is Third -> value as? T } val isFirst: Boolean get() = this is First val isSecond: Boolean get() = this is Second val isThird: Boolean get() = this is Third fun asFirstOrNull(): PurchaseAndroid? { val value = (this as? First)?.value ?: return null return value } fun asSecondOrNull(): PurchaseIOS? { val value = (this as? Second)?.value ?: return null return value } fun asThirdOrNull(): Array? { val value = (this as? Third)?.value ?: return null return value } inline fun match(first: (PurchaseAndroid) -> R, second: (PurchaseIOS) -> R, third: (Array) -> R): R { return when (this) { is First -> first(value) is Second -> second(value) is Third -> third(value) } } companion object { @JvmStatic @DoNotStrip fun create(value: PurchaseAndroid): RequestPurchaseResult = First(value) @JvmStatic @DoNotStrip fun create(value: PurchaseIOS): RequestPurchaseResult = Second(value) @JvmStatic @DoNotStrip fun create(value: Array): RequestPurchaseResult = Third(value) } }