Rules Events
Events are emitted whenever a rule is created, updated, or deleted. By subscribing to these events you can build a responsive integration that reacts to rule changes without polling.
To subscribe to rule events, follow the Event Subscriptions guide.
Event types
| Event type | Emitted when |
|---|---|
com.futureordering.rules.created | A new rule is created |
com.futureordering.rules.updated | An existing rule is modified |
com.futureordering.rules.deleted | A rule is deleted |
Event structure
All rule events use a data object that contains new and/or old properties, each holding a full rule object (same schema as the API Reference).
| Event type | new present | old present |
|---|---|---|
rules.created | Yes — the newly created rule | No |
rules.updated | Yes — the rule after the change | Yes — the rule before the change |
rules.deleted | No | Yes — the deleted rule |
"data": {
"new": {
// how the rule looks after the change (rules.created and rules.updated only)
},
"old": {
// how the rule looked before the change (rules.updated and rules.deleted only)
}
}
Example
The following is an example rules.updated event. The rule had one product added to its filter.products.values (from ["123"] to ["123", "456"]). The event structure is identical for all rule types.
{
"specversion": "1.0",
"data": {
"new": {
"comment": "Stockout Rule from Navigator - 2022-10-07T07:37:47.1968067+00:00",
"created": {
"timeStamp": "2021-12-16T15:26:52.095439Z"
},
"filter": {
"products": {
"appliesTo": "specific",
"values": [
"123",
"456"
]
},
"stores": {
"appliesTo": "allExceptSpecific",
"values": [
"10001"
]
},
"storeCountryIsoCodes": {
"appliesTo": "specific",
"values": [
"SE"
]
},
"orderClasses": {
"appliesTo": "all"
},
"daysOfWeek": {
"appliesTo": "all"
}
},
"activeDuring": {
"timeOfDay": {
"applies": "always"
},
"dates": {
"applies": "between",
"startDate": "2022-10-07T00:00:00Z",
"endDate": "9999-12-31T23:59:59.9999999Z"
}
},
"lastModified": {
"timestamp": "2022-10-07T07:37:47.1997627Z",
"by": "1122bb44-55bb-7788-99aa-112233cc5566"
},
"type": "Stockout",
"id": "1122ff44-55bb-7788-99cc-112233ee5566",
"executionIndex": 2147483647
},
"old": {
"comment": "Stockout Rule from Navigator - 2022-10-07T07:29:13.8572696+00:00",
"created": {
"timeStamp": "2021-12-16T15:26:52.095439Z"
},
"filter": {
"products": {
"appliesTo": "specific",
"values": [
"123"
]
},
"stores": {
"appliesTo": "allExceptSpecific",
"values": [
"10001"
]
},
"storeCountryIsoCodes": {
"appliesTo": "specific",
"values": [
"SE"
]
},
"orderClasses": {
"appliesTo": "all"
},
"daysOfWeek": {
"appliesTo": "all"
}
},
"activeDuring": {
"timeOfDay": {
"applies": "always"
},
"dates": {
"applies": "between",
"startDate": "2022-10-07T00:00:00Z",
"endDate": "9999-12-31T23:59:59.9999999Z"
}
},
"lastModified": {
"timestamp": "2022-10-07T07:29:13.9028706Z",
"by": "1122bb44-55bb-7788-99aa-112233cc5566"
},
"type": "Stockout",
"id": "1122ff44-55bb-7788-99cc-112233ee5566",
"executionIndex": 2147483647
}
},
"dataContentType": "application/json",
"extensionAttributes": {
"correlationId": "56d3358f-696a-4318-91c8-8e76573b6b0c"
},
"id": "d3d8876b-d47c-4481-b61f-d954986fe918",
"source": "https://api.futureordering.com",
"time": "2022-10-07T07:37:47.2623655+00:00",
"type": "com.futureordering.rules.updated"
}