How-to Guide - Rest API - Inbound & Outbound
Introduction
The purpose of this guide is to provide an understanding of the REST Integrations APIs provided by Enactor for use with external websites and for customer integrations. It is separated out into functional areas, with each section related to a specific service. Note that the final URL used to access the service will be determined based on how the Enactor REST Integrations API is deployed.
Following are Enactor REST Integrations APIs areas covered in this document:
-
Integrations API
-
Configuration Import & Export
-
XML/JSON Retail Transaction Archive / Cash Transactions / System Events Export
-
Broadcasting
-
Configuration Import / Export API
This section provides an outline into the REST APIs pertaining to the import and export of Enactor configurations. Following is the list of APIs covered in this section:
-
Configuration Import.
-
Configuration Export.
Configuration Import REST API
This REST API can be used to import configuration files into the Estate Manager. File imports can be done either synchronously or asynchronously through this API. The asynchronous file import will be done using a scheduled job where a new scheduled job will be created, and its job reference will be returned as the response. The synchronous file import will return the number of records imported, as the response.
Request
Request Service URL
POST /configuration/import/<filename>?async=true
Request Tokens
- filename:
String. The path the file should be saved inside the file repository.
Be mindful to use the correct extension since will determine the file import processor.
Request Parameters
- async:
Boolen. If true, file import will be done asynchronously; if false, file import will be done synchronously.
Eg: async=true
Request Body
The body should be the Enactor configuration file as a stream.
Request Headers
Parameter | Accepted values | Description |
---|---|---|
Authorization | String | Base64 encoded userName:password with “Basic” Ex: Basic aW5zdGFsbDppbnN0YWxs |
Content-Type | application/zip application/xml | |
Content-MD5 | String |
|
x-enactor-default-user-password | String |
|
x-enactor-connection-process-id | String |
|
x-enactor-connection-point-id | String |
|
x-enactor-runtime-context | String |
|
Response
Response Headers
There are no response headers.
Response Body
If the request is asynchronous, the response will be the scheduled job reference number as shown below:
{
"jobReference": 1
}
If the request is synchronous, the response will be the number of imported records as shown below.
{
"recordsImported": 10
}
Request & Response Examples
Request:
POST http://[SWARM_LEADER_IP]/WebRestApi/rest/configuration/user.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><retail:user xmlns:core="http://www.enactor.com/core">
<retail:dateTimeActivated>2024-05-13T06:13:21+01:00</retail:dateTimeActivated>
<retail:dateTimeDeactivated>2014-11-05T17:59:45Z</retail:dateTimeDeactivated>
<retail:disabled>false</retail:disabled>
<retail:disallowMultiLocationSignOn>false</retail:disallowMultiLocationSignOn>
<retail:cardSignOnOnly>false</retail:cardSignOnOnly>
<retail:skipPasswordIfCard>false</retail:skipPasswordIfCard>
<retail:displayName>000123</retail:displayName>
<retail:employeeId></retail:employeeId>
<retail:inactivityDelay>0</retail:inactivityDelay>
<retail:maintenanceInactivityDelay>0</retail:maintenanceInactivityDelay>
<retail:localeId variant="" country="NL">nl</retail:localeId>
<retail:locationId>estatemanager</retail:locationId>
<retail:password>iiTDAt80/fvDIq684xpcTZJxqG2P1Fh3fT+6rxJdJ+w=nRmbHOe7Kmc=</retail:password>
<retail:passwordExpiryTime>0</retail:passwordExpiryTime>
<retail:passwordLastChanged>2024-05-13T06:13:40.919+01:00</retail:passwordLastChanged>
<retail:forceChangePassword>false</retail:forceChangePassword>
<retail:strongPassword>false</retail:strongPassword>
<retail:forceAlphaNumericPassword>false</retail:forceAlphaNumericPassword>
<retail:forceMixedCasePassword>false</retail:forceMixedCasePassword>
<retail:preventPasswordReUse>false</retail:preventPasswordReUse>
<retail:minimumPasswordLength>1</retail:minimumPasswordLength>
<retail:maximumPasswordLength>20</retail:maximumPasswordLength>
<retail:roleId>
<retail:roleId>ADMINISTRATOR</retail:roleId>
<retail:regionId groupHierarchyId="All" groupTypeId="region">All</retail:regionId>
</retail:roleId>
<retail:shortId></retail:shortId>
<retail:trainingMode>false</retail:trainingMode>
<retail:address>
<retail:countryCodeId></retail:countryCodeId>
<retail:typeId></retail:typeId>
<retail:isTemplate>false</retail:isTemplate>
</retail:address>
<retail:userId>000123</retail:userId>
<retail:userName>
<retail:surname>Store Administrator Hertford</retail:surname>
</retail:userName>
<retail:timePeriod>
<core:dayOfWeek>1</core:dayOfWeek>
</retail:timePeriod>
<retail:timePeriod>
<core:dayOfWeek>2</core:dayOfWeek>
</retail:timePeriod>
<retail:timePeriod>
<core:dayOfWeek>3</core:dayOfWeek>
</retail:timePeriod>
<retail:timePeriod>
<core:dayOfWeek>4</core:dayOfWeek>
</retail:timePeriod>
<retail:timePeriod>
<core:dayOfWeek>5</core:dayOfWeek>
</retail:timePeriod>
<retail:timePeriod>
<core:dayOfWeek>6</core:dayOfWeek>
</retail:timePeriod>
<retail:timePeriod>
<core:dayOfWeek>7</core:dayOfWeek>
</retail:timePeriod>
<retail:disallowLockingMultiplePos>false</retail:disallowLockingMultiplePos>
<retail:lastUpdated>2024-05-13T06:13:44.098+01:00</retail:lastUpdated>
<retail:fiscalUserReference></retail:fiscalUserReference>
<retail:isTemplate>false</retail:isTemplate>
<retail:preventPasswordSimilarToUserId>false</retail:preventPasswordSimilarToUserId>
<retail:emailAccountName></retail:emailAccountName>
<retail:emailAddress></retail:emailAddress>
<retail:emailPassword></retail:emailPassword>
</retail:user>
Response:
[
{
"entityName": "user",
"acceptedCount": 1
}
]
Guide to Integrate
JavaScript (NodeJS) Example
const fetch = require("node-fetch");
const fs = require("fs");
const assert = require("assert").strict;
const BASE_URL = "{Enactor Rest API Base URL}/rest/configuration";
fetch(BASE_URL + "/import/configs.zip?async=true", {
method: "post",
headers: {
Authorization: "Basic aW5zdGFsbDppbnN0YWxs",
"Content-Type": "application/zip",
"Content-MD5": "0b04633be98c35777f72f70d0edde41a",
"x-enactor-default-user-password": "new_pw",
},
body: fs.createReadStream("standard-data-estateManager-TRUNK-SNAPSHOT.zip"),
})
.then((res) => assert.equal(res.status, 200))
.catch((err) => console.log(err.message));
Configuration Export REST API
This API provides the facility to export the Enactor configurations via REST. This will return a zip file as a byte stream. Since the zip file can be large it provides the facility of streaming the response. It will also make sure that the configuration file size is not more than 100 MB. If it exceeds 100 MB the request will fail.
Request
Request Service URL
POST /configuration/export
Request Tokens
There are no request tokens.
Request Parameters
There are no request parameters.
Request Body
Element | Required / Optional | Description |
---|---|---|
entityQNames | Required | This will be an entity qName array including localPart and
namespaceURI. The localPart is the name of the entity that will be exported. The namespaceURI is the namespace for the entity. |
startDate | Optional | The date since when the entities have been changed. |
endDate | Optional | The entities that have been created to date. |
Request Headers
Parameter | Accepted values | Description |
---|---|---|
Authorization | String | Base64 encoded userName:password with “Basic”. Ex: Basic aW5zdGFsbDppbnN0YWxs |
Content-Type | application/json | Sending the request body as JSON. |
Accept | application/octet-stream | The media types that the server can produce. Optional and able to use the default value. |
Response
Response Headers
Parameter | Accepted values | Description |
---|---|---|
Content-Type | application/zip | The content type of the zip file. |
Content-Length | Number | The size of the zip file in bytes. |
Content-MD5 | String | MD5 checksum value of the zip file. |
x-enactor-entity-count | Number | The total entity counts that is included in the zip file. |
Request & Response Examples
Request:
POST http://[SWARM_LEADER_IP]/WebRestApi/rest/configuration/export
{
"entityQNames": ["user"],
"criteria": {
"filters": [
{
"@type": "TextValueFilter",
"id": "UserId",
"comparisonOperator": "STARTS_WITH",
"supportValues": [
{
"value": "000101"
}
]
}
]
}
}
Response:
This API will send the byte stream of the zip file containing all the configuration files as per the given request.
Guide to Integrate
Java Example
package com.enactor.rest.api.config.service;
import java.util.HashMap;
import java.util.Map;
import com.enactor.core.webService.epr.IHttpServiceEndpointReference.HTTPMethod;
import com.enactor.core.webService.epr.IRestEndpoint;
import com.enactor.core.webService.epr.RestEndpoint;
import com.enactor.core.webService.rest.DefaultRestServiceInvoker;
import com.enactor.core.webService.rest.IRestServiceInvoker;
import com.enactor.core.webService.rest.RestRawMessageHandler;
import com.enactor.core.webService.rest.RestServiceInvocationException;
public class RestConfigServiceTest {
// The base URL of the configuration service
private static final String BASE_URL = "{Enactor Rest API Base URL}/rest/configuration";
public static void main(String[] args) throws RestServiceInvocationException {
// The request JSON as string
String request = "<request-body-as-above>";
// Initialize the REST service invoker
IRestServiceInvoker invoker = new DefaultRestServiceInvoker();
invoker.setMessageHandler(new RestRawMessageHandler());
// Create the REST endpoint
IRestEndpoint endpoint = new RestEndpoint();
// Assign the REST URL
endpoint.setUrl(BASE_URL + "/export");
// Define the HTTP method as POST
endpoint.setHttpMethod(HTTPMethod.POST);
// Set header parameters
Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/json");
headers.put("Authorization", "Basic aW5zdGFsbDppbnN0YWxs");
endpoint.setHeaders(headers);
Object responseObject = invoker.invoke(endpoint, request);
}
}
JavaScript (NodeJS) Example
const fetch = require('node-fetch');
const fs = require('fs');
const assert = require('assert').strict;
const BASE_URL = "{Enactor Rest API Base URL}/rest/configuration";
fetch(BASE_URL + '/export', {
method: 'post',
headers: {
'Authorization': 'Basic aW5zdGFsbDppbnN0YWxs',
'Content-Type', 'application/json'
},
body: JSON.stringify({
entityQNames: [
"user"
]
})
}).then(res => assert.equal(res.status, 200))
.catch(err => console.log(err.message))
XML/JSON Retail Transaction Archive / Cash Transactions / System Events Export API
This section provides an outline into the REST APIs pertaining to the import and export of Retail Transaction Archive, Cash Transactions and System Events. Following is the list of APIs covered in this section:
-
Secondary Retail Transaction Export.
-
Secondary Retail Transaction Count.
-
Secondary CM Transactions Export.
-
Secondary CM Transactions Count.
-
Secondary System Events Export.
-
Secondary System Events Count.
Overview
Request Headers
Parameter | Accepted values | Description |
---|---|---|
Authorization | String | Base64 encoded userName:password with “Basic”. Ex: Basic aW5zdGFsbDppbnN0YWxs |
Content-Type | application/json | Sending the request body as JSON. |
Request Body
This API will send the byte stream of the zip file containing all the configuration files as per the given request.
Response Header
Parameter | Accepted values | Description |
---|---|---|
Content-Type | application/zip | The content type of the zip file. |
Content-Length | Number | The size of the zip file in bytes. |
Content-MD5 | String | MD5 checksum value of the zip file. |
x-enactor-entity-count | Number | The total entity counts that is included in the zip file. |
Response Codes
Status Code | Status | Description |
---|---|---|
200 | Success | The request is successful and will send the zip fie as a byte stream. |
400 | Bad Request | The request has incorrect request parameters which are not acceptable. |
500 | Server Error | Unexpected error occurred while processing the request. |
Configuration Transaction Export REST API
This API provides the facility to export and count Secondary Retail Transactions, Secondary CM Transactions and Secondary System Events via REST. Export will return a zip file as a byte stream or all transactions via a single file. It will also make sure that the configuration file size is not more than 100 MB. If it exceeds 100 MB the request will fail.
Secondary Retail Transaction Export
This service allows to export the secondary retail transactions based on the filters that are set in the body of the request.
Request
Request Service URL
POST /retailTransactions/export
Request Tokens
There are no request tokens.
Request Parameters
There are no request parameters.
Request Body
Element | Required / Optional | Description |
---|---|---|
fromDate | Required | Date from which transactions need to be exported or counted (UTC). |
toDate | Required | Date to which transactions need to be exported or counted (UTC). |
fileFormat | Required | This can be XML or JSON. |
compress | Required | If true - All the transactions will be exported as a zip file. If false - All the transaction will be exported as a single file. |
Request Headers
Parameter | Accepted values | Description |
---|---|---|
Authorization | String | Base64 encoded userName:password with “Basic”. Ex: Basic aW5zdGFsbDppbnN0YWxs |
Content-Type | application/json | Sending the request body as JSON. |
Response
Response Headers
Parameter | Accepted values | Description |
---|---|---|
Content-Type | application/zip | The content type of the zip file. |
Content-Length | Number | The size of the zip file in bytes. |
Content-MD5 | String | MD5 checksum value of the zip file. |
x-enactor-entity-count | Number | The total entity counts that is included in the zip file. |
Response Body
This API will send the byte stream of the zip file containing all the configuration files as per the given request.
Request & Response Examples
Request:
POST http://[SWARM_LEADER_IP]/WebRestApi/rest/retailTransactions/export
{
"fromDate": "2024-01-01T13:45:30",
"toDate": "2024-01-07T13:45:30",
"fileFormat": "XML",
"compress": "true"
}
Response:
This API will send the byte stream of the zip file containing all the configuration files as per the given request.
Secondary Retail Transaction Count
This service allows to get the count of the secondary retail transactions based on the filters that are set in the body of the request.
Request
Request Service URL
POST /retailTransactions/count
Request Tokens
There are no request tokens.
Request Parameters
There are no request parameters.
Request Body
Element | Required / Optional | Description |
---|---|---|
fromDate | Required | Date from which transactions need to be exported or counted (UTC). |
toDate | Required | Date to which transactions need to be exported or counted (UTC). |
Request Headers
Parameter | Accepted values | Description |
---|---|---|
Authorization | String | Base64 encoded userName:password with “Basic”. Ex: Basic aW5zdGFsbDppbnN0YWxs |
Content-Type | application/json | Sending the request body as JSON. |
Response
Response Headers
Parameter | Accepted values | Description |
---|---|---|
Content-Type | application/zip | The content type of the zip file. |
Content-Length | Number | The size of the zip file in bytes. |
Content-MD5 | String | MD5 checksum value of the zip file. |
x-enactor-entity-count | Number | The total entity counts that is included in the zip file. |
Response Body
This API will send the byte stream of the zip file containing all the configuration files as per the given request.
Request & Response Examples
Request:
POST http://[SWARM_LEADER_IP]/WebRestApi/rest/retailTransactions/count
{
"fromDate": "2024-01-01T13:45:30",
"toDate": "2024-01-07T13:45:30"
}
Response:
{
"count": 17534
}
Secondary CM Transactions Export
This service allows to export the secondary cash management transactions based on the filters that are set in the body of the request.
Request
Request Service URL
POST /cMTransactions/export
Request Tokens
There are no request tokens.
Request Parameters
There are no request parameters.
Request Body
Element | Required / Optional | Description |
---|---|---|
fromDate | Required | Date from which transactions need to be exported or counted (UTC). |
toDate | Required | Date to which transactions need to be exported or counted (UTC). |
fileFormat | Required | This can be XML or JSON. |
compress | Required | If true - All the transactions will be exported as a zip file. If false - All the transaction will be exported as a single file. |
Request Headers
Parameter | Accepted values | Description |
---|---|---|
Authorization | String | Base64 encoded userName:password with “Basic”. Ex: Basic aW5zdGFsbDppbnN0YWxs |
Content-Type | application/json | Sending the request body as JSON. |
Response
Response Headers
Parameter | Accepted values | Description |
---|---|---|
Content-Type | application/zip | The content type of the zip file. |
Content-Length | Number | The size of the zip file in bytes. |
Content-MD5 | String | MD5 checksum value of the zip file. |
x-enactor-entity-count | Number | The total entity counts that is included in the zip file. |
Response Body
This API will send the byte stream of the zip file containing all the configuration files as per the given request.
Request & Response Examples
Request:
POST http://[SWARM_LEADER_IP]/WebRestApi/rest/cMTransactions/export
{
"fromDate": "2024-01-01T13:45:30",
"toDate": "2024-01-07T13:45:30",
"fileFormat": "XML",
"compress": "true"
}
Response:
This API will send the byte stream of the zip file containing all the configuration files as per the given request.
Secondary CM Transaction Count
This service allows to get the count of the secondary cash management transactions based on the filters that are set in the body of the request.
Request
Request Service URL
POST /cMTransactions/count
Request Tokens
There are no request tokens.
Request Parameters
There are no request parameters.
Request Body
Element | Required / Optional | Description |
---|---|---|
fromDate | Required | Date from which transactions need to be exported or counted (UTC). |
toDate | Required | Date to which transactions need to be exported or counted (UTC). |
Request Headers
Parameter | Accepted values | Description |
---|---|---|
Authorization | String | Base64 encoded userName:password with “Basic”. Ex: Basic aW5zdGFsbDppbnN0YWxs |
Content-Type | application/json | Sending the request body as JSON. |
Response
Response Headers
Parameter | Accepted values | Description |
---|---|---|
Content-Type | application/zip | The content type of the zip file. |
Content-Length | Number | The size of the zip file in bytes. |
Content-MD5 | String | MD5 checksum value of the zip file. |
x-enactor-entity-count | Number | The total entity counts that is included in the zip file. |
Response Body
This API will send the byte stream of the zip file containing all the configuration files as per the given request.
Request & Response Examples
Request:
POST http://[SWARM_LEADER_IP]/WebRestApi/rest/cMTransactions/count
{
"fromDate": "2024-01-01T13:45:30",
"toDate": "2024-01-07T13:45:30"
}
Response:
{
"count": 2735
}
Secondary System Events Export
This service allows to export the secondary system events based on the filters that are set in the body of the request.
Request
Request Service URL
POST /systemEvents/export
Request Tokens
There are no request tokens.
Request Parameters
There are no request parameters.
Request Body
Element | Required / Optional | Description |
---|---|---|
fromDate | Required | Date from which transactions need to be exported or counted (UTC). |
toDate | Required | Date to which transactions need to be exported or counted (UTC). |
fileFormat | Required | This can be XML or JSON. |
compress | Required | If true - All the transactions will be exported as a zip file. If false - All the transaction will be exported as a single file. |
Request Headers
Parameter | Accepted values | Description |
---|---|---|
Authorization | String | Base64 encoded userName:password with “Basic”. Ex: Basic aW5zdGFsbDppbnN0YWxs |
Content-Type | application/json | Sending the request body as JSON. |
Response
Response Headers
Parameter | Accepted values | Description |
---|---|---|
Content-Type | application/zip | The content type of the zip file. |
Content-Length | Number | The size of the zip file in bytes. |
Content-MD5 | String | MD5 checksum value of the zip file. |
x-enactor-entity-count | Number | The total entity counts that is included in the zip file. |
Response Body
This API will send the byte stream of the zip file containing all the configuration files as per the given request.
Request & Response Examples
Request:
POST http://[SWARM_LEADER_IP]/WebRestApi/rest/systemEvents/export
{
"fromDate": "2024-01-01T13:45:30",
"toDate": "2024-01-07T13:45:30",
"fileFormat": "XML",
"compress": "true"
}
Response:
This API will send the byte stream of the zip file containing all the configuration files as per the given request.
Secondary System Events Count
This service allows to get the count of the secondary system events based on the filters that are set in the body of the request.
Request
Request Service URL
POST /systemEvents/count
Request Tokens
There are no request tokens.
Request Parameters
There are no request parameters.
Request Body
Element | Required / Optional | Description |
---|---|---|
fromDate | Required | Date from which transactions need to be exported or counted (UTC). |
toDate | Required | Date to which transactions need to be exported or counted (UTC). |
Request Headers
Parameter | Accepted values | Description |
---|---|---|
Authorization | String | Base64 encoded userName:password with “Basic”. Ex: Basic aW5zdGFsbDppbnN0YWxs |
Content-Type | application/json | Sending the request body as JSON. |
Response
Response Headers
Parameter | Accepted values | Description |
---|---|---|
Content-Type | application/zip | The content type of the zip file. |
Content-Length | Number | The size of the zip file in bytes. |
Content-MD5 | String | MD5 checksum value of the zip file. |
x-enactor-entity-count | Number | The total entity counts that is included in the zip file. |
Response Body
This API will send the byte stream of the zip file containing all the configuration files as per the given request.
Request & Response Examples
Request:
POST http://[SWARM_LEADER_IP]/WebRestApi/rest/systemEvents/count
{
"fromDate": "2024-01-01T13:45:30",
"toDate": "2024-01-07T13:45:30"
}
Response:
{
"count": 84735
}
Broadcast API
The Broadcast API is used to get the status of a broadcast and get broadcast status of a specific device. Following is the list of Broadcast APIs covered in this section:
-
Get Broadcast Status.
-
Get Broadcast Status of a Device.
Authentication Requirements for REST Broadcast API
Basic Authentication is required. The Username and Password of the Estate Manager user should be sent in the request as the authorization header.
All the privileges required to run the Broadcast functionality in EM should be given to this authorization user.
Get Broadcast Status
This service is used to get the status of a broadcast from the Broadcast ID.
Request
Request Service URL
GET /broadcast/{ broadcastId}
Request Tokens
- broadcastId:
Required. The ID of the broadcast to get the status of.
Request Parameters
There are no request parameters.
Request Header
Basic authentication required. See above “Authentication Requirements for REST Broadcast API” section for more details.
Content type - JSON.
Request Body
There is no request body.
Response
Response Headers
There are no response headers.
Response Body
Element | Type | Description |
---|---|---|
itemsAffected | Integer format: int32 | The ID of the broadcast that has been triggered. |
predefinedBroadcastId | String | The Predefined Broadcast ID of the broadcast. |
dateTimeBroadcast | Date format: date-time | The date time of the broadcast. |
lastUpdated | Date format: date-time | The last updated date time. |
status | String Enum | One of the following is provided as the status value:
|
Request & Response Examples
Request:
GET http://[SWARM_LEADER_IP]/WebRestApi/rest/broadcast/4d02cd30-5f4d-4617-9bad-5d2c42712a2f
Response:
Status: 200 OK
{
"itemsAffected": 9,
"predefinedBroadcastId": "LOCATION",
"dateTimeBroadcast": 1628514037684,
"lastUpdated": 1628514070000,
"status": "SENDING_TO_RECIPIENTS"
}
Get Broadcast Status of a Device
This service is used to get the status of a broadcast from the Broadcast ID and Device ID.
Request
Request Service URL
GET /broadcast/{broadcastId}/{deviceId}
Request Tokens
- broadcastId:
Required. The ID of the broadcast to get the status of.
Request Parameters
There are no request parameters.
Request Header
Basic authentication required. See above “Authentication Requirements for REST Broadcast API” section for more details.
Content type - JSON.
Request Body
There is no request body.
Response
Response Headers
There are no response headers.
Response Body
Element | Type | Description |
---|---|---|
itemsAffected | Integer format: int32 | The ID of the broadcast that has been triggered. |
lastUpdated | Date format: date-time | The last updated date time. |
status | Integer format: int32 | The status of the broadcast where each integer is described as
follows - 2 – STATUS_PROCESSED: Processed successfully. 3 – STATUS_FAILED: Failed requires further investigation. 4 – STATUS_RETRY: Attempting to process the update again. 5 – STATUS_SCHEDULED: Scheduled download not to be processed until late date/time. 6 – STATUS_DOWNLOADED: downloaded but not processed. 7 – STATUS_RETRY_DOWNLOADED: Attempting to download the update again. |
Request & Response Examples
Request:
GET http://[SWARM_LEADER_IP]/WebRestApi/rest/broadcast/4d02cd30-5f4d-4617-9bad-5d2c42712a2f/pos1@0001.enactor
Response:
Status: 200 OK
{
"itemsAffected": 0,
"lastUpdated": 1628658383000,
"status": 2
}