The PagedItemInventoryResult JSON object defines a page of ItemInventory JSON Object results in the DSCO system.
- Make sure you're familiar with JSON before continuing.
- The JSON objects are defined using Orderly. Optional attrs end with a "?" all others are required.
- isodate fields use one of these ISO 8601 format: 2014-01-01T10:30:00.000+01:00, 2014-01-01T10:30:00.000+0100, 2014-01-01T10:30:00.000Z
- Dsco reserves the right to add new attributes at any time so Partners should ensure their validators won't break should this happen
Definition
If the API specified that the results be compressed then the base64EncodedCompressedItemInventory attribute will have the results which is a base64 encoded string of the GZip compressed itemInventory results. So, first decode this base64 string into a byte array and then decompress it using the gzip algorithm. The result will be an array of ItemInventory objects (see examples below on how to decode).
If the API did not ask for the results to be compressed then the itemInventory attribute will be present with the array of results.
Deprecation Warning
The following attributes are deprecated and will be removed in early 2019 (use scrollId instead)...
- lastId
- pageNum
- pageSize
- pageCount
Object { string scrollId?; # Use this value on subsequent API calls # to get the next page of results; lastId # will continue to work until sometime in # 2019 string base64EncodedCompressedItemInventory?; # Compressed, base 64 encoded itemInventory results int lastId?; # DEPRECATED. # If fastMode is true, use this on the next API # call to get the next page of results although # you should transition to using scrollId # since lastId costs time to map to the # real scrollId int pageNum; # DEPRECATED. # Page number of this page of Order results # (only applies if fastMode is false) int pageSize; # DEPRECATED. # The max number of Orders per page of results int pageCount; # DEPRECATED. # The number of total pages in the results # (only applies if fastMode is false) array{ref ItemInventory} itemInventory?; # Inventory in current page };
Example
{ "scrollId": "j23jl2k3j2lkj42l;k43j2lk4j2lk4j2kl4j24lk2j", "itemInventory": [ <ItemInventory>, <ItemInventory> ] }
Java Decode/Decompress Example
// The Base64 object below comes // from the org.apache.commons.codec.binary package. // The GZIPInputStream comes from java.util.zip package. // The ItemInventory class defines the attributes documented in the JSON. // The jsonMapper var is an instance of the Jackson library's JsonMapper // The TypeReference class comes from the Jackson library // Assume the base64EncodedCompressedItemInventory has been // placed in this variable. String encodedStr = null; if (encodedStr != null) { byte[] decodedBytes = Base64.decodeBase64(encodedStr); ByteArrayInputStream bis = new ByteArrayInputStream(decodedBytes); GZIPInputStream gis = new GZIPInputStream(bis); BufferedReader br = new BufferedReader(new InputStreamReader(gis, "UTF-8")); StringBuilder sb = new StringBuilder(); String line; while((line = br.readLine()) != null) { sb.append(line); } br.close(); gis.close(); bis.close(); List<ItemInventory> list = jsonMapper.readValue(sb.toString(), new TypeReference<List<ItemInventory>>(){}); }
Node JS Decode/Decompress Example
// Using the zlib library to decompress gzipped data const zlib = require('zlib'); // Assume that obj is AllItemInventoryResult JSON object const str = obj.base64EncodedCompressedItemInventory; if (str) { let buffer = new Buffer(str, 'base64'); let decompressedData = []; let decompressor = zlib.createGunzip(); decompressor.write(buffer); decompressor.end(); decompressor.on('data', function(d) { decompressedData.push(d); }); decompressor.on('error', function(e) { reject(e); }); decompressor.on('end', function() { let itemInventoryStr = decompressedData.join(''); let itemInventoryJson = JSON.parse(itemInventoryStr); console.log(JSON.stringify(itemInventoryJson)); }); }
Comments
Please sign in to leave a comment.