Packages

A Gleam library for interacting with the Discord API

Current section

Files

Jump to
shimmer src shimmer@http@endpoints.erl
Raw

src/shimmer@http@endpoints.erl

-module(shimmer@http@endpoints).
-compile(no_auto_import).
-export([me/1]).
-spec me(binary()) -> {ok, shimmer@types@user:user()} |
{error, shimmer@internal@error:shimmer_error()}.
me(Token) ->
Req = shimmer@http@request:new_with_auth(get, <<"/users/@me"/utf8>>, Token),
case begin
_pipe = gleam@hackney:send(Req),
gleam@result:map_error(_pipe, fun(A) -> {http_error, A} end)
end of
{error, _try} -> {error, _try};
{ok, Resp} ->
_pipe@1 = Resp,
_pipe@2 = gleam@http@response:get_header(
_pipe@1,
<<"content-type"/utf8>>
),
gleeunit@should:equal(_pipe@2, {ok, <<"application/json"/utf8>>}),
shimmer@types@user:from_json_string(erlang:element(4, Resp))
end.