Android · cartesian-core
Models
Product, Cart, Wishlist, Comparison, ShopperProfile and User.
Models wrap the backend's JSON. The typed getters cover common fields, and toJson() returns the full object so that fields specific to your backend aren't lost.
Product
| Property | Type | Notes |
|---|---|---|
id | String | product_id, falling back to id |
name | String | |
brand | String? | manufacturer |
price | Double? | The current price. Apparel sale_price wins when it is lower. |
regularPrice | Double? | Set only when the product is on sale |
isOnSale | Boolean | |
currency | String | Default USD |
imageUrl, productUrl, sku, size, category, department, aisle, shelf, color, description, promoLabel | String? | |
features | List<String> | |
rating | Double? | |
reviewCount | Int? | |
isUsual | Boolean | The shopper buys it regularly |
isSnapEligible | Boolean? | Grocery |
attributes | Set<String> | All JSON keys present |
val json = product.toJson()
val again = Product.fromJson(json)kotlinCart and Wishlist
Cart | |
|---|---|
lines | List<CartLine>, each with product and quantity |
itemCount / distinctItemCount | Int |
total / currency | Double? / String? |
allPricesAvailable | Boolean |
quantityOf(productId) | Int |
Wishlist.products: List<Product>, Wishlist.contains(productId). Both have an EMPTY constant.
Comparison
products, rows (feature, values), summary, nextStep, recommendations: Map<String, String>, and prosCons (product, pros, cons, whyBuy, whyNotBuy).
ShopperProfile
name, facts: Map<String, String>, and members (household members with id, name, relationship and facts), for example dietary needs and allergies the assistant remembers.
User and AuthState
sealed interface AuthState {
data object Restoring : AuthState
data object SignedOut : AuthState
class SignedIn(val user: User) : AuthState // user.id, user.email, user.displayName
}kotlin