Jamp is a client library to use JMAP with your mail server (if it supports it).
The next few sections will show the basic principles of JMAP and how to use the library. For more in depth examples visit the examples page
Methods
A method refers to what you can call against the JMAP server (It is also called an invocation). It has a name, arguments, and an ID (so you can get its result from the response. This library wraps methods in a Call[T] which stores
- Expected return type (T)
- What it requires the server to support
- ID, name, and arguments
When generating your own wrappers for JMAP specs it is best to return Call[T] so that the other procs in this library know how to handle it.
Requests
A request is multiple calls joined together. These calls are able to reference the result of other calls within the same request which saves having to make multiple requests. To reference other requests you need to pass a ResultReference as the parameter which contains ID and path of a call to use. Jamp implements helpers like reuse to simplify this process
Responses
A reponse contains responses for all methods that were called. If a method failed then its name will be "error" but its ID will stay the same. By keeping the Call around you can easily access these response values and check them
Example: cmd: -d:ssl -r:off
import jamp import std/sequtils let client = newJMAPClient(basicAuth("our@email.com", "password"), "host") client.startSession() let query = Email.query("1234") get = Email.get( "1234", ids = query.reuseIt(ids[]) ) var req = JMAPRequest() req &= query req &= get let resp = client.request(req) # We can get our values back using the calls assert resp.ok(query) assert resp.ok(get) echo "Total emails: ", resp[query].ids.len
Exports
-
MailGet, query, submissionCapability, get, Email, EmailFilter, get, query, Mailbox, mailCapability, setVal, vacationCapability, fromJson, copy, Core, echo, coreCapability, CopyResponse, point, startSession, newJMAPClient, AsyncJMAPClient, request, request, startSession, pretty, uploadBlob, hasSession, request, $, downloadBlob, downloadBlob, JMAPClient, request, uploadBlob, newAsyncHttpClient, initCall, ok, AuthorisationError, ResultReference, ok, SetError, id, JMAPRequest, CoreCapabilities, Blob, JMAPError, add, toJsonHook, JMAPResponse, addUsing, ok, Call, fromJsonHook, CallError, Session, Account, newInvocation, toJsonHook, fromJsonHook, [], Invocation, [], reuse, reuseIt, props, reuse, parseUTCDate, jmapUTCDateFormat, parseDate, jmapDateFormat, formatUTCDate, formatDate, FilterCondition, QueryChangesResponse, SetResponse, SetError, AddedItem, changes, Base, query, addParams, []=, Or, ChangesResponse, setVal, and, eqNil, GetResponse, defaultVal, And, not, Operator, or, isRef, QueryResponse, JPar, get, Comparator, initComparator, PatchObject, CopyResponse, Not, newFilter, FilterOperator, toJsonHook, AuthHandler, basicAuth, bearerAuth