fix: persist specialist_id on event create; 402 commercial without active sub. Fixes EventHub/EventHubBack#61
CI / test (push) Failing after 6m52s
CI / deploy-ift (push) Has been skipped
CI / e2e-ift (push) Has been skipped
CI / deploy-stage (push) Has been skipped
CI / e2e-stage (push) Has been skipped

This commit is contained in:
2026-07-27 21:17:15 +03:00
parent edb7c20f70
commit 81728301e2
9 changed files with 115 additions and 54 deletions
+17
View File
@@ -409,9 +409,26 @@ register_and_login(Email, Password) ->
-spec create_calendar(binary(), map()) -> binary().
create_calendar(Token, Params) ->
Type = maps:get(type, Params, maps:get(<<"type">>, Params, <<"personal">>)),
case Type of
<<"commercial">> -> ensure_commercial_subscription(Token);
commercial -> ensure_commercial_subscription(Token);
_ -> ok
end,
#{<<"id">> := CalId} = client_post(<<"/v1/calendars">>, Token, Params),
CalId.
-spec ensure_commercial_subscription(binary()) -> ok.
ensure_commercial_subscription(Token) ->
case client_request(post, <<"/v1/subscription">>, Token,
jsx:encode(#{action => <<"start_trial">>})) of
{ok, 201, _, _} -> ok;
{ok, 200, _, _} -> ok;
{ok, 409, _, _} -> ok; %% already has subscription / trial used with active
{ok, 400, _, _} -> ok; %% trial_already_used — may still have active paid
_ -> ok
end.
-spec create_event(binary(), binary(), map()) -> binary().
create_event(Token, CalId, Params) ->
Path = <<"/v1/calendars/", CalId/binary, "/events">>,