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 |
|
data-success-callback |
String value Default: no value |
|
data-error-callback |
String value Default: no value |
|
data-value |
String value Default: no value |
|
data-source |
String value Default: no value |
|
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 |
|
data-notify |
Boolean value Default: true |
This controls if a notification should be displayed once the integration execution is finished. 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 |
|
data-error-callback |
String value Default: no value |
|
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