Skip to main content
Version: 10.3.2

Rule Builder REST API

The page describes the rules-builder-test REST API. The integration with the Swagger UI allows you to easily explore and interact with API while testing API endpoints, viewing request and response details, and understanding available resources.

Prerequisites

Before running the application, complete the following steps:

  1. Install Java Development Kit (JDK).
  2. Install Maven.
  3. Clone the Git repository that contains the Spring Boot application.

Run application

To run the Spring Boot application, choose one of the ways:

Run from JAR file

To run the Spring Boot application from a JAR file, perform the following steps:

  1. Change your working directory to the root of the Spring Boot application.

    cd rulesbuilder

    Replace your-app-directory with the actual application directory, for instance, rules-worker-rest.

  2. Build the application using Maven. The command compiles the code and creates an executable JAR file:

    mvn clean package
  3. Once the build is successful, run the application:

    cd rules-builder-rest
    java -jar target/rules-worker-rest-${project-version}.jar eg:- java -jar target/rules-builder-rest-1.0.8.jar

Run from IDE

To run the application from IDE, go to RulesBuilderRestApplication and click Run.

Run in Swagger UI

To run the application from the Swagger UI, open a browser and navigate to the Swagger UI URL: http://localhost:8186.

Interact with API endpoints

The Swagger UI allows you to explore and interact with the API endpoints. You can view available resources, make test requests, and understand the request and response structure for each endpoint.

To access the Swagger UI documentation for API, ensure the Spring Boot application is running. Then, open a browser and navigate to the Swagger UI URL: http://localhost:5000/apidocs.

Endpoint 1

See the endpoint parameters below:

  • Description: the endpoint returns a decision response that contains the list of rules executed along with the decision.
  • HTTP method: POST
  • Path: /decisionRules
  • Request parameters:
    • data (Object, required): the root object that contains the input data.
    • configuration (Object, required): the root object that contains the rules to apply to the input data.
Request example 1
{
"data": {
"message": {
"transaction": {
"amount": "$6,982,926",
"country": "United Kingdom",
"itemtype": "Explosives",
"countrycode": "UK",
"date": "01/25/2000",
"address": " Broad St, Oxford OX1 3AZ, UK"
}
}
},
"configuration": {
"decision-rules": {
"decisionRules": {
"rules": [
{
"rulename": "Escalate for itemtype",
"ruleDescription": "Escalate if itemtype is explosives",
"enabled": "true",
"decision": "escalate",
"priority": "-1",
"narrative": "Rule triggered because ${message.transaction.itemtype} found in item type of transaction",
"ruleSet": [
{
"logicalOperator": "NONE",
"bridgeOperator": "NONE",
"rule": [
{
"lhs": {
"value": "message.transaction.itemtype",
"custom": false,
"type": "string"
},
"operator": "equals",
"rhs": {
"value": "Explosives",
"custom": true,
"type": "string"
}
}
]
}
]
},
{
"rulename": "Otherwise",
"ruleDescription": "Decision of this rule is falsePositive",
"enabled": "true",
"decision": "false positive",
"priority": "-2",
"narrative": "Rule triggered because all the other rules are false"
}
]
}
}
}
}
Response example 1
{
"decision": {
"outcome": "escalate",
"ruleList": [
{
"rulename": "Escalate for itemtype",
"decision": "escalate",
"enabled": true,
"priority": -1,
"fired": true,
"narrative": "Rule triggered because Explosives found in item type of transaction"
},
{
"rulename": "Otherwise",
"decision": "false positive",
"enabled": true,
"priority": -2,
"fired": false,
"narrative": "Rule triggered because all the other rules are false"
}
]
}
}
Request example 2
{
"data": {
"message": {
"transaction": {
"amount": "$6,982,926",
"country": "United Kingdom",
"itemtype": "Explosives",
"countrycode": "UK",
"date": "01/25/2000",
"address": " Broad St, Oxford OX1 3AZ, UK"
}
}
},
"configuration": {
"decision-rules": {
"decisionRules": {
"rules": [
{
"rulename": "Escalate for itemtype",
"ruleDescription": "Escalate if itemtype is Incendiaries",
"enabled": "true",
"decision": "escalate",
"priority": "-1",
"narrative": "Rule triggered because ${message.transaction.itemtype} found in item type of transaction",
"ruleSet": [
{
"logicalOperator": "NONE",
"bridgeOperator": "NONE",
"rule": [
{
"lhs": {
"value": "message.transaction.itemtype",
"custom": false,
"type": "string"
},
"operator": "equals",
"rhs": {
"value": "Incendiaries",
"custom": true,
"type": "string"
}
}
]
}
]
},
{
"rulename": "Otherwise",
"ruleDescription": "Decision of this rule is falsePositive",
"enabled": "true",
"decision": "false positive",
"priority": "-2",
"narrative": "Rule triggered because all the other rules are false"
}
]
}
}
}
}
Response example 2
{ "decision": 
{ "outcome": "escalate", "ruleList":
[
{ "rulename": "Escalate for itemtype", "decision": "escalate", "enabled": true, "priority": -1, "fired": false, "narrative": "Rule triggered because ${message.transaction.itemtype} found in item type of transaction"
},
{ "rulename": "Otherwise", "decision": "false positive", "enabled": true, "priority": -2, "fired": true, "narrative": "Rule triggered because all the other rules are false"
}
]
}
}

Endpoint 2

See the endpoint parameters below:

  • Description: the endpoint returns the transformed input data based on the rules.
  • HTTP method: POST
  • Path: /transformRules
  • Request parameters:
    • data (Object, required): the root object that contains the input data.
    • configuration (Object, required): the root object that contains the rules to apply to the input data.
Request example 1
{
"data": {
"message": {
"transaction": {
"amount": "$6,982,926",
"country": "United Kingdom",
"countrycode": "UK",
"date": "01/25/2000",
"address": " Broad St, Oxford OX1 3AZ, UK"
}
}
},
"configuration": {
"transformation-rules": {
"transformationRules": {
"rules": [
{
"rulename": "Remove Currency Field",
"ruleDescription": "Remove currency field such as $ and , from amount field",
"enabled": "true",
"priority": "-1",
"ruleSet": [
{
"logicalOperator": "NONE",
"bridgeOperator": "NONE",
"rule": [
{
"lhs": {
"value": "message.transaction.country",
"custom": false,
"type": "string"
},
"operator": "equals",
"rhs": {
"value": "United Kingdom",
"custom": true,
"type": "string"
}
}
]
}
],
"thenRule": [
{
"lhs": {
"value": "message.transaction.amount",
"custom": "false",
"type": "integer"
},
"operator": "REPLACE",
"rhs": {
"srcValue": {
"value": ",",
"custom": "true",
"type": "string"
},
"tgtValue": {
"value": "",
"custom": "true",
"type": "string"
}
}
}
]
}
]
}
}
}
}
Response example 1
{
"message": {
"transaction": {
"amount": "$6982926",
"country": "United Kingdom",
"countrycode": "UK",
"date": "01/25/2000",
"address": " Broad St, Oxford OX1 3AZ, UK"
}
}
}
Request example 2
{
"data": {
"message": {
"id": "11111",
"type": "PAYMENT_TRANSFER",
"accountHolderDetails": {
"type": "INDIVIDUAL",
"name": "Doer Jerry"
},
"hits": [
{
"id": "2001",
"tagContent": "DOE, J",
"tagType": "NAME",
"hitStartIndex": 0,
"hitEndIndex": 5,
"hitText": "DOE, J",
"screenedData": {
"type": "INDIVIDUAL",
"name": "DOE, J",
"dob": "10/12/1965",
"country": "US"
},
"additionalData": {
"type": "INDIVIDUAL",
"name": "Doer Jerry",
"dob": "10/10/1975",
"address": "10 Bressenden Place, 8th floor",
"country": "GBR",
"city": "london",
"state": "GBR",
"postal": "SW1E 5DH"
},
"sanctionData": {
"name": "doe, john",
"type": "INDIVIDUAL",
"country": "syrian arab republic",
"sourceEntryId": "1111",
"source": "OFAC",
"listType": "WORLD_COMPLIANCE"
}
},
{
"id": "2002",
"tagContent": "DOE, J",
"tagType": "NAME",
"hitStartIndex": 0,
"hitEndIndex": 5,
"hitText": "DOE, J",
"screenedData": {
"type": "INDIVIDUAL",
"name": "DOE, J",
"dob": "10/12/1965",
"country": "US"
},
"additionalData": {
"type": "INDIVIDUAL",
"name": "Doer Jerry",
"dob": "10/10/1975",
"address": "10 Bressenden Place, 8th floor",
"country": "GBR",
"city": "New York",
"state": "GBR",
"postal": "SW1E 5DH"
},
"sanctionData": {
"name": "doe, johanna",
"type": "INDIVIDUAL",
"dob": "10/21/1970",
"country": "US",
"sourceEntryId": "2222",
"source": "OFAC",
"listType": "WORLD_COMPLIANCE"
}
}
]
}
},
"configuration": {
"transformation-rules": {
"transformationRules": {
"rules": [
{
"rulename": "Tara Rule 1",
"ruleDescription": "filter hits if sanctionData.type = Individual",
"enabled": "true",
"priority": "-1",
"ruleSet": [
{
"logicalOperator": "AND",
"bridgeOperator": "NONE",
"rule": [
{
"lhs": {
"value": "message.hits.additionalData.name",
"custom": false,
"type": "string"
},
"operator": "equals",
"rhs": {
"value": "Doer Jerry",
"custom": true,
"type": "string"
}
},
{
"lhs": {
"value": "message.hits.additionalData.dob",
"custom": false,
"type": "string"
},
"operator": "equals",
"rhs": {
"value": "10/10/1975",
"custom": true,
"type": "string"
}
}
]
}
],
"thenRule": [
{
"lhs": {
"value": "message.hits",
"custom": "false",
"type": "list"
},
"operator": "remove",
"rhs": {
"srcValue": {
"value": "NONE",
"custom": "NONE",
"type": "NONE"
},
"tgtValue": {
"value": "NONE",
"custom": "NONE",
"type": "NONE"
}
}
}
]
}
]
}
}
}
}
Response example 2
{
"message": {
"id": "11111",
"type": "PAYMENT_TRANSFER",
"accountHolderDetails": {
"type": "INDIVIDUAL",
"name": "Doer Jerry"
},
"hits": []
}
}

Test API

You can use the Swagger UI to test the API endpoints directly from the web interface. To test an endpoint, perform the following steps:

  1. Open the Swagger UI in your browser.
  2. Navigate to the endpoint you want to test.
  3. Click the Try it out button.
  4. Provide values for any required parameters.
  5. Click Execute to send a request.
  6. Review a response with the results.