Replace the Fraud configuration for tenant. - Fabric

Replace the Fraud configuration for tenant.

cURL

curl --request PUT \
  --url https://prod01.oms.fabric.inc/api/v2/configurations/fraud-config/{processName}/{serviceName} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --header 'x-site-context: <x-site-context>' \
  --data '\n{
  "conditions": "[  // OR BLOCK START\n   [    // AND BLOCK STARTS\n     {\n       \"key\": \"orderDate\",\n       \"operator\": \"lte\",\n       \"type\": \"date\",\n       \"value\": [-59, \"SECONDS\"] // now -59 sec\n     },\n     {\n       \"key\": \"type\",\n       \"operator\": \"in\",\n       \"value\": [\"web\", \"mobile\"]\n     }\n   ],  // AND BLOCK END\n   [ // AND BLOCK STARTS\n     {\n       \"key\": \"orderDate\",\n       \"operator\": \"lt\",\n       \"type\": \"date\",\n       \"value\": [-10, \"MINUTES\"]\n     },\n     {\n       \"key\": \"type\",\n       \"operator\": \"is\",\n       \"value\": \"postman\"\n     }\n   ] // AND BLOCK ENDS\n ] // OR BLOCK ENDS\n"
}
' 

Python Example

import requests

url = "https://prod01.oms.fabric.inc/api/v2/configurations/fraud-config/{processName}/{serviceName}"

payload = { "conditions": "[  // OR BLOCK START\\
   [    // AND BLOCK STARTS\\
     {\\
       \"key\": \"orderDate\",\\
       \"operator\": \"lte\",\\
       \"type\": \"date\",\\
       \"value\": [-59, \"SECONDS\"] // now -59 sec\\
     },\\
     {\\
       \"key\": \"type\",\\
       \"operator\": \"in\",\\
       \"value\": [\"web\", \"mobile\"]\\
     }\\
   ],  // AND BLOCK END\\
   [ // AND BLOCK STARTS\\
     {\\
       \"key\": \"orderDate\",\\
       \"operator\": \"lt\",\\
       \"type\": \"date\",\\
       \"value\": [-10, \"MINUTES\"]\\
     },\\
     {\\
       \"key\": \"type\",\\
       \"operator\": \"is\",\\
       \"value\": \"postman\"\\
     }\\
   ] // AND BLOCK ENDS\\
 ] // OR BLOCK ENDS\n" }
headers = {
    "x-site-context": "<x-site-context>",
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.put(url, json=payload, headers=headers)

print(response.text)

JavaScript Example

const options = {
  method: 'PUT',
  headers: {
    'x-site-context': '<x-site-context>',
    Authorization: 'Bearer <token>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    conditions: '[  // OR BLOCK START\n   [    // AND BLOCK STARTS\n     {\n       "key": "orderDate",\n       "operator": "lte",\n       "type": "date",\n       "value": [-59, "SECONDS"] // now -59 sec\n     },\n     {\n       "key": "type",\n       "operator": "in",\n       "value": ["web", "mobile"]\n     }\n   ],  // AND BLOCK END\n   [ // AND BLOCK STARTS\n     {\n       "key": "orderDate",\n       "operator": "lt",\n       "type": "date",\n       "value": [-10, "MINUTES"]\n     },\n     {\n       "key": "type",\n       "operator": "is",\n       "value": "postman"\n     }\n   ] // AND BLOCK ENDS\n ] // OR BLOCK ENDS\n'
  })
};

fetch('https://prod01.oms.fabric.inc/api/v2/configurations/fraud-config/{processName}/{serviceName}', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));

Response Example

{
  "serviceName": "FRAUD_RELEASE_SERVICE",
  "processName": "ORDER_CREATE",
  "configuration": {
    "conditions": "[  // OR BLOCK START\n   [    // AND BLOCK STARTS\n     {\n       \"key\": \"orderDate\",\n       \"operator\": \"lte\",\n       \"type\": \"date\",\n       \"value\": [-59, \"SECONDS\"] // now -59 sec\n     },\n     {\n       \"key\": \"type\",\n       \"operator\": \"in\",\n       \"value\": [\"web\", \"mobile\"]\n     }\n   ],  // AND BLOCK END\n   [ // AND BLOCK STARTS\n     {\n       \"key\": \"orderDate\",\n       \"operator\": \"lt\",\n       \"type\": \"date\",\n       \"value\": [-10, \"MINUTES"]\n     },\n     {\n       \"key\": \"type\",\n       \"operator\": \"is\",\n       \"value\": \"postman\"\n     }\n   ] // AND BLOCK ENDS\n ] // OR BLOCK ENDS\n",
  },
  "tenantId": "asferf3r4safasdcd"
}

Error Responses

{
  "message": "Bad Request"
}
{
  "message": "Fraud Config not Found"
}
{
  "message": "Config already exists"
}
{
  "message": "Internal Server Error"
}