Sample code for 30+ languages & platforms
Zig

Walmart v3 Get All Feed Statuses

See more Walmart v3 Examples

Returns the feed statuses for all the specified Feed IDs.

Chilkat Zig Downloads

Zig
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();

    // Implements the following CURL command:

    // curl -X GET \
    //   https://marketplace.walmartapis.com/v3/feeds?feedId={feedId}&limit={limit}&offset={offset} \
    //   -H 'WM_SVC.NAME: Walmart Marketplace'
    //   -H 'WM_SEC.ACCESS_TOKEN: eyJraWQiOiIzZjVhYTFmNS1hYWE5LTQzM.....'
    //   -H 'WM_QOS.CORRELATION_ID: b3261d2d-028a-4ef7-8602-633c23200af6'
    //   -H 'Content-Type: application/xml'
    //   -H 'Accept: application/xml'

    http.setRequestHeader("WM_QOS.CORRELATION_ID", "b3261d2d-028a-4ef7-8602-633c23200af6");
    http.setRequestHeader("Content-Type", "application/xml");
    http.setRequestHeader("WM_SEC.ACCESS_TOKEN", "eyJraWQiOiIzZjVhYTFmNS1hYWE5LTQzM.....");
    http.setRequestHeader("Accept", "application/xml");
    http.setRequestHeader("WM_SVC.NAME", "Walmart Marketplace");

    const sb_response_body = try chilkat.StringBuilder.init();
    defer sb_response_body.deinit();
    http.quickGetSb("https://marketplace.walmartapis.com/v3/feeds?feedId={feedId}&limit={limit}&offset={offset}", sb_response_body) catch {
        std.debug.print("{s}\n", .{try http.getLastErrorText(alloc)});
        return;
    };

    const xml_response = try chilkat.Xml.init();
    defer xml_response.deinit();
    xml_response.loadSb(sb_response_body, true) catch {};

    // Sample XML response:
    // (Sample code for parsing the XML response is shown below)

    // <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    // <ns2:list xmlns:ns2="http://walmart.com/">
    //     <ns2:totalResults>2</ns2:totalResults>
    //     <ns2:offset>0</ns2:offset>
    //     <ns2:limit>50</ns2:limit>
    //     <ns2:results>
    //         <ns2:feed>
    //             <ns2:feedId>12234EGGT564YTEGFA@AQMBAQA</ns2:feedId>
    //             <ns2:feedSource>MARKETPLACE_PARTNER</ns2:feedSource>
    //             <ns2:feedType>item</ns2:feedType>
    //             <ns2:partnerId>1413254255</ns2:partnerId>
    //             <ns2:itemsReceived>1</ns2:itemsReceived>
    //             <ns2:itemsSucceeded>1</ns2:itemsSucceeded>
    //             <ns2:itemsFailed>0</ns2:itemsFailed>
    //             <ns2:itemsProcessing>0</ns2:itemsProcessing>
    //             <ns2:feedStatus>PROCESSED</ns2:feedStatus>
    //             <ns2:feedDate>2018-07-20T21:56:12.605Z</ns2:feedDate>
    //             <ns2:batchId>HP_REQUEST_BATCH</ns2:batchId>
    //             <ns2:modifiedDtm>2018-07-20T21:56:17.948Z</ns2:modifiedDtm>
    //             <ns2:fileName>ItemFeed99_ParadiseCounty_paperback.xml</ns2:fileName>
    //             <ns2:itemDataErrorCount>0</ns2:itemDataErrorCount>
    //             <ns2:itemSystemErrorCount>0</ns2:itemSystemErrorCount>
    //             <ns2:itemTimeoutErrorCount>0</ns2:itemTimeoutErrorCount>
    //             <ns2:channelType>WM_TEST</ns2:channelType>
    //         </ns2:feed>
    //         <ns2:feed>
    //             <ns2:feedId>12234EGGT564YTEGFA@AQMBAQA</ns2:feedId>
    //             <ns2:feedSource>MARKETPLACE_PARTNER</ns2:feedSource>
    //             <ns2:feedType>item</ns2:feedType>
    //             <ns2:partnerId>1413254255</ns2:partnerId>
    //             <ns2:itemsReceived>1</ns2:itemsReceived>
    //             <ns2:itemsSucceeded>1</ns2:itemsSucceeded>
    //             <ns2:itemsFailed>0</ns2:itemsFailed>
    //             <ns2:itemsProcessing>0</ns2:itemsProcessing>
    //             <ns2:feedStatus>PROCESSED</ns2:feedStatus>
    //             <ns2:feedDate>2018-07-20T21:56:12.605Z</ns2:feedDate>
    //             <ns2:batchId>HP_REQUEST_BATCH</ns2:batchId>
    //             <ns2:modifiedDtm>2018-07-20T21:56:17.948Z</ns2:modifiedDtm>
    //             <ns2:fileName>ItemFeed99_ParadiseCounty_paperback.xml</ns2:fileName>
    //             <ns2:itemDataErrorCount>0</ns2:itemDataErrorCount>
    //             <ns2:itemSystemErrorCount>0</ns2:itemSystemErrorCount>
    //             <ns2:itemTimeoutErrorCount>0</ns2:itemTimeoutErrorCount>
    //             <ns2:channelType>WM_TEST</ns2:channelType>
    //         </ns2:feed>
    //     </ns2:results>
    // </ns2:list>

    // Sample code for parsing the XML response...
    // Use the following online tool to generate parsing code from sample XML:
    // Generate Parsing Code from XML

    var i: i32 = 0;
    var ns2_feed_id: [:0]const u8 = "";
    var ns2_feed_source: [:0]const u8 = "";
    var ns2_feed_type: [:0]const u8 = "";
    var ns2_partner_id: i32 = 0;
    var ns2_items_received: i32 = 0;
    var ns2_items_succeeded: i32 = 0;
    var ns2_items_failed: i32 = 0;
    var ns2_items_processing: i32 = 0;
    var ns2_feed_status: [:0]const u8 = "";
    var ns2_feed_date: [:0]const u8 = "";
    var ns2_batch_id: [:0]const u8 = "";
    var ns2_modified_dtm: [:0]const u8 = "";
    var ns2_file_name: [:0]const u8 = "";
    var ns2_item_data_error_count: i32 = 0;
    var ns2_item_system_error_count: i32 = 0;
    var ns2_item_timeout_error_count: i32 = 0;
    var ns2_channel_type: [:0]const u8 = "";

    _ = try xml_response.getAttrValue(alloc, "xmlns:ns2");
    _ = xml_response.getChildIntValue("ns2:totalResults");
    _ = xml_response.getChildIntValue("ns2:offset");
    _ = xml_response.getChildIntValue("ns2:limit");
    i = 0;
    const count_i = xml_response.numChildrenHavingTag("ns2:results|ns2:feed");
    while (i < count_i) {
        xml_response.setI(i);
        ns2_feed_id = try xml_response.getChildContent(alloc, "ns2:results|ns2:feed[i]|ns2:feedId");
        ns2_feed_source = try xml_response.getChildContent(alloc, "ns2:results|ns2:feed[i]|ns2:feedSource");
        ns2_feed_type = try xml_response.getChildContent(alloc, "ns2:results|ns2:feed[i]|ns2:feedType");
        ns2_partner_id = xml_response.getChildIntValue("ns2:results|ns2:feed[i]|ns2:partnerId");
        ns2_items_received = xml_response.getChildIntValue("ns2:results|ns2:feed[i]|ns2:itemsReceived");
        ns2_items_succeeded = xml_response.getChildIntValue("ns2:results|ns2:feed[i]|ns2:itemsSucceeded");
        ns2_items_failed = xml_response.getChildIntValue("ns2:results|ns2:feed[i]|ns2:itemsFailed");
        ns2_items_processing = xml_response.getChildIntValue("ns2:results|ns2:feed[i]|ns2:itemsProcessing");
        ns2_feed_status = try xml_response.getChildContent(alloc, "ns2:results|ns2:feed[i]|ns2:feedStatus");
        ns2_feed_date = try xml_response.getChildContent(alloc, "ns2:results|ns2:feed[i]|ns2:feedDate");
        ns2_batch_id = try xml_response.getChildContent(alloc, "ns2:results|ns2:feed[i]|ns2:batchId");
        ns2_modified_dtm = try xml_response.getChildContent(alloc, "ns2:results|ns2:feed[i]|ns2:modifiedDtm");
        ns2_file_name = try xml_response.getChildContent(alloc, "ns2:results|ns2:feed[i]|ns2:fileName");
        ns2_item_data_error_count = xml_response.getChildIntValue("ns2:results|ns2:feed[i]|ns2:itemDataErrorCount");
        ns2_item_system_error_count = xml_response.getChildIntValue("ns2:results|ns2:feed[i]|ns2:itemSystemErrorCount");
        ns2_item_timeout_error_count = xml_response.getChildIntValue("ns2:results|ns2:feed[i]|ns2:itemTimeoutErrorCount");
        ns2_channel_type = try xml_response.getChildContent(alloc, "ns2:results|ns2:feed[i]|ns2:channelType");
        i = i + 1;
    }
}