- Installation
- API Key authentication
- Making a read GET request
- Making a list GET request
- Making a create POST request
- Making an update PUT request
- Making a delete DELETE request
!!! note
This is an unofficial (3rd party) client.
For the source code, refer to GitHub.
This Zig espocrm library provides an API client for EspoCRM. To get started you'll have to provide the URL where EspoCRM is located and your method of authentication. Read more from the official documentation.
Add this to your build.zig.zon
.dependencies = .{
.espocrmz = .{
.url = "https://github.com/definitepotato/espocrmz/archive/refs/heads/master.tar.gz",
.hash = "the correct hash will be suggested by zig at build time",
}
}Add this to your build.zig
const espocrmz = b.dependency("espocrmz", .{
.target = target,
.optimize = optimize,
});
exe.root_module.addImport("espocrmz", espocrmz.module("espocrmz"));You can then import the library into your code like this
const espocrm = @import("espocrmz");const allocator = std.heap.page_allocator;
const client: espocrm.Client = .init(
"https://espocrm.example.com",
.{ .api_key = "Your API Key here" },
);const allocator = std.heap.page_allocator;
const result = try client.readEntity(
allocator,
"Contact",
"78abc123def456",
);
defer result.deinit();var params = espocrm.Parameters.init();
_ = params.setMaxSize(10).setOrder(espocrm.Parameters.Order.Asc);
const params_encoded = try params.encode(allocator);
const allocator = std.heap.page_allocator;
const result = try client.listEntities(allocator, "Contact", params, &[_]espocrm.Where{
.{ .filter_type = espocrm.FilterOption.Equals, .filter_attribute = "name", .filter_value = "Alice" },
.{ .filter_type = espocrm.FilterOption.GreaterThan, .filter_attribute = "age", .filter_value = "42" },
});
defer result.deinit();const allocator = std.heap.page_allocator;
const new_contact =
\\{
\\ "name": "Alice",
\\ "age": 69
\\}
;
const result = try espocrm.createEntity(
allocator,
"Contact",
new_contact,
);
defer result.deinit();const allocator = std.heap.page_allocator;
const update_info =
\\{
\\ "name": "Bob"
\\}
;
const result = try client.updateEntity(
allocator,
"Contact",
"67abe33f5883bd9e",
update_info
);
defer result.deinit();const result = try client.deleteEntity(
allocator,
"Contact",
"67abe33f5883bd9e"
);
defer result.deinit();