Package com.tomtom.ivi.platform.alexa.api.common.util

This package contains classes and functions which are intended for use by services or frontends that interact with the Alexa Voice Personal Assistant (VPA).

More specifically, the AacsSenderWrapper class and the utility functions in AlexaMessageData, such as parseAasbMessage or createAasbReplyHeader, should be used when implementing a com.tomtom.ivi.platform.alexa.api.service.alexahandler.AlexaHandlerService.

Types

Link copied to clipboard
class AacsSenderWrapper

A class that is used to send Alexa Auto Services Bridge (AASB) messages to the Alexa Auto Client Service (AACS). A service implementing the AlexaHandlerService should use this class to send requests/replies to the AACS.

Link copied to clipboard
data class AasbMessageNoPayload(val header: Header)

A class representing a basic AASB message with no custom payload. The classes mirror the JSON messages as described in the Alexa Auto AASB specification.

Link copied to clipboard
data class Header(    val id: String,     val messageDescription: MessageDescription,     val messageType: String,     val version: String)

A class representing the header field of a generic AASB message, as described in the Alexa Auto AASB specification.

Link copied to clipboard
data class ImageSource(    val url: String? = null,     val darkBackgroundUrl: String? = null,     val size: String? = null,     val widthPixels: Long? = null,     val heightPixels: Long? = null)
Link copied to clipboard
typealias ImageSources = List<ImageSource>
Link copied to clipboard
data class ImageStructure(val contentDescription: String? = null, val sources: ImageSources)
Link copied to clipboard
data class MessageDescription(    val topic: String,     val action: String,     val replyToId: String? = null)

A class representing the messageDescription field of the header of a generic AASB message, as described in the Alexa Auto AASB specification.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.FIELD])
annotation class WarnIfMissingOrNull

Annotation used to mark JSON fields that we allow to be null or missing, but for which we want to print a warning when that's the case.

Functions

Link copied to clipboard
fun Any.checkMissingOrNullFields()
Link copied to clipboard
fun createAasbReplyHeader(    requestId: String,     topic: String,     action: String): Header

Create an AASB reply header object. A reply is the response to a previously received message.

Link copied to clipboard
fun createAasbRequestHeader(    requestId: String,     topic: String,     action: String): Header

Create an AASB request header object. A request is a message from the client to Alexa which is not a reply to a previously sent message from Alexa. A request may or may not have a reply.

Link copied to clipboard
fun createAasbRequestNoPayload(    id: String,     topic: String,     action: String): AasbMessageNoPayload

Creates an object to represent a request from the client to Alexa, that does not require a payload. A request is a message from the client to Alexa which is not a reply to a previously sent message from Alexa. A request may or may not have a reply.

Link copied to clipboard
fun String.excludePlaceholderUrl(): String?
Link copied to clipboard
fun ImageStructure?.getAppropriateImageSourceOrNull(): ImageSource?
Link copied to clipboard
inline fun <T : Any> parseAasbMessage(json: Json, jsonMessage: String): T?

Parses an AASB (Alexa Auto Services Bridge) message. These are messages sent via Intents from the Alexa Auto Client Service (AACS). A service implementing the AlexaHandlerService should use this method to parse AASB messages.

Link copied to clipboard
inline fun <T> parseJson(jsonData: String): T?
Link copied to clipboard
fun ImageSources.selectAppropriateImageSource(): ImageSource?
Link copied to clipboard
fun String.withAasbIntentPrefix(): String

Returns this string with the Alexa Auto Service Broker (AASB) prefix, resulting in the fully-qualified name of the Intent action or category.

Link copied to clipboard
fun String.withoutAasbIntentPrefix(): String?

Returns this string without the Alexa Auto Service Broker (AASB) prefix, or null if such a prefix was not found.