Packages

A Gleam library for building Discord webhook payloads safely.

Current section

Files

Jump to
kitazith src kitazith@internal@query_helper.erl
Raw

src/kitazith@internal@query_helper.erl

-module(kitazith@internal@query_helper).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/kitazith/internal/query_helper.gleam").
-export([list_omit_none/1, optional/3, bool/1]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
?MODULEDOC(false).
-file("src/kitazith/internal/query_helper.gleam", 4).
?DOC(false).
-spec list_omit_none(list(gleam@option:option({binary(), binary()}))) -> list({binary(),
binary()}).
list_omit_none(Fields) ->
_pipe = Fields,
gleam@list:filter_map(_pipe, fun(Field) -> case Field of
{some, Pair} ->
{ok, Pair};
none ->
{error, nil}
end end).
-file("src/kitazith/internal/query_helper.gleam", 16).
?DOC(false).
-spec optional(binary(), gleam@option:option(EKI), fun((EKI) -> binary())) -> gleam@option:option({binary(),
binary()}).
optional(Key, Value, Encoder) ->
case Value of
{some, Value@1} ->
{some, {Key, Encoder(Value@1)}};
none ->
none
end.
-file("src/kitazith/internal/query_helper.gleam", 27).
?DOC(false).
-spec bool(boolean()) -> binary().
bool(Value) ->
case Value of
true ->
<<"true"/utf8>>;
false ->
<<"false"/utf8>>
end.