Zig
Zig
Lightspeed - Delete a Product
See more Lightspeed Examples
Remove an existing product based on the unique identifierChilkat 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();
// Implements the following CURL command:
// curl -X DELETE https://api.webshopapp.com/en/products/PRODUCT_ID.json \
// -u API_KEY:API_SECRET
// Use the following online tool to generate HTTP code from a CURL command
// Convert a cURL Command to HTTP Source Code
http.setLogin("API_KEY");
http.setPassword("API_SECRET");
// Use the correct cluster for your shop. Here are the choices:
// eu1 https://api.webshopapp.com/en/
// us1 https://api.shoplightspeed.com/en/
const resp = try chilkat.HttpResponse.init();
defer resp.deinit();
http.httpNoBody("DELETE", "https://api.webshopapp.com/en/products/PRODUCT_ID.json", resp) catch {
std.debug.print("{s}\n", .{try http.getLastErrorText(alloc)});
return;
};
const resp_status_code = resp.getStatusCode();
std.debug.print("Response Status Code = {d}\n", .{resp_status_code});
if (resp_status_code != 204) {
std.debug.print("Response Header:\n", .{});
std.debug.print("{s}\n", .{try resp.getHeader(alloc)});
std.debug.print("Response Body:\n", .{});
std.debug.print("{s}\n", .{try resp.getBodyStr(alloc)});
std.debug.print("Failed.\n", .{});
return;
}
std.debug.print("Success.\n", .{});
}