in facebook-core/src/main/java/com/facebook/appevents/AppEventsLoggerImpl.kt [183:255]
fun logProductItem(
itemID: String?,
availability: AppEventsLogger.ProductAvailability?,
condition: AppEventsLogger.ProductCondition?,
description: String?,
imageLink: String?,
link: String?,
title: String?,
priceAmount: BigDecimal?,
currency: Currency?,
gtin: String?,
mpn: String?,
brand: String?,
parameters: Bundle?
) {
var parameters = parameters
if (itemID == null) {
notifyDeveloperError("itemID cannot be null")
return
} else if (availability == null) {
notifyDeveloperError("availability cannot be null")
return
} else if (condition == null) {
notifyDeveloperError("condition cannot be null")
return
} else if (description == null) {
notifyDeveloperError("description cannot be null")
return
} else if (imageLink == null) {
notifyDeveloperError("imageLink cannot be null")
return
} else if (link == null) {
notifyDeveloperError("link cannot be null")
return
} else if (title == null) {
notifyDeveloperError("title cannot be null")
return
} else if (priceAmount == null) {
notifyDeveloperError("priceAmount cannot be null")
return
} else if (currency == null) {
notifyDeveloperError("currency cannot be null")
return
} else if (gtin == null && mpn == null && brand == null) {
notifyDeveloperError("Either gtin, mpn or brand is required")
return
}
if (parameters == null) {
parameters = Bundle()
}
parameters.putString(Constants.EVENT_PARAM_PRODUCT_ITEM_ID, itemID)
parameters.putString(Constants.EVENT_PARAM_PRODUCT_AVAILABILITY, availability.name)
parameters.putString(Constants.EVENT_PARAM_PRODUCT_CONDITION, condition.name)
parameters.putString(Constants.EVENT_PARAM_PRODUCT_DESCRIPTION, description)
parameters.putString(Constants.EVENT_PARAM_PRODUCT_IMAGE_LINK, imageLink)
parameters.putString(Constants.EVENT_PARAM_PRODUCT_LINK, link)
parameters.putString(Constants.EVENT_PARAM_PRODUCT_TITLE, title)
parameters.putString(
Constants.EVENT_PARAM_PRODUCT_PRICE_AMOUNT,
priceAmount.setScale(3, BigDecimal.ROUND_HALF_UP).toString())
parameters.putString(Constants.EVENT_PARAM_PRODUCT_PRICE_CURRENCY, currency.currencyCode)
if (gtin != null) {
parameters.putString(Constants.EVENT_PARAM_PRODUCT_GTIN, gtin)
}
if (mpn != null) {
parameters.putString(Constants.EVENT_PARAM_PRODUCT_MPN, mpn)
}
if (brand != null) {
parameters.putString(Constants.EVENT_PARAM_PRODUCT_BRAND, brand)
}
logEvent(AppEventsConstants.EVENT_NAME_PRODUCT_CATALOG_UPDATE, parameters)
eagerFlush()
}