Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(C) Walmart v3 Ship Order LinesSee more Walmart v3 ExamplesUpdates 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. For more information, see https://developer.walmart.com/api/us/mp/orders#operation/shippingUpdates
#include <C_CkHttp.h> #include <C_CkJsonObject.h> #include <C_CkHttpResponse.h> void ChilkatSample(void) { HCkHttp http; BOOL success; HCkJsonObject json; int orderLineIndex; int statusIndex; HCkHttpResponse resp; const char *lineNumber; const char *ProductName; const char *Sku; const char *UnitOfMeasurement; const char *Amount; int statusDate; int count_j; const char *chargeType; const char *chargeName; const char *v_Currency; int chargeAmountAmount; const char *TaxName; const char *TaxAmountCurrency; const char *TaxAmountAmount; const char *status; const char *statusQuantityUnitOfMeasurement; const char *statusQuantityAmount; int ShipDateTime; const char *Carrier; const char *trackingInfoMethodCode; const char *TrackingNumber; const char *TrackingURL; const char *returnCenterAddressName; const char *returnCenterAddressAddress1; const char *returnCenterAddressCity; const char *returnCenterAddressState; const char *returnCenterAddressPostalCode; const char *returnCenterAddressCountry; const char *DayPhone; const char *EmailId; const char *PurchaseOrderId; const char *CustomerOrderId; const char *SellerOrderId; const char *CustomerEmailId; int OrderDate; const char *Phone; int EstimatedDeliveryDate; int EstimatedShipDate; const char *MethodCode; const char *Name; const char *Address1; const char *City; const char *State; const char *PostalCode; const char *Country; const char *AddressType; int i; int j; int count_i; // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. http = CkHttp_Create(); CkHttp_SetRequestHeader(http,"WM_QOS.CORRELATION_ID","b3261d2d-028a-4ef7-8602-633c23200af6"); CkHttp_SetRequestHeader(http,"WM_SEC.ACCESS_TOKEN","eyJraWQiOiIzZjVhYTFmNS1hYWE5LTQzM....."); CkHttp_SetRequestHeader(http,"Accept","application/json"); CkHttp_SetRequestHeader(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 = CkJsonObject_Create(); orderLineIndex = 0; statusIndex = 0; CkJsonObject_putI(json,orderLineIndex); CkJsonObject_putJ(json,statusIndex); CkJsonObject_UpdateString(json,"orderShipment.orderLines.orderLine[i].lineNumber","1"); CkJsonObject_UpdateBool(json,"orderShipment.orderLines.orderLine[i].intentToCancelOverride",FALSE); CkJsonObject_UpdateString(json,"orderShipment.orderLines.orderLine[i].sellerOrderId","92344"); CkJsonObject_UpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].status","Shipped"); CkJsonObject_UpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.unitOfMeasurement","EACH"); CkJsonObject_UpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.amount","1"); CkJsonObject_UpdateInt(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.shipDateTime",123); CkJsonObject_UpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.carrierName.carrier","UPS"); CkJsonObject_UpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.methodCode","Standard"); CkJsonObject_UpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingNumber","22344"); CkJsonObject_UpdateString(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_UpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.name","walmart"); CkJsonObject_UpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.address1","walmart store 2"); CkJsonObject_UpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.city","Huntsville"); CkJsonObject_UpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.state","AL"); CkJsonObject_UpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.postalCode","35805"); CkJsonObject_UpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.country","USA"); CkJsonObject_UpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.dayPhone","12344"); CkJsonObject_UpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.emailId","walmart@walmart.com"); orderLineIndex = orderLineIndex + 1; statusIndex = 0; CkJsonObject_putI(json,orderLineIndex); CkJsonObject_putJ(json,statusIndex); CkJsonObject_UpdateString(json,"orderShipment.orderLines.orderLine[i].lineNumber","2"); CkJsonObject_UpdateString(json,"orderShipment.orderLines.orderLine[i].sellerOrderId","92344"); CkJsonObject_UpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].status","Shipped"); CkJsonObject_UpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.unitOfMeasurement","EACH"); CkJsonObject_UpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.amount","1"); CkJsonObject_UpdateInt(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.shipDateTime",123); CkJsonObject_UpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.carrierName.carrier","FedEx"); CkJsonObject_UpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.methodCode","Express"); CkJsonObject_UpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingNumber","22344"); CkJsonObject_UpdateString(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_UpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.name","walmart"); CkJsonObject_UpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.address1","walmart store 2"); CkJsonObject_UpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.city","Huntsville"); CkJsonObject_UpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.state","AL"); CkJsonObject_UpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.postalCode","35805"); CkJsonObject_UpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.country","USA"); CkJsonObject_UpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.dayPhone","12344"); CkJsonObject_UpdateString(json,"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.emailId","walmart@walmart.com"); resp = CkHttp_PostJson3(http,"https://api-gateway.walmart.com/v3/orders/{purchaseOrderId}/shipping","application/json",json); if (CkHttp_getLastMethodSuccess(http) == FALSE) { printf("%s\n",CkHttp_lastErrorText(http)); CkHttp_Dispose(http); CkJsonObject_Dispose(json); return; } printf("Response status code: %d\n",CkHttpResponse_getStatusCode(resp)); CkHttpResponse_GetBodyJson(resp,json); CkHttpResponse_Dispose(resp); // 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_putEmitCompact(json,FALSE); printf("Response JSON:\n"); printf("%s\n",CkJsonObject_emit(json)); // 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. PurchaseOrderId = CkJsonObject_stringOf(json,"order.purchaseOrderId"); CustomerOrderId = CkJsonObject_stringOf(json,"order.customerOrderId"); SellerOrderId = CkJsonObject_stringOf(json,"order.sellerOrderId"); CustomerEmailId = CkJsonObject_stringOf(json,"order.customerEmailId"); OrderDate = CkJsonObject_IntOf(json,"order.orderDate"); Phone = CkJsonObject_stringOf(json,"order.shippingInfo.phone"); EstimatedDeliveryDate = CkJsonObject_IntOf(json,"order.shippingInfo.estimatedDeliveryDate"); EstimatedShipDate = CkJsonObject_IntOf(json,"order.shippingInfo.estimatedShipDate"); MethodCode = CkJsonObject_stringOf(json,"order.shippingInfo.methodCode"); Name = CkJsonObject_stringOf(json,"order.shippingInfo.postalAddress.name"); Address1 = CkJsonObject_stringOf(json,"order.shippingInfo.postalAddress.address1"); City = CkJsonObject_stringOf(json,"order.shippingInfo.postalAddress.city"); State = CkJsonObject_stringOf(json,"order.shippingInfo.postalAddress.state"); PostalCode = CkJsonObject_stringOf(json,"order.shippingInfo.postalAddress.postalCode"); Country = CkJsonObject_stringOf(json,"order.shippingInfo.postalAddress.country"); AddressType = CkJsonObject_stringOf(json,"order.shippingInfo.postalAddress.addressType"); i = 0; j = 0; count_i = CkJsonObject_SizeOfArray(json,"order.orderLines.orderLine"); while (i < count_i) { CkJsonObject_putI(json,i); lineNumber = CkJsonObject_stringOf(json,"order.orderLines.orderLine[i].lineNumber"); ProductName = CkJsonObject_stringOf(json,"order.orderLines.orderLine[i].item.productName"); Sku = CkJsonObject_stringOf(json,"order.orderLines.orderLine[i].item.sku"); UnitOfMeasurement = CkJsonObject_stringOf(json,"order.orderLines.orderLine[i].orderLineQuantity.unitOfMeasurement"); Amount = CkJsonObject_stringOf(json,"order.orderLines.orderLine[i].orderLineQuantity.amount"); statusDate = CkJsonObject_IntOf(json,"order.orderLines.orderLine[i].statusDate"); j = 0; count_j = CkJsonObject_SizeOfArray(json,"order.orderLines.orderLine[i].charges.charge"); while (j < count_j) { CkJsonObject_putJ(json,j); chargeType = CkJsonObject_stringOf(json,"order.orderLines.orderLine[i].charges.charge[j].chargeType"); chargeName = CkJsonObject_stringOf(json,"order.orderLines.orderLine[i].charges.charge[j].chargeName"); v_Currency = CkJsonObject_stringOf(json,"order.orderLines.orderLine[i].charges.charge[j].chargeAmount.currency"); chargeAmountAmount = CkJsonObject_IntOf(json,"order.orderLines.orderLine[i].charges.charge[j].chargeAmount.amount"); TaxName = CkJsonObject_stringOf(json,"order.orderLines.orderLine[i].charges.charge[j].tax.taxName"); TaxAmountCurrency = CkJsonObject_stringOf(json,"order.orderLines.orderLine[i].charges.charge[j].tax.taxAmount.currency"); TaxAmountAmount = CkJsonObject_stringOf(json,"order.orderLines.orderLine[i].charges.charge[j].tax.taxAmount.amount"); j = j + 1; } j = 0; count_j = CkJsonObject_SizeOfArray(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus"); while (j < count_j) { CkJsonObject_putJ(json,j); status = CkJsonObject_stringOf(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].status"); statusQuantityUnitOfMeasurement = CkJsonObject_stringOf(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.unitOfMeasurement"); statusQuantityAmount = CkJsonObject_stringOf(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.amount"); ShipDateTime = CkJsonObject_IntOf(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.shipDateTime"); Carrier = CkJsonObject_stringOf(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.carrierName.carrier"); trackingInfoMethodCode = CkJsonObject_stringOf(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.methodCode"); TrackingNumber = CkJsonObject_stringOf(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingNumber"); TrackingURL = CkJsonObject_stringOf(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingURL"); returnCenterAddressName = CkJsonObject_stringOf(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.name"); returnCenterAddressAddress1 = CkJsonObject_stringOf(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.address1"); returnCenterAddressCity = CkJsonObject_stringOf(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.city"); returnCenterAddressState = CkJsonObject_stringOf(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.state"); returnCenterAddressPostalCode = CkJsonObject_stringOf(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.postalCode"); returnCenterAddressCountry = CkJsonObject_stringOf(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.country"); DayPhone = CkJsonObject_stringOf(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.dayPhone"); EmailId = CkJsonObject_stringOf(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.emailId"); j = j + 1; } i = i + 1; } CkHttp_Dispose(http); CkJsonObject_Dispose(json); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.