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 Messages | Outputs Messages |
---|---|---|
Authentication | Authentication TokenRefreshed | AuthenticationRequired , AuthenticationSucceeded , AuthenticationFailed , TokenExpired |
Application | CloseApp | |
Open Save | SnapshotRequested | SnapshotGenerated 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:
Key | Type | Description |
---|---|---|
event | string | The 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.
Key | Type | Value/Template | Description |
---|---|---|---|
event | string | AuthenticationRequired | – |
content | – | – | – |
Authentication
Input received when authentication is requested by the message AuthenticationRequired
, the parent window must reply with this message.
Key | Type | Value | Description |
---|---|---|---|
event | string | Authentication | – |
content | object | token 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.
Key | Type | Value/Template | Description |
---|---|---|---|
event | string | AuthenticationSucceeded | – |
content | object | origin 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.
Key | Type | Value/Template | Description |
---|---|---|---|
event | string | AuthenticationFailed | – |
content | object | httpCode 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.
Key | Type | Value/Template | Description |
---|---|---|---|
event | string | TokenExpired | – |
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.
Key | Type | Value | Description |
---|---|---|---|
event | string | TokenRefreshed | – |
content | object | token 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.
Key | Type | Value/Template | Description |
---|---|---|---|
event | string | CloseApp | – |
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.
Key | Type | Value/Template | Description |
---|---|---|---|
event | String | SaveRequested | – |
content | – | – | – |
SnapshotRequested
Input request that triggers the generation of a current view snapshot. SnapshotGenerated
event will be thrown at the end.
Key | Type | Value/Template | Description |
---|---|---|---|
event | string | SnapshotRequested | – |
content | – | – | – |
SnapshotGenerated
Output emitted when the computation of the snapshot has finished.
Key | Type | Value/Template | Description |
---|---|---|---|
event | string | SnapshotGenerated | – |
content | object | name 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
}