Skip to main content

Building a Code Interpreter

note

This section is currently under active development. Please check back later.

Interpret code request & response

Example request:

{
"code": "abc123",
"context": {
"orderId": "...",
"storeId": "...",
"userId": "..."
}
}

Example response:

{
"owner": true,
"statusCode": "successful",
"code": "abc123",
"actions": [
...
]
}

Response actions

show-modal-dialog

Returning this action shows a modal dialog to the guest. If mixed with other actions, action processing is paused until the dialog is closed.

Action object properties

PropertyTypeDescription
typestringThe action type: show-modal-dialog
titlelocalizedTextThe header shown in the modal dialog.
messagelocalizedTextThe message shown in the modal dialog.
buttonsmodalDialogButton[]A list of buttons to show in the modal dialog.

modalDialogButton object properties

PropertyTypeDescription
buttonTypestringThe button type.
Valid values: primary
textlocalizedTextThe button text.

localizedText object properties

PropertyTypeDescription
valuestringA fallback text value used if no applicable translation is found.
translationsobjectA map of culture code (e.g. en-GB) to translated text value.

Example:

{
"type": "show-modal-dialog",
"title": {
"value": "Welcome!",
"translations": {
"en-GB": "Welcome!",
"sv-SE": "Välkommen!"
}
},
"message": {
"value": "You are now signed in.",
"translations": {
"en-GB": "You are now signed in.",
"sv-SE": "Du är nu inloggad."
}
},
"button": {
"value": "OK",
"translations": {
"en-GB": "OK",
"sv-SE": "OK"
}
}
}

sign-in

Returning this action allows user sign-in as a result of scanning a code.

Action object properties

PropertyTypeDescription
typestringThe action type: sign-in
userIdstringThe ID of the user signing in.
authorizationCodestringA temporary authorization code generated for the user signing in. See xx for more information.

Example:

{
"type": "sign-in",
"userId": "abc123",
"authorizationCode": "def456"
}