Packages

Some help ingesting Keep data obtained via Takeout…

Current section

Files

Jump to
outkeep src outkeep@note.erl
Raw

src/outkeep@note.erl

-module(outkeep@note).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([decode/1, title/1, is_archived/1, is_trashed/1, created_at/1, edited_at/1]).
-export_type([note/0]).
-opaque note() :: {c, outkeep@checklist:checklist()} |
{tn, outkeep@text_note:text_note()} |
{un, outkeep@unknown_note:unknown_note()}.
-spec decode(gleam@dynamic:dynamic_()) -> {ok, note()} |
{error, list(gleam@dynamic:decode_error())}.
decode(Dyn) ->
_pipe = Dyn,
(gleam@dynamic:any([fun(D) -> _pipe@1 = D,
_pipe@2 = outkeep@checklist:decode(_pipe@1),
gleam@result:map(_pipe@2, fun(Field@0) -> {c, Field@0} end) end, fun(
D@1
) ->
_pipe@3 = D@1,
_pipe@4 = outkeep@text_note:decode(_pipe@3),
gleam@result:map(_pipe@4, fun(Field@0) -> {tn, Field@0} end)
end, fun(D@2) -> _pipe@5 = D@2,
_pipe@6 = outkeep@unknown_note:decode(_pipe@5),
gleam@result:map(_pipe@6, fun(Field@0) -> {un, Field@0} end) end]))(
_pipe
).
-spec title(note()) -> binary().
title(N) ->
case N of
{c, Checklist} ->
erlang:element(2, Checklist);
{tn, Text_note} ->
erlang:element(2, Text_note);
{un, Unknown_note} ->
erlang:element(2, Unknown_note)
end.
-spec is_archived(note()) -> boolean().
is_archived(N) ->
case N of
{c, Checklist} ->
erlang:element(3, Checklist);
{tn, Text_note} ->
erlang:element(3, Text_note);
{un, Unknown_note} ->
erlang:element(3, Unknown_note)
end.
-spec is_trashed(note()) -> boolean().
is_trashed(N) ->
case N of
{c, Checklist} ->
erlang:element(4, Checklist);
{tn, Text_note} ->
erlang:element(4, Text_note);
{un, Unknown_note} ->
erlang:element(4, Unknown_note)
end.
-spec created_at(note()) -> birl:time().
created_at(N) ->
case N of
{c, Checklist} ->
erlang:element(6, Checklist);
{tn, Text_note} ->
erlang:element(6, Text_note);
{un, Unknown_note} ->
erlang:element(5, Unknown_note)
end.
-spec edited_at(note()) -> birl:time().
edited_at(N) ->
case N of
{c, Checklist} ->
erlang:element(7, Checklist);
{tn, Text_note} ->
erlang:element(7, Text_note);
{un, Unknown_note} ->
erlang:element(6, Unknown_note)
end.