mirror of
https://github.com/valitydev/hellgate.git
synced 2024-11-06 02:45:20 +00:00
Fully embrace new woody args-are-tuples convention (#480)
This commit is contained in:
parent
29e2421b80
commit
d95579a0d7
@ -61,7 +61,7 @@
|
||||
account().
|
||||
|
||||
get_account(AccountID) ->
|
||||
case call_accounter('GetAccountByID', [AccountID]) of
|
||||
case call_accounter('GetAccountByID', {AccountID}) of
|
||||
{ok, Result} ->
|
||||
construct_account(AccountID, Result);
|
||||
{exception, #shumpune_AccountNotFound{}} ->
|
||||
@ -78,7 +78,7 @@ get_balance(AccountID) ->
|
||||
balance().
|
||||
|
||||
get_balance(AccountID, Clock) ->
|
||||
case call_accounter('GetBalanceByID', [AccountID, Clock]) of
|
||||
case call_accounter('GetBalanceByID', {AccountID, Clock}) of
|
||||
{ok, Result} ->
|
||||
construct_balance(AccountID, Result);
|
||||
{exception, #shumpune_AccountNotFound{}} ->
|
||||
@ -95,7 +95,7 @@ create_account(CurrencyCode) ->
|
||||
account_id().
|
||||
|
||||
create_account(CurrencyCode, Description) ->
|
||||
case call_accounter('CreateAccount', [construct_prototype(CurrencyCode, Description)]) of
|
||||
case call_accounter('CreateAccount', {construct_prototype(CurrencyCode, Description)}) of
|
||||
{ok, Result} ->
|
||||
Result;
|
||||
{exception, Exception} ->
|
||||
@ -191,7 +191,7 @@ rollback(PlanID, Batches) ->
|
||||
do('RollbackPlan', construct_plan(PlanID, Batches)).
|
||||
|
||||
do(Op, Plan) ->
|
||||
case call_accounter(Op, [Plan]) of
|
||||
case call_accounter(Op, {Plan}) of
|
||||
{ok, Clock} ->
|
||||
Clock;
|
||||
{exception, Exception} ->
|
||||
|
@ -54,12 +54,11 @@
|
||||
-spec handle_function(woody:func(), woody:args(), hg_woody_wrapper:handler_opts()) ->
|
||||
term() | no_return().
|
||||
handle_function(Func, Args, Opts) ->
|
||||
ArgsList = tuple_to_list(Args),
|
||||
scoper:scope(customer_management,
|
||||
fun() -> handle_function_(Func, ArgsList, Opts) end
|
||||
fun() -> handle_function_(Func, Args, Opts) end
|
||||
).
|
||||
|
||||
handle_function_('Create', [CustomerParams], _Opts) ->
|
||||
handle_function_('Create', {CustomerParams}, _Opts) ->
|
||||
DomainRevison = hg_domain:head(),
|
||||
CustomerID = hg_utils:unique_id(),
|
||||
ok = set_meta(CustomerID),
|
||||
@ -74,19 +73,19 @@ handle_function_('Create', [CustomerParams], _Opts) ->
|
||||
get_customer(get_state(CustomerID));
|
||||
|
||||
%% TODO Удалить после перехода на новый протокол
|
||||
handle_function_('Get', [CustomerID, undefined], _Opts) ->
|
||||
handle_function_('Get', {CustomerID, undefined}, _Opts) ->
|
||||
ok = set_meta(CustomerID),
|
||||
St = get_state(CustomerID),
|
||||
ok = assert_customer_accessible(St),
|
||||
get_customer(St);
|
||||
|
||||
handle_function_('Get', [CustomerID, #payproc_EventRange{'after' = AfterID, limit = Limit}], _Opts) ->
|
||||
handle_function_('Get', {CustomerID, #payproc_EventRange{'after' = AfterID, limit = Limit}}, _Opts) ->
|
||||
ok = set_meta(CustomerID),
|
||||
St = get_state(CustomerID, AfterID, Limit),
|
||||
ok = assert_customer_accessible(St),
|
||||
get_customer(St);
|
||||
|
||||
handle_function_('GetActiveBinding', [CustomerID], _Opts) ->
|
||||
handle_function_('GetActiveBinding', {CustomerID}, _Opts) ->
|
||||
ok = set_meta(CustomerID),
|
||||
St = get_state(CustomerID),
|
||||
ok = assert_customer_accessible(St),
|
||||
@ -97,15 +96,16 @@ handle_function_('GetActiveBinding', [CustomerID], _Opts) ->
|
||||
throw(?invalid_customer_status(get_customer_status(get_customer(St))))
|
||||
end;
|
||||
|
||||
handle_function_('GetEvents', [CustomerID, Range], _Opts) ->
|
||||
handle_function_('GetEvents', {CustomerID, Range}, _Opts) ->
|
||||
ok = set_meta(CustomerID),
|
||||
ok = assert_customer_accessible(get_initial_state(CustomerID)),
|
||||
get_public_history(CustomerID, Range);
|
||||
|
||||
handle_function_(Fun, [CustomerID | _Tail] = Args, _Opts) when
|
||||
handle_function_(Fun, Args, _Opts) when
|
||||
Fun =:= 'Delete' orelse
|
||||
Fun =:= 'StartBinding'
|
||||
->
|
||||
CustomerID = element(1, Args),
|
||||
ok = set_meta(CustomerID),
|
||||
call(CustomerID, Fun, Args).
|
||||
|
||||
@ -276,13 +276,13 @@ process_call(Call, #{history := History}) ->
|
||||
{{exception, Exception}, #{}}
|
||||
end.
|
||||
|
||||
handle_call({{'CustomerManagement', 'Delete'}, [_CustomerID]}, St) ->
|
||||
handle_call({{'CustomerManagement', 'Delete'}, {_CustomerID}}, St) ->
|
||||
ok = assert_customer_operable(St),
|
||||
#{
|
||||
response => ok,
|
||||
changes => [?customer_deleted()]
|
||||
};
|
||||
handle_call({{'CustomerManagement', 'StartBinding'}, [_CustomerID, BindingParams]}, St) ->
|
||||
handle_call({{'CustomerManagement', 'StartBinding'}, {_CustomerID, BindingParams}}, St) ->
|
||||
ok = assert_customer_operable(St),
|
||||
start_binding(BindingParams, St).
|
||||
|
||||
@ -446,10 +446,10 @@ create_paytool_params(
|
||||
}.
|
||||
|
||||
create_recurrent_paytool(Params) ->
|
||||
issue_recurrent_paytools_call('Create', [Params]).
|
||||
issue_recurrent_paytools_call('Create', {Params}).
|
||||
|
||||
get_recurrent_paytool_events(RecurrentPaytoolID, EventRange) ->
|
||||
issue_recurrent_paytools_call('GetEvents', [RecurrentPaytoolID, EventRange]).
|
||||
issue_recurrent_paytools_call('GetEvents', {RecurrentPaytoolID, EventRange}).
|
||||
|
||||
get_recurrent_paytool_changes(RecurrentPaytoolID, LastEventID) ->
|
||||
EventRange = construct_event_range(LastEventID),
|
||||
|
@ -46,11 +46,11 @@ get_history_range(EventSinkID, After, Limit) ->
|
||||
|
||||
get_history_range(EventSinkID, After, Limit, Direction) ->
|
||||
HistoryRange = #mg_stateproc_HistoryRange{'after' = After, limit = Limit, direction = Direction},
|
||||
{ok, History} = call_event_sink('GetHistory', EventSinkID, [HistoryRange]),
|
||||
{ok, History} = call_event_sink('GetHistory', {EventSinkID, HistoryRange}),
|
||||
map_sink_events(History).
|
||||
|
||||
call_event_sink(Function, EventSinkID, Args) ->
|
||||
hg_woody_wrapper:call(eventsink, Function, [EventSinkID | Args]).
|
||||
call_event_sink(Function, Args) ->
|
||||
hg_woody_wrapper:call(eventsink, Function, Args).
|
||||
|
||||
map_sink_events(History) ->
|
||||
[map_sink_event(Ev) || Ev <- History].
|
||||
|
@ -144,7 +144,7 @@ build_operation_id(ServiceType, ID) ->
|
||||
{ok, initialised} | {error, any()} | disabled.
|
||||
init_service(ServiceId) ->
|
||||
ServiceConfig = build_config(),
|
||||
call('InitService', [ServiceId, ServiceConfig]).
|
||||
call('InitService', {ServiceId, ServiceConfig}).
|
||||
|
||||
%%------------------------------------------------------------------------------
|
||||
%% @doc
|
||||
@ -155,7 +155,7 @@ init_service(ServiceId) ->
|
||||
-spec init_service(service_id(), service_config()) ->
|
||||
{ok, initialised} | {error, any()} | disabled.
|
||||
init_service(ServiceId, ServiceConfig) ->
|
||||
call('InitService', [ServiceId, ServiceConfig]).
|
||||
call('InitService', {ServiceId, ServiceConfig}).
|
||||
|
||||
%%------------------------------------------------------------------------------
|
||||
%% @doc
|
||||
@ -168,7 +168,7 @@ init_service(ServiceId, ServiceConfig) ->
|
||||
%%------------------------------------------------------------------------------
|
||||
-spec get_statistics([service_id()]) -> [service_stats()].
|
||||
get_statistics(ServiceIds) when is_list(ServiceIds) ->
|
||||
call('GetStatistics', [ServiceIds]).
|
||||
call('GetStatistics', {ServiceIds}).
|
||||
|
||||
%%------------------------------------------------------------------------------
|
||||
%% @doc
|
||||
@ -201,7 +201,7 @@ register_operation(Status, ServiceId, OperationId, ServiceConfig) ->
|
||||
finish -> {Status, ?state_finish(hg_datetime:format_now())}
|
||||
end,
|
||||
Operation = ?operation(OperationId, OperationState),
|
||||
call('RegisterOperation', [ServiceId, Operation, ServiceConfig]).
|
||||
call('RegisterOperation', {ServiceId, Operation, ServiceConfig}).
|
||||
|
||||
%% PRIVATE
|
||||
|
||||
@ -220,41 +220,37 @@ maybe_call(false = _FDEnabled, 'GetStatistics', _Args, _Opts, _Deadline) ->
|
||||
maybe_call(false = _FDEnabled, _Service, _Args, _Opts, _Deadline) ->
|
||||
disabled.
|
||||
|
||||
do_call('InitService', Args, Opts, Deadline) ->
|
||||
do_call('InitService', {ServiceId, _ServiceConfig} = Args, Opts, Deadline) ->
|
||||
try hg_woody_wrapper:call(fault_detector, 'InitService', Args, Opts, Deadline) of
|
||||
{ok, _Result} -> {ok, initialised}
|
||||
catch
|
||||
error:{woody_error, {_Source, Class, _Details}} = Reason
|
||||
when Class =:= resource_unavailable orelse
|
||||
Class =:= result_unknown ->
|
||||
[ServiceId | _] = Args,
|
||||
ErrorText = "Unable to init service ~p in fault detector, ~p:~p",
|
||||
_ = logger:warning(ErrorText, [ServiceId, error, Reason]),
|
||||
{error, Reason};
|
||||
error:{woody_error, {_Source, result_unexpected, _Details}} = Reason ->
|
||||
[ServiceId | _] = Args,
|
||||
ErrorText = "Unable to init service ~p in fault detector, ~p:~p",
|
||||
_ = logger:error(ErrorText, [ServiceId, error, Reason]),
|
||||
{error, Reason}
|
||||
end;
|
||||
do_call('GetStatistics', Args, Opts, Deadline) ->
|
||||
do_call('GetStatistics', {ServiceIds} = Args, Opts, Deadline) ->
|
||||
try hg_woody_wrapper:call(fault_detector, 'GetStatistics', Args, Opts, Deadline) of
|
||||
{ok, Stats} -> Stats
|
||||
catch
|
||||
error:{woody_error, {_Source, Class, _Details}} = Reason
|
||||
when Class =:= resource_unavailable orelse
|
||||
Class =:= result_unknown ->
|
||||
[ServiceIds | _] = Args,
|
||||
String = "Unable to get statistics for services ~p from fault detector, ~p:~p",
|
||||
_ = logger:warning(String, [ServiceIds, error, Reason]),
|
||||
[];
|
||||
error:{woody_error, {_Source, result_unexpected, _Details}} = Reason ->
|
||||
[ServiceIds | _] = Args,
|
||||
String = "Unable to get statistics for services ~p from fault detector, ~p:~p",
|
||||
_ = logger:error(String, [ServiceIds, error, Reason]),
|
||||
[]
|
||||
end;
|
||||
do_call('RegisterOperation', Args, Opts, Deadline) ->
|
||||
do_call('RegisterOperation', {ServiceId, OperationId, _ServiceConfig} = Args, Opts, Deadline) ->
|
||||
try hg_woody_wrapper:call(fault_detector, 'RegisterOperation', Args, Opts, Deadline) of
|
||||
{ok, _Result} ->
|
||||
{ok, registered};
|
||||
@ -264,12 +260,10 @@ do_call('RegisterOperation', Args, Opts, Deadline) ->
|
||||
error:{woody_error, {_Source, Class, _Details}} = Reason
|
||||
when Class =:= resource_unavailable orelse
|
||||
Class =:= result_unknown ->
|
||||
[ServiceId, OperationId | _] = Args,
|
||||
ErrorText = "Unable to register operation ~p for service ~p in fault detector, ~p:~p",
|
||||
_ = logger:warning(ErrorText, [OperationId, ServiceId, error, Reason]),
|
||||
{error, Reason};
|
||||
error:{woody_error, {_Source, result_unexpected, _Details}} = Reason ->
|
||||
[ServiceId, OperationId | _] = Args,
|
||||
ErrorText = "Unable to register operation ~p for service ~p in fault detector, ~p:~p",
|
||||
_ = logger:error(ErrorText, [OperationId, ServiceId, error, Reason]),
|
||||
{error, Reason}
|
||||
|
@ -32,7 +32,7 @@ inspect(
|
||||
payment = get_payment_info(Shop, Invoice, Payment),
|
||||
options = maps:merge(ProxyDef#domain_ProxyDefinition.options, ProxyAdditional)
|
||||
},
|
||||
Result = issue_call('InspectPayment', [Context], hg_proxy:get_call_options(Proxy,
|
||||
Result = issue_call('InspectPayment', {Context}, hg_proxy:get_call_options(Proxy,
|
||||
Revision), FallBackRiskScore, DeadLine),
|
||||
case Result of
|
||||
{ok, RiskScore} when is_atom(RiskScore) ->
|
||||
|
@ -137,15 +137,14 @@ get_payment_opts(Revision, _, St = #st{invoice = Invoice}) ->
|
||||
term() | no_return().
|
||||
|
||||
handle_function(Func, Args, Opts) ->
|
||||
ArgsList = tuple_to_list(Args),
|
||||
scoper:scope(invoicing,
|
||||
fun() -> handle_function_(Func, ArgsList, Opts) end
|
||||
fun() -> handle_function_(Func, Args, Opts) end
|
||||
).
|
||||
|
||||
-spec handle_function_(woody:func(), list(), hg_woody_wrapper:handler_opts()) ->
|
||||
-spec handle_function_(woody:func(), woody:args(), hg_woody_wrapper:handler_opts()) ->
|
||||
term() | no_return().
|
||||
|
||||
handle_function_('Create', [UserInfo, InvoiceParams], _Opts) ->
|
||||
handle_function_('Create', {UserInfo, InvoiceParams}, _Opts) ->
|
||||
TimestampNow = hg_datetime:format_now(),
|
||||
DomainRevision = hg_domain:head(),
|
||||
InvoiceID = hg_utils:uid(InvoiceParams#payproc_InvoiceParams.id),
|
||||
@ -159,10 +158,10 @@ handle_function_('Create', [UserInfo, InvoiceParams], _Opts) ->
|
||||
_ = assert_party_shop_operable(Shop, Party),
|
||||
MerchantTerms = get_merchant_terms(Party, DomainRevision, Shop, TimestampNow),
|
||||
ok = validate_invoice_params(InvoiceParams, Party, Shop, MerchantTerms, DomainRevision),
|
||||
ok = ensure_started(InvoiceID, [undefined, Party#domain_Party.revision, InvoiceParams]),
|
||||
ok = ensure_started(InvoiceID, {undefined, Party#domain_Party.revision, InvoiceParams}),
|
||||
get_invoice_state(get_state(InvoiceID));
|
||||
|
||||
handle_function_('CreateWithTemplate', [UserInfo, Params], _Opts) ->
|
||||
handle_function_('CreateWithTemplate', {UserInfo, Params}, _Opts) ->
|
||||
TimestampNow = hg_datetime:format_now(),
|
||||
DomainRevision = hg_domain:head(),
|
||||
InvoiceID = hg_utils:uid(Params#payproc_InvoiceWithTemplateParams.id),
|
||||
@ -172,63 +171,63 @@ handle_function_('CreateWithTemplate', [UserInfo, Params], _Opts) ->
|
||||
{Party, Shop, InvoiceParams} = make_invoice_params(Params),
|
||||
MerchantTerms = get_merchant_terms(Party, DomainRevision, Shop, TimestampNow),
|
||||
ok = validate_invoice_params(InvoiceParams, Party, Shop, MerchantTerms, DomainRevision),
|
||||
ok = ensure_started(InvoiceID, [TplID, Party#domain_Party.revision, InvoiceParams]),
|
||||
ok = ensure_started(InvoiceID, {TplID, Party#domain_Party.revision, InvoiceParams}),
|
||||
get_invoice_state(get_state(InvoiceID));
|
||||
|
||||
handle_function_('CapturePaymentNew', Args, Opts) ->
|
||||
handle_function_('CapturePayment', Args, Opts);
|
||||
|
||||
handle_function_('Get', [UserInfo, InvoiceID, #payproc_EventRange{'after' = AfterID, limit = Limit}], _Opts) ->
|
||||
handle_function_('Get', {UserInfo, InvoiceID, #payproc_EventRange{'after' = AfterID, limit = Limit}}, _Opts) ->
|
||||
ok = assume_user_identity(UserInfo),
|
||||
_ = set_invoicing_meta(InvoiceID),
|
||||
St = assert_invoice_accessible(get_state(InvoiceID, AfterID, Limit)),
|
||||
get_invoice_state(St);
|
||||
|
||||
%% TODO Удалить после перехода на новый протокол
|
||||
handle_function_('Get', [UserInfo, InvoiceID, undefined], _Opts) ->
|
||||
handle_function_('Get', {UserInfo, InvoiceID, undefined}, _Opts) ->
|
||||
ok = assume_user_identity(UserInfo),
|
||||
_ = set_invoicing_meta(InvoiceID),
|
||||
St = assert_invoice_accessible(get_state(InvoiceID)),
|
||||
get_invoice_state(St);
|
||||
|
||||
handle_function_('GetEvents', [UserInfo, InvoiceID, Range], _Opts) ->
|
||||
handle_function_('GetEvents', {UserInfo, InvoiceID, Range}, _Opts) ->
|
||||
ok = assume_user_identity(UserInfo),
|
||||
_ = set_invoicing_meta(InvoiceID),
|
||||
_ = assert_invoice_accessible(get_initial_state(InvoiceID)),
|
||||
get_public_history(InvoiceID, Range);
|
||||
|
||||
handle_function_('GetInvoiceAdjustment', [UserInfo, InvoiceID, ID], _Opts) ->
|
||||
handle_function_('GetInvoiceAdjustment', {UserInfo, InvoiceID, ID}, _Opts) ->
|
||||
St = assert_invoice_accessible(get_state(InvoiceID)),
|
||||
ok = assume_user_identity(UserInfo),
|
||||
ok = set_invoicing_meta(InvoiceID),
|
||||
get_adjustment(ID, St);
|
||||
|
||||
handle_function_('GetPayment', [UserInfo, InvoiceID, PaymentID], _Opts) ->
|
||||
handle_function_('GetPayment', {UserInfo, InvoiceID, PaymentID}, _Opts) ->
|
||||
ok = assume_user_identity(UserInfo),
|
||||
_ = set_invoicing_meta(InvoiceID, PaymentID),
|
||||
St = assert_invoice_accessible(get_state(InvoiceID)),
|
||||
get_payment_state(get_payment_session(PaymentID, St));
|
||||
|
||||
handle_function_('GetPaymentRefund', [UserInfo, InvoiceID, PaymentID, ID], _Opts) ->
|
||||
handle_function_('GetPaymentRefund', {UserInfo, InvoiceID, PaymentID, ID}, _Opts) ->
|
||||
ok = assume_user_identity(UserInfo),
|
||||
_ = set_invoicing_meta(InvoiceID, PaymentID),
|
||||
St = assert_invoice_accessible(get_state(InvoiceID)),
|
||||
hg_invoice_payment:get_refund(ID, get_payment_session(PaymentID, St));
|
||||
|
||||
handle_function_('GetPaymentChargeback', [UserInfo, InvoiceID, PaymentID, ID], _Opts) ->
|
||||
handle_function_('GetPaymentChargeback', {UserInfo, InvoiceID, PaymentID, ID}, _Opts) ->
|
||||
ok = assume_user_identity(UserInfo),
|
||||
_ = set_invoicing_meta(InvoiceID, PaymentID),
|
||||
St = assert_invoice_accessible(get_state(InvoiceID)),
|
||||
CBSt = hg_invoice_payment:get_chargeback_state(ID, get_payment_session(PaymentID, St)),
|
||||
hg_invoice_payment_chargeback:get(CBSt);
|
||||
|
||||
handle_function_('GetPaymentAdjustment', [UserInfo, InvoiceID, PaymentID, ID], _Opts) ->
|
||||
handle_function_('GetPaymentAdjustment', {UserInfo, InvoiceID, PaymentID, ID}, _Opts) ->
|
||||
ok = assume_user_identity(UserInfo),
|
||||
_ = set_invoicing_meta(InvoiceID, PaymentID),
|
||||
St = assert_invoice_accessible(get_state(InvoiceID)),
|
||||
hg_invoice_payment:get_adjustment(ID, get_payment_session(PaymentID, St));
|
||||
|
||||
handle_function_('ComputeTerms', [UserInfo, InvoiceID, PartyRevision0], _Opts) ->
|
||||
handle_function_('ComputeTerms', {UserInfo, InvoiceID, PartyRevision0}, _Opts) ->
|
||||
ok = assume_user_identity(UserInfo),
|
||||
_ = set_invoicing_meta(InvoiceID),
|
||||
St = assert_invoice_accessible(get_state(InvoiceID)),
|
||||
@ -247,7 +246,7 @@ handle_function_('ComputeTerms', [UserInfo, InvoiceID, PartyRevision0], _Opts) -
|
||||
Cash = get_cost(St),
|
||||
pm_party:reduce_terms(ShopTerms, #{cost => Cash}, Revision);
|
||||
|
||||
handle_function_(Fun, [UserInfo, InvoiceID | _Tail] = Args, _Opts) when
|
||||
handle_function_(Fun, Args, _Opts) when
|
||||
Fun =:= 'StartPayment' orelse
|
||||
Fun =:= 'CapturePayment' orelse
|
||||
Fun =:= 'CancelPayment' orelse
|
||||
@ -267,17 +266,19 @@ handle_function_(Fun, [UserInfo, InvoiceID | _Tail] = Args, _Opts) when
|
||||
Fun =:= 'Fulfill' orelse
|
||||
Fun =:= 'Rescind'
|
||||
->
|
||||
UserInfo = erlang:element(1, Args),
|
||||
InvoiceID = erlang:element(2, Args),
|
||||
ok = assume_user_identity(UserInfo),
|
||||
_ = set_invoicing_meta(InvoiceID),
|
||||
call(InvoiceID, Fun, Args);
|
||||
|
||||
handle_function_('Repair', [UserInfo, InvoiceID, Changes, Action, Params], _Opts) ->
|
||||
handle_function_('Repair', {UserInfo, InvoiceID, Changes, Action, Params}, _Opts) ->
|
||||
ok = assume_user_identity(UserInfo),
|
||||
_ = set_invoicing_meta(InvoiceID),
|
||||
_ = assert_invoice_accessible(get_initial_state(InvoiceID)),
|
||||
repair(InvoiceID, {changes, Changes, Action, Params});
|
||||
|
||||
handle_function_('RepairWithScenario', [UserInfo, InvoiceID, Scenario], _Opts) ->
|
||||
handle_function_('RepairWithScenario', {UserInfo, InvoiceID, Scenario}, _Opts) ->
|
||||
ok = assume_user_identity(UserInfo),
|
||||
_ = set_invoicing_meta(InvoiceID),
|
||||
_ = assert_invoice_accessible(get_initial_state(InvoiceID)),
|
||||
@ -394,8 +395,8 @@ publish_invoice_event(InvoiceID, {ID, Dt, Event}) ->
|
||||
payload = ?invoice_ev(Event)
|
||||
}.
|
||||
|
||||
ensure_started(ID, [TemplateID, PartyRevision, Params]) ->
|
||||
SerializedArgs = [TemplateID, PartyRevision, marshal_invoice_params(Params)],
|
||||
ensure_started(ID, {TemplateID, PartyRevision, Params}) ->
|
||||
SerializedArgs = {TemplateID, PartyRevision, marshal_invoice_params(Params)},
|
||||
map_start_error(do_start(ID, SerializedArgs)).
|
||||
|
||||
do_start(ID, Args) ->
|
||||
@ -483,10 +484,13 @@ publish_event(InvoiceID, Payload) ->
|
||||
namespace() ->
|
||||
?NS.
|
||||
|
||||
-spec init([invoice_tpl_id() | invoice_params()], hg_machine:machine()) ->
|
||||
-spec init(
|
||||
{invoice_tpl_id() | undefined, hg_party:party_revision() | undefined, binary()},
|
||||
hg_machine:machine()
|
||||
) ->
|
||||
hg_machine:result().
|
||||
|
||||
init([InvoiceTplID, PartyRevision, EncodedInvoiceParams], #{id := ID}) ->
|
||||
init({InvoiceTplID, PartyRevision, EncodedInvoiceParams}, #{id := ID}) ->
|
||||
InvoiceParams = unmarshal_invoice_params(EncodedInvoiceParams),
|
||||
Invoice = create_invoice(ID, InvoiceTplID, PartyRevision, InvoiceParams),
|
||||
% TODO ugly, better to roll state and events simultaneously, hg_party-like
|
||||
@ -599,14 +603,14 @@ process_call(Call, #{history := History}) ->
|
||||
-spec handle_call(call(), st()) ->
|
||||
call_result().
|
||||
|
||||
handle_call({{'Invoicing', 'StartPayment'}, [_UserInfo, _InvoiceID, PaymentParams]}, St) ->
|
||||
handle_call({{'Invoicing', 'StartPayment'}, {_UserInfo, _InvoiceID, PaymentParams}}, St) ->
|
||||
% TODO consolidate these assertions somehow
|
||||
_ = assert_invoice_accessible(St),
|
||||
_ = assert_invoice_operable(St),
|
||||
_ = assert_all_adjustments_finalised(St),
|
||||
start_payment(PaymentParams, St);
|
||||
|
||||
handle_call({{'Invoicing', 'CapturePayment'}, [_UserInfo, _InvoiceID, PaymentID, Params]}, St) ->
|
||||
handle_call({{'Invoicing', 'CapturePayment'}, {_UserInfo, _InvoiceID, PaymentID, Params}}, St) ->
|
||||
_ = assert_invoice_accessible(St),
|
||||
_ = assert_invoice_operable(St),
|
||||
#payproc_InvoicePaymentCaptureParams{
|
||||
@ -624,7 +628,7 @@ handle_call({{'Invoicing', 'CapturePayment'}, [_UserInfo, _InvoiceID, PaymentID,
|
||||
state => St
|
||||
};
|
||||
|
||||
handle_call({{'Invoicing', 'CancelPayment'}, [_UserInfo, _InvoiceID, PaymentID, Reason]}, St) ->
|
||||
handle_call({{'Invoicing', 'CancelPayment'}, {_UserInfo, _InvoiceID, PaymentID, Reason}}, St) ->
|
||||
_ = assert_invoice_accessible(St),
|
||||
_ = assert_invoice_operable(St),
|
||||
PaymentSession = get_payment_session(PaymentID, St),
|
||||
@ -637,7 +641,7 @@ handle_call({{'Invoicing', 'CancelPayment'}, [_UserInfo, _InvoiceID, PaymentID,
|
||||
state => St
|
||||
};
|
||||
|
||||
handle_call({{'Invoicing', 'Fulfill'}, [_UserInfo, _InvoiceID, Reason]}, St) ->
|
||||
handle_call({{'Invoicing', 'Fulfill'}, {_UserInfo, _InvoiceID, Reason}}, St) ->
|
||||
_ = assert_invoice_accessible(St),
|
||||
_ = assert_invoice_operable(St),
|
||||
_ = assert_invoice_status(paid, St),
|
||||
@ -647,7 +651,7 @@ handle_call({{'Invoicing', 'Fulfill'}, [_UserInfo, _InvoiceID, Reason]}, St) ->
|
||||
state => St
|
||||
};
|
||||
|
||||
handle_call({{'Invoicing', 'Rescind'}, [_UserInfo, _InvoiceID, Reason]}, St) ->
|
||||
handle_call({{'Invoicing', 'Rescind'}, {_UserInfo, _InvoiceID, Reason}}, St) ->
|
||||
_ = assert_invoice_accessible(St),
|
||||
_ = assert_invoice_operable(St),
|
||||
_ = assert_invoice_status(unpaid, St),
|
||||
@ -659,7 +663,7 @@ handle_call({{'Invoicing', 'Rescind'}, [_UserInfo, _InvoiceID, Reason]}, St) ->
|
||||
state => St
|
||||
};
|
||||
|
||||
handle_call({{'Invoicing', 'CreateInvoiceAdjustment'}, [_UserInfo, _InvoiceID, Params]}, St) ->
|
||||
handle_call({{'Invoicing', 'CreateInvoiceAdjustment'}, {_UserInfo, _InvoiceID, Params}}, St) ->
|
||||
ID = create_adjustment_id(St),
|
||||
St = assert_invoice_accessible(St),
|
||||
TargetStatus = get_adjustment_params_target_status(Params),
|
||||
@ -670,7 +674,7 @@ handle_call({{'Invoicing', 'CreateInvoiceAdjustment'}, [_UserInfo, _InvoiceID, P
|
||||
OccurredAt = hg_datetime:format_now(),
|
||||
wrap_adjustment_impact(ID, hg_invoice_adjustment:create(ID, Params, OccurredAt), St, OccurredAt);
|
||||
|
||||
handle_call({{'Invoicing', 'CaptureAdjustment'}, [_UserInfo, _InvoiceID, ID]}, St) ->
|
||||
handle_call({{'Invoicing', 'CaptureAdjustment'}, {_UserInfo, _InvoiceID, ID}}, St) ->
|
||||
_ = assert_invoice_accessible(St),
|
||||
_ = assert_adjustment_processed(ID, St),
|
||||
OccurredAt = hg_datetime:format_now(),
|
||||
@ -683,7 +687,7 @@ handle_call({{'Invoicing', 'CaptureAdjustment'}, [_UserInfo, _InvoiceID, ID]}, S
|
||||
state => St
|
||||
};
|
||||
|
||||
handle_call({{'Invoicing', 'CancelAdjustment'}, [_UserInfo, _InvoiceID, ID]}, St) ->
|
||||
handle_call({{'Invoicing', 'CancelAdjustment'}, {_UserInfo, _InvoiceID, ID}}, St) ->
|
||||
_ = assert_invoice_accessible(St),
|
||||
_ = assert_adjustment_processed(ID, St),
|
||||
OccurredAt = hg_datetime:format_now(),
|
||||
@ -696,53 +700,53 @@ handle_call({{'Invoicing', 'CancelAdjustment'}, [_UserInfo, _InvoiceID, ID]}, St
|
||||
state => St
|
||||
};
|
||||
|
||||
handle_call({{'Invoicing', 'RefundPayment'}, [_UserInfo, _InvoiceID, PaymentID, Params]}, St) ->
|
||||
handle_call({{'Invoicing', 'RefundPayment'}, {_UserInfo, _InvoiceID, PaymentID, Params}}, St) ->
|
||||
_ = assert_invoice_accessible(St),
|
||||
_ = assert_invoice_operable(St),
|
||||
PaymentSession = get_payment_session(PaymentID, St),
|
||||
start_refund(refund, Params, PaymentID, PaymentSession, St);
|
||||
|
||||
handle_call({{'Invoicing', 'CreateManualRefund'}, [_UserInfo, _InvoiceID, PaymentID, Params]}, St) ->
|
||||
handle_call({{'Invoicing', 'CreateManualRefund'}, {_UserInfo, _InvoiceID, PaymentID, Params}}, St) ->
|
||||
_ = assert_invoice_accessible(St),
|
||||
_ = assert_invoice_operable(St),
|
||||
PaymentSession = get_payment_session(PaymentID, St),
|
||||
start_refund(manual_refund, Params, PaymentID, PaymentSession, St);
|
||||
|
||||
handle_call({{'Invoicing', 'CreateChargeback'}, [_UserInfo, _InvoiceID, PaymentID, Params]}, St) ->
|
||||
handle_call({{'Invoicing', 'CreateChargeback'}, {_UserInfo, _InvoiceID, PaymentID, Params}}, St) ->
|
||||
_ = assert_invoice_accessible(St),
|
||||
PaymentSession = get_payment_session(PaymentID, St),
|
||||
PaymentOpts = get_payment_opts(St),
|
||||
start_chargeback(Params, PaymentID, PaymentSession, PaymentOpts, St);
|
||||
|
||||
handle_call({{'Invoicing', 'CancelChargeback'}, [_UserInfo, _InvoiceID, PaymentID, ChargebackID, Params]}, St) ->
|
||||
handle_call({{'Invoicing', 'CancelChargeback'}, {_UserInfo, _InvoiceID, PaymentID, ChargebackID, Params}}, St) ->
|
||||
#payproc_InvoicePaymentChargebackCancelParams{occurred_at = OccurredAt} = Params,
|
||||
_ = assert_invoice_accessible(St),
|
||||
PaymentSession = get_payment_session(PaymentID, St),
|
||||
CancelResult = hg_invoice_payment:cancel_chargeback(ChargebackID, PaymentSession, Params),
|
||||
wrap_payment_impact(PaymentID, CancelResult, St, OccurredAt);
|
||||
|
||||
handle_call({{'Invoicing', 'RejectChargeback'}, [_UserInfo, _InvoiceID, PaymentID, ChargebackID, Params]}, St) ->
|
||||
handle_call({{'Invoicing', 'RejectChargeback'}, {_UserInfo, _InvoiceID, PaymentID, ChargebackID, Params}}, St) ->
|
||||
#payproc_InvoicePaymentChargebackRejectParams{occurred_at = OccurredAt} = Params,
|
||||
_ = assert_invoice_accessible(St),
|
||||
PaymentSession = get_payment_session(PaymentID, St),
|
||||
RejectResult = hg_invoice_payment:reject_chargeback(ChargebackID, PaymentSession, Params),
|
||||
wrap_payment_impact(PaymentID, RejectResult, St, OccurredAt);
|
||||
|
||||
handle_call({{'Invoicing', 'AcceptChargeback'}, [_UserInfo, _InvoiceID, PaymentID, ChargebackID, Params]}, St) ->
|
||||
handle_call({{'Invoicing', 'AcceptChargeback'}, {_UserInfo, _InvoiceID, PaymentID, ChargebackID, Params}}, St) ->
|
||||
#payproc_InvoicePaymentChargebackAcceptParams{occurred_at = OccurredAt} = Params,
|
||||
_ = assert_invoice_accessible(St),
|
||||
PaymentSession = get_payment_session(PaymentID, St),
|
||||
AcceptResult = hg_invoice_payment:accept_chargeback(ChargebackID, PaymentSession, Params),
|
||||
wrap_payment_impact(PaymentID, AcceptResult, St, OccurredAt);
|
||||
|
||||
handle_call({{'Invoicing', 'ReopenChargeback'}, [_UserInfo, _InvoiceID, PaymentID, ChargebackID, Params]}, St) ->
|
||||
handle_call({{'Invoicing', 'ReopenChargeback'}, {_UserInfo, _InvoiceID, PaymentID, ChargebackID, Params}}, St) ->
|
||||
#payproc_InvoicePaymentChargebackReopenParams{occurred_at = OccurredAt} = Params,
|
||||
_ = assert_invoice_accessible(St),
|
||||
PaymentSession = get_payment_session(PaymentID, St),
|
||||
ReopenResult = hg_invoice_payment:reopen_chargeback(ChargebackID, PaymentSession, Params),
|
||||
wrap_payment_impact(PaymentID, ReopenResult, St, OccurredAt);
|
||||
|
||||
handle_call({{'Invoicing', 'CreatePaymentAdjustment'}, [_UserInfo, _InvoiceID, PaymentID, Params]}, St) ->
|
||||
handle_call({{'Invoicing', 'CreatePaymentAdjustment'}, {_UserInfo, _InvoiceID, PaymentID, Params}}, St) ->
|
||||
_ = assert_invoice_accessible(St),
|
||||
PaymentSession = get_payment_session(PaymentID, St),
|
||||
Timestamp = hg_datetime:format_now(),
|
||||
@ -753,7 +757,7 @@ handle_call({{'Invoicing', 'CreatePaymentAdjustment'}, [_UserInfo, _InvoiceID, P
|
||||
St
|
||||
);
|
||||
|
||||
handle_call({{'Invoicing', 'CapturePaymentAdjustment'}, [_UserInfo, _InvoiceID, PaymentID, ID]}, St) ->
|
||||
handle_call({{'Invoicing', 'CapturePaymentAdjustment'}, {_UserInfo, _InvoiceID, PaymentID, ID}}, St) ->
|
||||
_ = assert_invoice_accessible(St),
|
||||
PaymentSession = get_payment_session(PaymentID, St),
|
||||
Adjustment = hg_invoice_payment:get_adjustment(ID, PaymentSession),
|
||||
@ -765,7 +769,7 @@ handle_call({{'Invoicing', 'CapturePaymentAdjustment'}, [_UserInfo, _InvoiceID,
|
||||
Impact = hg_invoice_payment:capture_adjustment(ID, PaymentSession, PaymentOpts),
|
||||
wrap_payment_impact(PaymentID, Impact, St);
|
||||
|
||||
handle_call({{'Invoicing', 'CancelPaymentAdjustment'}, [_UserInfo, _InvoiceID, PaymentID, ID]}, St) ->
|
||||
handle_call({{'Invoicing', 'CancelPaymentAdjustment'}, {_UserInfo, _InvoiceID, PaymentID, ID}}, St) ->
|
||||
_ = assert_invoice_accessible(St),
|
||||
PaymentSession = get_payment_session(PaymentID, St),
|
||||
Adjustment = hg_invoice_payment:get_adjustment(ID, PaymentSession),
|
||||
|
@ -3418,10 +3418,10 @@ collapse_changes(Changes, St, Opts) ->
|
||||
%%
|
||||
|
||||
get_rec_payment_tool(RecPaymentToolID) ->
|
||||
hg_woody_wrapper:call(recurrent_paytool, 'Get', [RecPaymentToolID]).
|
||||
hg_woody_wrapper:call(recurrent_paytool, 'Get', {RecPaymentToolID}).
|
||||
|
||||
get_customer(CustomerID) ->
|
||||
case issue_customer_call('Get', [CustomerID, #payproc_EventRange{}]) of
|
||||
case issue_customer_call('Get', {CustomerID, #payproc_EventRange{}}) of
|
||||
{ok, Customer} ->
|
||||
Customer;
|
||||
{exception, #payproc_CustomerNotFound{}} ->
|
||||
|
@ -55,15 +55,14 @@ get_invoice_template(ID) ->
|
||||
term() | no_return().
|
||||
|
||||
handle_function(Func, Args, Opts) ->
|
||||
ArgsList = tuple_to_list(Args),
|
||||
scoper:scope(invoice_templating,
|
||||
fun() -> handle_function_(Func, ArgsList, Opts) end
|
||||
fun() -> handle_function_(Func, Args, Opts) end
|
||||
).
|
||||
|
||||
-spec handle_function_(woody:func(), list(), hg_woody_wrapper:handler_opts()) ->
|
||||
-spec handle_function_(woody:func(), woody:args(), hg_woody_wrapper:handler_opts()) ->
|
||||
term() | no_return().
|
||||
|
||||
handle_function_('Create', [UserInfo, Params], _Opts) ->
|
||||
handle_function_('Create', {UserInfo, Params}, _Opts) ->
|
||||
TplID = hg_utils:unique_id(),
|
||||
ok = assume_user_identity(UserInfo),
|
||||
_ = set_meta(TplID),
|
||||
@ -73,14 +72,14 @@ handle_function_('Create', [UserInfo, Params], _Opts) ->
|
||||
ok = start(TplID, Params),
|
||||
get_invoice_template(TplID);
|
||||
|
||||
handle_function_('Get', [UserInfo, TplID], _Opts) ->
|
||||
handle_function_('Get', {UserInfo, TplID}, _Opts) ->
|
||||
ok = assume_user_identity(UserInfo),
|
||||
_ = set_meta(TplID),
|
||||
Tpl = get_invoice_template(TplID),
|
||||
_ = hg_invoice_utils:assert_party_accessible(Tpl#domain_InvoiceTemplate.owner_id),
|
||||
Tpl;
|
||||
|
||||
handle_function_('Update' = Fun, [UserInfo, TplID, Params] = Args, _Opts) ->
|
||||
handle_function_('Update' = Fun, {UserInfo, TplID, Params} = Args, _Opts) ->
|
||||
ok = assume_user_identity(UserInfo),
|
||||
_ = set_meta(TplID),
|
||||
Tpl = get_invoice_template(TplID),
|
||||
@ -89,7 +88,7 @@ handle_function_('Update' = Fun, [UserInfo, TplID, Params] = Args, _Opts) ->
|
||||
ok = validate_update_params(Params, Shop),
|
||||
call(TplID, Fun, Args);
|
||||
|
||||
handle_function_('Delete' = Fun, [UserInfo, TplID] = Args, _Opts) ->
|
||||
handle_function_('Delete' = Fun, {UserInfo, TplID} = Args, _Opts) ->
|
||||
ok = assume_user_identity(UserInfo),
|
||||
Tpl = get_invoice_template(TplID),
|
||||
Party = get_party(Tpl#domain_InvoiceTemplate.owner_id),
|
||||
@ -97,7 +96,7 @@ handle_function_('Delete' = Fun, [UserInfo, TplID] = Args, _Opts) ->
|
||||
_ = set_meta(TplID),
|
||||
call(TplID, Fun, Args);
|
||||
|
||||
handle_function_('ComputeTerms', [UserInfo, TplID, Timestamp, PartyRevision0], _Opts) ->
|
||||
handle_function_('ComputeTerms', {UserInfo, TplID, Timestamp, PartyRevision0}, _Opts) ->
|
||||
ok = assume_user_identity(UserInfo),
|
||||
_ = set_meta(TplID),
|
||||
Tpl = get_invoice_template(TplID),
|
||||
@ -270,10 +269,10 @@ process_call(Call, #{history := History}) ->
|
||||
{{exception, Exception}, #{}}
|
||||
end.
|
||||
|
||||
handle_call({{'InvoiceTemplating', 'Update'}, [_UserInfo, _TplID, Params]}, Tpl) ->
|
||||
handle_call({{'InvoiceTemplating', 'Update'}, {_UserInfo, _TplID, Params}}, Tpl) ->
|
||||
Changes = [?tpl_updated(Params)],
|
||||
{merge_changes(Changes, Tpl), Changes};
|
||||
handle_call({{'InvoiceTemplating', 'Delete'}, [_UserInfo, _TplID]}, _Tpl) ->
|
||||
handle_call({{'InvoiceTemplating', 'Delete'}, {_UserInfo, _TplID}}, _Tpl) ->
|
||||
{ok, [?tpl_deleted()]}.
|
||||
|
||||
collapse_history(History) ->
|
||||
@ -598,4 +597,3 @@ construct_invoice_template_details(Product, Cost) when Product =/= undefined, Co
|
||||
}};
|
||||
construct_invoice_template_details(Product, Cost) ->
|
||||
error({unmarshal_event_error, {'Cant construct invoice template details', Product, Cost}}).
|
||||
|
||||
|
@ -149,7 +149,7 @@ collect_validation_varset(Cost, Party, Shop) ->
|
||||
|
||||
-spec compute_shop_terms(user_info(), party_id(), shop_id(), timestamp(), party_revision_param()) -> term_set().
|
||||
compute_shop_terms(UserInfo, PartyID, ShopID, Timestamp, PartyRevision) ->
|
||||
Args = [UserInfo, PartyID, ShopID, Timestamp, PartyRevision],
|
||||
Args = {UserInfo, PartyID, ShopID, Timestamp, PartyRevision},
|
||||
{ok, TermSet} = hg_woody_wrapper:call(party_management, 'ComputeShopTerms', Args),
|
||||
TermSet.
|
||||
|
||||
|
@ -116,7 +116,7 @@
|
||||
-spec start(ns(), id(), term()) ->
|
||||
{ok, term()} | {error, exists | term()} | no_return().
|
||||
start(Ns, ID, Args) ->
|
||||
call_automaton('Start', [Ns, ID, wrap_args(Args)]).
|
||||
call_automaton('Start', {Ns, ID, wrap_args(Args)}).
|
||||
|
||||
-spec thrift_call(ns(), ref(), service_name(), function_ref(), args()) ->
|
||||
response() | {error, notfound | failed}.
|
||||
@ -170,7 +170,7 @@ call(Ns, Ref, Args, After, Limit, Direction) ->
|
||||
|
||||
repair(Ns, Ref, Args) ->
|
||||
Descriptor = prepare_descriptor(Ns, Ref, #mg_stateproc_HistoryRange{}),
|
||||
call_automaton('Repair', [Descriptor, wrap_args(Args)]).
|
||||
call_automaton('Repair', {Descriptor, wrap_args(Args)}).
|
||||
|
||||
-spec get_history(ns(), ref()) ->
|
||||
{ok, history()} | {error, notfound} | no_return().
|
||||
@ -201,7 +201,7 @@ get_history(Ns, Ref, AfterID, Limit, Direction) ->
|
||||
get_machine(Ns, Ref, AfterID, Limit, Direction) ->
|
||||
Range = #mg_stateproc_HistoryRange{'after' = AfterID, limit = Limit, direction = Direction},
|
||||
Descriptor = prepare_descriptor(Ns, Ref, Range),
|
||||
case call_automaton('GetMachine', [Descriptor]) of
|
||||
case call_automaton('GetMachine', {Descriptor}) of
|
||||
{ok, #mg_stateproc_Machine{} = Machine} ->
|
||||
{ok, unmarshal_machine(Machine)};
|
||||
Error ->
|
||||
@ -225,7 +225,7 @@ do_call(Ns, Ref, Args, After, Limit, Direction) ->
|
||||
'direction' = Direction
|
||||
},
|
||||
Descriptor = prepare_descriptor(Ns, Ref, HistoryRange),
|
||||
case call_automaton('Call', [Descriptor, wrap_args(Args)]) of
|
||||
case call_automaton('Call', {Descriptor, wrap_args(Args)}) of
|
||||
{ok, Response} ->
|
||||
{ok, unmarshal_response(Response)};
|
||||
{error, _} = Error ->
|
||||
@ -254,14 +254,13 @@ call_automaton(Function, Args) ->
|
||||
term() | no_return().
|
||||
|
||||
handle_function(Func, Args, Opts) ->
|
||||
ArgsList = tuple_to_list(Args),
|
||||
scoper:scope(machine,
|
||||
fun() -> handle_function_(Func, ArgsList, Opts) end
|
||||
fun() -> handle_function_(Func, Args, Opts) end
|
||||
).
|
||||
|
||||
-spec handle_function_(func(), list(), #{ns := ns()}) -> term() | no_return().
|
||||
-spec handle_function_(func(), woody:args(), #{ns := ns()}) -> term() | no_return().
|
||||
|
||||
handle_function_('ProcessSignal', [Args], #{ns := Ns} = _Opts) ->
|
||||
handle_function_('ProcessSignal', {Args}, #{ns := Ns} = _Opts) ->
|
||||
#mg_stateproc_SignalArgs{signal = {Type, Signal}, machine = #mg_stateproc_Machine{id = ID} = Machine} = Args,
|
||||
scoper:add_meta(#{
|
||||
namespace => Ns,
|
||||
@ -271,7 +270,7 @@ handle_function_('ProcessSignal', [Args], #{ns := Ns} = _Opts) ->
|
||||
}),
|
||||
dispatch_signal(Ns, Signal, unmarshal_machine(Machine));
|
||||
|
||||
handle_function_('ProcessCall', [Args], #{ns := Ns} = _Opts) ->
|
||||
handle_function_('ProcessCall', {Args}, #{ns := Ns} = _Opts) ->
|
||||
#mg_stateproc_CallArgs{arg = Payload, machine = #mg_stateproc_Machine{id = ID} = Machine} = Args,
|
||||
scoper:add_meta(#{
|
||||
namespace => Ns,
|
||||
|
@ -56,26 +56,26 @@ collect_proxy_options(#domain_PaymentRoute{provider = ProviderRef, terminal = Te
|
||||
-spec process_payment(_ProxyContext, route()) ->
|
||||
term().
|
||||
process_payment(ProxyContext, Route) ->
|
||||
issue_call('ProcessPayment', [ProxyContext], Route).
|
||||
issue_call('ProcessPayment', {ProxyContext}, Route).
|
||||
|
||||
-spec generate_token(_ProxyContext, route()) ->
|
||||
term().
|
||||
generate_token(ProxyContext, Route) ->
|
||||
issue_call('GenerateToken', [ProxyContext], Route).
|
||||
issue_call('GenerateToken', {ProxyContext}, Route).
|
||||
|
||||
-spec handle_payment_callback(_Payload, _ProxyContext, route()) ->
|
||||
term().
|
||||
handle_payment_callback(Payload, ProxyContext, Route) ->
|
||||
issue_call('HandlePaymentCallback', [Payload, ProxyContext], Route).
|
||||
issue_call('HandlePaymentCallback', {Payload, ProxyContext}, Route).
|
||||
|
||||
-spec handle_recurrent_token_callback(_Payload, _ProxyContext, route()) ->
|
||||
term().
|
||||
handle_recurrent_token_callback(Payload, ProxyContext, Route) ->
|
||||
issue_call('HandleRecurrentTokenCallback', [Payload, ProxyContext], Route).
|
||||
issue_call('HandleRecurrentTokenCallback', {Payload, ProxyContext}, Route).
|
||||
|
||||
|
||||
|
||||
-spec issue_call(woody:func(), list(), route()) ->
|
||||
-spec issue_call(woody:func(), woody:args(), route()) ->
|
||||
term().
|
||||
issue_call(Func, Args, Route) ->
|
||||
CallID = hg_utils:unique_id(),
|
||||
|
@ -91,12 +91,11 @@ handle_function('GetLastEventID', {}, _Opts) ->
|
||||
throw(#payproc_NoLastEvent{})
|
||||
end;
|
||||
handle_function(Func, Args, Opts) ->
|
||||
ArgsList = tuple_to_list(Args),
|
||||
scoper:scope(recurrent_payment_tools,
|
||||
fun() -> handle_function_(Func, ArgsList, Opts) end
|
||||
fun() -> handle_function_(Func, Args, Opts) end
|
||||
).
|
||||
|
||||
handle_function_('Create', [RecurrentPaymentToolParams], _Opts) ->
|
||||
handle_function_('Create', {RecurrentPaymentToolParams}, _Opts) ->
|
||||
RecurrentPaymentToolParams0 = ensure_params_paytool_id_defined(RecurrentPaymentToolParams),
|
||||
RecPaymentToolID = get_paytool_id(RecurrentPaymentToolParams0),
|
||||
ok = set_meta(RecPaymentToolID),
|
||||
@ -104,13 +103,13 @@ handle_function_('Create', [RecurrentPaymentToolParams], _Opts) ->
|
||||
_ = validate_paytool_params(RecurrentPaymentToolParams1),
|
||||
ok = start(RecPaymentToolID, RecurrentPaymentToolParams1),
|
||||
get_rec_payment_tool(get_state(RecPaymentToolID));
|
||||
handle_function_('Abandon', [RecPaymentToolID], _Opts) ->
|
||||
handle_function_('Abandon', {RecPaymentToolID}, _Opts) ->
|
||||
ok = set_meta(RecPaymentToolID),
|
||||
call(RecPaymentToolID, abandon);
|
||||
handle_function_('Get', [RecPaymentToolID], _Opts) ->
|
||||
handle_function_('Get', {RecPaymentToolID}, _Opts) ->
|
||||
ok = set_meta(RecPaymentToolID),
|
||||
get_rec_payment_tool(get_state(RecPaymentToolID));
|
||||
handle_function_('GetEvents', [RecPaymentToolID, Range], _Opts) ->
|
||||
handle_function_('GetEvents', {RecPaymentToolID, Range}, _Opts) ->
|
||||
ok = set_meta(RecPaymentToolID),
|
||||
get_public_history(RecPaymentToolID, Range).
|
||||
|
||||
|
@ -67,13 +67,12 @@
|
||||
|
||||
%% API
|
||||
|
||||
-spec serialize_function_args(thrift_fun_full_ref(), list(term())) ->
|
||||
-spec serialize_function_args(thrift_fun_full_ref(), woody:args()) ->
|
||||
binary().
|
||||
|
||||
serialize_function_args({Module, {Service, Function}}, Args) when is_list(Args) ->
|
||||
serialize_function_args({Module, {Service, Function}}, Args) when is_tuple(Args) ->
|
||||
ArgsType = Module:function_info(Service, Function, params_type),
|
||||
ArgsRecord = erlang:list_to_tuple([args | Args]),
|
||||
serialize(ArgsType, ArgsRecord).
|
||||
serialize(ArgsType, Args).
|
||||
|
||||
-spec serialize_function_reply(thrift_fun_full_ref(), term()) ->
|
||||
binary().
|
||||
@ -87,19 +86,17 @@ serialize_function_reply({Module, {Service, Function}}, Data) ->
|
||||
|
||||
serialize_function_exception(FunctionRef, Exception) ->
|
||||
ExceptionType = get_fun_exception_type(FunctionRef),
|
||||
Name = find_exception_name(ExceptionType, Exception),
|
||||
Name = find_exception_name(FunctionRef, Exception),
|
||||
serialize(ExceptionType, {Name, Exception}).
|
||||
|
||||
-spec serialize(thrift_type(), term()) -> binary().
|
||||
|
||||
serialize(Type, Data) ->
|
||||
{ok, Trans} = thrift_membuffer_transport:new(),
|
||||
{ok, Proto} = new_protocol(Trans),
|
||||
case thrift_protocol:write(Proto, {Type, Data}) of
|
||||
{NewProto, ok} ->
|
||||
{_, {ok, Result}} = thrift_protocol:close_transport(NewProto),
|
||||
Result;
|
||||
{_NewProto, {error, Reason}} ->
|
||||
Codec0 = thrift_strict_binary_codec:new(),
|
||||
case thrift_strict_binary_codec:write(Codec0, Type, Data) of
|
||||
{ok, Codec1} ->
|
||||
thrift_strict_binary_codec:close(Codec1);
|
||||
{error, Reason} ->
|
||||
erlang:error({thrift, {protocol, Reason}})
|
||||
end.
|
||||
|
||||
@ -107,22 +104,25 @@ serialize(Type, Data) ->
|
||||
term().
|
||||
|
||||
deserialize(Type, Data) ->
|
||||
{ok, Trans} = thrift_membuffer_transport:new(Data),
|
||||
{ok, Proto} = new_protocol(Trans),
|
||||
case thrift_protocol:read(Proto, Type) of
|
||||
{_NewProto, {ok, Result}} ->
|
||||
Result;
|
||||
{_NewProto, {error, Reason}} ->
|
||||
Codec0 = thrift_strict_binary_codec:new(Data),
|
||||
case thrift_strict_binary_codec:read(Codec0, Type) of
|
||||
{ok, Result, Codec1} ->
|
||||
case thrift_strict_binary_codec:close(Codec1) of
|
||||
<<>> ->
|
||||
Result;
|
||||
Leftovers ->
|
||||
erlang:error({thrift, {protocol, {excess_binary_data, Leftovers}}})
|
||||
end;
|
||||
{error, Reason} ->
|
||||
erlang:error({thrift, {protocol, Reason}})
|
||||
end.
|
||||
|
||||
-spec deserialize_function_args(thrift_fun_full_ref(), binary()) ->
|
||||
list(term()).
|
||||
woody:args().
|
||||
|
||||
deserialize_function_args({Module, {Service, Function}}, Data) ->
|
||||
ArgsType = Module:function_info(Service, Function, params_type),
|
||||
Args = deserialize(ArgsType, Data),
|
||||
erlang:tuple_to_list(Args).
|
||||
deserialize(ArgsType, Data).
|
||||
|
||||
-spec deserialize_function_reply(thrift_fun_full_ref(), binary()) ->
|
||||
term().
|
||||
@ -139,11 +139,6 @@ deserialize_function_exception(FunctionRef, Data) ->
|
||||
{_Name, Exception} = deserialize(ExceptionType, Data),
|
||||
Exception.
|
||||
|
||||
%% Internals
|
||||
|
||||
new_protocol(Trans) ->
|
||||
thrift_binary_protocol:new(Trans, [{strict_read, true}, {strict_write, true}]).
|
||||
|
||||
%%
|
||||
|
||||
-spec record_to_proplist(Record :: tuple(), RecordInfo :: [atom()]) -> [{atom(), _}].
|
||||
@ -172,25 +167,13 @@ get_fun_exception_type({Module, {Service, Function}}) ->
|
||||
{struct, struct, Exceptions} = DeclaredType,
|
||||
{struct, union, Exceptions}.
|
||||
|
||||
-spec find_exception_name(thrift_type(), thrift_exception()) ->
|
||||
-spec find_exception_name(thrift_fun_full_ref(), thrift_exception()) ->
|
||||
Name :: atom().
|
||||
|
||||
find_exception_name(Type, Exception) ->
|
||||
RecordName = erlang:element(1, Exception),
|
||||
{struct, union, Variants} = Type,
|
||||
do_find_exception_name(Variants, RecordName).
|
||||
|
||||
-spec do_find_exception_name(thrift_struct_def(), atom()) ->
|
||||
Name :: atom().
|
||||
|
||||
do_find_exception_name([], RecordName) ->
|
||||
erlang:error({thrift, {unknown_exception, RecordName}});
|
||||
do_find_exception_name([{_Tag, _Req, Type, Name, _Default} | Tail], RecordName) ->
|
||||
{struct, exception, {Module, Exception}} = Type,
|
||||
case Module:record_name(Exception) of
|
||||
TypeRecordName when TypeRecordName =:= RecordName ->
|
||||
find_exception_name({Module, {Service, Function}}, Exception) ->
|
||||
case thrift_processor_codec:match_exception({Module, Service}, Function, Exception) of
|
||||
{ok, {_Type, Name}} ->
|
||||
Name;
|
||||
_Other ->
|
||||
do_find_exception_name(Tail, RecordName)
|
||||
{error, bad_exception} ->
|
||||
erlang:error({thrift, {unknown_exception, Exception}})
|
||||
end.
|
||||
|
||||
|
@ -56,7 +56,7 @@ handle_function(Func, Args, WoodyContext0, #{handler := Handler} = Opts) ->
|
||||
hg_context:cleanup()
|
||||
end.
|
||||
|
||||
-spec call(atom(), woody:func(), list()) ->
|
||||
-spec call(atom(), woody:func(), woody:args()) ->
|
||||
term().
|
||||
|
||||
call(ServiceName, Function, Args) ->
|
||||
@ -64,21 +64,20 @@ call(ServiceName, Function, Args) ->
|
||||
Deadline = undefined,
|
||||
call(ServiceName, Function, Args, Opts, Deadline).
|
||||
|
||||
-spec call(atom(), woody:func(), list(), client_opts()) ->
|
||||
-spec call(atom(), woody:func(), woody:args(), client_opts()) ->
|
||||
term().
|
||||
|
||||
call(ServiceName, Function, Args, Opts) ->
|
||||
Deadline = undefined,
|
||||
call(ServiceName, Function, Args, Opts, Deadline).
|
||||
|
||||
-spec call(atom(), woody:func(), list(), client_opts(), woody_deadline:deadline()) ->
|
||||
-spec call(atom(), woody:func(), woody:args(), client_opts(), woody_deadline:deadline()) ->
|
||||
term().
|
||||
|
||||
call(ServiceName, Function, Args, Opts, Deadline) ->
|
||||
Service = get_service_modname(ServiceName),
|
||||
Context = hg_context:get_woody_context(hg_context:load()),
|
||||
ArgsTuple = list_to_tuple(Args),
|
||||
Request = {Service, Function, ArgsTuple},
|
||||
Request = {Service, Function, Args},
|
||||
woody_client:call(
|
||||
Request,
|
||||
Opts#{event_handler => {
|
||||
|
@ -40,7 +40,7 @@
|
||||
account().
|
||||
|
||||
get_account(AccountID) ->
|
||||
case call_accounter('GetAccountByID', [AccountID]) of
|
||||
case call_accounter('GetAccountByID', {AccountID}) of
|
||||
{ok, Result} ->
|
||||
construct_account(AccountID, Result);
|
||||
{exception, #shumpune_AccountNotFound{}} ->
|
||||
@ -57,7 +57,7 @@ get_balance(AccountID) ->
|
||||
balance().
|
||||
|
||||
get_balance(AccountID, Clock) ->
|
||||
case call_accounter('GetBalanceByID', [AccountID, Clock]) of
|
||||
case call_accounter('GetBalanceByID', {AccountID, Clock}) of
|
||||
{ok, Result} ->
|
||||
construct_balance(AccountID, Result);
|
||||
{exception, #shumpune_AccountNotFound{}} ->
|
||||
@ -74,7 +74,7 @@ create_account(CurrencyCode) ->
|
||||
account_id().
|
||||
|
||||
create_account(CurrencyCode, Description) ->
|
||||
case call_accounter('CreateAccount', [construct_prototype(CurrencyCode, Description)]) of
|
||||
case call_accounter('CreateAccount', {construct_prototype(CurrencyCode, Description)}) of
|
||||
{ok, Result} ->
|
||||
Result;
|
||||
{exception, Exception} ->
|
||||
|
@ -23,8 +23,7 @@ handle_function_(Fun, {PartyID, _Claim} = Args, _Opts) when Fun == 'Accept'; Fun
|
||||
call(PartyID, FunctionName, Args) ->
|
||||
ok = scoper:add_meta(#{party_id => PartyID}),
|
||||
try
|
||||
ArgsList = tuple_to_list(Args),
|
||||
pm_party_machine:call(PartyID, claim_committer, {'ClaimCommitter', FunctionName}, ArgsList)
|
||||
pm_party_machine:call(PartyID, claim_committer, {'ClaimCommitter', FunctionName}, Args)
|
||||
catch
|
||||
throw:#payproc_PartyNotFound{} ->
|
||||
erlang:throw(#claim_management_PartyNotFound{})
|
||||
|
@ -50,7 +50,7 @@
|
||||
result().
|
||||
|
||||
-type call() :: _.
|
||||
-type thrift_call() :: {pm_proto_utils:thrift_fun_ref(), Args :: [term()]}.
|
||||
-type thrift_call() :: {pm_proto_utils:thrift_fun_ref(), woody:args()}.
|
||||
-type response() :: ok | {ok, term()} | {exception, term()}.
|
||||
|
||||
-callback process_call(call(), machine()) ->
|
||||
@ -116,7 +116,7 @@
|
||||
-spec start(ns(), id(), term()) ->
|
||||
{ok, term()} | {error, exists | term()} | no_return().
|
||||
start(Ns, ID, Args) ->
|
||||
call_automaton('Start', [Ns, ID, wrap_args(Args)]).
|
||||
call_automaton('Start', {Ns, ID, wrap_args(Args)}).
|
||||
|
||||
-spec thrift_call(ns(), ref(), service_name(), function_ref(), args()) ->
|
||||
response() | {error, notfound | failed}.
|
||||
@ -170,7 +170,7 @@ call(Ns, Ref, Args, After, Limit, Direction) ->
|
||||
|
||||
repair(Ns, Ref, Args) ->
|
||||
Descriptor = prepare_descriptor(Ns, Ref, #mg_stateproc_HistoryRange{}),
|
||||
call_automaton('Repair', [Descriptor, wrap_args(Args)]).
|
||||
call_automaton('Repair', {Descriptor, wrap_args(Args)}).
|
||||
|
||||
-spec get_history(ns(), ref()) ->
|
||||
{ok, history()} | {error, notfound} | no_return().
|
||||
@ -201,7 +201,7 @@ get_history(Ns, Ref, AfterID, Limit, Direction) ->
|
||||
get_machine(Ns, Ref, AfterID, Limit, Direction) ->
|
||||
Range = #mg_stateproc_HistoryRange{'after' = AfterID, limit = Limit, direction = Direction},
|
||||
Descriptor = prepare_descriptor(Ns, Ref, Range),
|
||||
case call_automaton('GetMachine', [Descriptor]) of
|
||||
case call_automaton('GetMachine', {Descriptor}) of
|
||||
{ok, #mg_stateproc_Machine{} = Machine} ->
|
||||
{ok, unmarshal_machine(Machine)};
|
||||
Error ->
|
||||
@ -225,7 +225,7 @@ do_call(Ns, Ref, Args, After, Limit, Direction) ->
|
||||
'direction' = Direction
|
||||
},
|
||||
Descriptor = prepare_descriptor(Ns, Ref, HistoryRange),
|
||||
case call_automaton('Call', [Descriptor, wrap_args(Args)]) of
|
||||
case call_automaton('Call', {Descriptor, wrap_args(Args)}) of
|
||||
{ok, Response} ->
|
||||
{ok, unmarshal_response(Response)};
|
||||
{error, _} = Error ->
|
||||
@ -254,14 +254,13 @@ call_automaton(Function, Args) ->
|
||||
term() | no_return().
|
||||
|
||||
handle_function(Func, Args, Opts) ->
|
||||
ArgsList = tuple_to_list(Args),
|
||||
scoper:scope(machine,
|
||||
fun() -> handle_function_(Func, ArgsList, Opts) end
|
||||
fun() -> handle_function_(Func, Args, Opts) end
|
||||
).
|
||||
|
||||
-spec handle_function_(func(), list(), #{ns := ns()}) -> term() | no_return().
|
||||
-spec handle_function_(func(), woody:args(), #{ns := ns()}) -> term() | no_return().
|
||||
|
||||
handle_function_('ProcessSignal', [Args], #{ns := Ns} = _Opts) ->
|
||||
handle_function_('ProcessSignal', {Args}, #{ns := Ns} = _Opts) ->
|
||||
#mg_stateproc_SignalArgs{signal = {Type, Signal}, machine = #mg_stateproc_Machine{id = ID} = Machine} = Args,
|
||||
scoper:add_meta(#{
|
||||
namespace => Ns,
|
||||
@ -271,7 +270,7 @@ handle_function_('ProcessSignal', [Args], #{ns := Ns} = _Opts) ->
|
||||
}),
|
||||
dispatch_signal(Ns, Signal, unmarshal_machine(Machine));
|
||||
|
||||
handle_function_('ProcessCall', [Args], #{ns := Ns} = _Opts) ->
|
||||
handle_function_('ProcessCall', {Args}, #{ns := Ns} = _Opts) ->
|
||||
#mg_stateproc_CallArgs{arg = Payload, machine = #mg_stateproc_Machine{id = ID} = Machine} = Args,
|
||||
scoper:add_meta(#{
|
||||
namespace => Ns,
|
||||
|
@ -14,54 +14,55 @@
|
||||
term()| no_return().
|
||||
|
||||
handle_function(Func, Args, Opts) ->
|
||||
ArgsList = tuple_to_list(Args),
|
||||
scoper:scope(partymgmt,
|
||||
fun() -> handle_function_(Func, ArgsList, Opts) end
|
||||
fun() -> handle_function_(Func, Args, Opts) end
|
||||
).
|
||||
|
||||
-spec handle_function_(woody:func(), list(), pm_woody_wrapper:handler_opts()) ->
|
||||
-spec handle_function_(woody:func(), woody:args(), pm_woody_wrapper:handler_opts()) ->
|
||||
term()| no_return().
|
||||
|
||||
%% Party
|
||||
|
||||
handle_function_('Create', [UserInfo, PartyID, PartyParams], _Opts) ->
|
||||
handle_function_('Create', {UserInfo, PartyID, PartyParams}, _Opts) ->
|
||||
ok = set_meta_and_check_access(UserInfo, PartyID),
|
||||
pm_party_machine:start(PartyID, PartyParams);
|
||||
|
||||
handle_function_('Checkout', [UserInfo, PartyID, RevisionParam], _Opts) ->
|
||||
handle_function_('Checkout', {UserInfo, PartyID, RevisionParam}, _Opts) ->
|
||||
ok = set_meta_and_check_access(UserInfo, PartyID),
|
||||
checkout_party(PartyID, RevisionParam, #payproc_InvalidPartyRevision{});
|
||||
|
||||
handle_function_('Get', [UserInfo, PartyID], _Opts) ->
|
||||
handle_function_('Get', {UserInfo, PartyID}, _Opts) ->
|
||||
ok = set_meta_and_check_access(UserInfo, PartyID),
|
||||
pm_party_machine:get_party(PartyID);
|
||||
|
||||
handle_function_('GetRevision', [UserInfo, PartyID], _Opts) ->
|
||||
handle_function_('GetRevision', {UserInfo, PartyID}, _Opts) ->
|
||||
ok = set_meta_and_check_access(UserInfo, PartyID),
|
||||
pm_party_machine:get_last_revision(PartyID);
|
||||
|
||||
handle_function_('GetStatus', [UserInfo, PartyID], _Opts) ->
|
||||
handle_function_('GetStatus', {UserInfo, PartyID}, _Opts) ->
|
||||
ok = set_meta_and_check_access(UserInfo, PartyID),
|
||||
pm_party_machine:get_status(PartyID);
|
||||
|
||||
handle_function_(Fun, [UserInfo, PartyID | _Tail] = Args, _Opts) when
|
||||
handle_function_(Fun, Args, _Opts) when
|
||||
Fun =:= 'Block' orelse
|
||||
Fun =:= 'Unblock' orelse
|
||||
Fun =:= 'Suspend' orelse
|
||||
Fun =:= 'Activate'
|
||||
->
|
||||
UserInfo = erlang:element(1, Args),
|
||||
PartyID = erlang:element(2, Args),
|
||||
ok = set_meta_and_check_access(UserInfo, PartyID),
|
||||
call(PartyID, Fun, Args);
|
||||
|
||||
%% Contract
|
||||
|
||||
handle_function_('GetContract', [UserInfo, PartyID, ContractID], _Opts) ->
|
||||
handle_function_('GetContract', {UserInfo, PartyID, ContractID}, _Opts) ->
|
||||
ok = set_meta_and_check_access(UserInfo, PartyID),
|
||||
Party = pm_party_machine:get_party(PartyID),
|
||||
ensure_contract(pm_party:get_contract(ContractID, Party));
|
||||
|
||||
handle_function_('ComputeContractTerms', Args, _Opts) ->
|
||||
[UserInfo, PartyID, ContractID, Timestamp, PartyRevisionParams, DomainRevision, Varset] = Args,
|
||||
{UserInfo, PartyID, ContractID, Timestamp, PartyRevisionParams, DomainRevision, Varset} = Args,
|
||||
ok = set_meta_and_check_access(UserInfo, PartyID),
|
||||
Party = checkout_party(PartyID, PartyRevisionParams),
|
||||
Contract = ensure_contract(pm_party:get_contract(ContractID, Party)),
|
||||
@ -75,12 +76,12 @@ handle_function_('ComputeContractTerms', Args, _Opts) ->
|
||||
|
||||
%% Shop
|
||||
|
||||
handle_function_('GetShop', [UserInfo, PartyID, ID], _Opts) ->
|
||||
handle_function_('GetShop', {UserInfo, PartyID, ID}, _Opts) ->
|
||||
ok = set_meta_and_check_access(UserInfo, PartyID),
|
||||
Party = pm_party_machine:get_party(PartyID),
|
||||
ensure_shop(pm_party:get_shop(ID, Party));
|
||||
|
||||
handle_function_('ComputeShopTerms', [UserInfo, PartyID, ShopID, Timestamp, PartyRevision], _Opts) ->
|
||||
handle_function_('ComputeShopTerms', {UserInfo, PartyID, ShopID, Timestamp, PartyRevision}, _Opts) ->
|
||||
ok = set_meta_and_check_access(UserInfo, PartyID),
|
||||
Party = checkout_party(PartyID, pm_maybe:get_defined(PartyRevision, {timestamp, Timestamp})),
|
||||
Shop = ensure_shop(pm_party:get_shop(ShopID, Party)),
|
||||
@ -95,18 +96,20 @@ handle_function_('ComputeShopTerms', [UserInfo, PartyID, ShopID, Timestamp, Part
|
||||
},
|
||||
pm_party:reduce_terms(pm_party:get_terms(Contract, Timestamp, Revision), VS, Revision);
|
||||
|
||||
handle_function_(Fun, [UserInfo, PartyID | _Tail] = Args, _Opts) when
|
||||
handle_function_(Fun, Args, _Opts) when
|
||||
Fun =:= 'BlockShop' orelse
|
||||
Fun =:= 'UnblockShop' orelse
|
||||
Fun =:= 'SuspendShop' orelse
|
||||
Fun =:= 'ActivateShop'
|
||||
->
|
||||
UserInfo = erlang:element(1, Args),
|
||||
PartyID = erlang:element(2, Args),
|
||||
ok = set_meta_and_check_access(UserInfo, PartyID),
|
||||
call(PartyID, Fun, Args);
|
||||
|
||||
%% Wallet
|
||||
|
||||
handle_function_('ComputeWalletTermsNew', [UserInfo, PartyID, ContractID, Timestamp, Varset], _Opts) ->
|
||||
handle_function_('ComputeWalletTermsNew', {UserInfo, PartyID, ContractID, Timestamp, Varset}, _Opts) ->
|
||||
ok = set_meta_and_check_access(UserInfo, PartyID),
|
||||
Party = checkout_party(PartyID, {timestamp, Timestamp}),
|
||||
Contract = pm_party:get_contract(ContractID, Party),
|
||||
@ -119,39 +122,41 @@ handle_function_('ComputeWalletTermsNew', [UserInfo, PartyID, ContractID, Timest
|
||||
|
||||
%% Claim
|
||||
|
||||
handle_function_('GetClaim', [UserInfo, PartyID, ID], _Opts) ->
|
||||
handle_function_('GetClaim', {UserInfo, PartyID, ID}, _Opts) ->
|
||||
ok = set_meta_and_check_access(UserInfo, PartyID),
|
||||
pm_party_machine:get_claim(ID, PartyID);
|
||||
|
||||
handle_function_('GetClaims', [UserInfo, PartyID], _Opts) ->
|
||||
handle_function_('GetClaims', {UserInfo, PartyID}, _Opts) ->
|
||||
ok = set_meta_and_check_access(UserInfo, PartyID),
|
||||
pm_party_machine:get_claims(PartyID);
|
||||
|
||||
handle_function_(Fun, [UserInfo, PartyID | _Tail] = Args, _Opts) when
|
||||
handle_function_(Fun, Args, _Opts) when
|
||||
Fun =:= 'CreateClaim' orelse
|
||||
Fun =:= 'AcceptClaim' orelse
|
||||
Fun =:= 'UpdateClaim' orelse
|
||||
Fun =:= 'DenyClaim' orelse
|
||||
Fun =:= 'RevokeClaim'
|
||||
->
|
||||
UserInfo = erlang:element(1, Args),
|
||||
PartyID = erlang:element(2, Args),
|
||||
ok = set_meta_and_check_access(UserInfo, PartyID),
|
||||
call(PartyID, Fun, Args);
|
||||
|
||||
%% Event
|
||||
|
||||
handle_function_('GetEvents', [UserInfo, PartyID, Range], _Opts) ->
|
||||
handle_function_('GetEvents', {UserInfo, PartyID, Range}, _Opts) ->
|
||||
ok = set_meta_and_check_access(UserInfo, PartyID),
|
||||
#payproc_EventRange{'after' = AfterID, limit = Limit} = Range,
|
||||
pm_party_machine:get_public_history(PartyID, AfterID, Limit);
|
||||
|
||||
%% ShopAccount
|
||||
|
||||
handle_function_('GetAccountState', [UserInfo, PartyID, AccountID], _Opts) ->
|
||||
handle_function_('GetAccountState', {UserInfo, PartyID, AccountID}, _Opts) ->
|
||||
ok = set_meta_and_check_access(UserInfo, PartyID),
|
||||
Party = pm_party_machine:get_party(PartyID),
|
||||
pm_party:get_account_state(AccountID, Party);
|
||||
|
||||
handle_function_('GetShopAccount', [UserInfo, PartyID, ShopID], _Opts) ->
|
||||
handle_function_('GetShopAccount', {UserInfo, PartyID, ShopID}, _Opts) ->
|
||||
ok = set_meta_and_check_access(UserInfo, PartyID),
|
||||
Party = pm_party_machine:get_party(PartyID),
|
||||
pm_party:get_shop_account(ShopID, Party);
|
||||
@ -159,14 +164,14 @@ handle_function_('GetShopAccount', [UserInfo, PartyID, ShopID], _Opts) ->
|
||||
%% Providers
|
||||
|
||||
handle_function_('ComputeProvider', Args, _Opts) ->
|
||||
[UserInfo, ProviderRef, DomainRevision, Varset] = Args,
|
||||
{UserInfo, ProviderRef, DomainRevision, Varset} = Args,
|
||||
ok = assume_user_identity(UserInfo),
|
||||
Provider = get_provider(ProviderRef, DomainRevision),
|
||||
VS = prepare_varset(Varset),
|
||||
pm_provider:reduce_provider(Provider, VS, DomainRevision);
|
||||
|
||||
handle_function_('ComputeProviderTerminalTerms', Args, _Opts) ->
|
||||
[UserInfo, ProviderRef, TerminalRef, DomainRevision, Varset] = Args,
|
||||
{UserInfo, ProviderRef, TerminalRef, DomainRevision, Varset} = Args,
|
||||
ok = assume_user_identity(UserInfo),
|
||||
Provider = get_provider(ProviderRef, DomainRevision),
|
||||
Terminal = get_terminal(TerminalRef, DomainRevision),
|
||||
@ -176,7 +181,7 @@ handle_function_('ComputeProviderTerminalTerms', Args, _Opts) ->
|
||||
%% Globals
|
||||
|
||||
handle_function_('ComputeGlobals', Args, _Opts) ->
|
||||
[UserInfo, GlobalsRef, DomainRevision, Varset] = Args,
|
||||
{UserInfo, GlobalsRef, DomainRevision, Varset} = Args,
|
||||
ok = assume_user_identity(UserInfo),
|
||||
Globals = get_globals(GlobalsRef, DomainRevision),
|
||||
VS = prepare_varset(Varset),
|
||||
@ -185,7 +190,7 @@ handle_function_('ComputeGlobals', Args, _Opts) ->
|
||||
%% RuleSets
|
||||
|
||||
handle_function_('ComputePaymentRoutingRuleset', Args, _Opts) ->
|
||||
[UserInfo, RuleSetRef, DomainRevision, Varset] = Args,
|
||||
{UserInfo, RuleSetRef, DomainRevision, Varset} = Args,
|
||||
ok = assume_user_identity(UserInfo),
|
||||
RuleSet = get_payment_routing_ruleset(RuleSetRef, DomainRevision),
|
||||
VS = prepare_varset(Varset),
|
||||
@ -193,18 +198,20 @@ handle_function_('ComputePaymentRoutingRuleset', Args, _Opts) ->
|
||||
|
||||
%% PartyMeta
|
||||
|
||||
handle_function_('GetMeta', [UserInfo, PartyID], _Opts) ->
|
||||
handle_function_('GetMeta', {UserInfo, PartyID}, _Opts) ->
|
||||
ok = set_meta_and_check_access(UserInfo, PartyID),
|
||||
pm_party_machine:get_meta(PartyID);
|
||||
|
||||
handle_function_('GetMetaData', [UserInfo, PartyID, NS], _Opts) ->
|
||||
handle_function_('GetMetaData', {UserInfo, PartyID, NS}, _Opts) ->
|
||||
ok = set_meta_and_check_access(UserInfo, PartyID),
|
||||
pm_party_machine:get_metadata(NS, PartyID);
|
||||
|
||||
handle_function_(Fun, [UserInfo, PartyID | _Tail] = Args, _Opts) when
|
||||
handle_function_(Fun, Args, _Opts) when
|
||||
Fun =:= 'SetMetaData' orelse
|
||||
Fun =:= 'RemoveMetaData'
|
||||
->
|
||||
UserInfo = erlang:element(1, Args),
|
||||
PartyID = erlang:element(2, Args),
|
||||
ok = set_meta_and_check_access(UserInfo, PartyID),
|
||||
call(PartyID, Fun, Args);
|
||||
|
||||
@ -212,7 +219,7 @@ handle_function_(Fun, [UserInfo, PartyID | _Tail] = Args, _Opts) when
|
||||
|
||||
handle_function_(
|
||||
'ComputePaymentInstitutionTerms',
|
||||
[UserInfo, PaymentInstitutionRef, Varset],
|
||||
{UserInfo, PaymentInstitutionRef, Varset},
|
||||
_Opts
|
||||
) ->
|
||||
ok = assume_user_identity(UserInfo),
|
||||
@ -224,7 +231,7 @@ handle_function_(
|
||||
pm_party:reduce_terms(Terms, VS, Revision);
|
||||
|
||||
handle_function_('ComputePaymentInstitution', Args, _Opts) ->
|
||||
[UserInfo, PaymentInstitutionRef, DomainRevision, Varset] = Args,
|
||||
{UserInfo, PaymentInstitutionRef, DomainRevision, Varset} = Args,
|
||||
ok = assume_user_identity(UserInfo),
|
||||
PaymentInstitution = get_payment_institution(PaymentInstitutionRef, DomainRevision),
|
||||
VS = prepare_varset(Varset),
|
||||
@ -234,7 +241,7 @@ handle_function_('ComputePaymentInstitution', Args, _Opts) ->
|
||||
|
||||
handle_function_(
|
||||
'ComputePayoutCashFlow',
|
||||
[UserInfo, PartyID, #payproc_PayoutParams{id = ShopID, amount = Amount, timestamp = Timestamp} = PayoutParams],
|
||||
{UserInfo, PartyID, #payproc_PayoutParams{id = ShopID, amount = Amount, timestamp = Timestamp} = PayoutParams},
|
||||
_Opts
|
||||
) ->
|
||||
ok = set_meta_and_check_access(UserInfo, PartyID),
|
||||
|
@ -132,11 +132,11 @@ process_signal({repair, _}, _Machine) ->
|
||||
-spec process_call(call(), pm_machine:machine()) ->
|
||||
{pm_machine:response(), pm_machine:result()}.
|
||||
|
||||
process_call({{'PartyManagement', Fun}, FunArgs}, Machine) ->
|
||||
[_UserInfo, PartyID | Args] = FunArgs,
|
||||
process_call({{'PartyManagement', Fun}, Args}, Machine) ->
|
||||
PartyID = erlang:element(2, Args),
|
||||
process_call_(PartyID, Fun, Args, Machine);
|
||||
process_call({{'ClaimCommitter', Fun}, FunArgs}, Machine) ->
|
||||
[PartyID | Args] = FunArgs,
|
||||
process_call({{'ClaimCommitter', Fun}, Args}, Machine) ->
|
||||
PartyID = erlang:element(1, Args),
|
||||
process_call_(PartyID, Fun, Args, Machine).
|
||||
|
||||
process_call_(PartyID, Fun, Args, Machine) ->
|
||||
@ -161,35 +161,35 @@ process_call_(PartyID, Fun, Args, Machine) ->
|
||||
|
||||
%% Party
|
||||
|
||||
handle_call('Block', [Reason], AuxSt, St) ->
|
||||
handle_call('Block', {_, _PartyID, Reason}, AuxSt, St) ->
|
||||
handle_block(party, Reason, AuxSt, St);
|
||||
|
||||
handle_call('Unblock', [Reason], AuxSt, St) ->
|
||||
handle_call('Unblock', {_, _PartyID, Reason}, AuxSt, St) ->
|
||||
handle_unblock(party, Reason, AuxSt, St);
|
||||
|
||||
handle_call('Suspend', [], AuxSt, St) ->
|
||||
handle_call('Suspend', {_, _PartyID}, AuxSt, St) ->
|
||||
handle_suspend(party, AuxSt, St);
|
||||
|
||||
handle_call('Activate', [], AuxSt, St) ->
|
||||
handle_call('Activate', {_, _PartyID}, AuxSt, St) ->
|
||||
handle_activate(party, AuxSt, St);
|
||||
|
||||
%% Shop
|
||||
|
||||
handle_call('BlockShop', [ID, Reason], AuxSt, St) ->
|
||||
handle_call('BlockShop', {_, _PartyID, ID, Reason}, AuxSt, St) ->
|
||||
handle_block({shop, ID}, Reason, AuxSt, St);
|
||||
|
||||
handle_call('UnblockShop', [ID, Reason], AuxSt, St) ->
|
||||
handle_call('UnblockShop', {_, _PartyID, ID, Reason}, AuxSt, St) ->
|
||||
handle_unblock({shop, ID}, Reason, AuxSt, St);
|
||||
|
||||
handle_call('SuspendShop', [ID], AuxSt, St) ->
|
||||
handle_call('SuspendShop', {_, _PartyID, ID}, AuxSt, St) ->
|
||||
handle_suspend({shop, ID}, AuxSt, St);
|
||||
|
||||
handle_call('ActivateShop', [ID], AuxSt, St) ->
|
||||
handle_call('ActivateShop', {_, _PartyID, ID}, AuxSt, St) ->
|
||||
handle_activate({shop, ID}, AuxSt, St);
|
||||
|
||||
%% PartyMeta
|
||||
|
||||
handle_call('SetMetaData', [NS, Data], AuxSt, St) ->
|
||||
handle_call('SetMetaData', {_, _PartyID, NS, Data}, AuxSt, St) ->
|
||||
respond(
|
||||
ok,
|
||||
[?party_meta_set(NS, Data)],
|
||||
@ -197,7 +197,7 @@ handle_call('SetMetaData', [NS, Data], AuxSt, St) ->
|
||||
St
|
||||
);
|
||||
|
||||
handle_call('RemoveMetaData', [NS], AuxSt, St) ->
|
||||
handle_call('RemoveMetaData', {_, _PartyID, NS}, AuxSt, St) ->
|
||||
_ = get_st_metadata(NS, St),
|
||||
respond(
|
||||
ok,
|
||||
@ -208,7 +208,7 @@ handle_call('RemoveMetaData', [NS], AuxSt, St) ->
|
||||
|
||||
%% Claim
|
||||
|
||||
handle_call('CreateClaim', [Changeset], AuxSt, St) ->
|
||||
handle_call('CreateClaim', {_, _PartyID, Changeset}, AuxSt, St) ->
|
||||
ok = assert_party_operable(St),
|
||||
{Claim, Changes} = create_claim(Changeset, St),
|
||||
respond(
|
||||
@ -218,7 +218,7 @@ handle_call('CreateClaim', [Changeset], AuxSt, St) ->
|
||||
St
|
||||
);
|
||||
|
||||
handle_call('UpdateClaim', [ID, ClaimRevision, Changeset], AuxSt, St) ->
|
||||
handle_call('UpdateClaim', {_, _PartyID, ID, ClaimRevision, Changeset}, AuxSt, St) ->
|
||||
ok = assert_party_operable(St),
|
||||
ok = assert_claim_modification_allowed(ID, ClaimRevision, St),
|
||||
respond(
|
||||
@ -228,7 +228,7 @@ handle_call('UpdateClaim', [ID, ClaimRevision, Changeset], AuxSt, St) ->
|
||||
St
|
||||
);
|
||||
|
||||
handle_call('AcceptClaim', [ID, ClaimRevision], AuxSt, St) ->
|
||||
handle_call('AcceptClaim', {_, _PartyID, ID, ClaimRevision}, AuxSt, St) ->
|
||||
ok = assert_claim_modification_allowed(ID, ClaimRevision, St),
|
||||
Timestamp = pm_datetime:format_now(),
|
||||
Revision = get_next_party_revision(St),
|
||||
@ -245,7 +245,7 @@ handle_call('AcceptClaim', [ID, ClaimRevision], AuxSt, St) ->
|
||||
St
|
||||
);
|
||||
|
||||
handle_call('DenyClaim', [ID, ClaimRevision, Reason], AuxSt, St) ->
|
||||
handle_call('DenyClaim', {_, _PartyID, ID, ClaimRevision, Reason}, AuxSt, St) ->
|
||||
ok = assert_claim_modification_allowed(ID, ClaimRevision, St),
|
||||
Timestamp = pm_datetime:format_now(),
|
||||
Claim = pm_claim:deny(Reason, Timestamp, get_st_claim(ID, St)),
|
||||
@ -256,7 +256,7 @@ handle_call('DenyClaim', [ID, ClaimRevision, Reason], AuxSt, St) ->
|
||||
St
|
||||
);
|
||||
|
||||
handle_call('RevokeClaim', [ID, ClaimRevision, Reason], AuxSt, St) ->
|
||||
handle_call('RevokeClaim', {_, _PartyID, ID, ClaimRevision, Reason}, AuxSt, St) ->
|
||||
ok = assert_party_operable(St),
|
||||
ok = assert_claim_modification_allowed(ID, ClaimRevision, St),
|
||||
Timestamp = pm_datetime:format_now(),
|
||||
@ -270,7 +270,7 @@ handle_call('RevokeClaim', [ID, ClaimRevision, Reason], AuxSt, St) ->
|
||||
|
||||
%% ClaimCommitter
|
||||
|
||||
handle_call('Accept', [Claim], AuxSt, St) ->
|
||||
handle_call('Accept', {_PartyID, Claim}, AuxSt, St) ->
|
||||
#claim_management_Claim{
|
||||
changeset = Changeset
|
||||
} = Claim,
|
||||
@ -307,7 +307,7 @@ handle_call('Accept', [Claim], AuxSt, St) ->
|
||||
})
|
||||
end;
|
||||
|
||||
handle_call('Commit', [CmClaim], AuxSt, St) ->
|
||||
handle_call('Commit', {_PartyID, CmClaim}, AuxSt, St) ->
|
||||
PayprocClaim = pm_claim_committer:from_claim_mgmt(CmClaim),
|
||||
Changes = get_changes(PayprocClaim, St),
|
||||
respond(
|
||||
@ -522,7 +522,7 @@ get_status(PartyID) ->
|
||||
get_party(PartyID)
|
||||
).
|
||||
|
||||
-spec call(party_id(), service_name(), pm_proto_utils:thrift_fun_ref(), Args :: [term()]) ->
|
||||
-spec call(party_id(), service_name(), pm_proto_utils:thrift_fun_ref(), woody:args()) ->
|
||||
term() | no_return().
|
||||
|
||||
call(PartyID, ServiceName, FucntionRef, Args) ->
|
||||
|
@ -55,7 +55,7 @@ handle_function(Func, Args, WoodyContext0, #{handler := Handler} = Opts) ->
|
||||
pm_context:cleanup()
|
||||
end.
|
||||
|
||||
-spec call(atom(), woody:func(), list()) ->
|
||||
-spec call(atom(), woody:func(), woody:args()) ->
|
||||
term().
|
||||
|
||||
call(ServiceName, Function, Args) ->
|
||||
@ -63,21 +63,20 @@ call(ServiceName, Function, Args) ->
|
||||
Deadline = undefined,
|
||||
call(ServiceName, Function, Args, Opts, Deadline).
|
||||
|
||||
-spec call(atom(), woody:func(), list(), client_opts()) ->
|
||||
-spec call(atom(), woody:func(), woody:args(), client_opts()) ->
|
||||
term().
|
||||
|
||||
call(ServiceName, Function, Args, Opts) ->
|
||||
Deadline = undefined,
|
||||
call(ServiceName, Function, Args, Opts, Deadline).
|
||||
|
||||
-spec call(atom(), woody:func(), list(), client_opts(), woody_deadline:deadline()) ->
|
||||
-spec call(atom(), woody:func(), woody:args(), client_opts(), woody_deadline:deadline()) ->
|
||||
term().
|
||||
|
||||
call(ServiceName, Function, Args, Opts, Deadline) ->
|
||||
Service = get_service_modname(ServiceName),
|
||||
Context = pm_context:get_woody_context(pm_context:load()),
|
||||
ArgsTuple = list_to_tuple(Args),
|
||||
Request = {Service, Function, ArgsTuple},
|
||||
Request = {Service, Function, Args},
|
||||
woody_client:call(
|
||||
Request,
|
||||
Opts#{event_handler => {
|
||||
|
@ -67,13 +67,12 @@
|
||||
|
||||
%% API
|
||||
|
||||
-spec serialize_function_args(thrift_fun_full_ref(), list(term())) ->
|
||||
-spec serialize_function_args(thrift_fun_full_ref(), woody:args()) ->
|
||||
binary().
|
||||
|
||||
serialize_function_args({Module, {Service, Function}}, Args) when is_list(Args) ->
|
||||
serialize_function_args({Module, {Service, Function}}, Args) when is_tuple(Args) ->
|
||||
ArgsType = Module:function_info(Service, Function, params_type),
|
||||
ArgsRecord = erlang:list_to_tuple([args | Args]),
|
||||
serialize(ArgsType, ArgsRecord).
|
||||
serialize(ArgsType, Args).
|
||||
|
||||
-spec serialize_function_reply(thrift_fun_full_ref(), term()) ->
|
||||
binary().
|
||||
@ -87,19 +86,17 @@ serialize_function_reply({Module, {Service, Function}}, Data) ->
|
||||
|
||||
serialize_function_exception(FunctionRef, Exception) ->
|
||||
ExceptionType = get_fun_exception_type(FunctionRef),
|
||||
Name = find_exception_name(ExceptionType, Exception),
|
||||
Name = find_exception_name(FunctionRef, Exception),
|
||||
serialize(ExceptionType, {Name, Exception}).
|
||||
|
||||
-spec serialize(thrift_type(), term()) -> binary().
|
||||
|
||||
serialize(Type, Data) ->
|
||||
{ok, Trans} = thrift_membuffer_transport:new(),
|
||||
{ok, Proto} = new_protocol(Trans),
|
||||
case thrift_protocol:write(Proto, {Type, Data}) of
|
||||
{NewProto, ok} ->
|
||||
{_, {ok, Result}} = thrift_protocol:close_transport(NewProto),
|
||||
Result;
|
||||
{_NewProto, {error, Reason}} ->
|
||||
Codec0 = thrift_strict_binary_codec:new(),
|
||||
case thrift_strict_binary_codec:write(Codec0, Type, Data) of
|
||||
{ok, Codec1} ->
|
||||
thrift_strict_binary_codec:close(Codec1);
|
||||
{error, Reason} ->
|
||||
erlang:error({thrift, {protocol, Reason}})
|
||||
end.
|
||||
|
||||
@ -107,22 +104,25 @@ serialize(Type, Data) ->
|
||||
term().
|
||||
|
||||
deserialize(Type, Data) ->
|
||||
{ok, Trans} = thrift_membuffer_transport:new(Data),
|
||||
{ok, Proto} = new_protocol(Trans),
|
||||
case thrift_protocol:read(Proto, Type) of
|
||||
{_NewProto, {ok, Result}} ->
|
||||
Result;
|
||||
{_NewProto, {error, Reason}} ->
|
||||
Codec0 = thrift_strict_binary_codec:new(Data),
|
||||
case thrift_strict_binary_codec:read(Codec0, Type) of
|
||||
{ok, Result, Codec1} ->
|
||||
case thrift_strict_binary_codec:close(Codec1) of
|
||||
<<>> ->
|
||||
Result;
|
||||
Leftovers ->
|
||||
erlang:error({thrift, {protocol, {excess_binary_data, Leftovers}}})
|
||||
end;
|
||||
{error, Reason} ->
|
||||
erlang:error({thrift, {protocol, Reason}})
|
||||
end.
|
||||
|
||||
-spec deserialize_function_args(thrift_fun_full_ref(), binary()) ->
|
||||
list(term()).
|
||||
woody:args().
|
||||
|
||||
deserialize_function_args({Module, {Service, Function}}, Data) ->
|
||||
ArgsType = Module:function_info(Service, Function, params_type),
|
||||
Args = deserialize(ArgsType, Data),
|
||||
erlang:tuple_to_list(Args).
|
||||
deserialize(ArgsType, Data).
|
||||
|
||||
-spec deserialize_function_reply(thrift_fun_full_ref(), binary()) ->
|
||||
term().
|
||||
@ -139,11 +139,6 @@ deserialize_function_exception(FunctionRef, Data) ->
|
||||
{_Name, Exception} = deserialize(ExceptionType, Data),
|
||||
Exception.
|
||||
|
||||
%% Internals
|
||||
|
||||
new_protocol(Trans) ->
|
||||
thrift_binary_protocol:new(Trans, [{strict_read, true}, {strict_write, true}]).
|
||||
|
||||
%%
|
||||
|
||||
-spec record_to_proplist(Record :: tuple(), RecordInfo :: [atom()]) -> [{atom(), _}].
|
||||
@ -172,25 +167,13 @@ get_fun_exception_type({Module, {Service, Function}}) ->
|
||||
{struct, struct, Exceptions} = DeclaredType,
|
||||
{struct, union, Exceptions}.
|
||||
|
||||
-spec find_exception_name(thrift_type(), thrift_exception()) ->
|
||||
-spec find_exception_name(thrift_fun_full_ref(), thrift_exception()) ->
|
||||
Name :: atom().
|
||||
|
||||
find_exception_name(Type, Exception) ->
|
||||
RecordName = erlang:element(1, Exception),
|
||||
{struct, union, Variants} = Type,
|
||||
do_find_exception_name(Variants, RecordName).
|
||||
|
||||
-spec do_find_exception_name(thrift_struct_def(), atom()) ->
|
||||
Name :: atom().
|
||||
|
||||
do_find_exception_name([], RecordName) ->
|
||||
erlang:error({thrift, {unknown_exception, RecordName}});
|
||||
do_find_exception_name([{_Tag, _Req, Type, Name, _Default} | Tail], RecordName) ->
|
||||
{struct, exception, {Module, Exception}} = Type,
|
||||
case Module:record_name(Exception) of
|
||||
TypeRecordName when TypeRecordName =:= RecordName ->
|
||||
find_exception_name({Module, {Service, Function}}, Exception) ->
|
||||
case thrift_processor_codec:match_exception({Module, Service}, Function, Exception) of
|
||||
{ok, {_Type, Name}} ->
|
||||
Name;
|
||||
_Other ->
|
||||
do_find_exception_name(Tail, RecordName)
|
||||
{error, bad_exception} ->
|
||||
erlang:error({thrift, {unknown_exception, Exception}})
|
||||
end.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user