summaryrefslogtreecommitdiff
path: root/lib/serializer.ml
diff options
context:
space:
mode:
authorMateus Cruz <mateuscolvr@gmail.com>2024-02-05 23:28:09 -0300
committerMateus Cruz <mateuscolvr@gmail.com>2024-02-05 23:28:09 -0300
commit372834401b0b08498286c92a206a48654ec86a71 (patch)
treed386911aa8152b86841540aae4e9e74fc062c408 /lib/serializer.ml
parentbd700d5098c6b51db63cdabda81d676f5c354eda (diff)
feat: add transaction serializer
Diffstat (limited to 'lib/serializer.ml')
-rw-r--r--lib/serializer.ml16
1 files changed, 16 insertions, 0 deletions
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)
+ )
+ ]
+;;