Zig Requires Chilkat v11.0.0+
Zig
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 Zig Downloads
const std = @import("std");
const chilkat = @import("chilkat");
pub fn main(init: std.process.Init) !void {
const alloc = init.arena.allocator();
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
const http = try chilkat.Http.init();
defer http.deinit();
http.setRequestHeader("WM_QOS.CORRELATION_ID", "b3261d2d-028a-4ef7-8602-633c23200af6");
http.setRequestHeader("WM_SEC.ACCESS_TOKEN", "eyJraWQiOiIzZjVhYTFmNS1hYWE5LTQzM.....");
http.setRequestHeader("Accept", "application/json");
http.setRequestHeader("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"
// }
// }
// ]
// }
// }
// ]
// }
// }
// }
const json = try chilkat.JsonObject.init();
defer json.deinit();
var order_line_index: i32 = 0;
var status_index: i32 = 0;
json.setI(order_line_index);
json.setJ(status_index);
json.updateString("orderShipment.orderLines.orderLine[i].lineNumber", "1") catch {};
json.updateBool("orderShipment.orderLines.orderLine[i].intentToCancelOverride", false) catch {};
json.updateString("orderShipment.orderLines.orderLine[i].sellerOrderId", "92344") catch {};
json.updateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].status", "Shipped") catch {};
json.updateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.unitOfMeasurement", "EACH") catch {};
json.updateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.amount", "1") catch {};
json.updateInt("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.shipDateTime", 123) catch {};
json.updateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.carrierName.carrier", "UPS") catch {};
json.updateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.methodCode", "Standard") catch {};
json.updateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingNumber", "22344") catch {};
json.updateString("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") catch {};
json.updateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.name", "walmart") catch {};
json.updateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.address1", "walmart store 2") catch {};
json.updateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.city", "Huntsville") catch {};
json.updateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.state", "AL") catch {};
json.updateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.postalCode", "35805") catch {};
json.updateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.country", "USA") catch {};
json.updateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.dayPhone", "12344") catch {};
json.updateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.emailId", "walmart@walmart.com") catch {};
order_line_index = order_line_index + 1;
status_index = 0;
json.setI(order_line_index);
json.setJ(status_index);
json.updateString("orderShipment.orderLines.orderLine[i].lineNumber", "2") catch {};
json.updateString("orderShipment.orderLines.orderLine[i].sellerOrderId", "92344") catch {};
json.updateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].status", "Shipped") catch {};
json.updateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.unitOfMeasurement", "EACH") catch {};
json.updateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.amount", "1") catch {};
json.updateInt("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.shipDateTime", 123) catch {};
json.updateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.carrierName.carrier", "FedEx") catch {};
json.updateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.methodCode", "Express") catch {};
json.updateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingNumber", "22344") catch {};
json.updateString("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") catch {};
json.updateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.name", "walmart") catch {};
json.updateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.address1", "walmart store 2") catch {};
json.updateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.city", "Huntsville") catch {};
json.updateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.state", "AL") catch {};
json.updateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.postalCode", "35805") catch {};
json.updateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.country", "USA") catch {};
json.updateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.dayPhone", "12344") catch {};
json.updateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.emailId", "walmart@walmart.com") catch {};
const resp = try chilkat.HttpResponse.init();
defer resp.deinit();
http.httpJson("POST", "https://api-gateway.walmart.com/v3/orders/{purchaseOrderId}/shipping", json, "application/json", resp) catch {
std.debug.print("{s}\n", .{try http.getLastErrorText(alloc)});
return;
};
std.debug.print("Response status code: {d}\n", .{resp.getStatusCode()});
resp.getBodyJson(json) catch {};
// 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.setEmitCompact(false);
std.debug.print("Response JSON:\n", .{});
std.debug.print("{s}\n", .{try json.emit(alloc)});
// Insert code here to load the above JSON into the json object.
var line_number: [:0]const u8 = "";
var product_name: [:0]const u8 = "";
var sku: [:0]const u8 = "";
var unit_of_measurement: [:0]const u8 = "";
var amount: [:0]const u8 = "";
var status_date: i32 = 0;
var count_j: i32 = 0;
var charge_type: [:0]const u8 = "";
var charge_name: [:0]const u8 = "";
var v_currency: [:0]const u8 = "";
var charge_amount_amount: i32 = 0;
var tax_name: [:0]const u8 = "";
var tax_amount_currency: [:0]const u8 = "";
var tax_amount_amount: [:0]const u8 = "";
var status: [:0]const u8 = "";
var status_quantity_unit_of_measurement: [:0]const u8 = "";
var status_quantity_amount: [:0]const u8 = "";
var ship_date_time: i32 = 0;
var carrier: [:0]const u8 = "";
var tracking_info_method_code: [:0]const u8 = "";
var tracking_number: [:0]const u8 = "";
var tracking_url: [:0]const u8 = "";
var return_center_address_name: [:0]const u8 = "";
var return_center_address_address1: [:0]const u8 = "";
var return_center_address_city: [:0]const u8 = "";
var return_center_address_state: [:0]const u8 = "";
var return_center_address_postal_code: [:0]const u8 = "";
var return_center_address_country: [:0]const u8 = "";
var day_phone: [:0]const u8 = "";
var email_id: [:0]const u8 = "";
_ = try json.stringOf(alloc, "order.purchaseOrderId");
_ = try json.stringOf(alloc, "order.customerOrderId");
_ = try json.stringOf(alloc, "order.sellerOrderId");
_ = try json.stringOf(alloc, "order.customerEmailId");
_ = json.intOf("order.orderDate");
_ = try json.stringOf(alloc, "order.shippingInfo.phone");
_ = json.intOf("order.shippingInfo.estimatedDeliveryDate");
_ = json.intOf("order.shippingInfo.estimatedShipDate");
_ = try json.stringOf(alloc, "order.shippingInfo.methodCode");
_ = try json.stringOf(alloc, "order.shippingInfo.postalAddress.name");
_ = try json.stringOf(alloc, "order.shippingInfo.postalAddress.address1");
_ = try json.stringOf(alloc, "order.shippingInfo.postalAddress.city");
_ = try json.stringOf(alloc, "order.shippingInfo.postalAddress.state");
_ = try json.stringOf(alloc, "order.shippingInfo.postalAddress.postalCode");
_ = try json.stringOf(alloc, "order.shippingInfo.postalAddress.country");
_ = try json.stringOf(alloc, "order.shippingInfo.postalAddress.addressType");
var i: i32 = 0;
var j: i32 = 0;
const count_i = json.sizeOfArray("order.orderLines.orderLine");
while (i < count_i) {
json.setI(i);
line_number = try json.stringOf(alloc, "order.orderLines.orderLine[i].lineNumber");
product_name = try json.stringOf(alloc, "order.orderLines.orderLine[i].item.productName");
sku = try json.stringOf(alloc, "order.orderLines.orderLine[i].item.sku");
unit_of_measurement = try json.stringOf(alloc, "order.orderLines.orderLine[i].orderLineQuantity.unitOfMeasurement");
amount = try json.stringOf(alloc, "order.orderLines.orderLine[i].orderLineQuantity.amount");
status_date = json.intOf("order.orderLines.orderLine[i].statusDate");
j = 0;
count_j = json.sizeOfArray("order.orderLines.orderLine[i].charges.charge");
while (j < count_j) {
json.setJ(j);
charge_type = try json.stringOf(alloc, "order.orderLines.orderLine[i].charges.charge[j].chargeType");
charge_name = try json.stringOf(alloc, "order.orderLines.orderLine[i].charges.charge[j].chargeName");
v_currency = try json.stringOf(alloc, "order.orderLines.orderLine[i].charges.charge[j].chargeAmount.currency");
charge_amount_amount = json.intOf("order.orderLines.orderLine[i].charges.charge[j].chargeAmount.amount");
tax_name = try json.stringOf(alloc, "order.orderLines.orderLine[i].charges.charge[j].tax.taxName");
tax_amount_currency = try json.stringOf(alloc, "order.orderLines.orderLine[i].charges.charge[j].tax.taxAmount.currency");
tax_amount_amount = try json.stringOf(alloc, "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");
while (j < count_j) {
json.setJ(j);
status = try json.stringOf(alloc, "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].status");
status_quantity_unit_of_measurement = try json.stringOf(alloc, "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.unitOfMeasurement");
status_quantity_amount = try json.stringOf(alloc, "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.amount");
ship_date_time = json.intOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.shipDateTime");
carrier = try json.stringOf(alloc, "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.carrierName.carrier");
tracking_info_method_code = try json.stringOf(alloc, "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.methodCode");
tracking_number = try json.stringOf(alloc, "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingNumber");
tracking_url = try json.stringOf(alloc, "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingURL");
return_center_address_name = try json.stringOf(alloc, "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.name");
return_center_address_address1 = try json.stringOf(alloc, "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.address1");
return_center_address_city = try json.stringOf(alloc, "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.city");
return_center_address_state = try json.stringOf(alloc, "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.state");
return_center_address_postal_code = try json.stringOf(alloc, "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.postalCode");
return_center_address_country = try json.stringOf(alloc, "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.country");
day_phone = try json.stringOf(alloc, "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.dayPhone");
email_id = try json.stringOf(alloc, "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.emailId");
j = j + 1;
}
i = i + 1;
}
}