Package-level declarations

Types

Link copied to clipboard
@Serializable
data class CapabilityRequest(val type: String, val config: JsonObject? = null, val playbookId: String? = null)

A capability to run, with its per-capability configuration.

Link copied to clipboard
data class Cart(val type: CartType, val products: List<CartProduct>, val additionalContext: Map<String, String>? = null, val vibes: List<Vibe>? = null) : ExperienceContext

A basket or selection of products.

Link copied to clipboard
data class CartProduct(val productId: String? = null, val name: String? = null, val brand: String? = null, val price: Double? = null, val category: String? = null)

A product in a cart. Supply productId to have the catalog fill the rest.

Link copied to clipboard
@Serializable
enum CartType : Enum<CartType>

What kind of cart is being described.

Link copied to clipboard
@Serializable
@SerialName(value = "cruise")
data class Cruise(val departurePort: String, val arrivalPort: String, val departureTimestamp: Long, val arrivalTimestamp: Long, val numTravelers: Int) : Travel

A cruise leg.

Link copied to clipboard
data class EngagementDecision(val decisionId: String, val experienceId: String, val accessToken: String, val status: String, val widgets: List<Widget> = emptyList(), val widgetData: JsonObject? = null)

The outcome of an engagement decision.

Link copied to clipboard

A handle to one experience.

Link copied to clipboard
sealed interface ExperienceContext

The subject of an experience.

Link copied to clipboard
@Serializable
data class ExperienceResult(val experienceId: String, val status: ExperienceStatus, val widgets: List<Widget> = emptyList())

A fully-polled experience.

Link copied to clipboard
@Serializable
enum ExperienceStatus : Enum<ExperienceStatus>

Where an experience is in its lifecycle.

Link copied to clipboard
@Serializable
@SerialName(value = "flight")
data class Flight(val departureAirport: String, val arrivalAirport: String, val departureTimestamp: Long, val arrivalTimestamp: Long, val numTravelers: Int, val seatClass: SeatClass) : Travel

A flight leg.

Link copied to clipboard
interface HttpEngine

The SDK's one outbound seam.

Link copied to clipboard
data class HttpResponse(val status: Int, val body: String)

A raw HTTP response, before any status interpretation.

Link copied to clipboard
class OkHttpEngine(client: OkHttpClient = defaultClient()) : HttpEngine

Default HttpEngine, backed by OkHttp.

Link copied to clipboard
@Serializable
enum SeatClass : Enum<SeatClass>

Cabin class on a flight.

Link copied to clipboard
@Serializable
data class Signal(val externalCustomerId: String, val signalType: String, val occurredAt: String = nowIso(), val clientSignalId: String = UUID.randomUUID().toString(), val properties: Map<String, String> = emptyMap())

One behavioural event about a customer.

Link copied to clipboard
@Serializable
data class SignalIngestResult(val accepted: Int = 0, val rejected: Int = 0, val errors: List<SignalRejection> = emptyList())

What ingest did with a batch.

Link copied to clipboard
@Serializable
data class SignalRejection(val clientSignalId: String? = null, val field: String? = null, val error: String? = null)

Why one signal was rejected at ingest.

Link copied to clipboard
class ThanklyCatalog(config: ThanklyConfig, engine: HttpEngine = OkHttpEngine())

Catalog reads and asset uploads.

Link copied to clipboard
class ThanklyClient(config: ThanklyConfig, engine: HttpEngine = OkHttpEngine())

Entry point for the Experience API.

Link copied to clipboard
class ThanklyConfig(apiHost: String, val tokenProvider: TokenProvider, val pollIntervalMs: Long, val maxPollAttempts: Int = 60)

How this client reaches Thankly.

Link copied to clipboard

Every error this SDK raises.

Link copied to clipboard
class ThanklyLifecycle(config: ThanklyConfig, engine: HttpEngine = OkHttpEngine())

Lifecycle marketing: signals in, engagement decisions out, outcomes back.

Link copied to clipboard
data class Token(val value: String, val expiresIn: Duration)

An access token and how long it remains valid.

Link copied to clipboard
fun interface TokenProvider

Supplies a Cognito access token for the X-Authorization header.

Link copied to clipboard
data class Topic(val topic: String, val questions: List<String>, val additionalContext: Map<String, String>? = null, val vibes: List<Vibe>? = null) : ExperienceContext

A subject the customer is interested in, with questions to answer about it.

Link copied to clipboard
@Serializable
sealed interface Travel

How a customer is travelling.

Link copied to clipboard
data class Trip(val travel: Travel? = null, val location: TripLocation? = null, val additionalContext: Map<String, String>? = null, val vibes: List<Vibe>? = null) : ExperienceContext

A journey, a place, or both.

Link copied to clipboard
data class TripLocation(val placeName: String? = null, val latitude: Double? = null, val longitude: Double? = null, val radiusMeters: Int? = null)

A place to bias discovery toward.

Link copied to clipboard
@Serializable
enum Vibe : Enum<Vibe>

Mood applied to recommendations. Mirrors Vibe in api/domains/experiences.py.

Link copied to clipboard
@Serializable
data class Widget(val capabilityId: String, val type: String? = null, val status: String, val currentVersion: Int = 0, val heading: String? = null, val errorMessage: String? = null, val data: JsonObject? = null)

One capability's output within an experience.

Functions

Link copied to clipboard
fun TokenProvider.Companion.caching(safetyMargin: Duration = 60.seconds, now: () -> Long = { System.currentTimeMillis() }, fetch: suspend () -> Token): TokenProvider

Wrap a token source in caching, early refresh, and refresh coalescing.

Link copied to clipboard
fun TokenProvider.Companion.clientCredentials(clientId: String, clientSecret: String, apiHost: String, engine: HttpEngine = OkHttpEngine()): TokenProvider

Exchange client credentials for an access token, with caching.