iosMain.com.revenuecat.purchases.kmp.mappings.Price.ios.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of purchases-kmp-mappings Show documentation
Show all versions of purchases-kmp-mappings Show documentation
Mobile subscriptions in hours, not months.
package com.revenuecat.purchases.kmp.mappings
import cocoapods.PurchasesHybridCommon.RCStoreProduct
import cocoapods.PurchasesHybridCommon.RCStoreProductDiscount
import cocoapods.PurchasesHybridCommon.priceAmount
import com.revenuecat.purchases.kmp.models.Price
internal fun RCStoreProduct.toPrice(): Price =
Price(
formatted = localizedPriceString(),
amountMicros = priceAmount().decimalNumberByMultiplyingByPowerOf10(6).longValue,
currencyCode = currencyCodeOrUsd(),
)
internal fun RCStoreProduct.currencyCodeOrUsd(): String =
currencyCode() ?: priceFormatter()?.currencyCode() ?: "USD" // FIXME revisit
internal fun RCStoreProductDiscount.toPrice(): Price =
Price(
formatted = localizedPriceString(),
amountMicros = priceAmount().decimalNumberByMultiplyingByPowerOf10(6).longValue,
currencyCode = currencyCodeOrUsd(),
)
internal fun RCStoreProductDiscount.currencyCodeOrUsd(): String =
currencyCode() ?: "USD" // FIXME revisit