-
Notifications
You must be signed in to change notification settings - Fork 0
Understanding Actions
Let's start with the basics. When an object is placed into a feed, various things can happen to it when the feed is processed.
- Create - Wasn't originally in the system, so a new record is created in BB to represent that object.
- Update - Object is already in the system, last_modified is compared and if feed object is newer, then it will be updated.
- Delete - Status is set to "deleted" on feed object. If last_modified is greater on feed, then object is deleted.
Above are the 3 standard core actions. There is another Action that can be performed. But we will come to that later.
You can set the default actions that can be applied to all objects at the top of the feed like what we show below. If not specified, then all actions are valid.
"actions": ["create", "update", "delete"]
{
"meta": {
"created_at": "2017-09-10T17:33:56+0100",
"feed_name": "The corporate"
},
"settings": {
"version": "0.0.1",
"actions": ["create", "update", "delete"]
},
"data": {
"people": [
{
As well as being able to specify in the settings block of the feed. You can also set it on the objects themselves, allow an implementation to customise what Actions should be performed at an Object level. Example below.
"companies": [
{
"actions": ["create", "update", "delete"],
"external_id": "msid_hash-tristin",
"object_type": "company",
"address": {
"line_1": "90907 Kuhic Field",
"line_2": "Apt. 999",
"line_3": "Apt. 138",
"locality": "Ardenmouth",
"region": "North Carolina",
"postal_code": "56918-5673",
"country": "Maldives"
},
"name": "Tristin Ruecker",
"description": "The FA's job title",
"status": "live",
Above we have mentioned the 3 core actions of the feed. But there is a 4th known as "activate". This one has slightly more complex logic compared to the others and that is the reason it gets its own section.
Sometimes, you may want to import a selection of objects like Company but in a state where they are in BookingBug, but in an inactive state. This is so a human/user can go turn them on later. Hence, they needed to be "activated". Reducing the Actions on an object to everything but "activate" means objects can be imported, updated and deleted. But they can't be activated via the feed.
The example below has the default set to allow all actions "create, update, delete, activate". However, one of the company objects has only "create, update, delete". Which means that even though the status of the company is live. It won't be activated when being imported.
{
"meta": {
"created_at": "2017-09-10T17:33:56+0100",
"feed_name": "The corporation"
},
"settings": {
"version": "0.0.1",
"actions": [
"create",
"update",
"delete",
"activate"
]
},
"data": {
"companies": [
{
"actions": [
"create",
"update",
"delete"
],
"external_id": "msid_hash-tristin",
"object_type": "company",
"address": {
"line_1": "90907 Kuhic Field",
"line_2": "Apt. 999",
"line_3": "Apt. 138",
"locality": "Ardenmouth",
"region": "North Carolina",
"postal_code": "56918-5673",
"country": "Maldives"
},
"name": "Tristin Ruecker",
"description": "The FA's job title",
"status": "live"
}
]
}
}