This section describes the operations available for counter definitions. It allows you to create counters, update them, and query their data.
NOTE: Some APIs allow you to retrieve data on pages only. In that case, the following parameters must be specified in the query string.
| Prerequisites | Required | Description |
|---|---|---|
| numberOfResults | Yes | Specifies the requested page size. The maximum allowed page size is 100. |
| orderBy | Yes | Specifies the result order. This can be any response field. Use one of the following formats to order the result: - Ascending Order: &orderBy={fieldName} ASC - Descending Order: &orderBy={fieldName} DESC - Sort by multiple fields: Specify several &orderBy= parameters. |
| startingIndex | Optional | Specifies the index of the first item that you want to retrieve on the requested page. The default value is 0. |
Create a New Counter
To create a new counter, you have to make the following POST request to the service:
POST https://dn-retail-counters-erp-eapi-dev.de-c1.eu1.cloudhub.io/api/v1/counters
{
"name": "Example",
"description": "Example counter.",
"statusId": 1,
"condition": {
"conditionType": "Age",
"columnName": "BirthDate",
"ageCalculationType": "ExactDate",
"operator": "Equal",
"age": 20
}
}This request will create a new active (statusId: 1) counter and automatically schedule the calculation of customers matching this counter. The following is a sample response:
{
"id": 12,
"jobResult": {
"jobId": "0b988097-b7d9-462a-89fc-d8d77bf6106f"
}
}This service returns a unique counter identifier and jobId that can be used to monitor the progress of counter recalculation.
Update an Existing Counter
To update the counter, send new data to api/v1/counters/{counterId} endpoint:
PUT https://dn-retail-counters-erp-eapi-dev.de-c1.eu1.cloudhub.io/api/v1/counters/12
{
"name": "Updated name",
"description": "Updated description",
"statusId": 1,
"condition": {
"conditionType": "Age",
"columnName": "BirthDate",
"ageCalculationType": "ExactDate",
"operator": "Equal",
"age": 20
}
}The update starts an asynchronous process of recalculating the counter customers. The returned response is the same as in the create request:
{
"id": 12,
"jobResult": {
"jobId": "ce7378da-3032-49ca-b809-2b1081c4943e"
}
}Retrieve Customer Counter Information
This section provides various examples to retrieve information about the customer counter.
Get a Single Counter by ID
GET https://dn-retail-counters-erp-eapi-dev.de-c1.eu1.cloudhub.io/api/v1/counters/12
Response
{
"id": 12,
"name": "Example",
"description": "Example counter.",
"statusId": 1,
"creationDateTimeUtc": "2019-01-30T12:43:20.1584617",
"lastUpdateDateTimeUtc": "2019-01-30T12:43:20.1584617",
"condition": {
"conditionType": "Age",
"columnName": "BirthDate",
"ageCalculationType": "ExactDate",
"operator": "Equal",
"age": 20
},
"customerCount": 1988,
"customerPercentageCoverage": 2.0,
"calculationStatusId": 2
}Get Paged List of Counters
GET https://dn-retail-counters-erp-eapi-dev.de-c1.eu1.cloudhub.io/api/v1/counters?numberOfResults=10&orderBy=id
Response
{
"totalCount": 5,
"items": [
{
"id": 1,
"name": "Counter1",
"description": "First counter",
"statusId": 1,
"creationDateTimeUtc": "2019-01-30T12:43:20.1584617",
"lastUpdateDateTimeUtc": "2019-01-30T12:43:20.1584617",
"condition": {
"conditionType": "Logical",
"operator": "And",
"conditions": [
{
"conditionType": "Age",
"ageCalculationType": "ExactDate",
"operator": "Equal",
"age": 20,
"columnName": "BirthDate"
}
]
},
"customerCount": 1988,
"customerPercentageCoverage": 2.0,
"calculationStatusId": 2
}
]
}Get a Paged List of Customers Assigned to a Counter
GET https://dn-retail-counters-erp-eapi-dev.de-c1.eu1.cloudhub.io/api/v1/counters/12/customers?numberOfResults=10&orderBy=id
Response
{
"totalCount": 12620,
"items": [
{
"id": 4,
"partyTypeKey": 1,
"registrationDateTimeUtc": "2019-01-15T23:23:28.8466667",
"birthDate": "1994-07-07T00:00:00",
"genderKey": 2,
"customerStatusKey": 3,
"customerTypeKey": 1,
"countryKey": 64,
"postalCode": "55224",
"city": "CityNo_131",
"operatingSystemKeys": [
1,
1
]
}]
}Get a Paged List of Counters Assigned to Customer
GET https://dn-retail-counters-erp-eapi-dev.de-c1.eu1.cloudhub.io/api/v1/counters/customers/1?request.numberOfResults=2&request.orderBy=id
Response
{
"totalCount": 1,
"items": [{
"id": 2,
"name": "string",
"description": "string",
"statusId": 1,
"creationDateTimeUtc": "2019-08-29T11:37:57.2072277",
"lastUpdateDateTimeUtc": "2019-08-29T11:37:57.2072277",
"condition": {
"conditionType": "LoyaltyAccount",
"earningTypeKey": 1,
"loyaltyProgramKey": 1,
"childCondition": {
"conditionType": "DecimalComparison",
"operator": "GreaterOrEqual",
"comparedValue": 10,
"columnName": "LoyaltyAccount.TotalEarnedValue"
}
},
"customerCount": 1,
"customerPercentageCoverage": 8,
"calculationStatusId": 1
}]
}Activate or Deactivate a Counter
This section provides examples to activate and deactivate a counter.
Activate a Counter
PUT https://dn-retail-counters-erp-eapi-dev.de-c1.eu1.cloudhub.io/api/v1/counters/12/status
{
"statusId": 1
}Response
{
"counterId": 1,
"statusId": 1,
"jobResult": {
"jobId": "bb4b8026-9fe7-41ef-9b08-c0998c3c0e03"
}
}Deactivate a Counter
PUT https://dn-retail-counters-erp-eapi-dev.de-c1.eu1.cloudhub.io/api/v1/counters/12/status
{
"statusId": 2
}Response
{
"counterId": 1,
"statusId": 2,
"jobResult": {
"jobId": "b0cca51b-c5fd-4284-8d6a-dad41c898c38"
}
}Get Status of Counter Recalculation
Counter recalculation is done asynchronously in the background. If you want to check the current status of the running or finished job, you must use the jobId GUID returned by the CRUD endpoints and call the GET request to /api/v1/Counters/RecalculationStatus/{jobId}.
GET http://dn-retail-counters-erp-eapi-dev.de-c1.eu1.cloudhub.io/api/v1/Counters/RecalculationStatus/a3681b4b-acd6-4b5a-8225-0c3bad329371
Response
{
"lastUpdateDateTimeUtc": "2019-01-31T16:13:41.8543797",
"jobId": "a3681b4b-acd6-4b5a-8225-0c3bad329371",
"jobTypeId": 1,
"jobTypeName": "CounterRecalculation",
"jobStatusId": 2,
"jobStatusName": "Succeeded",
"totalExecutionTimeInMSec": 58
}Force Counters Recalculation Assigned to a Given Customer
GET https://dn-retail-counters-erp-eapi-dev.de-c1.eu1.cloudhub.io/api/v1/counters/customers/1/recalculate
Response
{
"jobId": "39e36c27-f634-4d5c-8962-078e0b694d9d"
}Force Counter Recalculation by the Counter ID
GET https://dn-retail-counters-erp-eapi-dev.de-c1.eu1.cloudhub.io/api/v1/counters/1/recalculate
Response
{
"jobId": "39e36c27-f634-4d5c-8962-078e0b694d9d"
}