mirror of
https://github.com/valitydev/hellgate.git
synced 2024-11-06 10:55:22 +00:00
HG-503: Add GetStatus API call for PartyManagement (#361)
* HG-503: Add GetStatus API call for PartyManagement * Typo
This commit is contained in:
parent
4420f93174
commit
83925e1856
@ -23,6 +23,7 @@
|
||||
-export([create_party/3]).
|
||||
-export([blocking/2]).
|
||||
-export([suspension/2]).
|
||||
-export([get_status/1]).
|
||||
|
||||
-export([get_contractor/2]).
|
||||
-export([set_contractor/2]).
|
||||
@ -50,6 +51,7 @@
|
||||
|
||||
-export_type([party/0]).
|
||||
-export_type([party_revision/0]).
|
||||
-export_type([party_status/0]).
|
||||
|
||||
%% Asserts
|
||||
|
||||
@ -60,6 +62,7 @@
|
||||
-type party() :: dmsl_domain_thrift:'Party'().
|
||||
-type party_id() :: dmsl_domain_thrift:'PartyID'().
|
||||
-type party_revision() :: dmsl_domain_thrift:'PartyRevision'().
|
||||
-type party_status() :: dmsl_domain_thrift:'PartyStatus'().
|
||||
-type contract() :: dmsl_domain_thrift:'Contract'().
|
||||
-type contract_id() :: dmsl_domain_thrift:'ContractID'().
|
||||
-type contractor() :: dmsl_domain_thrift:'PartyContractor'().
|
||||
@ -130,6 +133,17 @@ blocking(Blocking, Party) ->
|
||||
suspension(Suspension, Party) ->
|
||||
Party#domain_Party{suspension = Suspension}.
|
||||
|
||||
-spec get_status(party()) ->
|
||||
party_status().
|
||||
|
||||
get_status(Party) ->
|
||||
#domain_PartyStatus{
|
||||
id = Party#domain_Party.id,
|
||||
revision = Party#domain_Party.revision,
|
||||
blocking = Party#domain_Party.blocking,
|
||||
suspension = Party#domain_Party.suspension
|
||||
}.
|
||||
|
||||
-spec get_contractor(contractor_id(), party()) ->
|
||||
contractor() | undefined.
|
||||
|
||||
|
@ -32,6 +32,7 @@
|
||||
-export([get_meta/1]).
|
||||
-export([get_metadata/2]).
|
||||
-export([get_last_revision/1]).
|
||||
-export([get_status/1]).
|
||||
|
||||
%%
|
||||
|
||||
@ -58,6 +59,7 @@
|
||||
|
||||
-type party() :: hg_party:party().
|
||||
-type party_id() :: dmsl_domain_thrift:'PartyID'().
|
||||
-type party_status() :: hg_party:party_status().
|
||||
-type shop_id() :: dmsl_domain_thrift:'ShopID'().
|
||||
-type claim_id() :: dmsl_payment_processing_thrift:'ClaimID'().
|
||||
-type claim() :: dmsl_payment_processing_thrift:'Claim'().
|
||||
@ -494,6 +496,14 @@ get_last_revision_old_way(PartyID) ->
|
||||
{History, Last, Step} = get_history_part(PartyID, undefined, ?STEP),
|
||||
get_revision_of_part(PartyID, History, Last, Step).
|
||||
|
||||
-spec get_status(party_id()) ->
|
||||
party_status() | no_return().
|
||||
|
||||
get_status(PartyID) ->
|
||||
hg_party:get_status(
|
||||
get_party(PartyID)
|
||||
).
|
||||
|
||||
-spec call(party_id(), service_name(), hg_proto_utils:thrift_fun_ref(), Args :: [term()]) ->
|
||||
term() | no_return().
|
||||
|
||||
|
@ -39,6 +39,10 @@ handle_function_('GetRevision', [UserInfo, PartyID], _Opts) ->
|
||||
ok = set_meta_and_check_access(UserInfo, PartyID),
|
||||
hg_party_machine:get_last_revision(PartyID);
|
||||
|
||||
handle_function_('GetStatus', [UserInfo, PartyID], _Opts) ->
|
||||
ok = set_meta_and_check_access(UserInfo, PartyID),
|
||||
hg_party_machine:get_status(PartyID);
|
||||
|
||||
handle_function_(Fun, [UserInfo, PartyID | _Tail] = Args, _Opts) when
|
||||
Fun =:= 'Block' orelse
|
||||
Fun =:= 'Unblock' orelse
|
||||
|
@ -40,6 +40,7 @@
|
||||
-export([party_activation/1]).
|
||||
-export([party_already_suspended/1]).
|
||||
-export([party_already_active/1]).
|
||||
-export([party_get_status/1]).
|
||||
|
||||
-export([party_meta_retrieval/1]).
|
||||
-export([party_metadata_setting/1]).
|
||||
@ -109,6 +110,7 @@ all() ->
|
||||
{group, party_revisioning},
|
||||
{group, party_blocking_suspension},
|
||||
{group, party_meta},
|
||||
{group, party_status},
|
||||
{group, contract_management},
|
||||
{group, shop_management},
|
||||
{group, shop_account_lazy_creation},
|
||||
@ -159,6 +161,10 @@ groups() ->
|
||||
party_metadata_removing,
|
||||
party_meta_retrieval
|
||||
]},
|
||||
{party_status, [sequence], [
|
||||
party_creation,
|
||||
party_get_status
|
||||
]},
|
||||
{contract_management, [sequence], [
|
||||
party_creation,
|
||||
contract_not_found,
|
||||
@ -393,6 +399,7 @@ end_per_testcase(_Name, _C) ->
|
||||
-spec party_activation(config()) -> _ | no_return().
|
||||
-spec party_already_suspended(config()) -> _ | no_return().
|
||||
-spec party_already_active(config()) -> _ | no_return().
|
||||
-spec party_get_status(config()) -> _ | no_return().
|
||||
|
||||
-spec party_meta_retrieval(config()) -> _ | no_return().
|
||||
-spec party_metadata_setting(config()) -> _ | no_return().
|
||||
@ -1196,6 +1203,17 @@ party_meta_retrieval(C) ->
|
||||
Meta1 = hg_client_party:get_meta(Client),
|
||||
Meta0 =/= Meta1.
|
||||
|
||||
party_get_status(C) ->
|
||||
Client = cfg(client, C),
|
||||
Status0 = hg_client_party:get_status(Client),
|
||||
?active(_) = Status0#domain_PartyStatus.suspension,
|
||||
?unblocked(_) = Status0#domain_PartyStatus.blocking,
|
||||
ok = hg_client_party:block(<<"too much">>, Client),
|
||||
Status1 = hg_client_party:get_status(Client),
|
||||
?active(_) = Status1#domain_PartyStatus.suspension,
|
||||
?blocked(<<"too much">>, _) = Status1#domain_PartyStatus.blocking,
|
||||
Status1 =/= Status0.
|
||||
|
||||
shop_blocking(C) ->
|
||||
Client = cfg(client, C),
|
||||
ShopID = ?REAL_SHOP_ID,
|
||||
|
@ -14,6 +14,7 @@
|
||||
-export([unblock/2]).
|
||||
-export([suspend/1]).
|
||||
-export([activate/1]).
|
||||
-export([get_status/1]).
|
||||
|
||||
-export([get_meta/1]).
|
||||
-export([get_metadata/2]).
|
||||
@ -121,6 +122,11 @@ get(Client) ->
|
||||
get_revision(Client) ->
|
||||
map_result_error(gen_server:call(Client, {call, 'GetRevision', []})).
|
||||
|
||||
-spec get_status(pid()) ->
|
||||
dmsl_domain_thrift:'PartyStatus'() | woody_error:business_error().
|
||||
|
||||
get_status(Client) ->
|
||||
map_result_error(gen_server:call(Client, {call, 'GetStatus', []})).
|
||||
|
||||
-spec checkout(party_revision_param(), pid()) ->
|
||||
dmsl_domain_thrift:'Party'() | woody_error:business_error().
|
||||
|
@ -10,7 +10,7 @@
|
||||
{<<"cowlib">>,{pkg,<<"cowlib">>,<<"2.6.0">>},2},
|
||||
{<<"damsel">>,
|
||||
{git,"git@github.com:rbkmoney/damsel.git",
|
||||
{ref,"1526bbb22e170e5188bf9c98e554e55b001e484a"}},
|
||||
{ref,"4339b6c286741fc9a4bc851a92eb58ebbcce81ab"}},
|
||||
0},
|
||||
{<<"dmt_client">>,
|
||||
{git,"git@github.com:rbkmoney/dmt_client.git",
|
||||
|
Loading…
Reference in New Issue
Block a user