package slack
Slack API implementation
Install
Dune Dependency
Authors
Maintainers
Sources
0.1.tar.gz
md5=f3be3accbb3b77babbc9b672746c603b
sha512=e715aa318eee97c65d254e1a2b052fb08a8e113d11343272c03a13cccd2f74a480678e064bcb6c901624aadcb83d16eabadbd6caa9181465a920cb69aee8f644
doc/src/slack.lib/atd_adapters.ml.html
Source file atd_adapters.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
(** Error detection in Slack API response. The web API communicates errors using an [error] field rather than status codes. Note, on the other hand, that webhooks do use status codes to communicate errors. *) module Slack_response_adapter : Atdgen_runtime.Json_adapter.S = struct let normalize (x : Yojson.Safe.t) = match x with | `Assoc fields -> begin match List.assoc "ok" fields with | `Bool true -> `List [ `String "Ok"; x ] | `Bool false -> begin match List.assoc "error" fields with | `String msg -> `List [ `String "Error"; `String msg ] | _ -> x end | _ | (exception Not_found) -> x end | _ -> x let restore (x : Yojson.Safe.t) = let mk_fields ok fields = ("ok", `Bool ok) :: List.filter (fun (k, _) -> k <> "ok") fields in match x with | `List [ `String "Ok"; `Assoc fields ] -> `Assoc (mk_fields true fields) | `List [ `String "Error"; `String msg ] -> `Assoc (mk_fields false [ "error", `String msg ]) | _ -> x end module Unfurl_adapter : Atdgen_runtime.Json_adapter.S = struct let normalize (x : Yojson.Safe.t) = match x with | `Assoc fields -> begin match List.assoc "blocks" fields with | `Bool true -> `List [ `String "Blocks"; x ] | `Bool false -> `List [ `String "Message_attachment"; x ] | _ | (exception Not_found) -> x end | _ -> x let restore (x : Yojson.Safe.t) = match x with | `List [ `String "Blocks"; `Assoc fields ] -> `Assoc fields | `List [ `String "Message_attachment"; `Assoc fields ] -> `Assoc fields | _ -> x end
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>