Swift
Swift
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 Swift Downloads
func chilkatTest() {
var success: Bool = false
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let http = CkoHttp()!
http.setRequestHeader(name: "WM_QOS.CORRELATION_ID", value: "b3261d2d-028a-4ef7-8602-633c23200af6")
http.setRequestHeader(name: "WM_SEC.ACCESS_TOKEN", value: "eyJraWQiOiIzZjVhYTFmNS1hYWE5LTQzM.....")
http.setRequestHeader(name: "Accept", value: "application/json")
http.setRequestHeader(name: "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"
// }
// }
// ]
// }
// }
// ]
// }
// }
// }
let json = CkoJsonObject()!
var orderLineIndex: Int = 0
var statusIndex: Int = 0
json.i = orderLineIndex
json.j = statusIndex
json.updateString(jsonPath: "orderShipment.orderLines.orderLine[i].lineNumber", value: "1")
json.updateBool(jsonPath: "orderShipment.orderLines.orderLine[i].intentToCancelOverride", value: false)
json.updateString(jsonPath: "orderShipment.orderLines.orderLine[i].sellerOrderId", value: "92344")
json.updateString(jsonPath: "orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].status", value: "Shipped")
json.updateString(jsonPath: "orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.unitOfMeasurement", value: "EACH")
json.updateString(jsonPath: "orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.amount", value: "1")
json.updateInt(jsonPath: "orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.shipDateTime", value: 123)
json.updateString(jsonPath: "orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.carrierName.carrier", value: "UPS")
json.updateString(jsonPath: "orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.methodCode", value: "Standard")
json.updateString(jsonPath: "orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingNumber", value: "22344")
json.updateString(jsonPath: "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(jsonPath: "orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.name", value: "walmart")
json.updateString(jsonPath: "orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.address1", value: "walmart store 2")
json.updateString(jsonPath: "orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.city", value: "Huntsville")
json.updateString(jsonPath: "orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.state", value: "AL")
json.updateString(jsonPath: "orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.postalCode", value: "35805")
json.updateString(jsonPath: "orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.country", value: "USA")
json.updateString(jsonPath: "orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.dayPhone", value: "12344")
json.updateString(jsonPath: "orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.emailId", value: "walmart@walmart.com")
orderLineIndex = orderLineIndex + 1
statusIndex = 0
json.i = orderLineIndex
json.j = statusIndex
json.updateString(jsonPath: "orderShipment.orderLines.orderLine[i].lineNumber", value: "2")
json.updateString(jsonPath: "orderShipment.orderLines.orderLine[i].sellerOrderId", value: "92344")
json.updateString(jsonPath: "orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].status", value: "Shipped")
json.updateString(jsonPath: "orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.unitOfMeasurement", value: "EACH")
json.updateString(jsonPath: "orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.amount", value: "1")
json.updateInt(jsonPath: "orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.shipDateTime", value: 123)
json.updateString(jsonPath: "orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.carrierName.carrier", value: "FedEx")
json.updateString(jsonPath: "orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.methodCode", value: "Express")
json.updateString(jsonPath: "orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingNumber", value: "22344")
json.updateString(jsonPath: "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(jsonPath: "orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.name", value: "walmart")
json.updateString(jsonPath: "orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.address1", value: "walmart store 2")
json.updateString(jsonPath: "orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.city", value: "Huntsville")
json.updateString(jsonPath: "orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.state", value: "AL")
json.updateString(jsonPath: "orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.postalCode", value: "35805")
json.updateString(jsonPath: "orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.country", value: "USA")
json.updateString(jsonPath: "orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.dayPhone", value: "12344")
json.updateString(jsonPath: "orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.emailId", value: "walmart@walmart.com")
let resp = CkoHttpResponse()!
success = http.httpJson(verb: "POST", url: "https://api-gateway.walmart.com/v3/orders/{purchaseOrderId}/shipping", json: json, contentType: "application/json", response: resp)
if success == false {
print("\(http.lastErrorText!)")
return
}
print("Response status code: \(resp.statusCode.intValue)")
resp.getBodyJson(json: 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 = false
print("Response JSON:")
print("\(json.emit()!)")
// Insert code here to load the above JSON into the json object.
var lineNumber: String?
var ProductName: String?
var Sku: String?
var UnitOfMeasurement: String?
var Amount: String?
var statusDate: Int
var count_j: Int
var chargeType: String?
var chargeName: String?
var v_Currency: String?
var chargeAmountAmount: Int
var TaxName: String?
var TaxAmountCurrency: String?
var TaxAmountAmount: String?
var status: String?
var statusQuantityUnitOfMeasurement: String?
var statusQuantityAmount: String?
var ShipDateTime: Int
var Carrier: String?
var trackingInfoMethodCode: String?
var TrackingNumber: String?
var TrackingURL: String?
var returnCenterAddressName: String?
var returnCenterAddressAddress1: String?
var returnCenterAddressCity: String?
var returnCenterAddressState: String?
var returnCenterAddressPostalCode: String?
var returnCenterAddressCountry: String?
var DayPhone: String?
var EmailId: String?
var PurchaseOrderId: String? = json.string(of: "order.purchaseOrderId")
var CustomerOrderId: String? = json.string(of: "order.customerOrderId")
var SellerOrderId: String? = json.string(of: "order.sellerOrderId")
var CustomerEmailId: String? = json.string(of: "order.customerEmailId")
var OrderDate: Int = json.int(of: "order.orderDate").intValue
var Phone: String? = json.string(of: "order.shippingInfo.phone")
var EstimatedDeliveryDate: Int = json.int(of: "order.shippingInfo.estimatedDeliveryDate").intValue
var EstimatedShipDate: Int = json.int(of: "order.shippingInfo.estimatedShipDate").intValue
var MethodCode: String? = json.string(of: "order.shippingInfo.methodCode")
var Name: String? = json.string(of: "order.shippingInfo.postalAddress.name")
var Address1: String? = json.string(of: "order.shippingInfo.postalAddress.address1")
var City: String? = json.string(of: "order.shippingInfo.postalAddress.city")
var State: String? = json.string(of: "order.shippingInfo.postalAddress.state")
var PostalCode: String? = json.string(of: "order.shippingInfo.postalAddress.postalCode")
var Country: String? = json.string(of: "order.shippingInfo.postalAddress.country")
var AddressType: String? = json.string(of: "order.shippingInfo.postalAddress.addressType")
var i: Int = 0
var j: Int = 0
var count_i: Int = json.size(ofArray: "order.orderLines.orderLine").intValue
while i < count_i {
json.i = i
lineNumber = json.string(of: "order.orderLines.orderLine[i].lineNumber")
ProductName = json.string(of: "order.orderLines.orderLine[i].item.productName")
Sku = json.string(of: "order.orderLines.orderLine[i].item.sku")
UnitOfMeasurement = json.string(of: "order.orderLines.orderLine[i].orderLineQuantity.unitOfMeasurement")
Amount = json.string(of: "order.orderLines.orderLine[i].orderLineQuantity.amount")
statusDate = json.int(of: "order.orderLines.orderLine[i].statusDate").intValue
j = 0
count_j = json.size(ofArray: "order.orderLines.orderLine[i].charges.charge").intValue
while j < count_j {
json.j = j
chargeType = json.string(of: "order.orderLines.orderLine[i].charges.charge[j].chargeType")
chargeName = json.string(of: "order.orderLines.orderLine[i].charges.charge[j].chargeName")
v_Currency = json.string(of: "order.orderLines.orderLine[i].charges.charge[j].chargeAmount.currency")
chargeAmountAmount = json.int(of: "order.orderLines.orderLine[i].charges.charge[j].chargeAmount.amount").intValue
TaxName = json.string(of: "order.orderLines.orderLine[i].charges.charge[j].tax.taxName")
TaxAmountCurrency = json.string(of: "order.orderLines.orderLine[i].charges.charge[j].tax.taxAmount.currency")
TaxAmountAmount = json.string(of: "order.orderLines.orderLine[i].charges.charge[j].tax.taxAmount.amount")
j = j + 1
}
j = 0
count_j = json.size(ofArray: "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus").intValue
while j < count_j {
json.j = j
status = json.string(of: "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].status")
statusQuantityUnitOfMeasurement = json.string(of: "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.unitOfMeasurement")
statusQuantityAmount = json.string(of: "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.amount")
ShipDateTime = json.int(of: "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.shipDateTime").intValue
Carrier = json.string(of: "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.carrierName.carrier")
trackingInfoMethodCode = json.string(of: "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.methodCode")
TrackingNumber = json.string(of: "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingNumber")
TrackingURL = json.string(of: "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingURL")
returnCenterAddressName = json.string(of: "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.name")
returnCenterAddressAddress1 = json.string(of: "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.address1")
returnCenterAddressCity = json.string(of: "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.city")
returnCenterAddressState = json.string(of: "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.state")
returnCenterAddressPostalCode = json.string(of: "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.postalCode")
returnCenterAddressCountry = json.string(of: "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.country")
DayPhone = json.string(of: "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.dayPhone")
EmailId = json.string(of: "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.emailId")
j = j + 1
}
i = i + 1
}
}