mirror of
https://github.com/valitydev/fistful-server.git
synced 2024-11-06 10:45:21 +00:00
FF-157: Refactor create functions (#176)
* refactored wip * updated proto # Conflicts: # apps/ff_server/src/ff_identity_codec.erl # apps/ff_server/src/ff_wallet_codec.erl # apps/wapi/src/wapi_identity_backend.erl # apps/wapi/src/wapi_wallet_backend.erl # apps/wapi/test/wapi_thrift_SUITE.erl # rebar.lock * fixed * updated proto # Conflicts: # apps/wapi/src/wapi_identity_backend.erl # rebar.lock * refactored * fixed * fixed
This commit is contained in:
parent
a68a1d1011
commit
8d059b1be7
@ -177,8 +177,7 @@ create_identity(PartyID, ProviderID, ClassID) ->
|
||||
|
||||
create_identity(ID, PartyID, ProviderID, ClassID) ->
|
||||
ok = ff_identity_machine:create(
|
||||
ID,
|
||||
#{party => PartyID, provider => ProviderID, class => ClassID},
|
||||
#{id => ID, party => PartyID, provider => ProviderID, class => ClassID},
|
||||
ff_entity_context:new()
|
||||
),
|
||||
ID.
|
||||
|
@ -57,8 +57,10 @@ marshal(id, V) ->
|
||||
marshal(event_id, V) ->
|
||||
marshal(integer, V);
|
||||
|
||||
marshal(blocked, V) ->
|
||||
marshal(bool, V);
|
||||
marshal(blocking, blocked) ->
|
||||
blocked;
|
||||
marshal(blocking, unblocked) ->
|
||||
unblocked;
|
||||
|
||||
marshal(transaction_info, TransactionInfo = #{
|
||||
id := TransactionID,
|
||||
@ -214,6 +216,11 @@ unmarshal(id, V) ->
|
||||
unmarshal(event_id, V) ->
|
||||
unmarshal(integer, V);
|
||||
|
||||
unmarshal(blocking, blocked) ->
|
||||
blocked;
|
||||
unmarshal(blocking, unblocked) ->
|
||||
unblocked;
|
||||
|
||||
unmarshal(transaction_info, #'TransactionInfo'{
|
||||
id = TransactionID,
|
||||
timestamp = Timestamp,
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
unmarshal_destination_params(Params) ->
|
||||
genlib_map:compact(#{
|
||||
id => unmarshal(id, Params#dst_DestinationParams.id),
|
||||
identity => unmarshal(id, Params#dst_DestinationParams.identity),
|
||||
name => unmarshal(string, Params#dst_DestinationParams.name),
|
||||
currency => unmarshal(string, Params#dst_DestinationParams.currency),
|
||||
|
@ -24,7 +24,7 @@ handle_function(Func, Args, Opts) ->
|
||||
handle_function_('Create', [Params], Opts) ->
|
||||
ID = Params#dst_DestinationParams.id,
|
||||
Ctx = Params#dst_DestinationParams.context,
|
||||
case ff_destination:create(ID,
|
||||
case ff_destination:create(
|
||||
ff_destination_codec:unmarshal_destination_params(Params),
|
||||
ff_destination_codec:unmarshal(ctx, Ctx))
|
||||
of
|
||||
|
@ -24,12 +24,14 @@
|
||||
ff_identity_machine:params().
|
||||
|
||||
unmarshal_identity_params(#idnt_IdentityParams{
|
||||
id = ID,
|
||||
party = PartyID,
|
||||
provider = ProviderID,
|
||||
cls = ClassID,
|
||||
external_id = ExternalID
|
||||
}) ->
|
||||
genlib_map:compact(#{
|
||||
id => unmarshal(id, ID),
|
||||
party => unmarshal(id, PartyID),
|
||||
provider => unmarshal(id, ProviderID),
|
||||
class => unmarshal(id, ClassID),
|
||||
@ -105,7 +107,8 @@ marshal_identity(Identity) ->
|
||||
cls = marshal(id, ff_identity:class(Identity)),
|
||||
contract = maybe_marshal(id, ff_identity:contract(Identity)),
|
||||
level = maybe_marshal(id, ff_identity:level(Identity)),
|
||||
blocked = maybe_marshal(bool, ff_identity:blocked(Identity)),
|
||||
blocking = maybe_marshal(blocking, ff_identity:blocking(Identity)),
|
||||
created_at = maybe_marshal(created_at, ff_identity:created_at(Identity)),
|
||||
external_id = maybe_marshal(id, ff_identity:external_id(Identity)),
|
||||
effective_challenge = EffectiveChallengeID
|
||||
}.
|
||||
@ -119,20 +122,22 @@ unmarshal_identity(#idnt_Identity{
|
||||
cls = ClassID,
|
||||
contract = ContractID,
|
||||
level = LevelID,
|
||||
blocked = Blocked,
|
||||
blocking = Blocking,
|
||||
external_id = ExternalID,
|
||||
created_at = CreatedAt,
|
||||
effective_challenge = EffectiveChallengeID
|
||||
}) ->
|
||||
genlib_map:compact(#{
|
||||
id => unmarshal(id, ID),
|
||||
party => unmarshal(id, PartyID),
|
||||
provider => unmarshal(id, ProviderID),
|
||||
class => unmarshal(id, ClassID),
|
||||
contract => unmarshal(id, ContractID),
|
||||
level => maybe_unmarshal(id, LevelID),
|
||||
blocked => maybe_unmarshal(bool, Blocked),
|
||||
external_id => maybe_unmarshal(id, ExternalID),
|
||||
effective => maybe_unmarshal(id, EffectiveChallengeID)
|
||||
id => unmarshal(id, ID),
|
||||
party => unmarshal(id, PartyID),
|
||||
provider => unmarshal(id, ProviderID),
|
||||
class => unmarshal(id, ClassID),
|
||||
contract => unmarshal(id, ContractID),
|
||||
level => maybe_unmarshal(id, LevelID),
|
||||
blocking => maybe_unmarshal(blocking, Blocking),
|
||||
external_id => maybe_unmarshal(id, ExternalID),
|
||||
created_at => maybe_unmarshal(created_at, CreatedAt),
|
||||
effective => maybe_unmarshal(id, EffectiveChallengeID)
|
||||
}).
|
||||
|
||||
-spec marshal(ff_codec:type_name(), ff_codec:decoded_value()) -> ff_codec:encoded_value().
|
||||
@ -203,6 +208,9 @@ marshal(resolution, denied) ->
|
||||
marshal(ctx, Ctx) ->
|
||||
maybe_marshal(context, Ctx);
|
||||
|
||||
marshal(created_at, TimeMS) ->
|
||||
marshal(string, ff_time:to_rfc3339(TimeMS));
|
||||
|
||||
marshal(T, V) ->
|
||||
ff_codec:marshal(T, V).
|
||||
|
||||
@ -276,6 +284,9 @@ unmarshal(effective_challenge, undefined) ->
|
||||
unmarshal(effective_challenge, EffectiveChallengeID) ->
|
||||
{ok, unmarshal(id, EffectiveChallengeID)};
|
||||
|
||||
unmarshal(created_at, Timestamp) ->
|
||||
unmarshal(integer, ff_time:from_rfc3339(Timestamp));
|
||||
|
||||
unmarshal(ctx, Ctx) ->
|
||||
maybe_unmarshal(context, Ctx);
|
||||
|
||||
@ -303,7 +314,7 @@ maybe_unmarshal(Type, Value) ->
|
||||
|
||||
-spec identity_test() -> _.
|
||||
identity_test() ->
|
||||
Blocked = true,
|
||||
Blocking = blocked,
|
||||
IdentityIn = #{
|
||||
id => genlib:unique(),
|
||||
party => genlib:unique(),
|
||||
@ -311,7 +322,7 @@ identity_test() ->
|
||||
class => genlib:unique(),
|
||||
contract => genlib:unique(),
|
||||
level => genlib:unique(),
|
||||
blocked => Blocked,
|
||||
blocking => Blocking,
|
||||
external_id => genlib:unique(),
|
||||
effective => genlib:unique()
|
||||
},
|
||||
|
@ -23,10 +23,10 @@ handle_function(Func, Args, Opts) ->
|
||||
%% Internals
|
||||
%%
|
||||
|
||||
handle_function_('Create', [IdentityID, IdentityParams], Opts) ->
|
||||
Params = ff_identity_codec:unmarshal_identity_params(IdentityParams),
|
||||
handle_function_('Create', [IdentityParams], Opts) ->
|
||||
Params = #{id := IdentityID} = ff_identity_codec:unmarshal_identity_params(IdentityParams),
|
||||
Context = ff_identity_codec:unmarshal(ctx, IdentityParams#idnt_IdentityParams.context),
|
||||
case ff_identity_machine:create(IdentityID, Params, Context) of
|
||||
case ff_identity_machine:create(Params, Context) of
|
||||
ok ->
|
||||
handle_function_('Get', [IdentityID], Opts);
|
||||
{error, {provider, notfound}} ->
|
||||
@ -41,7 +41,7 @@ handle_function_('Create', [IdentityID, IdentityParams], Opts) ->
|
||||
handle_function_('Get', [ID], _Opts) ->
|
||||
case ff_identity_machine:get(ID) of
|
||||
{ok, Machine} ->
|
||||
Identity = ff_identity:set_blocked(ff_identity_machine:identity(Machine)),
|
||||
Identity = ff_identity:set_blocking(ff_identity_machine:identity(Machine)),
|
||||
Ctx = ff_identity_codec:marshal(ctx, ff_identity_machine:ctx(Machine)),
|
||||
Response = ff_identity_codec:marshal_identity(Identity),
|
||||
{ok, Response#idnt_Identity{context = Ctx}};
|
||||
|
@ -25,7 +25,8 @@ handle_function(Func, Args, Opts) ->
|
||||
|
||||
handle_function_('CreateSource', [Params], Opts) ->
|
||||
SourceID = Params#ff_admin_SourceParams.id,
|
||||
case ff_source:create(SourceID, #{
|
||||
case ff_source:create(#{
|
||||
id => SourceID,
|
||||
identity => Params#ff_admin_SourceParams.identity_id,
|
||||
name => Params#ff_admin_SourceParams.name,
|
||||
currency => ff_codec:unmarshal(currency_ref, Params#ff_admin_SourceParams.currency),
|
||||
|
@ -23,7 +23,7 @@ handle_function(Func, Args, Opts) ->
|
||||
%%
|
||||
handle_function_('Create', [Params], Opts) ->
|
||||
WalletID = Params#wlt_WalletParams.id,
|
||||
case ff_wallet_machine:create(WalletID,
|
||||
case ff_wallet_machine:create(
|
||||
decode(wallet_params, Params),
|
||||
decode(context, Params#wlt_WalletParams.context))
|
||||
of
|
||||
@ -73,6 +73,7 @@ encode(currency, CurrencyId) ->
|
||||
decode(wallet_params, Params) ->
|
||||
AccountParams = Params#wlt_WalletParams.account_params,
|
||||
#{
|
||||
id => Params#wlt_WalletParams.id,
|
||||
name => Params#wlt_WalletParams.name,
|
||||
identity => AccountParams#account_AccountParams.identity_id,
|
||||
currency => AccountParams#account_AccountParams.symbolic_code,
|
||||
|
@ -169,8 +169,7 @@ create_person_identity(Party, C) ->
|
||||
create_identity(Party, ProviderID, ClassID, _C) ->
|
||||
ID = genlib:unique(),
|
||||
ok = ff_identity_machine:create(
|
||||
ID,
|
||||
#{party => Party, provider => ProviderID, class => ClassID},
|
||||
#{id => ID, party => Party, provider => ProviderID, class => ClassID},
|
||||
ff_entity_context:new()
|
||||
),
|
||||
ID.
|
||||
|
@ -96,8 +96,8 @@ get_identity_events_ok(C) ->
|
||||
LastEvent = ct_eventsink:last_id(Sink),
|
||||
|
||||
ok = ff_identity_machine:create(
|
||||
ID,
|
||||
#{
|
||||
id => ID,
|
||||
party => Party,
|
||||
provider => <<"good-one">>,
|
||||
class => <<"person">>
|
||||
@ -138,8 +138,8 @@ get_create_wallet_events_ok(C) ->
|
||||
LastEvent = ct_eventsink:last_id(Sink),
|
||||
|
||||
ok = ff_wallet_machine:create(
|
||||
ID,
|
||||
#{
|
||||
id => ID,
|
||||
identity => IdentityID,
|
||||
name => <<"EVENTS TEST">>,
|
||||
currency => <<"RUB">>
|
||||
@ -337,8 +337,7 @@ create_person_identity(Party, C) ->
|
||||
create_identity(Party, ProviderID, ClassID, _C) ->
|
||||
ID = genlib:unique(),
|
||||
ok = ff_identity_machine:create(
|
||||
ID,
|
||||
#{party => Party, provider => ProviderID, class => ClassID},
|
||||
#{id => ID, party => Party, provider => ProviderID, class => ClassID},
|
||||
ff_entity_context:new()
|
||||
),
|
||||
ID.
|
||||
@ -346,8 +345,7 @@ create_identity(Party, ProviderID, ClassID, _C) ->
|
||||
create_wallet(IdentityID, Name, Currency, _C) ->
|
||||
ID = genlib:unique(),
|
||||
ok = ff_wallet_machine:create(
|
||||
ID,
|
||||
#{identity => IdentityID, name => Name, currency => Currency},
|
||||
#{id => ID, identity => IdentityID, name => Name, currency => Currency},
|
||||
ff_entity_context:new()
|
||||
),
|
||||
ID.
|
||||
@ -356,17 +354,16 @@ create_instrument(Type, IdentityID, Name, Currency, Resource, C) ->
|
||||
ID = genlib:unique(),
|
||||
ok = create_instrument(
|
||||
Type,
|
||||
ID,
|
||||
#{identity => IdentityID, name => Name, currency => Currency, resource => Resource},
|
||||
#{id => ID, identity => IdentityID, name => Name, currency => Currency, resource => Resource},
|
||||
ff_entity_context:new(),
|
||||
C
|
||||
),
|
||||
ID.
|
||||
|
||||
create_instrument(destination, ID, Params, Ctx, _C) ->
|
||||
ff_destination:create(ID, Params, Ctx);
|
||||
create_instrument(source, ID, Params, Ctx, _C) ->
|
||||
ff_source:create(ID, Params, Ctx).
|
||||
create_instrument(destination, Params, Ctx, _C) ->
|
||||
ff_destination:create(Params, Ctx);
|
||||
create_instrument(source, Params, Ctx, _C) ->
|
||||
ff_source:create(Params, Ctx).
|
||||
|
||||
generate_id() ->
|
||||
genlib:to_binary(genlib_time:ticks()).
|
||||
|
@ -83,12 +83,12 @@ create_identity_ok(_C) ->
|
||||
IID = Identity#idnt_Identity.id,
|
||||
{ok, Identity_} = call_api('Get', [IID]),
|
||||
|
||||
ProvID = Identity_#idnt_Identity.provider,
|
||||
IID = Identity_#idnt_Identity.id,
|
||||
ProvID = Identity_#idnt_Identity.provider,
|
||||
IID = Identity_#idnt_Identity.id,
|
||||
PartyID = Identity_#idnt_Identity.party,
|
||||
ClassID = Identity_#idnt_Identity.cls,
|
||||
false = Identity_#idnt_Identity.blocked,
|
||||
Ctx = ff_entity_context_codec:unmarshal(Identity_#idnt_Identity.context),
|
||||
blocked = Identity_#idnt_Identity.blocking,
|
||||
Ctx = ff_entity_context_codec:unmarshal(Identity_#idnt_Identity.context),
|
||||
ok.
|
||||
|
||||
run_challenge_ok(C) ->
|
||||
@ -212,15 +212,15 @@ get_challenges_ok(C) ->
|
||||
%% INTERNAL
|
||||
%%----------
|
||||
create_identity(EID, PartyID, ProvID, ClassID, Ctx) ->
|
||||
IID = genlib:unique(),
|
||||
Params = #idnt_IdentityParams{
|
||||
id = genlib:unique(),
|
||||
party = PartyID,
|
||||
provider = ProvID,
|
||||
cls = ClassID,
|
||||
external_id = EID,
|
||||
context = Ctx
|
||||
},
|
||||
{ok, IdentityState} = call_api('Create', [IID, Params]),
|
||||
{ok, IdentityState} = call_api('Create', [Params]),
|
||||
IdentityState.
|
||||
|
||||
gen_challenge_param(ClgClassID, ChallengeID, C) ->
|
||||
|
@ -169,8 +169,7 @@ create_person_identity(Party, C) ->
|
||||
create_identity(Party, ProviderID, ClassID, _C) ->
|
||||
ID = genlib:unique(),
|
||||
ok = ff_identity_machine:create(
|
||||
ID,
|
||||
#{party => Party, provider => ProviderID, class => ClassID},
|
||||
#{id => ID, party => Party, provider => ProviderID, class => ClassID},
|
||||
ff_entity_context:new()
|
||||
),
|
||||
ID.
|
||||
|
@ -306,8 +306,8 @@ create_identity() ->
|
||||
IdentityID = genlib:unique(),
|
||||
Party = create_party(),
|
||||
ok = ff_identity_machine:create(
|
||||
IdentityID,
|
||||
#{
|
||||
id => IdentityID,
|
||||
party => Party,
|
||||
provider => <<"good-one">>,
|
||||
class => <<"person">>
|
||||
|
@ -133,8 +133,7 @@ create_identity(Party, C) ->
|
||||
create_identity(Party, ProviderID, ClassID, _C) ->
|
||||
ID = genlib:unique(),
|
||||
ok = ff_identity_machine:create(
|
||||
ID,
|
||||
#{party => Party, provider => ProviderID, class => ClassID},
|
||||
#{id => ID, party => Party, provider => ProviderID, class => ClassID},
|
||||
ff_entity_context:new()
|
||||
),
|
||||
ID.
|
||||
@ -155,17 +154,16 @@ create_instrument(Type, IdentityID, Name, Currency, Resource, C) ->
|
||||
ID = genlib:unique(),
|
||||
ok = create_instrument(
|
||||
Type,
|
||||
ID,
|
||||
#{identity => IdentityID, name => Name, currency => Currency, resource => Resource},
|
||||
#{id => ID, identity => IdentityID, name => Name, currency => Currency, resource => Resource},
|
||||
ff_entity_context:new(),
|
||||
C
|
||||
),
|
||||
ID.
|
||||
|
||||
create_instrument(destination, ID, Params, Ctx, _C) ->
|
||||
ff_destination:create(ID, Params, Ctx);
|
||||
create_instrument(source, ID, Params, Ctx, _C) ->
|
||||
ff_source:create(ID, Params, Ctx).
|
||||
create_instrument(destination, Params, Ctx, _C) ->
|
||||
ff_destination:create(Params, Ctx);
|
||||
create_instrument(source, Params, Ctx, _C) ->
|
||||
ff_source:create(Params, Ctx).
|
||||
|
||||
create_failed_session(IdentityID, DestinationID, _C) ->
|
||||
ID = genlib:unique(),
|
||||
|
@ -100,7 +100,7 @@
|
||||
|
||||
%% API
|
||||
|
||||
-export([create/3]).
|
||||
-export([create/2]).
|
||||
-export([get_machine/1]).
|
||||
-export([get/1]).
|
||||
-export([ctx/1]).
|
||||
@ -181,15 +181,15 @@ unwrap_resource_id(#{<<"bank_card">> := ID}) ->
|
||||
|
||||
-define(NS, 'ff/destination_v2').
|
||||
|
||||
-spec create(id(), params(), ctx()) ->
|
||||
-spec create(params(), ctx()) ->
|
||||
ok |
|
||||
{error,
|
||||
_InstrumentCreateError |
|
||||
exists
|
||||
}.
|
||||
|
||||
create(ID, Params, Ctx) ->
|
||||
ff_instrument_machine:create(?NS, ID, Params, Ctx).
|
||||
create(Params, Ctx) ->
|
||||
ff_instrument_machine:create(?NS, Params, Ctx).
|
||||
|
||||
-spec get_machine(id()) ->
|
||||
{ok, machine()} |
|
||||
|
@ -19,7 +19,7 @@
|
||||
-export_type([events/1]).
|
||||
-export_type([params/1]).
|
||||
|
||||
-export([create/4]).
|
||||
-export([create/3]).
|
||||
-export([get/2]).
|
||||
-export([events/3]).
|
||||
|
||||
@ -43,6 +43,7 @@
|
||||
%%
|
||||
|
||||
-type params(T) :: #{
|
||||
id := id(),
|
||||
identity := ff_identity:id(),
|
||||
name := binary(),
|
||||
currency := ff_currency:id(),
|
||||
@ -50,14 +51,20 @@
|
||||
external_id => id()
|
||||
}.
|
||||
|
||||
-spec create(ns(), id(), params(_), ctx()) ->
|
||||
-spec create(ns(), params(_), ctx()) ->
|
||||
ok |
|
||||
{error,
|
||||
_InstrumentCreateError |
|
||||
exists
|
||||
}.
|
||||
|
||||
create(NS, ID, Params = #{identity := IdentityID, name := Name, currency := CurrencyID, resource := Resource}, Ctx) ->
|
||||
create(NS, Params = #{
|
||||
id := ID,
|
||||
identity := IdentityID,
|
||||
name := Name,
|
||||
currency := CurrencyID,
|
||||
resource := Resource
|
||||
}, Ctx) ->
|
||||
do(fun () ->
|
||||
Events = unwrap(ff_instrument:create(
|
||||
ID,
|
||||
|
@ -46,7 +46,7 @@
|
||||
|
||||
%% API
|
||||
|
||||
-export([create/3]).
|
||||
-export([create/2]).
|
||||
-export([get_machine/1]).
|
||||
-export([get/1]).
|
||||
-export([is_accessible/1]).
|
||||
@ -78,15 +78,15 @@ external_id(T) -> ff_instrument:external_id(T).
|
||||
|
||||
-define(NS, 'ff/source_v1').
|
||||
|
||||
-spec create(id(), params(), ctx()) ->
|
||||
-spec create(params(), ctx()) ->
|
||||
ok |
|
||||
{error,
|
||||
_InstrumentCreateError |
|
||||
exists
|
||||
}.
|
||||
|
||||
create(ID, Params, Ctx) ->
|
||||
ff_instrument_machine:create(?NS, ID, Params, Ctx).
|
||||
create(Params, Ctx) ->
|
||||
ff_instrument_machine:create(?NS, Params, Ctx).
|
||||
|
||||
-spec get_machine(id()) ->
|
||||
{ok, machine()} |
|
||||
|
@ -292,8 +292,7 @@ create_person_identity(Party, C, ProviderID) ->
|
||||
create_identity(Party, ProviderID, ClassID, _C) ->
|
||||
ID = genlib:unique(),
|
||||
ok = ff_identity_machine:create(
|
||||
ID,
|
||||
#{party => Party, provider => ProviderID, class => ClassID},
|
||||
#{id => ID, party => Party, provider => ProviderID, class => ClassID},
|
||||
ff_entity_context:new()
|
||||
),
|
||||
ID.
|
||||
@ -301,8 +300,7 @@ create_identity(Party, ProviderID, ClassID, _C) ->
|
||||
create_wallet(IdentityID, Name, Currency, _C) ->
|
||||
ID = genlib:unique(),
|
||||
ok = ff_wallet_machine:create(
|
||||
ID,
|
||||
#{identity => IdentityID, name => Name, currency => Currency},
|
||||
#{id => ID, identity => IdentityID, name => Name, currency => Currency},
|
||||
ff_entity_context:new()
|
||||
),
|
||||
ID.
|
||||
@ -339,8 +337,8 @@ generate_id() ->
|
||||
create_source(IID, _C) ->
|
||||
ID = generate_id(),
|
||||
SrcResource = #{type => internal, details => <<"Infinite source of cash">>},
|
||||
Params = #{identity => IID, name => <<"XSource">>, currency => <<"RUB">>, resource => SrcResource},
|
||||
ok = ff_source:create(ID, Params, ff_entity_context:new()),
|
||||
Params = #{id => ID, identity => IID, name => <<"XSource">>, currency => <<"RUB">>, resource => SrcResource},
|
||||
ok = ff_source:create(Params, ff_entity_context:new()),
|
||||
authorized = ct_helper:await(
|
||||
authorized,
|
||||
fun () ->
|
||||
|
@ -388,8 +388,7 @@ create_person_identity(Party, C, ProviderID) ->
|
||||
create_identity(Party, ProviderID, ClassID, _C) ->
|
||||
ID = genlib:unique(),
|
||||
ok = ff_identity_machine:create(
|
||||
ID,
|
||||
#{party => Party, provider => ProviderID, class => ClassID},
|
||||
#{id => ID, party => Party, provider => ProviderID, class => ClassID},
|
||||
ff_entity_context:new()
|
||||
),
|
||||
ID.
|
||||
@ -397,8 +396,7 @@ create_identity(Party, ProviderID, ClassID, _C) ->
|
||||
create_wallet(IdentityID, Name, Currency, _C) ->
|
||||
ID = genlib:unique(),
|
||||
ok = ff_wallet_machine:create(
|
||||
ID,
|
||||
#{identity => IdentityID, name => Name, currency => Currency},
|
||||
#{id => ID, identity => IdentityID, name => Name, currency => Currency},
|
||||
ff_entity_context:new()
|
||||
),
|
||||
ID.
|
||||
@ -441,8 +439,8 @@ generate_id() ->
|
||||
create_source(IID, _C) ->
|
||||
ID = generate_id(),
|
||||
SrcResource = #{type => internal, details => <<"Infinite source of cash">>},
|
||||
Params = #{identity => IID, name => <<"XSource">>, currency => <<"RUB">>, resource => SrcResource},
|
||||
ok = ff_source:create(ID, Params, ff_entity_context:new()),
|
||||
Params = #{id => ID, identity => IID, name => <<"XSource">>, currency => <<"RUB">>, resource => SrcResource},
|
||||
ok = ff_source:create(Params, ff_entity_context:new()),
|
||||
authorized = ct_helper:await(
|
||||
authorized,
|
||||
fun () ->
|
||||
|
@ -393,8 +393,7 @@ create_person_identity(Party, C, ProviderID) ->
|
||||
create_identity(Party, ProviderID, ClassID, _C) ->
|
||||
ID = genlib:unique(),
|
||||
ok = ff_identity_machine:create(
|
||||
ID,
|
||||
#{party => Party, provider => ProviderID, class => ClassID},
|
||||
#{id => ID, party => Party, provider => ProviderID, class => ClassID},
|
||||
ff_entity_context:new()
|
||||
),
|
||||
ID.
|
||||
@ -402,8 +401,7 @@ create_identity(Party, ProviderID, ClassID, _C) ->
|
||||
create_wallet(IdentityID, Name, Currency, _C) ->
|
||||
ID = genlib:unique(),
|
||||
ok = ff_wallet_machine:create(
|
||||
ID,
|
||||
#{identity => IdentityID, name => Name, currency => Currency},
|
||||
#{id => ID, identity => IdentityID, name => Name, currency => Currency},
|
||||
ff_entity_context:new()
|
||||
),
|
||||
ID.
|
||||
@ -450,8 +448,8 @@ generate_id() ->
|
||||
create_source(IID, _C) ->
|
||||
ID = generate_id(),
|
||||
SrcResource = #{type => internal, details => <<"Infinite source of cash">>},
|
||||
Params = #{identity => IID, name => <<"XSource">>, currency => <<"RUB">>, resource => SrcResource},
|
||||
ok = ff_source:create(ID, Params, ff_entity_context:new()),
|
||||
Params = #{id => ID, identity => IID, name => <<"XSource">>, currency => <<"RUB">>, resource => SrcResource},
|
||||
ok = ff_source:create(Params, ff_entity_context:new()),
|
||||
authorized = ct_helper:await(
|
||||
authorized,
|
||||
fun () ->
|
||||
|
@ -443,8 +443,7 @@ create_person_identity(Party, C, ProviderID) ->
|
||||
create_identity(Party, ProviderID, ClassID, _C) ->
|
||||
ID = genlib:unique(),
|
||||
ok = ff_identity_machine:create(
|
||||
ID,
|
||||
#{party => Party, provider => ProviderID, class => ClassID},
|
||||
#{id => ID, party => Party, provider => ProviderID, class => ClassID},
|
||||
ff_entity_context:new()
|
||||
),
|
||||
ID.
|
||||
@ -452,8 +451,7 @@ create_identity(Party, ProviderID, ClassID, _C) ->
|
||||
create_wallet(IdentityID, Name, Currency, _C) ->
|
||||
ID = genlib:unique(),
|
||||
ok = ff_wallet_machine:create(
|
||||
ID,
|
||||
#{identity => IdentityID, name => Name, currency => Currency},
|
||||
#{id => ID, identity => IdentityID, name => Name, currency => Currency},
|
||||
ff_entity_context:new()
|
||||
),
|
||||
ID.
|
||||
@ -500,8 +498,8 @@ generate_id() ->
|
||||
create_source(IID, _C) ->
|
||||
ID = generate_id(),
|
||||
SrcResource = #{type => internal, details => <<"Infinite source of cash">>},
|
||||
Params = #{identity => IID, name => <<"XSource">>, currency => <<"RUB">>, resource => SrcResource},
|
||||
ok = ff_source:create(ID, Params, ff_entity_context:new()),
|
||||
Params = #{id => ID, identity => IID, name => <<"XSource">>, currency => <<"RUB">>, resource => SrcResource},
|
||||
ok = ff_source:create(Params, ff_entity_context:new()),
|
||||
authorized = ct_helper:await(
|
||||
authorized,
|
||||
fun () ->
|
||||
|
@ -352,8 +352,7 @@ create_person_identity(Party, C, ProviderID) ->
|
||||
create_identity(Party, ProviderID, ClassID, _C) ->
|
||||
ID = genlib:unique(),
|
||||
ok = ff_identity_machine:create(
|
||||
ID,
|
||||
#{party => Party, provider => ProviderID, class => ClassID},
|
||||
#{id => ID, party => Party, provider => ProviderID, class => ClassID},
|
||||
ff_entity_context:new()
|
||||
),
|
||||
ID.
|
||||
@ -361,8 +360,7 @@ create_identity(Party, ProviderID, ClassID, _C) ->
|
||||
create_wallet(IdentityID, Name, Currency, _C) ->
|
||||
ID = genlib:unique(),
|
||||
ok = ff_wallet_machine:create(
|
||||
ID,
|
||||
#{identity => IdentityID, name => Name, currency => Currency},
|
||||
#{id => ID, identity => IdentityID, name => Name, currency => Currency},
|
||||
ff_entity_context:new()
|
||||
),
|
||||
ID.
|
||||
@ -404,17 +402,16 @@ create_instrument(Type, IdentityID, Name, Currency, Resource, C) ->
|
||||
ID = genlib:unique(),
|
||||
ok = create_instrument(
|
||||
Type,
|
||||
ID,
|
||||
#{identity => IdentityID, name => Name, currency => Currency, resource => Resource},
|
||||
#{id => ID, identity => IdentityID, name => Name, currency => Currency, resource => Resource},
|
||||
ff_entity_context:new(),
|
||||
C
|
||||
),
|
||||
ID.
|
||||
|
||||
create_instrument(destination, ID, Params, Ctx, _C) ->
|
||||
ff_destination:create(ID, Params, Ctx);
|
||||
create_instrument(source, ID, Params, Ctx, _C) ->
|
||||
ff_source:create(ID, Params, Ctx).
|
||||
create_instrument(destination, Params, Ctx, _C) ->
|
||||
ff_destination:create(Params, Ctx);
|
||||
create_instrument(source, Params, Ctx, _C) ->
|
||||
ff_source:create(Params, Ctx).
|
||||
|
||||
generate_id() ->
|
||||
genlib:to_binary(genlib_time:ticks()).
|
||||
|
@ -573,8 +573,7 @@ create_person_identity(Party, C, ProviderID) ->
|
||||
create_identity(Party, ProviderID, ClassID, _C) ->
|
||||
ID = genlib:unique(),
|
||||
ok = ff_identity_machine:create(
|
||||
ID,
|
||||
#{party => Party, provider => ProviderID, class => ClassID},
|
||||
#{id => ID, party => Party, provider => ProviderID, class => ClassID},
|
||||
ff_entity_context:new()
|
||||
),
|
||||
ID.
|
||||
@ -582,8 +581,7 @@ create_identity(Party, ProviderID, ClassID, _C) ->
|
||||
create_wallet(IdentityID, Name, Currency, _C) ->
|
||||
ID = genlib:unique(),
|
||||
ok = ff_wallet_machine:create(
|
||||
ID,
|
||||
#{identity => IdentityID, name => Name, currency => Currency},
|
||||
#{id => ID, identity => IdentityID, name => Name, currency => Currency},
|
||||
ff_entity_context:new()
|
||||
),
|
||||
ID.
|
||||
@ -626,8 +624,8 @@ create_destination(IID, Currency, Token, C) ->
|
||||
StoreSource#{token => Token}
|
||||
end,
|
||||
Resource = {bank_card, NewStoreResource},
|
||||
Params = #{identity => IID, name => <<"XDesination">>, currency => Currency, resource => Resource},
|
||||
ok = ff_destination:create(ID, Params, ff_entity_context:new()),
|
||||
Params = #{id => ID, identity => IID, name => <<"XDesination">>, currency => Currency, resource => Resource},
|
||||
ok = ff_destination:create(Params, ff_entity_context:new()),
|
||||
authorized = ct_helper:await(
|
||||
authorized,
|
||||
fun () ->
|
||||
@ -643,8 +641,8 @@ create_crypto_destination(IID, _C) ->
|
||||
id => <<"a30e277c07400c9940628828949efd48">>,
|
||||
currency => {litecoin, #{}}
|
||||
}},
|
||||
Params = #{identity => IID, name => <<"CryptoDestination">>, currency => <<"RUB">>, resource => Resource},
|
||||
ok = ff_destination:create(ID, Params, ff_entity_context:new()),
|
||||
Params = #{id => ID, identity => IID, name => <<"CryptoDestination">>, currency => <<"RUB">>, resource => Resource},
|
||||
ok = ff_destination:create(Params, ff_entity_context:new()),
|
||||
authorized = ct_helper:await(
|
||||
authorized,
|
||||
fun () ->
|
||||
|
@ -390,8 +390,7 @@ create_person_identity(Party, C, ProviderID) ->
|
||||
create_identity(Party, ProviderID, ClassID, _C) ->
|
||||
ID = genlib:unique(),
|
||||
ok = ff_identity_machine:create(
|
||||
ID,
|
||||
#{party => Party, provider => ProviderID, class => ClassID},
|
||||
#{id => ID, party => Party, provider => ProviderID, class => ClassID},
|
||||
ff_entity_context:new()
|
||||
),
|
||||
ID.
|
||||
@ -399,8 +398,7 @@ create_identity(Party, ProviderID, ClassID, _C) ->
|
||||
create_wallet(IdentityID, Name, Currency, _C) ->
|
||||
ID = genlib:unique(),
|
||||
ok = ff_wallet_machine:create(
|
||||
ID,
|
||||
#{identity => IdentityID, name => Name, currency => Currency},
|
||||
#{id => ID, identity => IdentityID, name => Name, currency => Currency},
|
||||
ff_entity_context:new()
|
||||
),
|
||||
ID.
|
||||
@ -443,8 +441,8 @@ generate_id() ->
|
||||
create_destination(IID, C) ->
|
||||
ID = generate_id(),
|
||||
Resource = {bank_card, ct_cardstore:bank_card(<<"4150399999000900">>, {12, 2025}, C)},
|
||||
Params = #{identity => IID, name => <<"XDesination">>, currency => <<"RUB">>, resource => Resource},
|
||||
ok = ff_destination:create(ID, Params, ff_entity_context:new()),
|
||||
Params = #{id => ID, identity => IID, name => <<"XDesination">>, currency => <<"RUB">>, resource => Resource},
|
||||
ok = ff_destination:create(Params, ff_entity_context:new()),
|
||||
authorized = ct_helper:await(
|
||||
authorized,
|
||||
fun () ->
|
||||
|
@ -24,7 +24,7 @@
|
||||
-type challenge_class() :: ff_identity_challenge:challenge_class().
|
||||
-type challenge_class_id() :: ff_identity_class:challenge_class_id().
|
||||
-type challenge_id() :: id().
|
||||
-type blocked() :: boolean().
|
||||
-type blocking() :: unblocked | blocked.
|
||||
-type level() :: ff_identity_class:level().
|
||||
-type level_id() :: ff_identity_class:level_id().
|
||||
|
||||
@ -38,7 +38,8 @@
|
||||
challenges => #{challenge_id() => challenge()},
|
||||
effective => challenge_id(),
|
||||
external_id => id(),
|
||||
blocked => blocked()
|
||||
blocking => blocking(),
|
||||
created_at => ff_time:timestamp_ms()
|
||||
}.
|
||||
|
||||
-type challenge() ::
|
||||
@ -81,10 +82,11 @@
|
||||
-export([challenge/2]).
|
||||
-export([effective_challenge/1]).
|
||||
-export([external_id/1]).
|
||||
-export([blocked/1]).
|
||||
-export([blocking/1]).
|
||||
-export([created_at/1]).
|
||||
|
||||
-export([is_accessible/1]).
|
||||
-export([set_blocked/1]).
|
||||
-export([set_blocking/1]).
|
||||
|
||||
-export([create/5]).
|
||||
|
||||
@ -109,7 +111,7 @@
|
||||
party_id().
|
||||
-spec contract(identity()) ->
|
||||
contract_id().
|
||||
-spec blocked(identity()) ->
|
||||
-spec blocking(identity()) ->
|
||||
boolean() | undefined.
|
||||
-spec level(identity()) ->
|
||||
level_id() | undefined.
|
||||
@ -121,6 +123,8 @@
|
||||
ff_map:result(challenge()).
|
||||
-spec external_id(identity()) ->
|
||||
external_id().
|
||||
-spec created_at(identity()) ->
|
||||
ff_time:timestamp_ms() | undefined.
|
||||
|
||||
id(#{id := V}) ->
|
||||
V.
|
||||
@ -137,8 +141,8 @@ party(#{party := V}) ->
|
||||
contract(#{contract := V}) ->
|
||||
V.
|
||||
|
||||
blocked(Identity) ->
|
||||
maps:get(blocked, Identity, undefined).
|
||||
blocking(Identity) ->
|
||||
maps:get(blocking, Identity, undefined).
|
||||
|
||||
level(Identity) ->
|
||||
maps:get(level, Identity, undefined).
|
||||
@ -155,6 +159,9 @@ challenge(ChallengeID, Identity) ->
|
||||
external_id(Identity) ->
|
||||
maps:get(external_id, Identity, undefined).
|
||||
|
||||
created_at(Identity) ->
|
||||
maps:get(created_at, Identity, undefined).
|
||||
|
||||
-spec is_accessible(identity()) ->
|
||||
{ok, accessible} |
|
||||
{error, ff_party:inaccessibility()}.
|
||||
@ -163,12 +170,16 @@ is_accessible(Identity) ->
|
||||
ff_party:is_accessible(party(Identity)).
|
||||
|
||||
|
||||
-spec set_blocked(identity()) -> identity().
|
||||
|
||||
set_blocked(Identity) ->
|
||||
Blocked = {ok, accessible} =/= is_accessible(Identity),
|
||||
maps:put(blocked, Blocked, Identity).
|
||||
-spec set_blocking(identity()) -> identity().
|
||||
|
||||
set_blocking(Identity) ->
|
||||
Blocking = case {ok, accessible} =/= is_accessible(Identity) of
|
||||
true ->
|
||||
unblocked;
|
||||
false ->
|
||||
blocked
|
||||
end,
|
||||
maps:put(blocking, Blocking, Identity).
|
||||
|
||||
%% Constructor
|
||||
|
||||
@ -193,7 +204,9 @@ create(ID, Party, ProviderID, ClassID, ExternalID) ->
|
||||
party => Party,
|
||||
provider => ProviderID,
|
||||
class => ClassID,
|
||||
contract => Contract
|
||||
contract => Contract,
|
||||
%% TODO need migration for events
|
||||
created_at => ff_time:now()
|
||||
})},
|
||||
{level_changed,
|
||||
LevelID
|
||||
|
@ -35,7 +35,7 @@
|
||||
-export_type([challenge_params/0]).
|
||||
-export_type([params/0]).
|
||||
|
||||
-export([create/3]).
|
||||
-export([create/2]).
|
||||
-export([get/1]).
|
||||
-export([events/2]).
|
||||
|
||||
@ -61,20 +61,21 @@
|
||||
-define(NS, 'ff/identity').
|
||||
|
||||
-type params() :: #{
|
||||
id := id(),
|
||||
party := ff_party:id(),
|
||||
provider := ff_provider:id(),
|
||||
class := ff_identity:class_id(),
|
||||
external_id => id()
|
||||
}.
|
||||
|
||||
-spec create(id(), params(), ctx()) ->
|
||||
-spec create(params(), ctx()) ->
|
||||
ok |
|
||||
{error,
|
||||
ff_identity:create_error() |
|
||||
exists
|
||||
}.
|
||||
|
||||
create(ID, Params = #{party := Party, provider := ProviderID, class := IdentityClassID}, Ctx) ->
|
||||
create(Params = #{id := ID, party := Party, provider := ProviderID, class := IdentityClassID}, Ctx) ->
|
||||
do(fun () ->
|
||||
Events = unwrap(ff_identity:create(
|
||||
ID,
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
-export_type([id/0]).
|
||||
|
||||
-export([create/3]).
|
||||
-export([create/2]).
|
||||
-export([get/1]).
|
||||
-export([events/2]).
|
||||
|
||||
@ -56,16 +56,17 @@ ctx(St) ->
|
||||
%%
|
||||
|
||||
-type params() :: #{
|
||||
id := id(),
|
||||
identity := ff_identity_machine:id(),
|
||||
name := binary(),
|
||||
currency := ff_currency:id(),
|
||||
external_id => id()
|
||||
}.
|
||||
|
||||
-spec create(id(), params(), ctx()) ->
|
||||
-spec create(params(), ctx()) ->
|
||||
ok | {error, exists | ff_wallet:create_error() }.
|
||||
|
||||
create(ID, Params = #{identity := IdentityID, name := Name, currency := CurrencyID}, Ctx) ->
|
||||
create(Params = #{id := ID, identity := IdentityID, name := Name, currency := CurrencyID}, Ctx) ->
|
||||
do(fun () ->
|
||||
Events = unwrap(ff_wallet:create(
|
||||
ID,
|
||||
|
@ -72,8 +72,8 @@ get_missing_fails(_C) ->
|
||||
create_missing_fails(_C) ->
|
||||
ID = genlib:unique(),
|
||||
{error, {provider, notfound}} = ff_identity_machine:create(
|
||||
ID,
|
||||
#{
|
||||
id => ID,
|
||||
party => <<"party">>,
|
||||
provider => <<"who">>,
|
||||
class => <<"person">>
|
||||
@ -81,8 +81,8 @@ create_missing_fails(_C) ->
|
||||
ff_entity_context:new()
|
||||
),
|
||||
{error, {identity_class, notfound}} = ff_identity_machine:create(
|
||||
ID,
|
||||
#{
|
||||
id => ID,
|
||||
party => <<"party">>,
|
||||
provider => <<"good-one">>,
|
||||
class => <<"nosrep">>
|
||||
@ -94,8 +94,8 @@ create_ok(C) ->
|
||||
ID = genlib:unique(),
|
||||
Party = create_party(C),
|
||||
ok = ff_identity_machine:create(
|
||||
ID,
|
||||
#{
|
||||
id => ID,
|
||||
party => Party,
|
||||
provider => <<"good-one">>,
|
||||
class => <<"person">>
|
||||
@ -111,8 +111,8 @@ identify_ok(C) ->
|
||||
ID = genlib:unique(),
|
||||
Party = create_party(C),
|
||||
ok = ff_identity_machine:create(
|
||||
ID,
|
||||
#{
|
||||
id => ID,
|
||||
party => Party,
|
||||
provider => <<"good-one">>,
|
||||
class => <<"person">>
|
||||
|
@ -88,7 +88,7 @@ create_ok(C) ->
|
||||
Party = create_party(C),
|
||||
IdentityID = create_identity(Party, C),
|
||||
WalletParams = construct_wallet_params(IdentityID),
|
||||
CreateResult = ff_wallet_machine:create(ID, WalletParams, ff_entity_context:new()),
|
||||
CreateResult = ff_wallet_machine:create(WalletParams#{id => ID}, ff_entity_context:new()),
|
||||
Wallet = ff_wallet_machine:wallet(unwrap(ff_wallet_machine:get(ID))),
|
||||
Accessibility = unwrap(ff_wallet:is_accessible(Wallet)),
|
||||
Account = ff_wallet:account(Wallet),
|
||||
@ -103,15 +103,15 @@ create_error_id_exists(C) ->
|
||||
Party = create_party(C),
|
||||
IdentityID = create_identity(Party, C),
|
||||
WalletParams = construct_wallet_params(IdentityID),
|
||||
CreateResult0 = ff_wallet_machine:create(ID, WalletParams, ff_entity_context:new()),
|
||||
CreateResult1 = ff_wallet_machine:create(ID, WalletParams, ff_entity_context:new()),
|
||||
CreateResult0 = ff_wallet_machine:create(WalletParams#{id => ID}, ff_entity_context:new()),
|
||||
CreateResult1 = ff_wallet_machine:create(WalletParams#{id => ID}, ff_entity_context:new()),
|
||||
?assertMatch(ok, CreateResult0),
|
||||
?assertMatch({error, exists}, CreateResult1).
|
||||
|
||||
create_error_identity_not_found(_C) ->
|
||||
ID = genlib:unique(),
|
||||
WalletParams = construct_wallet_params(genlib:unique()),
|
||||
CreateResult = ff_wallet_machine:create(ID, WalletParams, ff_entity_context:new()),
|
||||
CreateResult = ff_wallet_machine:create(WalletParams#{id => ID}, ff_entity_context:new()),
|
||||
?assertMatch({error, {identity, notfound}}, CreateResult).
|
||||
|
||||
create_error_currency_not_found(C) ->
|
||||
@ -119,7 +119,7 @@ create_error_currency_not_found(C) ->
|
||||
Party = create_party(C),
|
||||
IdentityID = create_identity(Party, C),
|
||||
WalletParams = construct_wallet_params(IdentityID, <<"EOS">>),
|
||||
CreateResult = ff_wallet_machine:create(ID, WalletParams, ff_entity_context:new()),
|
||||
CreateResult = ff_wallet_machine:create(WalletParams#{id => ID}, ff_entity_context:new()),
|
||||
?assertMatch({error, {currency, notfound}}, CreateResult).
|
||||
|
||||
create_error_party_blocked(C) ->
|
||||
@ -128,7 +128,7 @@ create_error_party_blocked(C) ->
|
||||
IdentityID = create_identity(Party, C),
|
||||
ok = block_party(Party, C),
|
||||
WalletParams = construct_wallet_params(IdentityID),
|
||||
CreateResult = ff_wallet_machine:create(ID, WalletParams, ff_entity_context:new()),
|
||||
CreateResult = ff_wallet_machine:create(WalletParams#{id => ID}, ff_entity_context:new()),
|
||||
?assertMatch({error, {party, {inaccessible, blocked}}}, CreateResult).
|
||||
|
||||
create_error_party_suspended(C) ->
|
||||
@ -137,7 +137,7 @@ create_error_party_suspended(C) ->
|
||||
IdentityID = create_identity(Party, C),
|
||||
ok = suspend_party(Party, C),
|
||||
WalletParams = construct_wallet_params(IdentityID),
|
||||
CreateResult = ff_wallet_machine:create(ID, WalletParams, ff_entity_context:new()),
|
||||
CreateResult = ff_wallet_machine:create(WalletParams#{id => ID}, ff_entity_context:new()),
|
||||
?assertMatch({error, {party, {inaccessible, suspended}}}, CreateResult).
|
||||
|
||||
create_error_terms_not_allowed_currency(C) ->
|
||||
@ -145,7 +145,7 @@ create_error_terms_not_allowed_currency(C) ->
|
||||
Party = create_party(C),
|
||||
IdentityID = create_identity(Party, C),
|
||||
WalletParams = construct_wallet_params(IdentityID, <<"EUR">>),
|
||||
CreateResult = ff_wallet_machine:create(ID, WalletParams, ff_entity_context:new()),
|
||||
CreateResult = ff_wallet_machine:create(WalletParams#{id => ID}, ff_entity_context:new()),
|
||||
ExpectedError = {terms, {terms_violation, {not_allowed_currency, {<<"EUR">>, [
|
||||
#domain_CurrencyRef{symbolic_code = <<"RUB">>},
|
||||
#domain_CurrencyRef{symbolic_code = <<"USD">>}
|
||||
@ -167,8 +167,8 @@ create_identity(Party, C) ->
|
||||
create_identity(Party, ProviderID, ClassID, _C) ->
|
||||
ID = genlib:unique(),
|
||||
ok = ff_identity_machine:create(
|
||||
ID,
|
||||
#{
|
||||
id => ID,
|
||||
party => Party,
|
||||
provider => ProviderID,
|
||||
class => ClassID
|
||||
|
@ -123,8 +123,7 @@ create_person_identity(Party, C, ProviderID) ->
|
||||
create_identity(Party, ProviderID, ClassID, _C) ->
|
||||
ID = genlib:unique(),
|
||||
ok = ff_identity_machine:create(
|
||||
ID,
|
||||
#{party => Party, provider => ProviderID, class => ClassID},
|
||||
#{id => ID, party => Party, provider => ProviderID, class => ClassID},
|
||||
ff_entity_context:new()
|
||||
),
|
||||
ID.
|
||||
|
@ -71,8 +71,7 @@ create_person_identity(Party, C, ProviderID) ->
|
||||
create_identity(Party, ProviderID, ClassID, _C) ->
|
||||
ID = genlib:unique(),
|
||||
ok = ff_identity_machine:create(
|
||||
ID,
|
||||
#{party => Party, provider => ProviderID, class => ClassID},
|
||||
#{id => ID, party => Party, provider => ProviderID, class => ClassID},
|
||||
ff_entity_context:new()
|
||||
),
|
||||
ID.
|
||||
|
@ -377,8 +377,7 @@ create_person_identity(Party, C, ProviderID) ->
|
||||
create_identity(Party, ProviderID, ClassID, _C) ->
|
||||
ID = genlib:unique(),
|
||||
ok = ff_identity_machine:create(
|
||||
ID,
|
||||
#{party => Party, provider => ProviderID, class => ClassID},
|
||||
#{id => ID, party => Party, provider => ProviderID, class => ClassID},
|
||||
ff_entity_context:new()
|
||||
),
|
||||
ID.
|
||||
|
@ -146,10 +146,10 @@ get_identity(IdentityId, Context) ->
|
||||
{external_id_conflict, id(), external_id()}
|
||||
).
|
||||
create_identity(Params, Context) ->
|
||||
IdentityParams = from_swag(identity_params, Params),
|
||||
CreateIdentity = fun(ID, EntityCtx) ->
|
||||
ff_identity_machine:create(
|
||||
ID,
|
||||
maps:merge(from_swag(identity_params, Params), #{party => wapi_handler_utils:get_owner(Context)}),
|
||||
maps:merge(IdentityParams#{id => ID}, #{party => wapi_handler_utils:get_owner(Context)}),
|
||||
add_meta_to_ctx([<<"name">>], Params, EntityCtx)
|
||||
)
|
||||
end,
|
||||
@ -278,11 +278,11 @@ get_wallet_by_external_id(ExternalID, #{woody_context := WoodyContext} = Context
|
||||
ff_wallet:create_error()
|
||||
).
|
||||
create_wallet(Params = #{<<"identity">> := IdenityId}, Context) ->
|
||||
WalletParams = from_swag(wallet_params, Params),
|
||||
CreateFun = fun(ID, EntityCtx) ->
|
||||
_ = check_resource(identity, IdenityId, Context),
|
||||
ff_wallet_machine:create(
|
||||
ID,
|
||||
from_swag(wallet_params, Params),
|
||||
WalletParams#{id => ID},
|
||||
add_meta_to_ctx([], Params, EntityCtx)
|
||||
)
|
||||
end,
|
||||
@ -355,8 +355,7 @@ create_destination(Params = #{<<"identity">> := IdenityId}, Context) ->
|
||||
DestinationParams = from_swag(destination_params, Params),
|
||||
Resource = unwrap(construct_resource(maps:get(resource, DestinationParams))),
|
||||
ff_destination:create(
|
||||
ID,
|
||||
DestinationParams#{resource => Resource},
|
||||
DestinationParams#{id => ID, resource => Resource},
|
||||
add_meta_to_ctx([], Params, EntityCtx)
|
||||
)
|
||||
end,
|
||||
|
@ -59,7 +59,7 @@
|
||||
0},
|
||||
{<<"fistful_proto">>,
|
||||
{git,"git@github.com:rbkmoney/fistful-proto.git",
|
||||
{ref,"6f874c11828dfd248dd9c9447db02dd4eee72783"}},
|
||||
{ref,"2baaac00772ab167e31bec6ce975bd6e1d586250"}},
|
||||
0},
|
||||
{<<"fistful_reporter_proto">>,
|
||||
{git,"git@github.com:rbkmoney/fistful-reporter-proto.git",
|
||||
|
Loading…
Reference in New Issue
Block a user