PureBasic
PureBasic
Walmart v3 Ship Order Lines
See more Walmart v3 Examples
Updates the status of order lines to Shipped and trigger the charge to the customer. The response to a successful call contains the order with the shipped line items.Chilkat PureBasic Downloads
IncludeFile "CkHttpResponse.pb"
IncludeFile "CkHttp.pb"
IncludeFile "CkJsonObject.pb"
Procedure ChilkatExample()
success.i = 0
; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
http.i = CkHttp::ckCreate()
If http.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkHttp::ckSetRequestHeader(http,"WM_QOS.CORRELATION_ID","b3261d2d-028a-4ef7-8602-633c23200af6")
CkHttp::ckSetRequestHeader(http,"WM_SEC.ACCESS_TOKEN","eyJraWQiOiIzZjVhYTFmNS1hYWE5LTQzM.....")
CkHttp::ckSetRequestHeader(http,"Accept","application/json")
CkHttp::ckSetRequestHeader(http,"WM_SVC.NAME","Walmart Marketplace")
; Send the following in the request body:
; {
; "orderShipment": {
; "orderLines": {
; "orderLine": [
; {
; "lineNumber": "1",
; "intentToCancelOverride": false,
; "sellerOrderId": "92344",
; "orderLineStatuses": {
; "orderLineStatus": [
; {
; "status": "Shipped",
; "statusQuantity": {
; "unitOfMeasurement": "EACH",
; "amount": "1"
; },
; "trackingInfo": {
; "shipDateTime": 1580821866000,
; "carrierName": {
; "carrier": "UPS"
; },
; "methodCode": "Standard",
; "trackingNumber": "22344",
; "trackingURL": "http://walmart/tracking/ups?&type=MP&seller_id=12345&promise_date=03/02/2020&dzip=92840&tracking_numbers=92345"
; },
; "returnCenterAddress": {
; "name": "walmart",
; "address1": "walmart store 2",
; "city": "Huntsville",
; "state": "AL",
; "postalCode": "35805",
; "country": "USA",
; "dayPhone": "12344",
; "emailId": "walmart@walmart.com"
; }
; }
; ]
; }
; },
; {
; "lineNumber": "2",
; "sellerOrderId": "92344",
; "orderLineStatuses": {
; "orderLineStatus": [
; {
; "status": "Shipped",
; "statusQuantity": {
; "unitOfMeasurement": "EACH",
; "amount": "1"
; },
; "trackingInfo": {
; "shipDateTime": 1580821866000,
; "carrierName": {
; "carrier": "FedEx"
; },
; "methodCode": "Express",
; "trackingNumber": "22344",
; "trackingURL": "http://walmart/tracking/fedEx?&type=MP&seller_id=12345&promise_date=03/02/2020&dzip=92840&tracking_numbers=92344"
; },
; "returnCenterAddress": {
; "name": "walmart",
; "address1": "walmart store 2",
; "city": "Huntsville",
; "state": "AL",
; "postalCode": "35805",
; "country": "USA",
; "dayPhone": "12344",
; "emailId": "walmart@walmart.com"
; }
; }
; ]
; }
; }
; ]
; }
; }
; }
json.i = CkJsonObject::ckCreate()
If json.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
orderLineIndex.i = 0
statusIndex.i = 0
CkJsonObject::setCkI(json, orderLineIndex)
CkJsonObject::setCkJ(json, statusIndex)
CkJsonObject::ckUpdateString(json,"orderShipment.orderLines.orderLine[i].lineNumber","1")
CkJsonObject::ckUpdateBool(json,"orderShipment.orderLines.orderLine[i].intentToCancelOverride",0)
CkJsonObject::ckUpdateString(json,"orderShipment.orderLines.orderLine[i].sellerOrderId","92344")
CkJsonObject::ckUpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].status","Shipped")
CkJsonObject::ckUpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.unitOfMeasurement","EACH")
CkJsonObject::ckUpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.amount","1")
CkJsonObject::ckUpdateInt(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.shipDateTime",123)
CkJsonObject::ckUpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.carrierName.carrier","UPS")
CkJsonObject::ckUpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.methodCode","Standard")
CkJsonObject::ckUpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingNumber","22344")
CkJsonObject::ckUpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingURL","http://walmart/tracking/ups?&type=MP&seller_id=12345&promise_date=03/02/2020&dzip=92840&tracking_numbers=92345")
CkJsonObject::ckUpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.name","walmart")
CkJsonObject::ckUpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.address1","walmart store 2")
CkJsonObject::ckUpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.city","Huntsville")
CkJsonObject::ckUpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.state","AL")
CkJsonObject::ckUpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.postalCode","35805")
CkJsonObject::ckUpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.country","USA")
CkJsonObject::ckUpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.dayPhone","12344")
CkJsonObject::ckUpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.emailId","walmart@walmart.com")
orderLineIndex = orderLineIndex + 1
statusIndex = 0
CkJsonObject::setCkI(json, orderLineIndex)
CkJsonObject::setCkJ(json, statusIndex)
CkJsonObject::ckUpdateString(json,"orderShipment.orderLines.orderLine[i].lineNumber","2")
CkJsonObject::ckUpdateString(json,"orderShipment.orderLines.orderLine[i].sellerOrderId","92344")
CkJsonObject::ckUpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].status","Shipped")
CkJsonObject::ckUpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.unitOfMeasurement","EACH")
CkJsonObject::ckUpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.amount","1")
CkJsonObject::ckUpdateInt(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.shipDateTime",123)
CkJsonObject::ckUpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.carrierName.carrier","FedEx")
CkJsonObject::ckUpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.methodCode","Express")
CkJsonObject::ckUpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingNumber","22344")
CkJsonObject::ckUpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingURL","http://walmart/tracking/fedEx?&type=MP&seller_id=12345&promise_date=03/02/2020&dzip=92840&tracking_numbers=92344")
CkJsonObject::ckUpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.name","walmart")
CkJsonObject::ckUpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.address1","walmart store 2")
CkJsonObject::ckUpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.city","Huntsville")
CkJsonObject::ckUpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.state","AL")
CkJsonObject::ckUpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.postalCode","35805")
CkJsonObject::ckUpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.country","USA")
CkJsonObject::ckUpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.dayPhone","12344")
CkJsonObject::ckUpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.emailId","walmart@walmart.com")
resp.i = CkHttpResponse::ckCreate()
If resp.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success = CkHttp::ckHttpJson(http,"POST","https://api-gateway.walmart.com/v3/orders/{purchaseOrderId}/shipping",json,"application/json",resp)
If success = 0
Debug CkHttp::ckLastErrorText(http)
CkHttp::ckDispose(http)
CkJsonObject::ckDispose(json)
CkHttpResponse::ckDispose(resp)
ProcedureReturn
EndIf
Debug "Response status code: " + Str(CkHttpResponse::ckStatusCode(resp))
CkHttpResponse::ckGetBodyJson(resp,json)
; A sample JSON response:
; {
; "order": {
; "purchaseOrderId": "1234567891234",
; "customerOrderId": "9876543212345",
; "sellerOrderId": "13233454564657",
; "customerEmailId": "customer@walmartlabs.com",
; "orderDate": 1478284060000,
; "shippingInfo": {
; "phone": "6501234567",
; "estimatedDeliveryDate": 1479798000000,
; "estimatedShipDate": 1478674800000,
; "methodCode": "Value",
; "postalAddress": {
; "name": "Jane Doe",
; "address1": "123 Main street",
; "city": "Sunnyvale",
; "state": "CA",
; "postalCode": "94086",
; "country": "USA",
; "addressType": "OFFICE"
; }
; },
; "orderLines": {
; "orderLine": [
; {
; "lineNumber": "1",
; "item": {
; "productName": "Kenmore CF-1 or 20-86883 Canister Secondary Filter Generic 2 Pack",
; "sku": "wei-ASSET-675gku675"
; },
; "charges": {
; "charge": [
; {
; "chargeType": "PRODUCT",
; "chargeName": "ItemPrice",
; "chargeAmount": {
; "currency": "USD",
; "amount": 555
; },
; "tax": {
; "taxName": "Tax1",
; "taxAmount": {
; "currency": "USD",
; "amount": 48.56
; }
; }
; }
; ]
; },
; "orderLineQuantity": {
; "unitOfMeasurement": "EACH",
; "amount": "1"
; },
; "statusDate": 1478297929000,
; "orderLineStatuses": {
; "orderLineStatus": [
; {
; "status": "Shipped",
; "statusQuantity": {
; "unitOfMeasurement": "EACH",
; "amount": "1"
; },
; "trackingInfo": {
; "shipDateTime": 1438163400000,
; "carrierName": {
; "carrier": "FedEx"
; },
; "methodCode": "Value",
; "trackingNumber": "911001572321619861",
; "trackingURL": "http://www.fedex.com/Tracking?action=track=english=us=x=911001572321619861"
; },
; "returnCenterAddress": {
; "name": "ABC",
; "address1": "123 Bridge street",
; "city": "Huntsville",
; "state": "AL",
; "postalCode": "35805",
; "country": "USA",
; "dayPhone": "6501234567",
; "emailId": "RCemailaddress@company.com"
; }
; }
; ]
; }
; }
; ]
; }
; }
; }
CkJsonObject::setCkEmitCompact(json, 0)
Debug "Response JSON:"
Debug CkJsonObject::ckEmit(json)
; Insert code here to load the above JSON into the json object.
lineNumber.s
ProductName.s
Sku.s
UnitOfMeasurement.s
Amount.s
statusDate.i
count_j.i
chargeType.s
chargeName.s
v_Currency.s
chargeAmountAmount.i
TaxName.s
TaxAmountCurrency.s
TaxAmountAmount.s
status.s
statusQuantityUnitOfMeasurement.s
statusQuantityAmount.s
ShipDateTime.i
Carrier.s
trackingInfoMethodCode.s
TrackingNumber.s
TrackingURL.s
returnCenterAddressName.s
returnCenterAddressAddress1.s
returnCenterAddressCity.s
returnCenterAddressState.s
returnCenterAddressPostalCode.s
returnCenterAddressCountry.s
DayPhone.s
EmailId.s
PurchaseOrderId.s = CkJsonObject::ckStringOf(json,"order.purchaseOrderId")
CustomerOrderId.s = CkJsonObject::ckStringOf(json,"order.customerOrderId")
SellerOrderId.s = CkJsonObject::ckStringOf(json,"order.sellerOrderId")
CustomerEmailId.s = CkJsonObject::ckStringOf(json,"order.customerEmailId")
OrderDate.i = CkJsonObject::ckIntOf(json,"order.orderDate")
Phone.s = CkJsonObject::ckStringOf(json,"order.shippingInfo.phone")
EstimatedDeliveryDate.i = CkJsonObject::ckIntOf(json,"order.shippingInfo.estimatedDeliveryDate")
EstimatedShipDate.i = CkJsonObject::ckIntOf(json,"order.shippingInfo.estimatedShipDate")
MethodCode.s = CkJsonObject::ckStringOf(json,"order.shippingInfo.methodCode")
Name.s = CkJsonObject::ckStringOf(json,"order.shippingInfo.postalAddress.name")
Address1.s = CkJsonObject::ckStringOf(json,"order.shippingInfo.postalAddress.address1")
City.s = CkJsonObject::ckStringOf(json,"order.shippingInfo.postalAddress.city")
State.s = CkJsonObject::ckStringOf(json,"order.shippingInfo.postalAddress.state")
PostalCode.s = CkJsonObject::ckStringOf(json,"order.shippingInfo.postalAddress.postalCode")
Country.s = CkJsonObject::ckStringOf(json,"order.shippingInfo.postalAddress.country")
AddressType.s = CkJsonObject::ckStringOf(json,"order.shippingInfo.postalAddress.addressType")
i.i = 0
j.i = 0
count_i.i = CkJsonObject::ckSizeOfArray(json,"order.orderLines.orderLine")
While i < count_i
CkJsonObject::setCkI(json, i)
lineNumber = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].lineNumber")
ProductName = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].item.productName")
Sku = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].item.sku")
UnitOfMeasurement = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].orderLineQuantity.unitOfMeasurement")
Amount = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].orderLineQuantity.amount")
statusDate = CkJsonObject::ckIntOf(json,"order.orderLines.orderLine[i].statusDate")
j = 0
count_j = CkJsonObject::ckSizeOfArray(json,"order.orderLines.orderLine[i].charges.charge")
While j < count_j
CkJsonObject::setCkJ(json, j)
chargeType = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].charges.charge[j].chargeType")
chargeName = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].charges.charge[j].chargeName")
v_Currency = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].charges.charge[j].chargeAmount.currency")
chargeAmountAmount = CkJsonObject::ckIntOf(json,"order.orderLines.orderLine[i].charges.charge[j].chargeAmount.amount")
TaxName = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].charges.charge[j].tax.taxName")
TaxAmountCurrency = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].charges.charge[j].tax.taxAmount.currency")
TaxAmountAmount = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].charges.charge[j].tax.taxAmount.amount")
j = j + 1
Wend
j = 0
count_j = CkJsonObject::ckSizeOfArray(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus")
While j < count_j
CkJsonObject::setCkJ(json, j)
status = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].status")
statusQuantityUnitOfMeasurement = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.unitOfMeasurement")
statusQuantityAmount = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.amount")
ShipDateTime = CkJsonObject::ckIntOf(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.shipDateTime")
Carrier = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.carrierName.carrier")
trackingInfoMethodCode = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.methodCode")
TrackingNumber = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingNumber")
TrackingURL = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingURL")
returnCenterAddressName = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.name")
returnCenterAddressAddress1 = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.address1")
returnCenterAddressCity = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.city")
returnCenterAddressState = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.state")
returnCenterAddressPostalCode = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.postalCode")
returnCenterAddressCountry = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.country")
DayPhone = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.dayPhone")
EmailId = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.emailId")
j = j + 1
Wend
i = i + 1
Wend
CkHttp::ckDispose(http)
CkJsonObject::ckDispose(json)
CkHttpResponse::ckDispose(resp)
ProcedureReturn
EndProcedure