package com.adealink.weparty.wallet.pay.model

import com.adealink.weparty.module.wallet.data.PayChannel
import com.adealink.weparty.module.wallet.data.SkuInfo
import com.android.billingclient.api.ProductDetails
import com.android.billingclient.api.SkuDetails

data class GoogleSkuInfo(
    override val payChannel: PayChannel = PayChannel.Google,
    val skuDetails: ProductDetails? = null,
    val skuDetailsOld: SkuDetails? = null,
) : SkuInfo {

    override fun getSkuId(): String {
        if (skuDetails != null) {
            return skuDetails.productId
        }
        if (skuDetailsOld != null) {
            return skuDetailsOld.sku
        }
        return ""
    }

    override fun getPriceAmountMicros(): Long {
        if (skuDetails != null) {
            return skuDetails.oneTimePurchaseOfferDetails?.priceAmountMicros ?: 0
        }
        if (skuDetailsOld != null) {
            return skuDetailsOld.priceAmountMicros
        }
        return 0
    }

    override fun getPriceCurrencyCode(): String {
        if (skuDetails != null) {
            return skuDetails.oneTimePurchaseOfferDetails?.priceCurrencyCode ?: ""
        }
        if (skuDetailsOld != null) {
            return skuDetailsOld.priceCurrencyCode
        }
        return ""
    }

}