All functions return a set of fields from database. An explanation of the fields is included below.

1) owner_id - Client Book CRM user_id or inventory ID of the user added the purchase

2) date_entered - when the purchase was added (format: yyyy-mm-dd hh:ii:ss)

3) item_id - the primary key or the purchase ID

4) item item name 

5) item_image - item image server URL

6) price - the price of the item

7) sku - stock keeping unit of the item

8) style_number - the style number of the item

9) update_date - the date of the last update

10) client_id - the ID of the customer or client who purchased the item

11) vendor_id - the ID of the item’s vendor

12) new_inventory_id - the primary key or ID in the your database (e.g database in user’s server that is synchronized or linked with the Client Book CRM database). Empty value indicates there is any changes in Client Book CRM database and need to be synchronized again, not empty indicates it has been synchronized.

14) old_inventory_id - the primary key or ID in the your database, obtained after the first synchronization process (e.g database in user’s server that is synchronized or linked with the Client Book CRM database).

Note: if both new_inventory_id and old_inventory_id are empty, the purchase has not synchronized with other database. If old_inventory_id is not empty and new_inventory_id is empty, it means there are some changes on the purchase information, so it needs to be synchronized again.

Function List: 

a. [GET] specificlist

Retrieve all purchase from specific client, sorted descending.

Return content in “data” field. “data” is in array format.

Parameters:

- cid : must have either cid or cinvid, but not both, this parameters to use this function. It contains specific client id

- cinvid : must have either cid or cinvid, but not both, this parameters to use this functions. It contains specific client inventory id

- order : to sort the result by specific value. Default is update.

Value: update | created

- limit : to set the number of the data displayed. Default 10

- offset : to set the number where to start displaying the data set (offset). Default 0 (the beginning of the data set)

b. [GET] listall

Retrieve all purchase related with the API authentication.

Return content in “data” field. “data” is in array format.

Parameters:

- cid : contains specific client id. Use either cid or cinvid, but not both

- cinvid : contains specific client inventory_id. Use either cid or cinvid, but not both

- order : to sort the result by specific value. Default is created.

Value: update | created

- limit : to set the number of the data displayed. If not set, it will return all data. In order to use this parameter, from must be set too.

- from : to set the number where to start displaying the data set (offset). If not set, it will return all data. In order to use this parameter, limit must be set too.

- q : keyword to search. Search in field “item”, “price”, “sku”, and “style_number”

- sku : get data with specific sku (stock keeping unit)

c. [GET] new

Retrieve all purchases which are new and have not been synchronized with the third-party database.

Return content in “data” field. “data” is in array format.

Parameters:

- cid : contains specific client id. Use either cid or cinvid, but not both

- cinvid : contains specific client inventory_id. Use either cid or cinvid, but not both

- order : to sort the result by specific value. Default is created.

Value: update | created

- limit : to set the number of the data displayed. If not set, it will return all data. In order to use this parameter, from must be set too.

- from : to set the number where to start displaying the data set (offset). If not set, it will return all data. In order to use this parameter, limit must be set too.

- q : keyword to search. Search in field “item”, “price”, “sku”, and “style_number”

- sku : get data with specific sku (stock keeping unit)

d. [GET] edited

Retrieve all purchase which have been updated and have not been synchronized with the third-party database.

Return content in “data” field. “data” is in array format.

Parameters:

- cid : contains specific client id. Use either cid or cinvid, but not both

- cinvid : contains specific client inventory_id. Use either cid or cinvid, but not both

- order : to sort the result by specific value. Default is created.

Value: update | created

- limit : to set the number of the data displayed. If not set, it will return all data. In order to use this parameter, from must be set too.

- from : to set the number where to start displaying the data set (offset). If not set, it will return all data. In order to use this parameter, limit must be set too.

- q : keyword to search. Search in field “item”, “price”, “sku”, and “style_number”

- sku : get data with specific sku (stock keeping unit)

e. [POST] saveinventory

Save the inventory_id (ID got from the synchronization process, ID from third-party database) into Client Book CRM database.

Return content in “data” field. “data” is in string format, either error message or success message.

Parameters:

- inventory_id : ID got from the synchronization process (ID from third-party database, mandatory)

- item_id : local purchase ID which is being synchronized (mandatory)

f. [POST] add

Add a purchase item into Client Book CRM database

Return content in “data” field. “data” is in string format, either error message or success message.

Parameters:

- item : item name (mandatory)

- client_id (mandatory)

- price

- date_entered

- owner_id

- sku

- style_number

- description

- vendor_id

- inventory_id (if filled, it will add an inventory_id for the item)

- client_inventory_id à client’s inventory_id in Client Book CRM database

g. [GET] view/:type/:id

Get specific purchase item by its’ ID.

Return content in “data” field. “data” is in array format.

Parameters:

:type : inventory | id

:id : the item_id or inventory_id of the specific purchase. item_id is an ID in Client Book CRM database, inventory_id is an ID got from synchronization process.

h. [POST] edit

Update a purchase item from Client Book CRM database

Return content in “data” field. “data” is in string format, either error message or success message.

Parameters:

- item_id : Client Book CRM item ID which is being updated (mandatory)

- item : item name (mandatory, if edited)

- client_id (mandatory)

- price

- sku

- style_number

- description

- vendor_id

i. [GET] count/:client_id

Return the purchase count of specified client_id.

Return content in “data” field. “data” is in string format.

Parameters:

- :client_id : Client Book CRM client_id which purchases will be counted