Zig
Zig
MYOB: Get List of Company Files
See more MYOB Examples
Gets a list of company files.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.setAuthToken("ACCESS_TOKEN");
http.setAccept("application/json");
http.setRequestHeader("x-myobapi-key", "MYOB_API_KEY");
http.setRequestHeader("x-myobapi-version", "v2");
const str_resp = http.quickGetStr(alloc, "https://ar1.api.myob.com/accountright") catch {
std.debug.print("{s}\n", .{try http.getLastErrorText(alloc)});
return;
};
std.debug.print("Response Status Code: {d}\n", .{http.getLastStatus()});
const json_response = try chilkat.JsonObject.init();
defer json_response.deinit();
json_response.load(str_resp) catch {};
json_response.setEmitCompact(false);
std.debug.print("{s}\n", .{try json_response.emit(alloc)});
if (http.getLastStatus() != 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
// {
// "Id": "d2014f64-ffdf-487b-8d12-67a20976aca6",
// "Name": "Internal Sandbox API",
// "LibraryPath": "Internal Sandbox API",
// "ProductVersion": "2013.0",
// "ProductLevel": {
// "Code": 20,
// "Name": "Standard"
// },
// "CheckedOutDate": "2013-06-11T01:47:47.0065514",
// "CheckedOutBy": "developers@myob.com",
// "Uri": "{cf_uri}",
// "Country": "AU"
// }
//
_ = try json_response.stringOf(alloc, "Id");
_ = try json_response.stringOf(alloc, "Name");
_ = try json_response.stringOf(alloc, "LibraryPath");
_ = try json_response.stringOf(alloc, "ProductVersion");
_ = json_response.intOf("ProductLevel.Code");
_ = try json_response.stringOf(alloc, "ProductLevel.Name");
_ = try json_response.stringOf(alloc, "CheckedOutDate");
_ = try json_response.stringOf(alloc, "CheckedOutBy");
_ = try json_response.stringOf(alloc, "Uri");
_ = try json_response.stringOf(alloc, "Country");
}