Promotion
Represents a promotion that was evaluated against a receipt.
Package: com.microblink.core
Declaration
class Promotion : Parcelable
Constructors:
Promotion(id: Long, slug: String?, errorCode: Int, errorMessage: String?) // reward = 0
Promotion(id: Long, slug: String?, reward: BigDecimal?, rewardCurrency: String?) // errorCode = 0
Promotion(
id: Long,
slug: String?,
reward: BigDecimal?,
rewardCurrency: String?,
errorCode: Int,
errorMessage: String?
)
Quick Reference
Properties
| Property | Description |
|---|---|
id() | Server-assigned promotion identifier |
slug() | Human-readable promotion slug |
reward() | Reward value for this promotion |
rewardCurrency() | Currency code for the reward amount |
errorCode() | Error code from promotion evaluation |
errorMessage() | Human-readable error message |
qualifications() | Groups of product indices satisfying each rule |
qualifiedProducts() | Products that qualified for this promotion |
relatedProductIndexes() | Indices of products related to this promotion |
Methods
| Method | Description |
|---|---|
plusReward(amount) | Adds an amount to the reward |
qualification(indexes) | Adds a group of qualifying product indices |
Properties
id()
fun id(): Long
Server-assigned promotion identifier.
slug()
fun slug(): String?
Human-readable promotion slug (e.g., "summer-save-5").
reward()
fun reward(): BigDecimal?
Reward value for this promotion.
rewardCurrency()
fun rewardCurrency(): String?
fun rewardCurrency(currency: String): Promotion
Currency code for the reward amount. The setter returns self for chaining.
errorCode()
fun errorCode(): Int
Error code from promotion evaluation. 0 indicates success.
errorMessage()
fun errorMessage(): String?
Human-readable error message if errorCode() != 0.
qualifications()
fun qualifications(): List<List<Int>>?
Groups of product indices that satisfy each qualification rule.
qualifiedProducts()
fun qualifiedProducts(): List<QualifiedProduct>?
Products that qualified for this promotion. See QualifiedProduct.
relatedProductIndexes()
fun relatedProductIndexes(): List<Int>?
Indices into ScanResults.products() for products related to this promotion.
Methods
plusReward(amount)
fun plusReward(amount: BigDecimal)
Adds amount to reward(). Has no effect when reward() is null.
qualification(indexes)
fun qualification(indexes: List<Int>): Promotion
Adds indexes as one group in qualifications() and updates relatedProductIndexes() to the unique indices across all groups. An empty list is ignored. Returns self for chaining.