Sample code for 30+ languages & platforms
Visual FoxPro

Shippo List All Orders

See more Shippo Examples

Demonstrates how to list all orders created by sending a GET request to the orders endpoint.

Chilkat Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loHttp
LOCAL loSbResponseBody
LOCAL loJResp
LOCAL lnRespStatusCode
LOCAL lnIntVal
LOCAL j
LOCAL lnCount_j
LOCAL lcObject_id
LOCAL lcTitle
LOCAL lcVariant_title
LOCAL lcSku
LOCAL lnQuantity
LOCAL lcTotal_price
LOCAL lcCurrency
LOCAL lcWeight
LOCAL lcWeight_unit
LOCAL lcManufacture_country
LOCAL lcMax_ship_time
LOCAL lcMax_delivery_time
LOCAL lcDescription
LOCAL lnCount
LOCAL lcNext
LOCAL lcPrevious
LOCAL i
LOCAL lnCount_i

lnSuccess = 0

* This example assumes the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.

loHttp = CreateObject('Chilkat.Http')

* Implements the following CURL command:

* curl https://api.goshippo.com/orders/ \
*     -H "Authorization: ShippoToken <API_Token>"

loHttp.SetRequestHeader("Authorization","ShippoToken <API_Token>")

loSbResponseBody = CreateObject('Chilkat.StringBuilder')
lnSuccess = loHttp.QuickGetSb("https://api.goshippo.com/orders/",loSbResponseBody)
IF (lnSuccess = 0) THEN
    ? loHttp.LastErrorText
    RELEASE loHttp
    RELEASE loSbResponseBody
    CANCEL
ENDIF

loJResp = CreateObject('Chilkat.JsonObject')
loJResp.LoadSb(loSbResponseBody)
loJResp.EmitCompact = 0

? "Response Body:"
? loJResp.Emit()

lnRespStatusCode = loHttp.LastStatus
? "Response Status Code = " + STR(lnRespStatusCode)
IF (lnRespStatusCode >= 400) THEN
    ? "Response Header:"
    ? loHttp.LastHeader
    ? "Failed."
    RELEASE loHttp
    RELEASE loSbResponseBody
    RELEASE loJResp
    CANCEL
ENDIF

* Sample JSON response:
* (Sample code for parsing the JSON response is shown below)

* {
*   "count": 1382,
*   "next": "https://api.goshippo.com/orders/?page=2",
*   "previous": null,
*   "results": [
*     {
*       "object_id": "4f2bc588e4e5446cb3f9fdb7cd5e190b",
*       "object_owner": "shippotle@goshippo.com",
*       "order_number": "#1068",
*       "order_status": "PAID",
*       "placed_at": "2016-09-23T01:28:12Z",
*       "to_address": {
*         "object_created": "2016-09-23T01:38:56Z",
*         "object_updated": "2016-09-23T01:38:56Z",
*         "object_id": "d799c2679e644279b59fe661ac8fa488",
*         "object_owner": "shippotle@goshippo.com",
*         "is_complete": true,
*         "validation_results": {},
*         "name": "Mr Hippo",
*         "company": "Shippo",
*         "street1": "215 Clayton St.",
*         "street2": "",
*         "city": "San Francisco",
*         "state": "CA",
*         "zip": "94117",
*         "country": "US",
*         "phone": "15553419393",
*         "email": "shippotle@goshippo.com",
*         "is_residential": null,
*         "metadata": ""
*       },
*       "from_address": null,
*       "line_items": [
*         {
*           "object_id": "abf7d5675d744b6ea9fdb6f796b28f28",
*           "title": "Hippo Magazines",
*           "variant_title": "",
*           "sku": "HM-123",
*           "quantity": 1,
*           "total_price": "12.10",
*           "currency": "USD",
*           "weight": "0.40",
*           "weight_unit": "lb",
*           "manufacture_country": null,
*           "max_ship_time": null,
*           "max_delivery_time": null,
*           "description": null
*         }
*       ],
*       "shipping_cost": "12.83",
*       "shipping_cost_currency": "USD",
*       "shipping_method": "USPS First Class Package",
*       "shop_app": "Shippo",
*       "subtotal_price": "12.10",
*       "total_price": "24.93",
*       "total_tax": "0.00",
*       "currency": "USD",
*       "transactions": [
*       ],
*       "weight": "0.40",
*       "weight_unit": "lb",
*       "notes": null
*     },
*     ...
*   ]
* }

* Sample code for parsing the JSON response...
* Use the following online tool to generate parsing code from sample JSON:
* Generate Parsing Code from JSON

lnCount = loJResp.IntOf("count")
lcNext = loJResp.StringOf("next")
lcPrevious = loJResp.StringOf("previous")
i = 0
lnCount_i = loJResp.SizeOfArray("results")
DO WHILE i < lnCount_i
    loJResp.I = i
    lnIntVal = loJResp.IntOf("results[i]")
    j = 0
    lnCount_j = loJResp.SizeOfArray("results[i].line_items")
    DO WHILE j < lnCount_j
        loJResp.J = j
        lcObject_id = loJResp.StringOf("results[i].line_items[j].object_id")
        lcTitle = loJResp.StringOf("results[i].line_items[j].title")
        lcVariant_title = loJResp.StringOf("results[i].line_items[j].variant_title")
        lcSku = loJResp.StringOf("results[i].line_items[j].sku")
        lnQuantity = loJResp.IntOf("results[i].line_items[j].quantity")
        lcTotal_price = loJResp.StringOf("results[i].line_items[j].total_price")
        lcCurrency = loJResp.StringOf("results[i].line_items[j].currency")
        lcWeight = loJResp.StringOf("results[i].line_items[j].weight")
        lcWeight_unit = loJResp.StringOf("results[i].line_items[j].weight_unit")
        lcManufacture_country = loJResp.StringOf("results[i].line_items[j].manufacture_country")
        lcMax_ship_time = loJResp.StringOf("results[i].line_items[j].max_ship_time")
        lcMax_delivery_time = loJResp.StringOf("results[i].line_items[j].max_delivery_time")
        lcDescription = loJResp.StringOf("results[i].line_items[j].description")
        j = j + 1
    ENDDO
    j = 0
    lnCount_j = loJResp.SizeOfArray("results[i].transactions")
    DO WHILE j < lnCount_j
        loJResp.J = j
        j = j + 1
    ENDDO
    i = i + 1
ENDDO

RELEASE loHttp
RELEASE loSbResponseBody
RELEASE loJResp