From 372834401b0b08498286c92a206a48654ec86a71 Mon Sep 17 00:00:00 2001 From: Mateus Cruz Date: Mon, 5 Feb 2024 23:28:09 -0300 Subject: feat: add transaction serializer --- lib/serializer.ml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 lib/serializer.ml (limited to 'lib/serializer.ml') diff --git a/lib/serializer.ml b/lib/serializer.ml new file mode 100644 index 0000000..35464ac --- /dev/null +++ b/lib/serializer.ml @@ -0,0 +1,16 @@ +let transaction (t : Operation.transaction) = + let transaction_type = + match t.transaction_type with + | `Credit -> "c" + | `Debit -> "d" + in + `Assoc + [ "valor", `Int t.value + ; "tipo", `String transaction_type + ; "descricao", `String t.description + ; ( "realizada_em" + , `String + (Format.asprintf "%a" (Ptime.pp_rfc3339 ~tz_offset_s:(-10800) ()) t.created_at) + ) + ] +;; -- cgit v1.2.3