Skip to content

How to use

James Williamson edited this page Jul 12, 2018 · 2 revisions

Where to find it

Using a POST method you can create a new import. You can also use the Async endpoint, which won't wait for the import to complete. Instead it will give back a url you can use to fetch the status of the import.

https://tetris.bookingbug.com/api/v1/admin/37000/imports

https://tetris.bookingbug.com/api/v1/admin/37000/imports/async

The code for this feature is contained inside the main Rails app.

Authentication

To use this functionality its expected that the "User" should be the Owner of the top level company. Use the Admin Authentication method as the method of authenticating as described here. https://dev.bookingbug.com/docs/rest-api/authentication.

Importing data (payload)

Delivery Payload

There are two top level keys Data and Meta. Data contains a set of top level keys that contain arrays. These arrays contain top level objects such as Companies and Staff. There is also a key called Meta that has to purposes. The information contained can be used for anayltics and tracking eg created_at, feed_name. The second purpose of meta is to provide settings tyhat helps the importer decide what to do with the Objects (Staff, Companies) being submited. For example type tells the Importer what stategy to use when writing to the database.

{ "meta": { "version": "0.0.1", "created_at": "2017-09-24T11:59:02+0100", "callback_url": "http://example.com/addison", "type": "create/update", "feed_name": "Voluptas est impedit ea temporibus sapiente." }, "data": { "staff": [

\],
"companies": \[
  
\],
"users": \[
	
\]

} }

Settings

This section describes how the import should behaviour during the import.

type

This the strategy used during the import. "create/update" which is the default, will create and objects that are missing. If the object exists, then the "last_modified" property will be compared to the one in the BookingBug. If "last_modified" in the feed is greater, then it will be imported and the object updated.

version

Can be used to identify what release to run the importer against.

base_company_external_id

At the centre of any implementation in BookingBug is the concept of a "parent" company. It is this company that provides the ancestor for all other company. That might be direct, or through other child.

Meta

This section of the payload does not change the functionality of the import. Instead it is used to create logs and auditing. Helping the debugging and reporting processes.

Object payloads

Objects exist as piece of JSON within the payload that represent an Object within BookingBug. A few of the object classes that exist are Company, Person, Resource etc.

Core properties of an Object

The follow properties are required to create/update an object within BookingBug from a Import payload.

external_id

This is used to identify an object within its class (eg person, company, user) and find the corresponding object within BookingBug (if exists).

last_modified

In order to figure out if an object should be updated, a comparison is done between 2 datetimes. One in the feed and one within BookingBug (if it exists). If the payloads one is greater, then the BookingBug object
will be updated.

status

Used to declare the state of an object. "live" means it should appear as a functionality object in the
journey application and can be used for Bookings.

"disabled" mean that though its within BookingBug, it is not to be used for Bookings or in the journey.

"deleted" remove it from the BookingBug application.

object_type

Provides a way to identify the class of object without relying on the collection that it was apart of.

{ "data": { "companies": [ { "external_id": "e843:5eff:205f:9fd0:518a:813e:c177:10d9", "bookingbug_id": 11234, "object_type": "company", "updated_at": "2018-02-19T09:14:03+0000", "status": "live" } ] } }

The data payload

There are currently 3 classes of objects that sit within the "data" section of the JSON.

- company (companies)
- person (people)
- user (users)

Each of these objects have the standard common properties to held sync'in behaviour.

Companies Payload

A company serves a few purposes. Firstly it can provide a grouping of other objects such as people, services and resources. This basically creates a logic grouping when doing bookings.

The other purpose is it can identify a location.

If you put these to concepts together and apply it to a Bank. A company would be a Branch that contains a number of staff that can take appointments.

{ "data": { "companies": [ { "external_id": "e843:5eff:205f:9fd0:518a:813e:c177:10d9", "object_type": "company", "addresses": [ { "line_1": "34292 Rath Land", "line_2": "Apt. 623", "line_3": "Apt. 484", "locality": "Robertston", "region": "Montana", "postal_code": "93073", "country": "Zimbabwe", "lat": 28.077861, "long": 75.310147 } ], "name": "Green, Kling and Macejkovic", "status": "live", "created_at": "2017-09-12T11:59:03+0100", "updated_at": "2018-02-19T09:14:03+0000", "timezone": "Australia/Perth", "telephone": "521-389-9005 x07854", "currency_code": "ERN", "country_code": "GQ" } ] } }

Staff Payload

{ "data": { "staff": [ { "external_id": "753:1d14:7025:b539:e981:4517:1f8d:6383", "name": "Tomasa DuBuque", "object_type": "staff", "base_company_external_id": "e843:5eff:205f:9fd0:518a:813e:c177:10d9", "company_external_ids": [ "f107:909e:12fc:dc01:a822:676b:f278:4cb7", "e843:5eff:205f:9fd0:518a:813e:c177:10d9" ], "created_at": "2017-08-14T11:59:03+0100", "updated_at": "2018-02-19T08:34:03+0000", "email": "augusta_dach@example.org", "ews": { "enabled": false, "ews_email": "fredy@example.org" }, "telephone": "466.796.5877 x90153" } ] } }

Resources:

Example Json

{ "meta": { "version": "0.0.1", "created_at": "2017-09-24T11:59:02+0100", "callback_url": "http://example.com/addison", "type": "create/update", "feed_name": "Voluptas est impedit ea temporibus sapiente." }, "data": { "staff": [ { "external_id": "753:1d14:7025:b539:e981:4517:1f8d:6383", "name": "Tomasa DuBuque", "object_type": "staff", "base_company_external_id": "e843:5eff:205f:9fd0:518a:813e:c177:10d9", "company_external_ids": [ "f107:909e:12fc:dc01:a822:676b:f278:4cb7", "e843:5eff:205f:9fd0:518a:813e:c177:10d9" ], "created_at": "2017-08-14T11:59:03+0100", "updated_at": "2018-02-19T08:34:03+0000", "email": "augusta_dach@example.org", "ews": { "enabled": false, "ews_email": "fredy@example.org" }, "telephone": "466.796.5877 x90153" }, { "external_id": "c4d7:32c0:f721:c2a7:e858:3fb1:ebb5:d59a", "name": "Layne Johns", "object_type": "staff", "base_company_external_id": "e843:5eff:205f:9fd0:518a:813e:c177:10d9", "company_external_ids": [ "e843:5eff:205f:9fd0:518a:813e:c177:10d9", "f107:909e:12fc:dc01:a822:676b:f278:4cb7" ], "created_at": "2017-09-05T11:59:03+0100", "updated_at": "2018-02-19T08:00:03+0000", "email": "marlon@example.net", "ews": { "enabled": false, "ews_email": "millie.herzog@example.org" }, "telephone": "551-108-7924" }, { "external_id": "60cc:6496:3ef5:fbc3:cfb7:95d4:c7fd:11a", "name": "Maia Carroll", "object_type": "staff", "base_company_external_id": "e843:5eff:205f:9fd0:518a:813e:c177:10d9", "company_external_ids": [ "e843:5eff:205f:9fd0:518a:813e:c177:10d9", "f107:909e:12fc:dc01:a822:676b:f278:4cb7" ], "created_at": "2017-09-12T11:59:03+0100", "updated_at": "2018-02-19T08:00:03+0000", "email": "leonora@example.net", "ews": { "enabled": true, "ews_email": "dolly@example.com" }, "telephone": "553.390.8300 x1683" }, { "external_id": "617e:e374:9a05:915c:363f:d483:e1fc:a612", "name": "Jay Trantow", "object_type": "staff", "base_company_external_id": "f107:909e:12fc:dc01:a822:676b:f278:4cb7", "company_external_ids": [ "e843:5eff:205f:9fd0:518a:813e:c177:10d9" ], "created_at": "2017-10-24T11:59:03+0100", "updated_at": "2018-02-19T07:45:03+0000", "email": "bridget@example.com", "ews": { "enabled": false, "ews_email": "daryl_hirthe@example.com" }, "telephone": "1-988-059-2165" }, { "external_id": "dd6f:d7a7:e517:9a23:b942:f26:d025:f079", "name": "Cyrus Carter", "object_type": "staff", "base_company_external_id": "f107:909e:12fc:dc01:a822:676b:f278:4cb7", "company_external_ids": [ "e843:5eff:205f:9fd0:518a:813e:c177:10d9" ], "created_at": "2017-09-26T11:59:03+0100", "updated_at": "2018-02-19T07:44:03+0000", "email": "columbus@example.com", "ews": { "enabled": false, "ews_email": "victor_kuhlman@example.com" }, "telephone": "764.139.0519 x374" } ], "companies": [ { "external_id": "f107:909e:12fc:dc01:a822:676b:f278:4cb7", "object_type": "company", "addresses": [ { "line_1": "7689 Block Road", "line_2": "Apt. 820", "line_3": "Suite 724", "locality": "Balistrerishire", "region": "Connecticut", "postal_code": "89430-2322", "country": "Martinique", "lat": -27.929827, "long": -18.518605 } ], "name": "Auer, Schiller and Raynor", "status": "disabled", "created_at": "2017-09-16T11:59:03+0100", "updated_at": "2018-02-19T08:19:03+0000", "timezone": "Asia/Colombo", "telephone": "1-238-533-8085", "currency_code": "XCD", "country_code": "PR" }, { "external_id": "e843:5eff:205f:9fd0:518a:813e:c177:10d9", "object_type": "company", "addresses": [ { "line_1": "34292 Rath Land", "line_2": "Apt. 623", "line_3": "Apt. 484", "locality": "Robertston", "region": "Montana", "postal_code": "93073", "country": "Zimbabwe", "lat": 28.077861, "long": 75.310147 } ], "name": "Green, Kling and Macejkovic", "status": "live", "created_at": "2017-09-12T11:59:03+0100", "updated_at": "2018-02-19T09:14:03+0000", "timezone": "Australia/Perth", "telephone": "521-389-9005 x07854", "currency_code": "ERN", "country_code": "GQ" } ], "logins": [ { "name": "Giuseppe Parker", "object_type": "login", "company_external_ids": [ "f107:909e:12fc:dc01:a822:676b:f278:4cb7", "e843:5eff:205f:9fd0:518a:813e:c177:10d9" ], "created_at": "2017-11-09T10:59:03+0000", "updated_at": "2018-02-19T08:38:03+0000", "email": "lucy.cremin@example.com" }, { "name": "Mrs. Marie Blanda", "object_type": "login", "company_external_ids": [ "e843:5eff:205f:9fd0:518a:813e:c177:10d9" ], "created_at": "2017-10-31T10:59:03+0000", "updated_at": "2018-02-19T07:47:03+0000", "email": "jasper_borer@example.org" } ] } }

Clone this wiki locally