(sigil jmap client)
(sigil jmap client) - JMAP Client Core
Handles JMAP session discovery, request building, and response parsing per RFC 8620. Provides the transport layer for all JMAP method calls.
Exports
jmap-clientprocedureConstruct a jmap-client struct.
jmap-client?procedureTest if a value is a jmap-client struct.
jmap-client-session-urlprocedureGet the session-url field of a jmap-client struct.
jmap-client-auth-headerprocedureGet the auth-header field of a jmap-client struct.
jmap-client-api-urlprocedureGet the api-url field of a jmap-client struct.
jmap-client-download-urlprocedureGet the download-url field of a jmap-client struct.
jmap-client-upload-urlprocedureGet the upload-url field of a jmap-client struct.
jmap-client-account-idprocedureGet the account-id field of a jmap-client struct.
jmap-client-accountsprocedureGet the accounts field of a jmap-client struct.
jmap-client-capabilitiesprocedureGet the capabilities field of a jmap-client struct.
jmap-client-session-stateprocedureGet the session-state field of a jmap-client struct.
set-jmap-client-api-url!procedureSet the api-url field of a jmap-client struct.
set-jmap-client-download-url!procedureSet the download-url field of a jmap-client struct.
set-jmap-client-upload-url!procedureSet the upload-url field of a jmap-client struct.
set-jmap-client-account-id!procedureSet the account-id field of a jmap-client struct.
set-jmap-client-accounts!procedureSet the accounts field of a jmap-client struct.
set-jmap-client-capabilities!procedureSet the capabilities field of a jmap-client struct.
set-jmap-client-session-state!procedureSet the session-state field of a jmap-client struct.
jmap-connectvariableConnect to a JMAP server and discover session capabilities.
Fetches the JMAP session resource, populates the client with API URLs, account IDs, and capabilities. Authenticates using either a Bearer token or a pre-built Authorization header.
(jmap-connect
url: "https://api.fastmail.com/.well-known/jmap"
token: "fmu1-...")
(jmap-connect
url: "https://jmap.example.com/.well-known/jmap"
auth: "Basic dXNlcjpwYXNz")jmap-callprocedureBuild a JMAP method call triple.
Returns an array of [method-name, arguments, call-id] suitable for inclusion in the methodCalls array of a JMAP request.
(jmap-call "Mailbox/get"
#{ accountId: "abc123" ids: 'null })
; => #["Mailbox/get" #{ accountId: "abc123" ids: null } "0"]
(jmap-call "Email/query"
#{ accountId: "abc123" }
"q0")
; => #["Email/query" #{ accountId: "abc123" } "q0"]jmap-requestvariableSend JMAP method calls to the server.
Takes the client and one or more method call triples (from jmap-call). Returns the parsed JSON response body, or raises an error on HTTP failure.
The using: keyword specifies JMAP capability URNs to include. Defaults to core and mail capabilities.
(jmap-request client
(jmap-call "Mailbox/get" #{ accountId: id ids: 'null }))jmap-response-getprocedureExtract a method response by call ID from a JMAP response.
Searches the methodResponses array for a triple matching the given call ID and returns its arguments dict. Returns #f if no match is found.
(jmap-response-get response "0")
; => #{ accountId: "abc" state: "..." list: #[...] }jmap-response-error?procedureCheck if a method response is a JMAP error.
Returns #t if the response triple for the given call ID has "error" as its method name.
(jmap-response-error? response "0")
; => #fjmap-error-typeprocedureGet the error type from a JMAP error response.
Returns the type field from the error arguments, or #f if the response is not an error.
(jmap-error-type response "0")
; => "unknownMethod"jmap-result-refvariableSend a single JMAP method call and return the result directly.
Convenience wrapper around jmap-request + jmap-response-get. Raises an error if the response is a JMAP-level error.
(jmap-result-ref client
(jmap-call "Mailbox/get" #{ accountId: id ids: 'null }))
; => #{ accountId: "abc" state: "..." list: #[...] }