Cartesiandocs

Android · cartesian-core

CartesianClient

The headless client. It handles session, connection, cart, wishlist, threads and chat.

public class CartesianClient @JvmOverloads constructor(
    public val config: CartesianConfig,
    sessionStore: SessionStore = InMemorySessionStore(),
) : Closeable
kotlin

When you use cartesian-ui, get it from Cartesian.client. Create one yourself only for headless use.

State

PropertyType
authStateStateFlow<AuthState>
connectionStateFlow<ConnectionState>
cartStateFlow<Cart>
wishlistStateFlow<Wishlist>
threadsStateFlow<List<ThreadSummary>>
chatChatSession
hasSavedSessionBoolean

Session

MethodHTTPNotes
suspend signIn(sessionToken): UserGET /api/auth/sessionSaves the token, connects, and loads the cart, wishlist and threads
suspend restore(): AuthStateGET /api/auth/sessionRestores the saved token. Network and 5xx errors keep it.
suspend signOut()POST /api/auth/logoutClears the stored token
suspend connect() / disconnect()WS /wsUsually automatic
close()Releases the socket and scope

Threads

MethodHTTP
suspend refreshThreads(): List<ThreadSummary>GET /api/threads
suspend renameThread(threadId, name)PATCH /api/threads/{id}
suspend deleteThread(threadId)DELETE /api/threads/{id}

Cart

MethodHTTP
suspend refreshCart(): CartGET /api/account/cart
suspend addToCart(product, quantity = 1): CartPOST /api/account/cart/items (or the thread cart during a conversation)
suspend setCartQuantity(productId, quantity): CartPUT /api/account/cart/items/{id}
suspend removeFromCart(productId): CartDELETE /api/account/cart/items/{id}
suspend clearCart(): CartDELETE /api/account/cart

Wishlist, profile and tools

MethodHTTP
suspend refreshWishlist(): WishlistGET /api/account/wishlist
suspend save(product): WishlistPOST /api/account/wishlist
suspend unsave(productId): WishlistDELETE /api/account/wishlist/{id}
suspend profile(): ShopperProfileGET /api/account/profile
suspend compare(productIds): ComparisonPOST /api/threads/{id}/compare
suspend readPhotoText(jpegDataUrl): StringPOST /api/ocr

CartesianConfig

CartesianConfig.builder(vertical: Vertical, baseUrl: String)
    .okHttpClient(client)
    .userAgent("App/1.0")
    .logger { Log.d("Cartesian", it) }
    .licenseKey(key)
    .build()
kotlin

Every request carries User-Agent: cartesian-android/<version> <yours> and X-Cartesian-SDK: android/<version>.