Android Journey Service
Functions
syncJourneys
suspend fun syncJourneys(): Result<Unit>
Synchronize Journey list with the Orchestrator.
Parameters: None.
syncJourneys
fun syncJourneys(
onSuccess: () -> Unit,
onError: ((Throwable) -> Unit)? = null
): Unit
Synchronize Journey list with the Orchestrator.
Parameters:
onSuccess: () -> Unit— Called when the sync operation completes successfully.onError: ((Throwable) -> Unit)?— Called when an error occurs during sync.
getJourneys
suspend fun getJourneys(
tags: List<String> = emptyList(),
statuses: List<JourneyStatus> = listOf(JourneyStatus.NOT_STARTED)
): Result<List<Journey>>
Fetch journeys from local storage, optionally filtered by tags and status.
Parameters:
tags: List— Optional filter list. Empty means no tag filtering.statuses: List— Optional status filter. Empty means no filtering.
getJourneys
fun getJourneys(
tags: List<String> = emptyList(),
statuses: List<JourneyStatus> = listOf(JourneyStatus.NOT_STARTED),
onSuccess: (List<Journey>) -> Unit,
onError: ((Throwable) -> Unit)? = null
): Unit
Fetch journeys from local storage, optionally filtered by tags and status.
Parameters:
tags: List— Optional filter list. Empty means no tag filtering.statuses: List— Optional status filter. Empty means no filtering.onSuccess: (List) -> Unit— Returns all matching journeys.onError: ((Throwable) -> Unit)?— Error callback.
getJourney
suspend fun getJourney(name: String): Result<Journey?>
Retrieves a journey by its name from local storage.
Parameters:
name: String— Name of the journey.
getJourney
fun getJourney(
name: String,
onSuccess: (Journey?) -> Unit,
onError: ((Throwable) -> Unit)? = null
): Unit
Retrieves a journey by its name from local storage.
Parameters:
name: String— Name of the journey.onSuccess: (Journey?) -> Unit— Returns the journey or null.onError: ((Throwable) -> Unit)?— Error callback.
getJourneyExecutionRecords
suspend fun getJourneyExecutionRecords(name: String): Result<List<JourneyExecutionRecord>?>
Retrieves all execution records associated with the specified journey.
Parameters:
name: String— Name of the journey.
getJourneyExecutionRecords
fun getJourneyExecutionRecords(
name: String,
onSuccess: (List<JourneyExecutionRecord>?) -> Unit,
onError: ((Throwable) -> Unit)? = null
): Unit
Retrieves all execution records associated with the specified journey.
Parameters:
name: String— Name of the journey.onSuccess: (List?) -> Unit— List of execution records or null.onError: ((Throwable) -> Unit)?— Error callback.
getLastJourneyExecutionRecord
suspend fun getLastJourneyExecutionRecord(name: String): Result<JourneyExecutionRecord?>
Returns the latest execution record for the given journey.
Parameters:
name: String— Name of the journey.
getLastJourneyExecutionRecord
fun getLastJourneyExecutionRecord(
name: String,
onSuccess: (JourneyExecutionRecord?) -> Unit,
onError: ((Throwable) -> Unit)? = null
): Unit
Returns the latest execution record for the given journey.
Parameters:
name: String— Name of the journey.onSuccess: (JourneyExecutionRecord?) -> Unit— Latest execution record or null.onError: ((Throwable) -> Unit)?— Error callback.
getJourneyStatus
suspend fun getJourneyStatus(name: String): Result<JourneyStatus?>
Retrieves the current status of the specified journey.
Parameters:
name: String— Name of the journey.
getJourneyStatus
fun getJourneyStatus(
name: String,
onSuccess: (JourneyStatus?) -> Unit,
onError: ((Throwable) -> Unit)? = null
): Unit
Retrieves the current status of the specified journey.
Parameters:
name: String— Name of the journey.onSuccess: (JourneyStatus?) -> Unit— The current status.onError: ((Throwable) -> Unit)?— Error callback.
runJourney
suspend fun runJourney(
context: Context,
name: String,
data: Map<String, Any?>? = null
): Result<Map<String, Any?>>
Launches the specified journey UI and returns its output data upon completion.
Parameters:
context: Context— Android context.name: String— Journey name.data: Map?— Optional initial payload.
runJourney
fun runJourney(
context: Context,
name: String,
data: Map<String, Any?>? = null,
onSuccess: (Map<String, Any?>) -> Unit,
onError: ((Throwable) -> Unit)? = null
): Map<String, Any?>
Launches the specified journey UI and returns its output data upon completion.
Parameters:
context: Context— Android context.name: String— Journey name.data: Map?— Optional initial payload.onSuccess: () -> Unit— Resulting output data.onError: ((Throwable) -> Unit)?— Error callback.
Classes
Journey
data class Journey(
val id: UUID,
val name: String,
val flow: JourneyFlow,
val metadata: JourneyMetadata,
val tags: List<String>? = listOf(),
val zpdRequest: JourneyZPDRequest?,
val createdAt: Double,
val updatedAt: Double? = null,
val publishedAt: Double? = null
)
JourneyMetadata
data class JourneyMetadata(
val title: String,
val description: String? = null,
val imageUrl: String? = null
)
JourneyFlow
data class JourneyFlow(
val xml: String,
val data: List<JourneyFlowData>? = listOf()
)
JourneyFlowData
data class JourneyFlowData(
val type: String,
val name: String,
val source: String,
val origin: String? = null
)
JourneyZPDRequest
data class JourneyZPDRequest(
val requested: List<JourneyFlowData>? = listOf()
)
JourneyFlowDataType
enum class JourneyFlowDataType(val type: String) {
MEDATA("MEDATA"),
INPUT("INPUT"),
CALCULATED("CALCULATED"),
ANSWER("ANSWER")
}
JourneyStatus
enum class JourneyStatus {
NOT_STARTED,
COMPLETED,
SENT
}
JourneyStatusFilter
typealias JourneyStatusFilter = List<JourneyStatus>
JourneyContext
class JourneyContext private constructor(
private val values: MutableMap<String, Any?> = mutableMapOf()
)
JourneyExecutionRecord
data class JourneyExecutionRecord(
val id: UUID,
val status: String,
val journeyContext: JourneyContext?,
val date: Double
)
JourneyZPD
data class JourneyZPD(
val data: List<SharedData>
)
SharedData
data class SharedData(
val type: String,
val name: String,
val source: String,
val origin: String? = null,
val value: String,
)