Current section
Files
Jump to
Current section
Files
src/glitch@types@grant.erl
-module(glitch@types@grant).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([to_string/1, from_string/1]).
-export_type([grant_type/0]).
-type grant_type() :: authorization_code |
client_credentials |
refresh_token |
device_code |
implicit.
-spec to_string(grant_type()) -> binary().
to_string(Grant_type) ->
case Grant_type of
authorization_code ->
<<"authorization_code"/utf8>>;
client_credentials ->
<<"client_credentials"/utf8>>;
refresh_token ->
<<"refresh_token"/utf8>>;
device_code ->
<<"device_code"/utf8>>;
implicit ->
<<"implicit"/utf8>>
end.
-spec from_string(binary()) -> {ok, grant_type()} | {error, nil}.
from_string(Str) ->
case Str of
<<"authorization_code"/utf8>> ->
{ok, authorization_code};
<<"client_credentials"/utf8>> ->
{ok, client_credentials};
<<"refresh_token"/utf8>> ->
{ok, refresh_token};
<<"device_code"/utf8>> ->
{ok, device_code};
<<"implicit"/utf8>> ->
{ok, implicit};
_ ->
{error, nil}
end.