Sample code for 30+ languages & platforms
Zig

IntakeQ: Query Intake Forms

See more IntakeQ Examples

Use this method to query client intake form summaries. The result set does not contain all the contents of the intake forms, but only their basic information (id, status, client info).

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://intakeq.com/api/v1/intakes/summary?client=[searchString]&startDate=[yyyy-MM-dd]&endDate=[yyyy-MM-dd]&page=[pageNumber]&all=[bool] \
    //   -H 'X-Auth-Key: xxxxxxxxxxxxxxxxxxxxxxxxx'

    // Use the following online tool to generate HTTP code from a CURL command
    // Convert a cURL Command to HTTP Source Code

    http.setRequestHeader("X-Auth-Key", "xxxxxxxxxxxxxxxxxxxxxxxxx");

    const sb_response_body = try chilkat.StringBuilder.init();
    defer sb_response_body.deinit();
    http.quickGetSb("https://intakeq.com/api/v1/intakes/summary?client=[searchString]&startDate=[yyyy-MM-dd]&endDate=[yyyy-MM-dd]&page=[pageNumber]&all=[bool]", sb_response_body) catch {
        std.debug.print("{s}\n", .{try http.getLastErrorText(alloc)});
        return;
    };

    const jarr_resp = try chilkat.JsonArray.init();
    defer jarr_resp.deinit();
    jarr_resp.loadSb(sb_response_body) catch {};
    jarr_resp.setEmitCompact(false);

    std.debug.print("Response Body:\n", .{});
    std.debug.print("{s}\n", .{try jarr_resp.emit(alloc)});

    const resp_status_code = http.getLastStatus();
    std.debug.print("Response Status Code = {d}\n", .{resp_status_code});
    if (resp_status_code >= 400) {
        std.debug.print("Response Header:\n", .{});
        std.debug.print("{s}\n", .{try http.getLastHeader(alloc)});
        std.debug.print("Failed.\n", .{});
        return;
    }

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

    // [
    //   {
    //     "Id": "00000000-0000-0000-0000-000000000000",
    //     "ClientName": "test",
    //     "ClientEmail": "test@email.com",
    //     "ClientId": 9999,
    //     "Status": "Completed",
    //     "DateCreated": 1458526480368,
    //     "DateSubmitted": 1458526532654,
    //     "QuestionnaireName": "test",
    //     "QuestionnaireId": "1234acbd",
    //     "Practitioner": "test@email.com",
    //     "PractitionerName": "FirstName LastName"
    //   },
    //   {
    //     "Id": "00000000-0000-0000-0000-000000000000",
    //     "ClientName": "test",
    //     "ClientEmail": "test@email.com",
    //     "ClientId": 9999,
    //     "Status": "Completed",
    //     "DateCreated": 1458526480368,
    //     "DateSubmitted": 1458526532654,
    //     "QuestionnaireName": "test",
    //     "QuestionnaireId": "1234acbd",
    //     "Practitioner": "test@email.com",
    //     "PractitionerName": "FirstName LastName"
    //   }
    // ]

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

    var id: [:0]const u8 = "";
    var client_name: [:0]const u8 = "";
    var client_email: [:0]const u8 = "";
    var client_id: i32 = 0;
    var status: [:0]const u8 = "";
    var date_created: i32 = 0;
    var date_submitted: i32 = 0;
    var questionnaire_name: [:0]const u8 = "";
    var questionnaire_id: [:0]const u8 = "";
    var practitioner: [:0]const u8 = "";
    var practitioner_name: [:0]const u8 = "";

    var i: i32 = 0;
    const count_i = jarr_resp.getSize();
    while (i < count_i) {
        const json = try jarr_resp.objectAt(i);
        defer json.deinit();
        id = try json.stringOf(alloc, "Id");
        client_name = try json.stringOf(alloc, "ClientName");
        client_email = try json.stringOf(alloc, "ClientEmail");
        client_id = json.intOf("ClientId");
        status = try json.stringOf(alloc, "Status");
        date_created = json.intOf("DateCreated");
        date_submitted = json.intOf("DateSubmitted");
        questionnaire_name = try json.stringOf(alloc, "QuestionnaireName");
        questionnaire_id = try json.stringOf(alloc, "QuestionnaireId");
        practitioner = try json.stringOf(alloc, "Practitioner");
        practitioner_name = try json.stringOf(alloc, "PractitionerName");

        i = i + 1;
    }
}