Static counters maintain a constant list of the customers that are not recalculated.
The response is always set to default jobId, i.e., equal to 00000000-0000-0000-0000-000000000000 due to the following reasons:
- The recalculation process does not exist.
- There is a requirement to extend the already existing endpoints for static counters.
Creating Counters
Static counter can be created using POST endpoint with or without customers but cannot contain conditions. A static type counter is defined with Id equal to 2.
{
"name": "Static customers",
"description": "Static list of the customers",
"statusId": 1,
"typeId": 2,
"customerIds": [
1, 2, 3, 4, 5, 6, 7, 8, 9, 112, 1021
]
}Modifying Counters
Customers can be added or removed at any time using the available PUT endpoint. The request contains the additional parameter originCounterId, which can be used interchangeably with the customerIds parameter. Remember that you can pass only one of the parameters.
In the case of a PUT operation, the originCounterId value should be equal to the counterId value, which means that the list of the customers will not be changed. The list of customerIds is always treated as a complete list of customers assigned to the counter. An empty list will remove all the customers from the counter.
For counterId = 2
{
"originCounterId": 2,
"name": "Static customers",
"description": "Static list of the customers",
"statusId": 1,
"typeId": 2
}OR
{
"name": "string",
"description": "string",
"statusId": 1,
"typeId": 2,
"customerIds": [
1, 2, 3, 4, 5
]
}Changing the Counter Type
Use the PUT endpoint to change counter type from dynamic to static and vice versa.
- Change Dynamic Counter to Static Counter: Changing to a static counter loses conditions and generated SQL, and the update frequency is set to None. All assigned customers should be passed as a list of customerIds or if the customers are not modified, then the originCounterId property can be used.
- Change Static Counter to Dynamic Counter: It is required to create conditions from scratch, and list of customers is not allowed as well as originCounterId property. All old customers will be removed by the recalculation task executed for the new condition.
Cloning Counters
Counters can be also created by cloning existing objects using a dedicated POST endpoint. Depending on counter type, different parameters are required. Similar to static counter, a list of customers can be passed as originCounterId from which customers are copied or as a full list of customerIds. In the result body, a new counter ID is returned.
Assigning Customer to Counters
Using new PUT endpoint, specific customer can be assigned to many static counters.
{
"counterIds": [
1, 2, 3, 4, 6, 78, 98, 165, 254, 344
]
}