LIST (GET /inventories.xml)
Retrieve list of inventories. Each call returns only 1 page worth of records. The default and maximum page size is 50. If you have multiple branches, you can pass the parameter branch_id; otherwise, only the home branch inventories will be returned.
Example 1: Listing of Inventories
Retrieve list of inventories. Only page 1 or first 50 records will be returned. You can use page parameter to return more pages.
curl -u 4acc660ce98b9d38d7fea10705aa1ebd7d836fe0:X \
-H "Accept: application/xml" \
-H "Content-Type: application/xml" \
"https://test_account.imonggo.com/api/inventories.xml"
Sample Result:
<?xml version="1.0" encoding="UTF-8"?>
<inventories type="array">
<inventory>
...
</inventory>
<inventory>
....
</inventory>
...
</inventories>
Sample result (when empty):
<inventories/>
Example 2: Listing with page and per_page parameter
To retrieve page 1 of inventories with default page size of 50.
curl -u 4acc660ce98b9d38d7fea10705aa1ebd7d836fe0:X \
-H "Accept: application/xml" -H "Content-Type: application/xml" \
"https://test_account.imonggo.com/api/inventories.xml?page=1"
To retrieve page 2 of the inventories list:
curl -u 4acc660ce98b9d38d7fea10705aa1ebd7d836fe0:X \
-H "Accept: application/xml" -H "Content-Type: application/xml" \
"https://test_account.imonggo.com/api/inventories.xml?page=2
Parameters for LIST (GET /inventories.xml)
Page Filters
Page filters are used in LIST to limit the inventories to be retrieved. You can combined page filter with date Filters (_before_, after, from and to).
page: default of 1 (eg. page=1)
per_page: any number between 1 to 50 (e.g. per_page=10)
Date Filters
Date filtered are used in LIST to limit the inventories to be retrieved. Date format must be given in UTC date/time format ("YYYY-MM-DDTHH:MM:SSZ").
before: updated date < given date
after: updated date > given date
from: updated date >= give date
to: updated date <= give date
Inquiry
q=count - returns a number of inventories
q=last_updated_at - returns the last updated date for your inventory database
More Examples
Example 1: Counting Inventories
To count on the total number of records in the inventories
curl -u 4acc660ce98b9d38d7fea10705aa1ebd7d836fe0:X \
-H "Accept: application/xml" -H "Content-Type: application/xml" \
"https://test_account.imonggo.com/api/inventories.xml?q=count"
Sample Result:
<?xml version="1.0" encoding="UTF-8"?>
<hash>
<count type="integer">7</count>
</hash>
To count on the total number of active inventories updated after Jan 1, 2011.
curl -u 4acc660ce98b9d38d7fea10705aa1ebd7d836fe0:X \
-H "Accept: application/xml" -H "Content-Type: application/xml" \
"https://test_account.imonggo.com/api/inventories.xml?q=count&after=2011-01-01T00:00:00Z"
Example 2: Limiting Inventories Listing with Last updated date
To inquire on the total number of inventories updated after April 1, 2011
curl -u 4acc660ce98b9d38d7fea10705aa1ebd7d836fe0:X \
-H "Accept: application/xml" -H "Content-Type: application/xml" \
"https://test_account.imonggo.com/api/inventories.xml?q=count&after=2011-04-1T00:00:00Z"
Sample Result:
<?xml version="1.0" encoding="UTF-8"?>
<hash>
<count type="integer">1</count>
</hash>
Retrieve list of inventories updated after Dec 31, 2010.
curl -u 4acc660ce98b9d38d7fea10705aa1ebd7d836fe0:X \
-H "Accept: application/xml" -H "Content-Type: application/xml" \
"https://test_account.imonggo.com/api/inventories.xml?after=2010-12-31T23:59:00Z"
Sample Result:
<?xml version="1.0" encoding="UTF-8"?>
<inventories type="array">
<inventory>
...
</inventory>
<inventory>
....
</inventory>
...
</inventories>
Example 3: Last Updated At
To inquire on the last updated date, use q=last_updated_at
curl -u 4acc660ce98b9d38d7fea10705aa1ebd7d836fe0:X \
-H "Accept: application/xml" -H "Content-Type: application/xml" \
"https://test_account.imonggo.com/api/inventories.xml?q=last_updated_at"
Sample Result:
<?xml version="1.0" encoding="UTF-8"?>
<hash>
<last-updated-at>2011-04-13 04:37:45</last-updated-at>
</hash>
Proposed Algorithm for synchronizing inventory incrementally
Keep a local persistent variable: previous_last_updated_date (which is initially nil)
GET last_updated_date from server
GET inventories after previous_last_updated_date to last_updated_date
Start with page 1 until inventories return contains an empty array
Override local variable pervious_last_updated_date with last_updated_date
Multiple Branch Operation
If you have multiple branches, you should pass the parameter branch_id; otherwise, only the home branch inventories will be returned.
Example: Retrieving inventories with branch_id parameter
curl -u 4acc660ce98b9d38d7fea10705aa1ebd7d836fe0:X \
-H "Accept: application/xml" \
-H "Content-Type: application/xml" \
"https://test_account.imonggo.com/api/inventories.xml?branch_id=99"