Skip to main content
Version: Released

Template Application Iframe Messages

As the planner, the template application can be embedded in a web site. This section describes Iframe messages that are listened by the template editor (input) to react to parent window actions or emitted by the template editor (output) to enable parent window to react.

 

For...Inputs MessagesOutputs Messages
AuthenticationAuthentication TokenRefreshedAuthenticationRequired, AuthenticationSucceeded, AuthenticationFailed, TokenExpired
ApplicationCloseApp
Open SaveSnapshotRequestedSnapshotGenerated SaveRequested

Endpoints

A website offering access to the template editor application must embed it in an Iframe. The application endpoint to use depends on the integration context. You have to add /TemplateEditor/ after your environment url.

Example : https://xxx.by.me/TemplateEditor/

The xxx part depends on the integration context that was provided to you.

Iframe communication

To have an overview of the subject, we advise you to read window.postMessage documentation on the web.

➡️ Refer to PostMessage documentation 🔗

Every message received by the application or sent by the application through window.postMessage must be an object of this format:

KeyTypeDescription
eventstringThe event name is used as unique identifier for a given event.
content*Content sent with the event. It is optional and can be anything: integer, array, object...
Template
{
event:" AuthenticationRequired ",
content:
{
"token": string,
"distributionID": string
}
}

Authentication

AuthenticationRequired

Output emitted when the application requests authentication parameters. Upon this request, the parent window must reply with an Authentication message.

KeyTypeValue/TemplateDescription
eventstringAuthenticationRequired
content

Authentication

Input received when authentication is requested by the message AuthenticationRequired, the parent window must reply with this message.

KeyTypeValueDescription
eventstringAuthentication
contentobjecttoken
distributionID
token: The legal entity token generated by the client website.
distributionID: The specific distribution in the legal entity.
Template
{
"token": string
"distributionID": string
}

AuthenticationSucceeded

Output emitted by the application to acknowledge that authentication is successful.

KeyTypeValue/TemplateDescription
eventstringAuthenticationSucceeded
contentobjectorigin
appID
distributionID
distributionParams
origin: the domain from which the message originated.
appID: the application ID associated with the provided credentials.
distributionID: the distribution ID associated with the provided credentials.
distributionParams: the distribution-specific parameters, if any, of the distribution associated with the provided credentials.
Template
{
"origin": string,
"appID": string,
"distributionID": string,
"distributionParams": object
}

AuthenticationFailed

Output emitted by the application to inform that authentication has failed.

KeyTypeValue/TemplateDescription
eventstringAuthenticationFailed
contentobjecthttpCode
id
message
httpCode: the HTTP error code for the request.
id: the error id.
message: the detailed error message.
Template
{
"httpCode": HttpErrorCode,
"id": string,
"message": string
}

TokenExpired

Output emitted and sent to the parent window when a token is expired, subsequent calls to the web-services will fail with a 401 error.

KeyTypeValue/TemplateDescription
eventstringTokenExpired
content

TokenRefreshed

Input received from the parent window. This message is send by the parent window when receiving TokenExpired. This message provides a new valid token to the application to authentify subsequent calls to web services.

KeyTypeValueDescription
eventstringTokenRefreshed
contentobjecttoken
distributionID
token: The legal entity token generated by the client website.
distributionID: The specific distribution in the legal entity.
Template
{
"token": string,
"distributionID": string
}

Application

CloseApp

Output emitted when the user clicks on the cross button to close the application.

KeyTypeValue/TemplateDescription
eventstringCloseApp
content

Open Save

SaveRequested

Output emitted on click on save in template application. It is emitted before the save of the template on local disk.

KeyTypeValue/TemplateDescription
eventStringSaveRequested
content

SnapshotRequested

Input request that triggers the generation of a current view snapshot. SnapshotGenerated event will be thrown at the end.

KeyTypeValue/TemplateDescription
eventstringSnapshotRequested
content

SnapshotGenerated

Output emitted when the computation of the snapshot has finished.

KeyTypeValue/TemplateDescription
eventstringSnapshotGenerated
contentobjectname
image
name: "Snapshot" string.
image: Contains a jpeg image of the snapshot as a base-64 encoded string. It can be set directly to an img tag by doing "img.src = image".
Template
{
"name": string,
"image": string
}