package com.fireworksdk.bridge.models import com.firework.common.tracking.ProductItem object FWTrackPurchaseMapper { /** * Maps bridge purchase products to the native SDK [ProductItem] list. * * Returns null when [products] is null so the native SDK omits `line_items` * instead of sending an empty array. */ fun toProductItems(products: List?): List? { return products?.map { ProductItem( productId = it.extProductId ?: it.sku ?: "", price = it.price ?: 0.0, quantity = it.quantity ?: 0, productName = it.productName, sku = it.sku, ) } } }