How To Use Printavo’s API – Updating Orders

An API is a way to pull and push data into one application from another.  We built an API to allow our customers to connect 3rd party applications on the web to Printavo which helps you be even more efficient.  Beware, this article might get a bit technical for some folks.

In this example, we’ll be updating an existing order using PUT to your Printavo account.  <a href=”http://blog.teamtreehouse.com/its-time-to-httparty” target=”_blank”>Read more</a> about sending data to APIs. Note that if you add an ID to a line item or fee attribute, it will update the existing object. If there’s no ID, a new object will be created.

Here’s is an example JSON object you would PUT to our API:

{
 "key": "your_api_key",
 "id": existing_order_id,
 "sales_tax": 10.0,
 "discount": 5.0,
 "discount_as_percentage": false,
 "customer_id": 91167,
 "user_id": 25,
 "orderstatus_id": 1546,
 "production_notes": "",
 "order_nickname": "",
 "formatted_due_date": "05/01/2016",
 "formatted_customer_due_date": "05/01/2016",
 "lineitems_attributes": [{
   "id": 1270394,
   "style_description": "Gildan 2000 100% Cotton 2",
   "taxable": true,
   "style_number": "G2000",
   "color": "White",
   "size_other": null,
   "size_yxs": null,
   "size_ys": null,
   "size_ym": null,
   "size_yl": null,
   "size_yxl": null,
   "size_xs": null,
   "size_s": null,
   "size_m": null,
   "size_l": 15,
   "size_xl": null,
   "size_2xl": null,
   "size_3xl": 30,
   "size_4xl": null,
   "size_5xl": null,
   "size_6xl": null,
   "unit_cost": 9.5
 }, {
   "id": 1270395,
   "style_description": "Gildan 2000 100% Cotton",
   "taxable": true,
   "style_number": "G2000",
   "color": "Blue",
   "size_other": null,
   "size_yxs": null,
   "size_ys": null,
   "size_ym": null,
   "size_yl": null,
   "size_yxl": null,
   "size_xs": null,
   "size_s": null,
   "size_m": null,
   "size_l": 40,
   "size_xl": 15,
   "size_2xl": null,
   "size_3xl": 1,
   "size_4xl": null,
   "size_5xl": null,
   "size_6xl": null,
   "unit_cost": 7.0
 }],
 "order_fees_attributes": [{
   "id": insert_existing_id
   "amount": 15.0,
   "description": "Shipping Fee",
   "taxable": true
 }]
 }

View full documentation