/// /// Purchase.kt /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo /// package com.margelo.nitro.iap import com.facebook.proguard.annotations.DoNotStrip /** * Represents the TypeScript variant "PurchaseAndroid | PurchaseIOS". */ @Suppress("ClassName") @DoNotStrip sealed class Purchase { @DoNotStrip data class First(@DoNotStrip val value: PurchaseAndroid): Purchase() @DoNotStrip data class Second(@DoNotStrip val value: PurchaseIOS): Purchase() val isFirst: Boolean get() = this is First val isSecond: Boolean get() = this is Second 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 } inline fun match(first: (PurchaseAndroid) -> R, second: (PurchaseIOS) -> R): R { return when (this) { is First -> first(value) is Second -> second(value) } } companion object { @JvmStatic @DoNotStrip fun create(value: PurchaseAndroid): Purchase = First(value) @JvmStatic @DoNotStrip fun create(value: PurchaseIOS): Purchase = Second(value) } }