Zig Requires Chilkat v11.0.0+
Zig
Walmart V3 API - Get All Released Orders
See more Walmart v3 Examples
Retrieves all the orders with line items that are in the "created" status, that is, these orders have been released from the Walmart Order Management System to the seller for processing. The released orders are the orders that are ready for a seller to fulfill.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 requires 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.setAccept("application/json");
// Setting the Login and Password properties to the clientId and clientSecret
// will cause the Basic Auth header to be added (i.e. BaseEncode64(clientId:clientSecret))
http.setLogin("clientId");
http.setPassword("clientSecret");
http.setBasicAuth(true);
http.setRequestHeader("Content-Type", "application/json");
http.setRequestHeader("WM_QOS.CORRELATION_ID", "b3261d2d-028a-4ef7-8602-633c23200af6");
// Use the access token obtained from this example: Walmart v3 API Get OAuth2 Access Token using Client Credentials
http.setRequestHeader("WM_SEC.ACCESS_TOKEN", "eyJraWQiOiIzZjVhYTFmNS1hYWE5LTQzM.....");
http.setRequestHeader("WM_SVC.NAME", "Walmart Marketplace");
http.setUrlVar("createdStartDate", "2020-01-16T10:30:15Z") catch {};
http.setUrlVar("limit", "200") catch {};
// Can also be 3PLFulfilled
http.setUrlVar("shippingProgramType", "SellerFulfilled") catch {};
http.setUrlVar("shipNodeType", "TWO_DAY") catch {};
const resp = try chilkat.HttpResponse.init();
defer resp.deinit();
http.httpNoBody("GET", "/v3/orders/released?createdStartDate={$createdStartDate}&limit={$limit}&shippingProgramType={$shippingProgramType}&shipNodeType={$shipNodeType}", resp) catch {
std.debug.print("{s}\n", .{try http.getLastErrorText(alloc)});
return;
};
std.debug.print("Response Status Code: {d}\n", .{resp.getStatusCode()});
const json_response = try chilkat.JsonObject.init();
defer json_response.deinit();
json_response.load(try resp.getBodyStr(alloc)) catch {};
json_response.setEmitCompact(false);
std.debug.print("{s}\n", .{try json_response.emit(alloc)});
if (resp.getStatusCode() != 200) {
std.debug.print("Failed.\n", .{});
return;
}
// Sample output...
// (See the parsing code below..)
//
// Use the this online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
// {
// "list": {
// "meta": {
// "totalCount": 25228,
// "limit": 10,
// "nextCursor": "?limit=10&hasMoreElements=true&soIndex=25228&poIndex=10&sellerId=152&createdStartDate=2019-04-02T00:00:00.000Z&createdEndDate=2019-09-26T16:05:49.648Z"
// },
// "elements": {
// "order": [
// {
// "purchaseOrderId": "4792701510371",
// "customerOrderId": "5401973367419",
// "customerEmailId": "47B81ACD2C62434DBE64F47B9E1F7630@relay.walmart.com",
// "orderDate": 1569513584000,
// "shippingInfo": {
// "phone": "2134488377",
// "estimatedDeliveryDate": 1569870000000,
// "estimatedShipDate": 1569553200000,
// "methodCode": "Express",
// "postalAddress": {
// "name": "Julio Hernandez",
// "address1": "9713 pleasant view dr",
// "address2": null,
// "city": "Rancho Cucamonga",
// "state": "CA",
// "postalCode": "91701",
// "country": "USA",
// "addressType": "RESIDENTIAL"
// }
// },
// "orderLines": {
// "orderLine": [
// {
// "lineNumber": "1",
// "item": {
// "productName": "Refurbished Lenovo YB1-X90F Grey Yoga Book with WiFi 10.1\" Touchscreen Tablet Android 6.0.1",
// "sku": "VO190403007727R"
// },
// "charges": {
// "charge": [
// {
// "chargeType": "PRODUCT",
// "chargeName": "ItemPrice",
// "chargeAmount": {
// "currency": "USD",
// "amount": 259
// },
// "tax": {
// "taxName": "Tax1",
// "taxAmount": {
// "currency": "USD",
// "amount": 20.07
// }
// }
// },
// {
// "chargeType": "FEE",
// "chargeName": "Fee",
// "chargeAmount": {
// "currency": "USD",
// "amount": 0
// },
// "tax": {
// "taxName": "Electronic Waste Recycling Fee",
// "taxAmount": {
// "currency": "USD",
// "amount": 5
// }
// }
// }
// ]
// },
// "orderLineQuantity": {
// "unitOfMeasurement": "EACH",
// "amount": "1"
// },
// "statusDate": 1569513724000,
// "orderLineStatuses": {
// "orderLineStatus": [
// {
// "status": "Acknowledged",
// "statusQuantity": {
// "unitOfMeasurement": "EACH",
// "amount": "1"
// },
// "cancellationReason": null,
// "trackingInfo": null,
// "returnCenterAddress": null
// }
// ]
// },
// "refund": null,
// "fulfillment": {
// "fulfillmentOption": "S2H",
// "shipMethod": "EXPEDITED",
// "storeId": null,
// "pickUpDateTime": 1569870000000,
// "pickUpBy": null,
// "shippingProgramType": "TWO_DAY"
// }
// }
// ]
// },
// "shipNode": {
// "type": "3PLFulfilled"
// }
// }
// ]
// }
// }
// }
//
var purchase_order_id: [:0]const u8 = "";
var customer_order_id: [:0]const u8 = "";
var customer_email_id: [:0]const u8 = "";
var order_date: i32 = 0;
var shipping_info_phone: [:0]const u8 = "";
var shipping_info_estimated_delivery_date: i32 = 0;
var shipping_info_estimated_ship_date: i32 = 0;
var shipping_info_method_code: [:0]const u8 = "";
var shipping_info_postal_address_name: [:0]const u8 = "";
var shipping_info_postal_address_address1: [:0]const u8 = "";
var shipping_info_postal_address_address2: [:0]const u8 = "";
var shipping_info_postal_address_city: [:0]const u8 = "";
var shipping_info_postal_address_state: [:0]const u8 = "";
var shipping_info_postal_address_postal_code: [:0]const u8 = "";
var shipping_info_postal_address_country: [:0]const u8 = "";
var shipping_info_postal_address_address_type: [:0]const u8 = "";
var ship_node_type: [:0]const u8 = "";
var j: i32 = 0;
var count_j: i32 = 0;
var line_number: [:0]const u8 = "";
var item_product_name: [:0]const u8 = "";
var item_sku: [:0]const u8 = "";
var order_line_quantity_unit_of_measurement: [:0]const u8 = "";
var order_line_quantity_amount: [:0]const u8 = "";
var status_date: i32 = 0;
var refund: [:0]const u8 = "";
var fulfillment_fulfillment_option: [:0]const u8 = "";
var fulfillment_ship_method: [:0]const u8 = "";
var fulfillment_store_id: [:0]const u8 = "";
var fulfillment_pick_up_date_time: i32 = 0;
var fulfillment_pick_up_by: [:0]const u8 = "";
var fulfillment_shipping_program_type: [:0]const u8 = "";
var k: i32 = 0;
var count_k: i32 = 0;
var charge_type: [:0]const u8 = "";
var charge_name: [:0]const u8 = "";
var charge_amount_currency: [:0]const u8 = "";
var charge_amount_amount: i32 = 0;
var tax_tax_name: [:0]const u8 = "";
var tax_tax_amount_currency: [:0]const u8 = "";
var tax_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 cancellation_reason: [:0]const u8 = "";
var tracking_info: [:0]const u8 = "";
var return_center_address: [:0]const u8 = "";
_ = json_response.intOf("list.meta.totalCount");
_ = json_response.intOf("list.meta.limit");
_ = try json_response.stringOf(alloc, "list.meta.nextCursor");
var i: i32 = 0;
const count_i = json_response.sizeOfArray("list.elements.order");
while (i < count_i) {
json_response.setI(i);
purchase_order_id = try json_response.stringOf(alloc, "list.elements.order[i].purchaseOrderId");
customer_order_id = try json_response.stringOf(alloc, "list.elements.order[i].customerOrderId");
customer_email_id = try json_response.stringOf(alloc, "list.elements.order[i].customerEmailId");
order_date = json_response.intOf("list.elements.order[i].orderDate");
shipping_info_phone = try json_response.stringOf(alloc, "list.elements.order[i].shippingInfo.phone");
shipping_info_estimated_delivery_date = json_response.intOf("list.elements.order[i].shippingInfo.estimatedDeliveryDate");
shipping_info_estimated_ship_date = json_response.intOf("list.elements.order[i].shippingInfo.estimatedShipDate");
shipping_info_method_code = try json_response.stringOf(alloc, "list.elements.order[i].shippingInfo.methodCode");
shipping_info_postal_address_name = try json_response.stringOf(alloc, "list.elements.order[i].shippingInfo.postalAddress.name");
shipping_info_postal_address_address1 = try json_response.stringOf(alloc, "list.elements.order[i].shippingInfo.postalAddress.address1");
shipping_info_postal_address_address2 = try json_response.stringOf(alloc, "list.elements.order[i].shippingInfo.postalAddress.address2");
shipping_info_postal_address_city = try json_response.stringOf(alloc, "list.elements.order[i].shippingInfo.postalAddress.city");
shipping_info_postal_address_state = try json_response.stringOf(alloc, "list.elements.order[i].shippingInfo.postalAddress.state");
shipping_info_postal_address_postal_code = try json_response.stringOf(alloc, "list.elements.order[i].shippingInfo.postalAddress.postalCode");
shipping_info_postal_address_country = try json_response.stringOf(alloc, "list.elements.order[i].shippingInfo.postalAddress.country");
shipping_info_postal_address_address_type = try json_response.stringOf(alloc, "list.elements.order[i].shippingInfo.postalAddress.addressType");
ship_node_type = try json_response.stringOf(alloc, "list.elements.order[i].shipNode.type");
j = 0;
count_j = json_response.sizeOfArray("list.elements.order[i].orderLines.orderLine");
while (j < count_j) {
json_response.setJ(j);
line_number = try json_response.stringOf(alloc, "list.elements.order[i].orderLines.orderLine[j].lineNumber");
item_product_name = try json_response.stringOf(alloc, "list.elements.order[i].orderLines.orderLine[j].item.productName");
item_sku = try json_response.stringOf(alloc, "list.elements.order[i].orderLines.orderLine[j].item.sku");
order_line_quantity_unit_of_measurement = try json_response.stringOf(alloc, "list.elements.order[i].orderLines.orderLine[j].orderLineQuantity.unitOfMeasurement");
order_line_quantity_amount = try json_response.stringOf(alloc, "list.elements.order[i].orderLines.orderLine[j].orderLineQuantity.amount");
status_date = json_response.intOf("list.elements.order[i].orderLines.orderLine[j].statusDate");
refund = try json_response.stringOf(alloc, "list.elements.order[i].orderLines.orderLine[j].refund");
fulfillment_fulfillment_option = try json_response.stringOf(alloc, "list.elements.order[i].orderLines.orderLine[j].fulfillment.fulfillmentOption");
fulfillment_ship_method = try json_response.stringOf(alloc, "list.elements.order[i].orderLines.orderLine[j].fulfillment.shipMethod");
fulfillment_store_id = try json_response.stringOf(alloc, "list.elements.order[i].orderLines.orderLine[j].fulfillment.storeId");
fulfillment_pick_up_date_time = json_response.intOf("list.elements.order[i].orderLines.orderLine[j].fulfillment.pickUpDateTime");
fulfillment_pick_up_by = try json_response.stringOf(alloc, "list.elements.order[i].orderLines.orderLine[j].fulfillment.pickUpBy");
fulfillment_shipping_program_type = try json_response.stringOf(alloc, "list.elements.order[i].orderLines.orderLine[j].fulfillment.shippingProgramType");
k = 0;
count_k = json_response.sizeOfArray("list.elements.order[i].orderLines.orderLine[j].charges.charge");
while (k < count_k) {
json_response.setK(k);
charge_type = try json_response.stringOf(alloc, "list.elements.order[i].orderLines.orderLine[j].charges.charge[k].chargeType");
charge_name = try json_response.stringOf(alloc, "list.elements.order[i].orderLines.orderLine[j].charges.charge[k].chargeName");
charge_amount_currency = try json_response.stringOf(alloc, "list.elements.order[i].orderLines.orderLine[j].charges.charge[k].chargeAmount.currency");
charge_amount_amount = json_response.intOf("list.elements.order[i].orderLines.orderLine[j].charges.charge[k].chargeAmount.amount");
tax_tax_name = try json_response.stringOf(alloc, "list.elements.order[i].orderLines.orderLine[j].charges.charge[k].tax.taxName");
tax_tax_amount_currency = try json_response.stringOf(alloc, "list.elements.order[i].orderLines.orderLine[j].charges.charge[k].tax.taxAmount.currency");
tax_tax_amount_amount = try json_response.stringOf(alloc, "list.elements.order[i].orderLines.orderLine[j].charges.charge[k].tax.taxAmount.amount");
k = k + 1;
}
k = 0;
count_k = json_response.sizeOfArray("list.elements.order[i].orderLines.orderLine[j].orderLineStatuses.orderLineStatus");
while (k < count_k) {
json_response.setK(k);
status = try json_response.stringOf(alloc, "list.elements.order[i].orderLines.orderLine[j].orderLineStatuses.orderLineStatus[k].status");
status_quantity_unit_of_measurement = try json_response.stringOf(alloc, "list.elements.order[i].orderLines.orderLine[j].orderLineStatuses.orderLineStatus[k].statusQuantity.unitOfMeasurement");
status_quantity_amount = try json_response.stringOf(alloc, "list.elements.order[i].orderLines.orderLine[j].orderLineStatuses.orderLineStatus[k].statusQuantity.amount");
cancellation_reason = try json_response.stringOf(alloc, "list.elements.order[i].orderLines.orderLine[j].orderLineStatuses.orderLineStatus[k].cancellationReason");
tracking_info = try json_response.stringOf(alloc, "list.elements.order[i].orderLines.orderLine[j].orderLineStatuses.orderLineStatus[k].trackingInfo");
return_center_address = try json_response.stringOf(alloc, "list.elements.order[i].orderLines.orderLine[j].orderLineStatuses.orderLineStatus[k].returnCenterAddress");
k = k + 1;
}
j = j + 1;
}
i = i + 1;
}
}