AppBus Integration API
The following capabilities are available as part of the integration capability of SmartHub.
Attribute-driven Configuration
The following attributes can be used in HTML to configure/customize the integration execution.
Field Attributes
Attribute | Value | Description |
---|---|---|
data-edit |
Boolean value Default: false |
Controls if the field is supposed to be editable |
data-type |
String value Default: text |
Controls what type of field it is. Available types:
|
data-onblur |
String value Default: cancel |
Controls what happens when you click outside a field that you are editing
|
data-integration-mapTo |
String value Default: no value |
Controls the name of the flow parameter that needs to be sent when making the call When using a MULTIPART action the value for data-integration-mapTo property for non-file fields needs to be prefixed with data. For example: data-integration-mapTo="data.parameter1" |
data-success-callback |
String value Default: no value |
Function that should be called when the user finished editing the field. The format is a full name function like: window.some.custom.namespaced.functionName |
data-error-callback |
String value Default: no value |
Function that should be called when the user finished editing the field, but the UI failed to update. The format is a full name function like: window.some.custom.namespaced.functionName |
data-value |
String value Default: no value |
The current value of the field being edited. If missing, the inner value of the HTML element is used instead. If the field is type checklist then the value format is expected to be a JSON array like: data-value="[value1,value2]" |
data-source |
String value Default: no value |
Controls the list of available values when the field is a type that supports listing multiple options like - select or checklist The format of the field is a JSON array with properties value and text like: data-source="[{ value:1, text: 'Option 1'}, { value:2, text: 'Option 2'}]" |
data-base64 |
Boolean value Default: false |
Used only for fields of data-type="file" to control if the field data needs to be sent via MULTIPART requests or as a normal JSON field using base64 encoding |
Trigger Button Attribute
These are the attributes used to configure the trigger button that runs the AppBus flow and sends the parameters:
Attribute | Value | Description |
---|---|---|
data-integration-url |
String value Default: no value |
Relative URL pointing to the AppBus flow that needs to be executed Example: api/contoso/flow1 |
data-notify |
Boolean value Default: true |
Controls if a notification should be displayed once the integration finished execution. Two types of notifications are supported:
|
data-integration-type |
String value Default: GET |
Controls what type of request the flow is configured to receive: Typically:
Note: When using MULTIPART the value for data-integration-mapTo property for non-file fields needs to be prefixed with data.
|
data-description |
String value Default: calling integration [data-integration-type] : [data-integration-url] |
|
data-success-callback |
String value Default: no value |
Function that should be called when the API finished running the integration flow. The format is a full name function like: window.some.custom.namespaced.functionName |
data-error-callback |
String value Default: no value |
Function that should be called when the API triggered errors while running the integration flow. The format is a full name function, such as: window.some.custom.namespaced.functionName |
data-long-running |
Boolean value Default: false |
Controls behavior if the integration API call is long-running:
|
JavaScript Integration API
The following JavaScript functionality is available via the integration capability:
Integration API Calls
To call the integration API manually, use the functions under window.SH.Services.IntegrationService.
All functions return a promise, so you can wait for them to finish and read the result of the call.
Available Functions
The available functions are:
Function definition | Sample call | Comments |
---|---|---|
SH.Services.IntegrationService.RunGet(integrationProvider, integrationParams, queryString, headers) | SH.Services.IntegrationService.RunGet("appbus", "api/contoso/flow1", "param1=value¶m2=value", { header1: value1 }).done(function(result){ ... }); | This runs a GET call for the flow and passes the query string parameters with the request |
SH.Services.IntegrationService.RunPost(integrationProvider, integrationParams, postData, headers) | SH.Services.IntegrationService.RunPost("appbus", "api/contoso/flow2", { param1: true, param2: "value2" }, { header1: value1 }).done(function(result){ ... }); | This runs a POST call for the flow and passes the data object as the JSON request body |
SH.Services.IntegrationService.RunMultiPart(integrationProvider, integrationParams, postData, headers) | SH.Services.IntegrationService.RunMultiPart("appbus", "api/contoso/flow2", { param1: true, param2: "value2" }, { header1: value1 }).done(function(result){ ... }); | This runs a POST call for the flow and passes the data object as the request body. This call uses multi-part body instead of JSON request body |
Edit Capability API calls
To enable the edit capability for different types of forms for the functions under windows.SH.utils
Available Functions
The available functions are:
Function definition | Sample call | Comments | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
SH.utils.makeEditableForm(formElement) | SH.utils.makeEditableForm(SH.$(".formContainer")) |
Analyzes the child elements of the formContainer element for the following information:
|
|||||||||||||||||||||
SH.utils.makeEditablecontrol(controlElement) | SH.utils.makeEditableControl(SH.$(".singleFieldForm")) |
Reads the parent element of the singleFieldForm element and makes the parent an editable form. The requirements are:
The method analyzes the elements for the following information:
|
|||||||||||||||||||||
SH.utils.readEditedContent(formElement, callback) | SH.utils.readEditedContent(SH.$(".formContainer"), function(data){ ... }) |
Analyzes the child elements of the formContainer element for the following information:
And calls the callback function and passes it the data object where all the properties are mapped to the values of the corresponding elements that are mapped to them |
|||||||||||||||||||||
SH.utils.showNotification(message, options) | SH.utils.showNotification("This is a new notification") |
Triggers a new notification in the UI. It supports 2 types of notifications:
Certain extra options can be passed and possibly used by the function (depending on the type of notification that ends up being used):
Because the function calls the HTML5 notification system, all options are passed to the Notification constructor, so any additional options used by the HTML5 Notification API can be specified in the option's parameter. See all possible options here. |
Integration API: Available Functions
End Point
SmartHub exposes an API for this capability which has the following format:
http(s)://smarthub.contoso.com/_integration/appbus/[relative AppBus API to call]?[query string parameters]
Methods
The API can be called with:
- GET
- POST - application/json
- POST - multipart
Header
The API expects the X-SH-Authorization header to be sent with the value "Bearer <token>" where the token is the SmartHub token used for authentication