Objective-C
Objective-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 Objective-C Downloads
#import <CkoHttp.h>
#import <CkoJsonObject.h>
#import <CkoHttpResponse.h>
#import <NSString.h>
BOOL success = NO;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkoHttp *http = [[CkoHttp alloc] init];
[http SetRequestHeader: @"WM_QOS.CORRELATION_ID" value: @"b3261d2d-028a-4ef7-8602-633c23200af6"];
[http SetRequestHeader: @"WM_SEC.ACCESS_TOKEN" value: @"eyJraWQiOiIzZjVhYTFmNS1hYWE5LTQzM....."];
[http SetRequestHeader: @"Accept" value: @"application/json"];
[http SetRequestHeader: @"WM_SVC.NAME" value: @"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"
// }
// }
// ]
// }
// }
// ]
// }
// }
// }
CkoJsonObject *json = [[CkoJsonObject alloc] init];
int orderLineIndex = 0;
int statusIndex = 0;
json.I = [NSNumber numberWithInt: orderLineIndex];
json.J = [NSNumber numberWithInt: statusIndex];
[json UpdateString: @"orderShipment.orderLines.orderLine[i].lineNumber" value: @"1"];
[json UpdateBool: @"orderShipment.orderLines.orderLine[i].intentToCancelOverride" value: NO];
[json UpdateString: @"orderShipment.orderLines.orderLine[i].sellerOrderId" value: @"92344"];
[json UpdateString: @"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].status" value: @"Shipped"];
[json UpdateString: @"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.unitOfMeasurement" value: @"EACH"];
[json UpdateString: @"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.amount" value: @"1"];
[json UpdateInt: @"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.shipDateTime" value: [NSNumber numberWithInt: 123]];
[json UpdateString: @"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.carrierName.carrier" value: @"UPS"];
[json UpdateString: @"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.methodCode" value: @"Standard"];
[json UpdateString: @"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingNumber" value: @"22344"];
[json UpdateString: @"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingURL" value: @"http://walmart/tracking/ups?&type=MP&seller_id=12345&promise_date=03/02/2020&dzip=92840&tracking_numbers=92345"];
[json UpdateString: @"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.name" value: @"walmart"];
[json UpdateString: @"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.address1" value: @"walmart store 2"];
[json UpdateString: @"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.city" value: @"Huntsville"];
[json UpdateString: @"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.state" value: @"AL"];
[json UpdateString: @"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.postalCode" value: @"35805"];
[json UpdateString: @"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.country" value: @"USA"];
[json UpdateString: @"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.dayPhone" value: @"12344"];
[json UpdateString: @"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.emailId" value: @"walmart@walmart.com"];
orderLineIndex = orderLineIndex + 1;
statusIndex = 0;
json.I = [NSNumber numberWithInt: orderLineIndex];
json.J = [NSNumber numberWithInt: statusIndex];
[json UpdateString: @"orderShipment.orderLines.orderLine[i].lineNumber" value: @"2"];
[json UpdateString: @"orderShipment.orderLines.orderLine[i].sellerOrderId" value: @"92344"];
[json UpdateString: @"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].status" value: @"Shipped"];
[json UpdateString: @"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.unitOfMeasurement" value: @"EACH"];
[json UpdateString: @"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.amount" value: @"1"];
[json UpdateInt: @"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.shipDateTime" value: [NSNumber numberWithInt: 123]];
[json UpdateString: @"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.carrierName.carrier" value: @"FedEx"];
[json UpdateString: @"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.methodCode" value: @"Express"];
[json UpdateString: @"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingNumber" value: @"22344"];
[json UpdateString: @"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingURL" value: @"http://walmart/tracking/fedEx?&type=MP&seller_id=12345&promise_date=03/02/2020&dzip=92840&tracking_numbers=92344"];
[json UpdateString: @"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.name" value: @"walmart"];
[json UpdateString: @"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.address1" value: @"walmart store 2"];
[json UpdateString: @"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.city" value: @"Huntsville"];
[json UpdateString: @"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.state" value: @"AL"];
[json UpdateString: @"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.postalCode" value: @"35805"];
[json UpdateString: @"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.country" value: @"USA"];
[json UpdateString: @"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.dayPhone" value: @"12344"];
[json UpdateString: @"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.emailId" value: @"walmart@walmart.com"];
CkoHttpResponse *resp = [[CkoHttpResponse alloc] init];
success = [http HttpJson: @"POST" url: @"https://api-gateway.walmart.com/v3/orders/{purchaseOrderId}/shipping" json: json contentType: @"application/json" response: resp];
if (success == NO) {
NSLog(@"%@",http.LastErrorText);
return;
}
NSLog(@"%@%d",@"Response status code: ",[resp.StatusCode intValue]);
[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.EmitCompact = NO;
NSLog(@"%@",@"Response JSON:");
NSLog(@"%@",[json Emit]);
// Insert code here to load the above JSON into the json object.
NSString *lineNumber = 0;
NSString *ProductName = 0;
NSString *Sku = 0;
NSString *UnitOfMeasurement = 0;
NSString *Amount = 0;
int statusDate;
int count_j;
NSString *chargeType = 0;
NSString *chargeName = 0;
NSString *v_Currency = 0;
int chargeAmountAmount;
NSString *TaxName = 0;
NSString *TaxAmountCurrency = 0;
NSString *TaxAmountAmount = 0;
NSString *status = 0;
NSString *statusQuantityUnitOfMeasurement = 0;
NSString *statusQuantityAmount = 0;
int ShipDateTime;
NSString *Carrier = 0;
NSString *trackingInfoMethodCode = 0;
NSString *TrackingNumber = 0;
NSString *TrackingURL = 0;
NSString *returnCenterAddressName = 0;
NSString *returnCenterAddressAddress1 = 0;
NSString *returnCenterAddressCity = 0;
NSString *returnCenterAddressState = 0;
NSString *returnCenterAddressPostalCode = 0;
NSString *returnCenterAddressCountry = 0;
NSString *DayPhone = 0;
NSString *EmailId = 0;
NSString *PurchaseOrderId = [json StringOf: @"order.purchaseOrderId"];
NSString *CustomerOrderId = [json StringOf: @"order.customerOrderId"];
NSString *SellerOrderId = [json StringOf: @"order.sellerOrderId"];
NSString *CustomerEmailId = [json StringOf: @"order.customerEmailId"];
int OrderDate = [[json IntOf: @"order.orderDate"] intValue];
NSString *Phone = [json StringOf: @"order.shippingInfo.phone"];
int EstimatedDeliveryDate = [[json IntOf: @"order.shippingInfo.estimatedDeliveryDate"] intValue];
int EstimatedShipDate = [[json IntOf: @"order.shippingInfo.estimatedShipDate"] intValue];
NSString *MethodCode = [json StringOf: @"order.shippingInfo.methodCode"];
NSString *Name = [json StringOf: @"order.shippingInfo.postalAddress.name"];
NSString *Address1 = [json StringOf: @"order.shippingInfo.postalAddress.address1"];
NSString *City = [json StringOf: @"order.shippingInfo.postalAddress.city"];
NSString *State = [json StringOf: @"order.shippingInfo.postalAddress.state"];
NSString *PostalCode = [json StringOf: @"order.shippingInfo.postalAddress.postalCode"];
NSString *Country = [json StringOf: @"order.shippingInfo.postalAddress.country"];
NSString *AddressType = [json StringOf: @"order.shippingInfo.postalAddress.addressType"];
int i = 0;
int j = 0;
int count_i = [[json SizeOfArray: @"order.orderLines.orderLine"] intValue];
while (i < count_i) {
json.I = [NSNumber numberWithInt: i];
lineNumber = [json StringOf: @"order.orderLines.orderLine[i].lineNumber"];
ProductName = [json StringOf: @"order.orderLines.orderLine[i].item.productName"];
Sku = [json StringOf: @"order.orderLines.orderLine[i].item.sku"];
UnitOfMeasurement = [json StringOf: @"order.orderLines.orderLine[i].orderLineQuantity.unitOfMeasurement"];
Amount = [json StringOf: @"order.orderLines.orderLine[i].orderLineQuantity.amount"];
statusDate = [[json IntOf: @"order.orderLines.orderLine[i].statusDate"] intValue];
j = 0;
count_j = [[json SizeOfArray: @"order.orderLines.orderLine[i].charges.charge"] intValue];
while (j < count_j) {
json.J = [NSNumber numberWithInt: j];
chargeType = [json StringOf: @"order.orderLines.orderLine[i].charges.charge[j].chargeType"];
chargeName = [json StringOf: @"order.orderLines.orderLine[i].charges.charge[j].chargeName"];
v_Currency = [json StringOf: @"order.orderLines.orderLine[i].charges.charge[j].chargeAmount.currency"];
chargeAmountAmount = [[json IntOf: @"order.orderLines.orderLine[i].charges.charge[j].chargeAmount.amount"] intValue];
TaxName = [json StringOf: @"order.orderLines.orderLine[i].charges.charge[j].tax.taxName"];
TaxAmountCurrency = [json StringOf: @"order.orderLines.orderLine[i].charges.charge[j].tax.taxAmount.currency"];
TaxAmountAmount = [json StringOf: @"order.orderLines.orderLine[i].charges.charge[j].tax.taxAmount.amount"];
j = j + 1;
}
j = 0;
count_j = [[json SizeOfArray: @"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus"] intValue];
while (j < count_j) {
json.J = [NSNumber numberWithInt: j];
status = [json StringOf: @"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].status"];
statusQuantityUnitOfMeasurement = [json StringOf: @"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.unitOfMeasurement"];
statusQuantityAmount = [json StringOf: @"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.amount"];
ShipDateTime = [[json IntOf: @"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.shipDateTime"] intValue];
Carrier = [json StringOf: @"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.carrierName.carrier"];
trackingInfoMethodCode = [json StringOf: @"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.methodCode"];
TrackingNumber = [json StringOf: @"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingNumber"];
TrackingURL = [json StringOf: @"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingURL"];
returnCenterAddressName = [json StringOf: @"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.name"];
returnCenterAddressAddress1 = [json StringOf: @"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.address1"];
returnCenterAddressCity = [json StringOf: @"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.city"];
returnCenterAddressState = [json StringOf: @"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.state"];
returnCenterAddressPostalCode = [json StringOf: @"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.postalCode"];
returnCenterAddressCountry = [json StringOf: @"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.country"];
DayPhone = [json StringOf: @"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.dayPhone"];
EmailId = [json StringOf: @"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.emailId"];
j = j + 1;
}
i = i + 1;
}