Manage Custom Widgets

Manage Custom Widgets

SDP.openWidget(options) 

Opens a new widget as a pop-up within the custom widget.
 
Parameters:
Name
Type
Description
options*
Object
Object which contains API details.

Property
Type
Description
id*
Long
Indicates the ID of the widget to be opened.
name*
String
Indicates the name of the widget to be opened.
title
String
Sets the title of the popup. If title is not passed, the widget name will be set as the popup title.
data
Object
Specifies the data to be passed to the widget that is opening.
 
* - Mandatory parameter

Info
Either ID or name parameters can be specified as an option to open the widget. If both are specified, only ID will be considered. 

Returns:
Promise - Resolved with Success or Rejected with Failure.

Syntax:
  1. SDP.openWidget(options).then(function(response) {
  2. console.log(response);
  3. }).catch(function(response) {
  4. console.log(response);
  5. });
 
Sample:
API Call
Success Response
Failure Response
SDP.openWidget({
id: "100000000000032273",
data: {
mode: "new_user"
}
}).then(function(response) {
console.log(response);
}).catch(function(response) {
console.log(response);
});
{
message: “Widget opened successfully”
}
{
"message": "Please provide a valid widget id or name with required visibility permissions to render"
}
 

SDP.closeWidget() 

Closes the pop up where the custom widget is loaded. This API is functional only if a widget is opened in a pop-up window, such as menu widget or a widget opened using the SDP.openWidget API.

Returns:
Promise - Resolved with Success or Rejected with Failure.

Syntax:
  1. SDP.closeWidget().catch(function(response) {
  2. console.log(response);
  3. });
 
SDP.closeWidget() call’s successful execution closes the widget popup in the window. Hence success callback is not needed for this API.

Sample:
API Call
Failure Response
SDP.closeWidget().catch(function(response) {
console.log(response);
});
{
message: “This requested action is not supported in this view”
}
 

SDP.resizeWidget(options) 

Resize the custom widget popup as needed. The maximum widget size allowed is 1200X800 pixels.
This API is functional only if a widget is opened in a pop-up window, such as menu widget or a widget opened using the SDP.openWidget API.

Parameters:
Name
Type
Description
options*
Object
Object which contains API details.
Property
Type
Description
width*
Integer
Specify the required widget popup width in pixels. Maximum width for popup is 1200 pixels.
height*
Integer
Specify the required widget popup height in pixels. Maximum height for popup is 800 pixels.
 
* - Mandatory parameter
Info
Either ID or name parameters can be specified as an option to open the widget. If both are specified, only ID will be considered. 

Returns:
Promise - Resolved with Success or Rejected with Failure.

Syntax:
  1. SDP.resizeWidget(options).then(function(response) {
  2. console.log(response);
  3. }).catch(function(response) {
  4. console.log(response);
  5. });
 
Sample:
API Call
Success Response
Failure Response
SDP.resizeWidget({
width: 1000,
height: 500
}).then(function(response) {
console.log(response);
}).catch(function(response) {
console.log(response);
});
{
"message": "Window resized successfully"
}
{
"message": "width is not a valid number"
}