Unicode C++
Unicode C++
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 Unicode C++ Downloads
#include <CkHttpW.h>
#include <CkJsonObjectW.h>
#include <CkHttpResponseW.h>
void ChilkatSample(void)
{
bool success = false;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkHttpW http;
http.SetRequestHeader(L"WM_QOS.CORRELATION_ID",L"b3261d2d-028a-4ef7-8602-633c23200af6");
http.SetRequestHeader(L"WM_SEC.ACCESS_TOKEN",L"eyJraWQiOiIzZjVhYTFmNS1hYWE5LTQzM.....");
http.SetRequestHeader(L"Accept",L"application/json");
http.SetRequestHeader(L"WM_SVC.NAME",L"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"
// }
// }
// ]
// }
// }
// ]
// }
// }
// }
CkJsonObjectW json;
int orderLineIndex = 0;
int statusIndex = 0;
json.put_I(orderLineIndex);
json.put_J(statusIndex);
json.UpdateString(L"orderShipment.orderLines.orderLine[i].lineNumber",L"1");
json.UpdateBool(L"orderShipment.orderLines.orderLine[i].intentToCancelOverride",false);
json.UpdateString(L"orderShipment.orderLines.orderLine[i].sellerOrderId",L"92344");
json.UpdateString(L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].status",L"Shipped");
json.UpdateString(L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.unitOfMeasurement",L"EACH");
json.UpdateString(L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.amount",L"1");
json.UpdateInt(L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.shipDateTime",123);
json.UpdateString(L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.carrierName.carrier",L"UPS");
json.UpdateString(L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.methodCode",L"Standard");
json.UpdateString(L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingNumber",L"22344");
json.UpdateString(L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingURL",L"http://walmart/tracking/ups?&type=MP&seller_id=12345&promise_date=03/02/2020&dzip=92840&tracking_numbers=92345");
json.UpdateString(L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.name",L"walmart");
json.UpdateString(L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.address1",L"walmart store 2");
json.UpdateString(L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.city",L"Huntsville");
json.UpdateString(L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.state",L"AL");
json.UpdateString(L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.postalCode",L"35805");
json.UpdateString(L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.country",L"USA");
json.UpdateString(L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.dayPhone",L"12344");
json.UpdateString(L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.emailId",L"walmart@walmart.com");
orderLineIndex = orderLineIndex + 1;
statusIndex = 0;
json.put_I(orderLineIndex);
json.put_J(statusIndex);
json.UpdateString(L"orderShipment.orderLines.orderLine[i].lineNumber",L"2");
json.UpdateString(L"orderShipment.orderLines.orderLine[i].sellerOrderId",L"92344");
json.UpdateString(L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].status",L"Shipped");
json.UpdateString(L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.unitOfMeasurement",L"EACH");
json.UpdateString(L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.amount",L"1");
json.UpdateInt(L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.shipDateTime",123);
json.UpdateString(L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.carrierName.carrier",L"FedEx");
json.UpdateString(L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.methodCode",L"Express");
json.UpdateString(L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingNumber",L"22344");
json.UpdateString(L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingURL",L"http://walmart/tracking/fedEx?&type=MP&seller_id=12345&promise_date=03/02/2020&dzip=92840&tracking_numbers=92344");
json.UpdateString(L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.name",L"walmart");
json.UpdateString(L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.address1",L"walmart store 2");
json.UpdateString(L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.city",L"Huntsville");
json.UpdateString(L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.state",L"AL");
json.UpdateString(L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.postalCode",L"35805");
json.UpdateString(L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.country",L"USA");
json.UpdateString(L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.dayPhone",L"12344");
json.UpdateString(L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.emailId",L"walmart@walmart.com");
CkHttpResponseW resp;
success = http.HttpJson(L"POST",L"https://api-gateway.walmart.com/v3/orders/{purchaseOrderId}/shipping",json,L"application/json",resp);
if (success == false) {
wprintf(L"%s\n",http.lastErrorText());
return;
}
wprintf(L"Response status code: %d\n",resp.get_StatusCode());
resp.GetBodyJson(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"
// }
// }
// ]
// }
// }
// ]
// }
// }
// }
json.put_EmitCompact(false);
wprintf(L"Response JSON:\n");
wprintf(L"%s\n",json.emit());
// Insert code here to load the above JSON into the json object.
// Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.
// See this example explaining how this memory should be used: const char * functions.
const wchar_t *lineNumber = 0;
const wchar_t *ProductName = 0;
const wchar_t *Sku = 0;
const wchar_t *UnitOfMeasurement = 0;
const wchar_t *Amount = 0;
int statusDate;
int count_j;
const wchar_t *chargeType = 0;
const wchar_t *chargeName = 0;
const wchar_t *v_Currency = 0;
int chargeAmountAmount;
const wchar_t *TaxName = 0;
const wchar_t *TaxAmountCurrency = 0;
const wchar_t *TaxAmountAmount = 0;
const wchar_t *status = 0;
const wchar_t *statusQuantityUnitOfMeasurement = 0;
const wchar_t *statusQuantityAmount = 0;
int ShipDateTime;
const wchar_t *Carrier = 0;
const wchar_t *trackingInfoMethodCode = 0;
const wchar_t *TrackingNumber = 0;
const wchar_t *TrackingURL = 0;
const wchar_t *returnCenterAddressName = 0;
const wchar_t *returnCenterAddressAddress1 = 0;
const wchar_t *returnCenterAddressCity = 0;
const wchar_t *returnCenterAddressState = 0;
const wchar_t *returnCenterAddressPostalCode = 0;
const wchar_t *returnCenterAddressCountry = 0;
const wchar_t *DayPhone = 0;
const wchar_t *EmailId = 0;
const wchar_t *PurchaseOrderId = json.stringOf(L"order.purchaseOrderId");
const wchar_t *CustomerOrderId = json.stringOf(L"order.customerOrderId");
const wchar_t *SellerOrderId = json.stringOf(L"order.sellerOrderId");
const wchar_t *CustomerEmailId = json.stringOf(L"order.customerEmailId");
int OrderDate = json.IntOf(L"order.orderDate");
const wchar_t *Phone = json.stringOf(L"order.shippingInfo.phone");
int EstimatedDeliveryDate = json.IntOf(L"order.shippingInfo.estimatedDeliveryDate");
int EstimatedShipDate = json.IntOf(L"order.shippingInfo.estimatedShipDate");
const wchar_t *MethodCode = json.stringOf(L"order.shippingInfo.methodCode");
const wchar_t *Name = json.stringOf(L"order.shippingInfo.postalAddress.name");
const wchar_t *Address1 = json.stringOf(L"order.shippingInfo.postalAddress.address1");
const wchar_t *City = json.stringOf(L"order.shippingInfo.postalAddress.city");
const wchar_t *State = json.stringOf(L"order.shippingInfo.postalAddress.state");
const wchar_t *PostalCode = json.stringOf(L"order.shippingInfo.postalAddress.postalCode");
const wchar_t *Country = json.stringOf(L"order.shippingInfo.postalAddress.country");
const wchar_t *AddressType = json.stringOf(L"order.shippingInfo.postalAddress.addressType");
int i = 0;
int j = 0;
int count_i = json.SizeOfArray(L"order.orderLines.orderLine");
while (i < count_i) {
json.put_I(i);
lineNumber = json.stringOf(L"order.orderLines.orderLine[i].lineNumber");
ProductName = json.stringOf(L"order.orderLines.orderLine[i].item.productName");
Sku = json.stringOf(L"order.orderLines.orderLine[i].item.sku");
UnitOfMeasurement = json.stringOf(L"order.orderLines.orderLine[i].orderLineQuantity.unitOfMeasurement");
Amount = json.stringOf(L"order.orderLines.orderLine[i].orderLineQuantity.amount");
statusDate = json.IntOf(L"order.orderLines.orderLine[i].statusDate");
j = 0;
count_j = json.SizeOfArray(L"order.orderLines.orderLine[i].charges.charge");
while (j < count_j) {
json.put_J(j);
chargeType = json.stringOf(L"order.orderLines.orderLine[i].charges.charge[j].chargeType");
chargeName = json.stringOf(L"order.orderLines.orderLine[i].charges.charge[j].chargeName");
v_Currency = json.stringOf(L"order.orderLines.orderLine[i].charges.charge[j].chargeAmount.currency");
chargeAmountAmount = json.IntOf(L"order.orderLines.orderLine[i].charges.charge[j].chargeAmount.amount");
TaxName = json.stringOf(L"order.orderLines.orderLine[i].charges.charge[j].tax.taxName");
TaxAmountCurrency = json.stringOf(L"order.orderLines.orderLine[i].charges.charge[j].tax.taxAmount.currency");
TaxAmountAmount = json.stringOf(L"order.orderLines.orderLine[i].charges.charge[j].tax.taxAmount.amount");
j = j + 1;
}
j = 0;
count_j = json.SizeOfArray(L"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus");
while (j < count_j) {
json.put_J(j);
status = json.stringOf(L"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].status");
statusQuantityUnitOfMeasurement = json.stringOf(L"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.unitOfMeasurement");
statusQuantityAmount = json.stringOf(L"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.amount");
ShipDateTime = json.IntOf(L"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.shipDateTime");
Carrier = json.stringOf(L"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.carrierName.carrier");
trackingInfoMethodCode = json.stringOf(L"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.methodCode");
TrackingNumber = json.stringOf(L"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingNumber");
TrackingURL = json.stringOf(L"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingURL");
returnCenterAddressName = json.stringOf(L"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.name");
returnCenterAddressAddress1 = json.stringOf(L"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.address1");
returnCenterAddressCity = json.stringOf(L"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.city");
returnCenterAddressState = json.stringOf(L"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.state");
returnCenterAddressPostalCode = json.stringOf(L"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.postalCode");
returnCenterAddressCountry = json.stringOf(L"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.country");
DayPhone = json.stringOf(L"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.dayPhone");
EmailId = json.stringOf(L"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.emailId");
j = j + 1;
}
i = i + 1;
}
}