This guide explains how to manage inventory across different warehouse locations in QuickBooks Commerce.
In this guide:Before you start working on a warehouse integration with QuickBooks Commerce, it’s helpful to understand some of the different warehouse-related resources.
draft
, active
, finalized
, fulfilled
, void
or deleted
.packed
, fulfilled
, void
or deleted
.draft
, active
, received
, void
or deleted
.received
.initial_stock_levels
where an array of hashes can be defined to set the initial stock level for each location. There is another attribute called initial_cost_price
that will be the cost price associated with the initial stock.purchase_order.create
webhook.received
.purchase_order.create
webhook.To get started, subscribe to the purchase_order.create
webhook to be notified when a new purchase order is created by a merchant.
require 'gecko-ruby'
gecko = Gecko::Client.new(<OAUTH_ID>, <OAUTH_SECRET>)
access_token = OAuth2::AccessToken.new(gecko.oauth_client, <ACCESS_TOKEN>)
gecko.access_token = access_token
webhook = gecko.Webhook.build(:address=>"https://mywebsite.com/webhooks", :event=>"purchase_order.create")
webhook.save
{
"webhook": {
"id": 1,
"created_at": "2018-09-24T11:12:49.244Z",
"updated_at": "2018-09-24T11:12:49.244Z",
"event": "purchase_order.create",
"address": "https://mywebsite.com/webhooks",
"oauth_application_id": 1
}
}
curl -X POST -H "Content-type: application/json" -H "Authorization: Bearer <ACCESS_TOKEN>"
https://api.tradegecko.com/webhooks/ -d '{"webhook":{"address":"https://mywebsite.com/webhooks","event":"purchase_order.create"}}'
{
"webhook": {
"id": 1,
"created_at": "2018-09-24T11:12:49.244Z",
"updated_at": "2018-09-24T11:12:49.244Z",
"event": "purchase_order.create",
"address": "https://mywebsite.com/webhooks",
"oauth_application_id": 1
}
}
require 'gecko-ruby'
gecko = Gecko::Client.new(<OAUTH_ID>, <OAUTH_SECRET>)
access_token = OAuth2::AccessToken.new(gecko.oauth_client, <ACCESS_TOKEN>)
gecko.access_token = access_token
gecko.PurchaseOrder.find(1)
{
"purchase_order": {
"id": 1,
"created_at": "2015-11-02T01:22:25.524Z",
"updated_at": "2015-12-02T01:11:25.524Z",
"stock_location_id": 1,
"purchase_line_item_ids": [1, 2, 3]
// more fields
}
}
curl -X GET -H "Content-type: application/json" -H "Authorization: Bearer <ACCESS_TOKEN>"
https://api.tradegecko.com/purchase_orders/1?include=purchase_order_line_items
{
"purchase_order_line_items": [
{
"id": 1,
"created_at": "2015-11-02T01:22:25.524Z",
"updated_at": "2015-12-02T01:11:25.524Z",
// more fields
}
],
"purchase_order": {
"id": 1,
"created_at": "2015-11-02T01:22:25.524Z",
"updated_at": "2015-12-02T01:11:25.524Z",
"stock_location_id": 1,
"purchase_line_item_ids": [1],
// more fields
}
}
received
.If you manage the procurement process for a merchant, once you have procured the items, you can update the original purchase order to received
through an API call to POST /purchase_orders/[:purchase_order_id]/actions/receive
. This will increase the Stock On Hand level of the procured items.
require 'gecko-ruby'
gecko = Gecko::Client.new(<OAUTH_ID>, <OAUTH_SECRET>)
access_token = OAuth2::AccessToken.new(gecko.oauth_client, <ACCESS_TOKEN>)
gecko.access_token = access_token
purchase_order = gecko.PurchaseOrder.find(1)
purchase_order.receive
{
"procurement": {
"id": 1,
// more fields
}
}
curl -X POST -H "Content-type: application/json" -H "Authorization: Bearer <ACCESS_TOKEN>"
https://api.tradegecko.com/purchase_orders/1/actions/receive
{
"procurement": {
"id": 1,
// more fields
}
}
Note: Partial procurements are currently not supported. If you need an endpoint for partial procurements, let us know here.
stock_transfer.create
webhook to be notified when a merchant creates a new stock transfer.See these additional resources for more information about authorization, webhooks and order actions.
For API feature requests, bug reports and other questions related to API guides, contact support@tradegecko.com.