this repo has no description
at main 1.7 kB view raw
1(*--------------------------------------------------------------------------- 2 Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 SPDX-License-Identifier: ISC 4 ---------------------------------------------------------------------------*) 5 6type t = { 7 id : Proto_id.t; 8 is_enabled : bool; 9 from_date : Ptime.t option; 10 to_date : Ptime.t option; 11 subject : string option; 12 text_body : string option; 13 html_body : string option; 14} 15 16let id t = t.id 17let is_enabled t = t.is_enabled 18let from_date t = t.from_date 19let to_date t = t.to_date 20let subject t = t.subject 21let text_body t = t.text_body 22let html_body t = t.html_body 23 24let singleton_id = Proto_id.of_string_exn "singleton" 25 26let make id is_enabled from_date to_date subject text_body html_body = 27 { id; is_enabled; from_date; to_date; subject; text_body; html_body } 28 29let jsont = 30 let kind = "VacationResponse" in 31 (* subject, textBody, htmlBody can be null per RFC 8621 Section 8 *) 32 let nullable_string = Jsont.(option string) in 33 Jsont.Object.map ~kind make 34 |> Jsont.Object.mem "id" Proto_id.jsont ~enc:id 35 |> Jsont.Object.mem "isEnabled" Jsont.bool ~enc:is_enabled 36 |> Jsont.Object.opt_mem "fromDate" Proto_date.Utc.jsont ~enc:from_date 37 |> Jsont.Object.opt_mem "toDate" Proto_date.Utc.jsont ~enc:to_date 38 |> Jsont.Object.mem "subject" nullable_string 39 ~dec_absent:None ~enc_omit:Option.is_none ~enc:subject 40 |> Jsont.Object.mem "textBody" nullable_string 41 ~dec_absent:None ~enc_omit:Option.is_none ~enc:text_body 42 |> Jsont.Object.mem "htmlBody" nullable_string 43 ~dec_absent:None ~enc_omit:Option.is_none ~enc:html_body 44 |> Jsont.Object.finish