Stage 3.4
This commit is contained in:
@@ -23,7 +23,8 @@ create_calendar(Req) ->
|
||||
case Decoded of
|
||||
#{<<"title">> := Title} ->
|
||||
Description = maps:get(<<"description">>, Decoded, <<"">>),
|
||||
case logic_calendar:create_calendar(UserId, Title, Description) of
|
||||
Confirmation = parse_confirmation(maps:get(<<"confirmation">>, Decoded, <<"manual">>)),
|
||||
case logic_calendar:create_calendar(UserId, Title, Description, Confirmation) of
|
||||
{ok, Calendar} ->
|
||||
Response = calendar_to_json(Calendar),
|
||||
send_json(Req2, 201, Response);
|
||||
@@ -45,6 +46,11 @@ create_calendar(Req) ->
|
||||
send_error(Req1, Code, Message)
|
||||
end.
|
||||
|
||||
parse_confirmation(<<"auto">>) -> auto;
|
||||
parse_confirmation(<<"manual">>) -> manual;
|
||||
parse_confirmation(#{<<"timeout">> := N}) when is_integer(N), N > 0 -> {timeout, N};
|
||||
parse_confirmation(_) -> manual.
|
||||
|
||||
%% GET /v1/calendars - список календарей
|
||||
list_calendars(Req) ->
|
||||
case handler_auth:authenticate(Req) of
|
||||
|
||||
Reference in New Issue
Block a user