Current section
Files
Jump to
Current section
Files
src/flwr_oauth2@revocation.erl
-module(flwr_oauth2@revocation).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/flwr_oauth2/revocation.gleam").
-export([to_http_request/1]).
-export_type([revocation_request/0, token_type_hint/0]).
-type revocation_request() :: {revocation_request,
gleam@uri:uri(),
binary(),
gleam@option:option(token_type_hint()),
flwr_oauth2:client_authentication()}.
-type token_type_hint() :: access_token | refresh_token | {other, binary()}.
-file("src/flwr_oauth2/revocation.gleam", 29).
-spec to_http_request(revocation_request()) -> {ok,
gleam@http@request:request(binary())} |
{error, flwr_oauth2:error()}.
to_http_request(Revocation_request) ->
Hint@2 = begin
gleam@option:map(
erlang:element(4, Revocation_request),
fun(Hint) ->
Token_type = case Hint of
access_token ->
<<"access_token"/utf8>>;
refresh_token ->
<<"refresh_token"/utf8>>;
{other, Hint@1} ->
Hint@1
end,
{<<"token_type_hint"/utf8>>, Token_type}
end
)
end,
Body = begin
_pipe = [{<<"token"/utf8>>, erlang:element(3, Revocation_request)}],
flwr_oauth2@helpers:add_if_present(_pipe, Hint@2)
end,
flwr_oauth2:setup_request(
erlang:element(2, Revocation_request),
Body,
erlang:element(5, Revocation_request)
).