Sample code for 30+ languages & platforms
PowerBuilder

Walmart V3 API - Get All Released Orders

See more Walmart v3 Examples

Retrieves all the orders with line items that are in the "created" status, that is, these orders have been released from the Walmart Order Management System to the seller for processing. The released orders are the orders that are ready for a seller to fulfill.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Http
oleobject loo_Resp
oleobject loo_JsonResponse
string ls_PurchaseOrderId
string ls_CustomerOrderId
string ls_CustomerEmailId
integer li_OrderDate
string ls_ShippingInfoPhone
integer li_ShippingInfoEstimatedDeliveryDate
integer li_ShippingInfoEstimatedShipDate
string ls_ShippingInfoMethodCode
string ls_ShippingInfoPostalAddressName
string ls_ShippingInfoPostalAddressAddress1
string ls_ShippingInfoPostalAddressAddress2
string ls_ShippingInfoPostalAddressCity
string ls_ShippingInfoPostalAddressState
string ls_ShippingInfoPostalAddressPostalCode
string ls_ShippingInfoPostalAddressCountry
string ls_ShippingInfoPostalAddressAddressType
string ls_ShipNodeType
integer j
integer li_Count_j
string ls_LineNumber
string ls_ItemProductName
string ls_ItemSku
string ls_OrderLineQuantityUnitOfMeasurement
string ls_OrderLineQuantityAmount
integer li_StatusDate
string ls_Refund
string ls_FulfillmentFulfillmentOption
string ls_FulfillmentShipMethod
string ls_FulfillmentStoreId
integer li_FulfillmentPickUpDateTime
string ls_FulfillmentPickUpBy
string ls_FulfillmentShippingProgramType
integer k
integer li_Count_k
string ls_ChargeType
string ls_ChargeName
string ls_ChargeAmountCurrency
integer li_ChargeAmountAmount
string ls_TaxTaxName
string ls_TaxTaxAmountCurrency
string ls_TaxTaxAmountAmount
string ls_Status
string ls_StatusQuantityUnitOfMeasurement
string ls_StatusQuantityAmount
string ls_CancellationReason
string ls_TrackingInfo
string ls_ReturnCenterAddress
integer li_ListMetaTotalCount
integer li_ListMetaLimit
string ls_ListMetaNextCursor
integer i
integer li_Count_i

li_Success = 0

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

loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

loo_Http.Accept = "application/json"

// Setting the Login and Password properties to the clientId and clientSecret
// will cause the Basic Auth header to be added (i.e. BaseEncode64(clientId:clientSecret))
loo_Http.Login = "clientId"
loo_Http.Password = "clientSecret"
loo_Http.BasicAuth = 1

loo_Http.SetRequestHeader("Content-Type","application/json")
loo_Http.SetRequestHeader("WM_QOS.CORRELATION_ID","b3261d2d-028a-4ef7-8602-633c23200af6")
// Use the access token obtained from this example:  Walmart v3 API Get OAuth2 Access Token using Client Credentials
loo_Http.SetRequestHeader("WM_SEC.ACCESS_TOKEN","eyJraWQiOiIzZjVhYTFmNS1hYWE5LTQzM.....")
loo_Http.SetRequestHeader("WM_SVC.NAME","Walmart Marketplace")

loo_Http.SetUrlVar("createdStartDate","2020-01-16T10:30:15Z")
loo_Http.SetUrlVar("limit","200")
// Can also be 3PLFulfilled
loo_Http.SetUrlVar("shippingProgramType","SellerFulfilled")
loo_Http.SetUrlVar("shipNodeType","TWO_DAY")

loo_Resp = create oleobject
li_rc = loo_Resp.ConnectToNewObject("Chilkat.HttpResponse")

li_Success = loo_Http.HttpNoBody("GET","/v3/orders/released?createdStartDate={$createdStartDate}&limit={$limit}&shippingProgramType={$shippingProgramType}&shipNodeType={$shipNodeType}",loo_Resp)
if li_Success = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_Resp
    return
end if

Write-Debug "Response Status Code: " + string(loo_Resp.StatusCode)

loo_JsonResponse = create oleobject
li_rc = loo_JsonResponse.ConnectToNewObject("Chilkat.JsonObject")

loo_JsonResponse.Load(loo_Resp.BodyStr)
loo_JsonResponse.EmitCompact = 0
Write-Debug loo_JsonResponse.Emit()

if loo_Resp.StatusCode <> 200 then
    Write-Debug "Failed."
    destroy loo_Http
    destroy loo_Resp
    destroy loo_JsonResponse
    return
end if

// Sample output...
// (See the parsing code below..)
// 
// Use the this online tool to generate parsing code from sample JSON: 
// Generate Parsing Code from JSON

// {
//   "list": {
//     "meta": {
//       "totalCount": 25228,
//       "limit": 10,
//       "nextCursor": "?limit=10&hasMoreElements=true&soIndex=25228&poIndex=10&sellerId=152&createdStartDate=2019-04-02T00:00:00.000Z&createdEndDate=2019-09-26T16:05:49.648Z"
//     },
//     "elements": {
//       "order": [
//         {
//           "purchaseOrderId": "4792701510371",
//           "customerOrderId": "5401973367419",
//           "customerEmailId": "47B81ACD2C62434DBE64F47B9E1F7630@relay.walmart.com",
//           "orderDate": 1569513584000,
//           "shippingInfo": {
//             "phone": "2134488377",
//             "estimatedDeliveryDate": 1569870000000,
//             "estimatedShipDate": 1569553200000,
//             "methodCode": "Express",
//             "postalAddress": {
//               "name": "Julio Hernandez",
//               "address1": "9713 pleasant view dr",
//               "address2": null,
//               "city": "Rancho Cucamonga",
//               "state": "CA",
//               "postalCode": "91701",
//               "country": "USA",
//               "addressType": "RESIDENTIAL"
//             }
//           },
//           "orderLines": {
//             "orderLine": [
//               {
//                 "lineNumber": "1",
//                 "item": {
//                   "productName": "Refurbished Lenovo YB1-X90F Grey Yoga Book with WiFi 10.1\" Touchscreen Tablet Android 6.0.1",
//                   "sku": "VO190403007727R"
//                 },
//                 "charges": {
//                   "charge": [
//                     {
//                       "chargeType": "PRODUCT",
//                       "chargeName": "ItemPrice",
//                       "chargeAmount": {
//                         "currency": "USD",
//                         "amount": 259
//                       },
//                       "tax": {
//                         "taxName": "Tax1",
//                         "taxAmount": {
//                           "currency": "USD",
//                           "amount": 20.07
//                         }
//                       }
//                     },
//                     {
//                       "chargeType": "FEE",
//                       "chargeName": "Fee",
//                       "chargeAmount": {
//                         "currency": "USD",
//                         "amount": 0
//                       },
//                       "tax": {
//                         "taxName": "Electronic Waste Recycling Fee",
//                         "taxAmount": {
//                           "currency": "USD",
//                           "amount": 5
//                         }
//                       }
//                     }
//                   ]
//                 },
//                 "orderLineQuantity": {
//                   "unitOfMeasurement": "EACH",
//                   "amount": "1"
//                 },
//                 "statusDate": 1569513724000,
//                 "orderLineStatuses": {
//                   "orderLineStatus": [
//                     {
//                       "status": "Acknowledged",
//                       "statusQuantity": {
//                         "unitOfMeasurement": "EACH",
//                         "amount": "1"
//                       },
//                       "cancellationReason": null,
//                       "trackingInfo": null,
//                       "returnCenterAddress": null
//                     }
//                   ]
//                 },
//                 "refund": null,
//                 "fulfillment": {
//                   "fulfillmentOption": "S2H",
//                   "shipMethod": "EXPEDITED",
//                   "storeId": null,
//                   "pickUpDateTime": 1569870000000,
//                   "pickUpBy": null,
//                   "shippingProgramType": "TWO_DAY"
//                 }
//               }
//             ]
//           },
//           "shipNode": {
//             "type": "3PLFulfilled"
//           }
//         }
//       ]
//     }
//   }
// }
// 

li_ListMetaTotalCount = loo_JsonResponse.IntOf("list.meta.totalCount")
li_ListMetaLimit = loo_JsonResponse.IntOf("list.meta.limit")
ls_ListMetaNextCursor = loo_JsonResponse.StringOf("list.meta.nextCursor")
i = 0
li_Count_i = loo_JsonResponse.SizeOfArray("list.elements.order")
do while i < li_Count_i
    loo_JsonResponse.I = i
    ls_PurchaseOrderId = loo_JsonResponse.StringOf("list.elements.order[i].purchaseOrderId")
    ls_CustomerOrderId = loo_JsonResponse.StringOf("list.elements.order[i].customerOrderId")
    ls_CustomerEmailId = loo_JsonResponse.StringOf("list.elements.order[i].customerEmailId")
    li_OrderDate = loo_JsonResponse.IntOf("list.elements.order[i].orderDate")
    ls_ShippingInfoPhone = loo_JsonResponse.StringOf("list.elements.order[i].shippingInfo.phone")
    li_ShippingInfoEstimatedDeliveryDate = loo_JsonResponse.IntOf("list.elements.order[i].shippingInfo.estimatedDeliveryDate")
    li_ShippingInfoEstimatedShipDate = loo_JsonResponse.IntOf("list.elements.order[i].shippingInfo.estimatedShipDate")
    ls_ShippingInfoMethodCode = loo_JsonResponse.StringOf("list.elements.order[i].shippingInfo.methodCode")
    ls_ShippingInfoPostalAddressName = loo_JsonResponse.StringOf("list.elements.order[i].shippingInfo.postalAddress.name")
    ls_ShippingInfoPostalAddressAddress1 = loo_JsonResponse.StringOf("list.elements.order[i].shippingInfo.postalAddress.address1")
    ls_ShippingInfoPostalAddressAddress2 = loo_JsonResponse.StringOf("list.elements.order[i].shippingInfo.postalAddress.address2")
    ls_ShippingInfoPostalAddressCity = loo_JsonResponse.StringOf("list.elements.order[i].shippingInfo.postalAddress.city")
    ls_ShippingInfoPostalAddressState = loo_JsonResponse.StringOf("list.elements.order[i].shippingInfo.postalAddress.state")
    ls_ShippingInfoPostalAddressPostalCode = loo_JsonResponse.StringOf("list.elements.order[i].shippingInfo.postalAddress.postalCode")
    ls_ShippingInfoPostalAddressCountry = loo_JsonResponse.StringOf("list.elements.order[i].shippingInfo.postalAddress.country")
    ls_ShippingInfoPostalAddressAddressType = loo_JsonResponse.StringOf("list.elements.order[i].shippingInfo.postalAddress.addressType")
    ls_ShipNodeType = loo_JsonResponse.StringOf("list.elements.order[i].shipNode.type")
    j = 0
    li_Count_j = loo_JsonResponse.SizeOfArray("list.elements.order[i].orderLines.orderLine")
    do while j < li_Count_j
        loo_JsonResponse.J = j
        ls_LineNumber = loo_JsonResponse.StringOf("list.elements.order[i].orderLines.orderLine[j].lineNumber")
        ls_ItemProductName = loo_JsonResponse.StringOf("list.elements.order[i].orderLines.orderLine[j].item.productName")
        ls_ItemSku = loo_JsonResponse.StringOf("list.elements.order[i].orderLines.orderLine[j].item.sku")
        ls_OrderLineQuantityUnitOfMeasurement = loo_JsonResponse.StringOf("list.elements.order[i].orderLines.orderLine[j].orderLineQuantity.unitOfMeasurement")
        ls_OrderLineQuantityAmount = loo_JsonResponse.StringOf("list.elements.order[i].orderLines.orderLine[j].orderLineQuantity.amount")
        li_StatusDate = loo_JsonResponse.IntOf("list.elements.order[i].orderLines.orderLine[j].statusDate")
        ls_Refund = loo_JsonResponse.StringOf("list.elements.order[i].orderLines.orderLine[j].refund")
        ls_FulfillmentFulfillmentOption = loo_JsonResponse.StringOf("list.elements.order[i].orderLines.orderLine[j].fulfillment.fulfillmentOption")
        ls_FulfillmentShipMethod = loo_JsonResponse.StringOf("list.elements.order[i].orderLines.orderLine[j].fulfillment.shipMethod")
        ls_FulfillmentStoreId = loo_JsonResponse.StringOf("list.elements.order[i].orderLines.orderLine[j].fulfillment.storeId")
        li_FulfillmentPickUpDateTime = loo_JsonResponse.IntOf("list.elements.order[i].orderLines.orderLine[j].fulfillment.pickUpDateTime")
        ls_FulfillmentPickUpBy = loo_JsonResponse.StringOf("list.elements.order[i].orderLines.orderLine[j].fulfillment.pickUpBy")
        ls_FulfillmentShippingProgramType = loo_JsonResponse.StringOf("list.elements.order[i].orderLines.orderLine[j].fulfillment.shippingProgramType")
        k = 0
        li_Count_k = loo_JsonResponse.SizeOfArray("list.elements.order[i].orderLines.orderLine[j].charges.charge")
        do while k < li_Count_k
            loo_JsonResponse.K = k
            ls_ChargeType = loo_JsonResponse.StringOf("list.elements.order[i].orderLines.orderLine[j].charges.charge[k].chargeType")
            ls_ChargeName = loo_JsonResponse.StringOf("list.elements.order[i].orderLines.orderLine[j].charges.charge[k].chargeName")
            ls_ChargeAmountCurrency = loo_JsonResponse.StringOf("list.elements.order[i].orderLines.orderLine[j].charges.charge[k].chargeAmount.currency")
            li_ChargeAmountAmount = loo_JsonResponse.IntOf("list.elements.order[i].orderLines.orderLine[j].charges.charge[k].chargeAmount.amount")
            ls_TaxTaxName = loo_JsonResponse.StringOf("list.elements.order[i].orderLines.orderLine[j].charges.charge[k].tax.taxName")
            ls_TaxTaxAmountCurrency = loo_JsonResponse.StringOf("list.elements.order[i].orderLines.orderLine[j].charges.charge[k].tax.taxAmount.currency")
            ls_TaxTaxAmountAmount = loo_JsonResponse.StringOf("list.elements.order[i].orderLines.orderLine[j].charges.charge[k].tax.taxAmount.amount")
            k = k + 1
        loop
        k = 0
        li_Count_k = loo_JsonResponse.SizeOfArray("list.elements.order[i].orderLines.orderLine[j].orderLineStatuses.orderLineStatus")
        do while k < li_Count_k
            loo_JsonResponse.K = k
            ls_Status = loo_JsonResponse.StringOf("list.elements.order[i].orderLines.orderLine[j].orderLineStatuses.orderLineStatus[k].status")
            ls_StatusQuantityUnitOfMeasurement = loo_JsonResponse.StringOf("list.elements.order[i].orderLines.orderLine[j].orderLineStatuses.orderLineStatus[k].statusQuantity.unitOfMeasurement")
            ls_StatusQuantityAmount = loo_JsonResponse.StringOf("list.elements.order[i].orderLines.orderLine[j].orderLineStatuses.orderLineStatus[k].statusQuantity.amount")
            ls_CancellationReason = loo_JsonResponse.StringOf("list.elements.order[i].orderLines.orderLine[j].orderLineStatuses.orderLineStatus[k].cancellationReason")
            ls_TrackingInfo = loo_JsonResponse.StringOf("list.elements.order[i].orderLines.orderLine[j].orderLineStatuses.orderLineStatus[k].trackingInfo")
            ls_ReturnCenterAddress = loo_JsonResponse.StringOf("list.elements.order[i].orderLines.orderLine[j].orderLineStatuses.orderLineStatus[k].returnCenterAddress")
            k = k + 1
        loop
        j = j + 1
    loop
    i = i + 1
loop


destroy loo_Http
destroy loo_Resp
destroy loo_JsonResponse