Implement commercial calendars: booking_open, specialists, expire without type downgrade.
Refs EventHub/EventHubBack#54
This commit is contained in:
@@ -139,9 +139,13 @@ update_calendar(Req) ->
|
||||
Updates = convert_calendar_fields(Updates0),
|
||||
case logic_calendar:update_calendar(UserId, CalendarId, Updates) of
|
||||
{ok, Calendar} ->
|
||||
handler_utils:send_json(Req2, 200, handler_utils:calendar_to_json(Calendar));
|
||||
Json0 = handler_utils:calendar_to_json(Calendar),
|
||||
Following = logic_calendar_follow:is_following(UserId, CalendarId),
|
||||
handler_utils:send_json(Req2, 200, Json0#{following => Following});
|
||||
{error, access_denied} ->
|
||||
handler_utils:send_error(Req2, 403, <<"Access denied">>);
|
||||
{error, subscription_required} ->
|
||||
handler_utils:send_error(Req2, 402, <<"Subscription required for commercial calendar">>);
|
||||
{error, not_found} ->
|
||||
handler_utils:send_error(Req2, 404, <<"Calendar not found">>);
|
||||
{error, _} ->
|
||||
@@ -182,6 +186,8 @@ convert_calendar_fields(Updates) ->
|
||||
-spec convert_field({binary(), term()}) -> {atom(), term()}.
|
||||
convert_field({<<"title">>, Val}) -> {title, Val};
|
||||
convert_field({<<"description">>, Val}) -> {description, Val};
|
||||
convert_field({<<"type">>, <<"personal">>}) -> {type, personal};
|
||||
convert_field({<<"type">>, <<"commercial">>}) -> {type, commercial};
|
||||
convert_field({<<"type">>, Val}) -> {type, Val};
|
||||
convert_field({<<"confirmation">>, <<"auto">>}) -> {confirmation, auto};
|
||||
convert_field({<<"confirmation">>, <<"manual">>}) -> {confirmation, manual};
|
||||
|
||||
Reference in New Issue
Block a user