this repo has no description
at main 77 lines 2.3 kB view raw
1(*--------------------------------------------------------------------------- 2 Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 SPDX-License-Identifier: ISC 4 ---------------------------------------------------------------------------*) 5 6(* Identity properties *) 7 8type property = [ 9 | `Id 10 | `Name 11 | `Email 12 | `Reply_to 13 | `Bcc 14 | `Text_signature 15 | `Html_signature 16 | `May_delete 17] 18 19let property_to_string : [< property ] -> string = function 20 | `Id -> "id" 21 | `Name -> "name" 22 | `Email -> "email" 23 | `Reply_to -> "replyTo" 24 | `Bcc -> "bcc" 25 | `Text_signature -> "textSignature" 26 | `Html_signature -> "htmlSignature" 27 | `May_delete -> "mayDelete" 28 29let property_of_string s : property option = 30 match s with 31 | "id" -> Some `Id 32 | "name" -> Some `Name 33 | "email" -> Some `Email 34 | "replyTo" -> Some `Reply_to 35 | "bcc" -> Some `Bcc 36 | "textSignature" -> Some `Text_signature 37 | "htmlSignature" -> Some `Html_signature 38 | "mayDelete" -> Some `May_delete 39 | _ -> None 40 41(* Identity type *) 42 43type t = { 44 id : Proto_id.t option; 45 name : string option; 46 email : string option; 47 reply_to : Mail_address.t list option; 48 bcc : Mail_address.t list option; 49 text_signature : string option; 50 html_signature : string option; 51 may_delete : bool option; 52} 53 54let id t = t.id 55let name t = t.name 56let email t = t.email 57let reply_to t = t.reply_to 58let bcc t = t.bcc 59let text_signature t = t.text_signature 60let html_signature t = t.html_signature 61let may_delete t = t.may_delete 62 63let make id name email reply_to bcc text_signature html_signature may_delete = 64 { id; name; email; reply_to; bcc; text_signature; html_signature; may_delete } 65 66let jsont = 67 let kind = "Identity" in 68 Jsont.Object.map ~kind make 69 |> Jsont.Object.opt_mem "id" Proto_id.jsont ~enc:id 70 |> Jsont.Object.opt_mem "name" Jsont.string ~enc:name 71 |> Jsont.Object.opt_mem "email" Jsont.string ~enc:email 72 |> Jsont.Object.opt_mem "replyTo" (Jsont.list Mail_address.jsont) ~enc:reply_to 73 |> Jsont.Object.opt_mem "bcc" (Jsont.list Mail_address.jsont) ~enc:bcc 74 |> Jsont.Object.opt_mem "textSignature" Jsont.string ~enc:text_signature 75 |> Jsont.Object.opt_mem "htmlSignature" Jsont.string ~enc:html_signature 76 |> Jsont.Object.opt_mem "mayDelete" Jsont.bool ~enc:may_delete 77 |> Jsont.Object.finish