···9898 in
9999 { account_id; ids; properties }
100100101101+ (** Convert request to JSON *)
102102+ let request_to_json (req : 'a request) =
103103+ let fields = [
104104+ ("accountId", Jmap_id.to_json req.account_id);
105105+ ] in
106106+ let fields = match req.ids with
107107+ | Some ids -> ("ids", `A (List.map Jmap_id.to_json ids)) :: fields
108108+ | None -> fields
109109+ in
110110+ let fields = match req.properties with
111111+ | Some props -> ("properties", `A (List.map (fun s -> `String s) props)) :: fields
112112+ | None -> fields
113113+ in
114114+ `O fields
115115+101116 (** Parse response from JSON.
102117 Test files: test/data/core/response_get.json *)
103118 let response_of_json parse_obj json =
+3
stack/jmap/jmap-core/jmap_standard_methods.mli
···3232 (** Constructor for response *)
3333 val response_v : account_id:Jmap_id.t -> state:string -> list:'a list -> not_found:Jmap_id.t list -> 'a response
34343535+ (** Convert request to JSON *)
3636+ val request_to_json : 'a request -> Ezjsonm.value
3737+3538 (** Parse request from JSON *)
3639 val request_of_json : (Ezjsonm.value -> 'a) -> Ezjsonm.value -> 'a request
3740
+74
stack/jmap/jmap-mail/jmap_mailbox.ml
···197197 type request = t Jmap_core.Standard_methods.Get.request
198198 type response = t Jmap_core.Standard_methods.Get.response
199199200200+ (** Constructor for request *)
201201+ let request_v = Jmap_core.Standard_methods.Get.v
202202+203203+ (** Convert request to JSON *)
204204+ let request_to_json = Jmap_core.Standard_methods.Get.request_to_json
205205+200206 (** Parse get request from JSON *)
201207 let request_of_json json =
202208 Jmap_core.Standard_methods.Get.request_of_json Parser.of_json json
···266272 (* Constructor *)
267273 let v ?parent_id ?name ?role ?has_any_role ?is_subscribed () =
268274 { parent_id; name; role; has_any_role; is_subscribed }
275275+276276+ (* Convert to JSON *)
277277+ let to_json t =
278278+ let fields = [] in
279279+ let fields = match t.parent_id with
280280+ | Some id -> ("parentId", Jmap_core.Id.to_json id) :: fields
281281+ | None -> fields
282282+ in
283283+ let fields = match t.name with
284284+ | Some n -> ("name", `String n) :: fields
285285+ | None -> fields
286286+ in
287287+ let fields = match t.role with
288288+ | Some r -> ("role", `String r) :: fields
289289+ | None -> fields
290290+ in
291291+ let fields = match t.has_any_role with
292292+ | Some har -> ("hasAnyRole", `Bool har) :: fields
293293+ | None -> fields
294294+ in
295295+ let fields = match t.is_subscribed with
296296+ | Some is -> ("isSubscribed", `Bool is) :: fields
297297+ | None -> fields
298298+ in
299299+ `O fields
269300end
270301271302(** Standard /query method with Mailbox-specific extensions (RFC 8621 Section 2.5) *)
···351382 in
352383 { account_id; filter; sort; position; anchor; anchor_offset; limit;
353384 calculate_total; sort_as_tree; filter_as_tree }
385385+386386+ (** Convert query request to JSON *)
387387+ let request_to_json req =
388388+ let fields = [
389389+ ("accountId", Jmap_core.Id.to_json req.account_id);
390390+ ] in
391391+ let fields = match req.filter with
392392+ | Some f -> ("filter", Jmap_core.Filter.to_json Filter.to_json f) :: fields
393393+ | None -> fields
394394+ in
395395+ let fields = match req.sort with
396396+ | Some s -> ("sort", `A (List.map Jmap_core.Comparator.to_json s)) :: fields
397397+ | None -> fields
398398+ in
399399+ let fields = match req.position with
400400+ | Some p -> ("position", Jmap_core.Primitives.Int53.to_json p) :: fields
401401+ | None -> fields
402402+ in
403403+ let fields = match req.anchor with
404404+ | Some a -> ("anchor", Jmap_core.Id.to_json a) :: fields
405405+ | None -> fields
406406+ in
407407+ let fields = match req.anchor_offset with
408408+ | Some ao -> ("anchorOffset", Jmap_core.Primitives.Int53.to_json ao) :: fields
409409+ | None -> fields
410410+ in
411411+ let fields = match req.limit with
412412+ | Some l -> ("limit", Jmap_core.Primitives.UnsignedInt.to_json l) :: fields
413413+ | None -> fields
414414+ in
415415+ let fields = match req.calculate_total with
416416+ | Some ct -> ("calculateTotal", `Bool ct) :: fields
417417+ | None -> fields
418418+ in
419419+ let fields = match req.sort_as_tree with
420420+ | Some sat -> ("sortAsTree", `Bool sat) :: fields
421421+ | None -> fields
422422+ in
423423+ let fields = match req.filter_as_tree with
424424+ | Some fat -> ("filterAsTree", `Bool fat) :: fields
425425+ | None -> fields
426426+ in
427427+ `O fields
354428355429 (** Parse query response from JSON.
356430 Test files: test/data/mail/mailbox_query_response.json *)
+4
stack/jmap/jmap-mail/jmap_mailbox.mli
···9393 type request = t Standard_methods.Get.request
9494 type response = t Standard_methods.Get.response
95959696+ val request_v : account_id:Id.t -> ?ids:Id.t list -> ?properties:string list -> unit -> request
9797+ val request_to_json : request -> Ezjsonm.value
9698 val request_of_json : Ezjsonm.value -> request
9799 val response_of_json : Ezjsonm.value -> response
98100end
···133135 unit ->
134136 t
135137138138+ val to_json : t -> Ezjsonm.value
136139 val of_json : Ezjsonm.value -> t
137140end
138141···180183 unit ->
181184 request
182185186186+ val request_to_json : request -> Ezjsonm.value
183187 val request_of_json : Ezjsonm.value -> request
184188 val response_of_json : Ezjsonm.value -> response
185189end