Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions apps/party_management/src/pm_party_handler.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

-include_lib("damsel/include/dmsl_payproc_thrift.hrl").
-include_lib("damsel/include/dmsl_domain_thrift.hrl").
-include_lib("damsel/include/dmsl_domain_conf_v2_thrift.hrl").

%% Woody handler called by pm_woody_wrapper

Expand All @@ -19,6 +20,15 @@ handle_function(Func, Args, Opts) ->

-spec handle_function_(woody:func(), woody:args(), pm_woody_wrapper:handler_opts()) -> term() | no_return().
%% Accounts
handle_function_('GetShopAccountForLatestVersion', {PartyRef, ShopRef}, Opts) ->
DomainRevision = dmt_client:get_latest_version(),
handle_function('GetShopAccount', {PartyRef, ShopRef, DomainRevision}, Opts);
handle_function_('GetWalletAccountForLatestVersion', {PartyRef, WalletRef}, Opts) ->
DomainRevision = dmt_client:get_latest_version(),
handle_function_('GetWalletAccount', {PartyRef, WalletRef, DomainRevision}, Opts);
handle_function_('GetAccountStateForLatestVersion', {PartyRef, AccountID}, Opts) ->
DomainRevision = dmt_client:get_latest_version(),
handle_function_('GetAccountState', {PartyRef, AccountID, DomainRevision}, Opts);
handle_function_('GetShopAccount', {PartyRef, ShopRef, DomainRevision}, _Opts) ->
_ = set_party_mgmt_meta(PartyRef),
pm_party:get_shop_account(ShopRef, PartyRef, DomainRevision);
Expand Down
34 changes: 34 additions & 0 deletions apps/party_management/test/pm_party_tests_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
-include_lib("damsel/include/dmsl_domain_thrift.hrl").
-include_lib("damsel/include/dmsl_base_thrift.hrl").
-include_lib("damsel/include/dmsl_limiter_config_thrift.hrl").
-include_lib("damsel/include/dmsl_domain_conf_v2_thrift.hrl").

-export([all/0]).
-export([groups/0]).
Expand All @@ -18,6 +19,9 @@
-export([init_per_testcase/2]).
-export([end_per_testcase/2]).

-export([get_shop_account_for_latest_version/1]).
-export([get_wallet_account_for_latest_version/1]).
-export([get_account_state_for_latest_version/1]).
-export([get_shop_account/1]).
-export([get_shop_account_non_existant_version/1]).
-export([get_wallet_account/1]).
Expand Down Expand Up @@ -76,6 +80,9 @@ all() ->
groups() ->
[
{accounts, [parallel], [
get_shop_account_for_latest_version,
get_wallet_account_for_latest_version,
get_account_state_for_latest_version,
get_shop_account,
get_shop_account_non_existant_version,
get_wallet_account,
Expand Down Expand Up @@ -150,6 +157,9 @@ end_per_testcase(_Name, _C) ->

-define(WRONG_DMT_OBJ_ID, 99999).

-spec get_shop_account_for_latest_version(config()) -> _ | no_return().
-spec get_wallet_account_for_latest_version(config()) -> _ | no_return().
-spec get_account_state_for_latest_version(config()) -> _ | no_return().
-spec get_shop_account(config()) -> _ | no_return().
-spec get_shop_account_non_existant_version(config()) -> _ | no_return().
-spec get_wallet_account(config()) -> _ | no_return().
Expand Down Expand Up @@ -185,6 +195,30 @@ end_per_testcase(_Name, _C) ->
-define(NON_EXISTANT_DOMAIN_REVISION, 42_000_000).
-define(NON_EXISTANT_ACCOUNT_ID, 42_000).

get_shop_account_for_latest_version(C) ->
Client = cfg(client, C),
?assertMatch(
#domain_ShopAccount{},
pm_client_party:get_shop_account_for_latest_version(?shop(?SHOP_ID), Client)
).

get_wallet_account_for_latest_version(C) ->
Client = cfg(client, C),
?assertMatch(
#domain_WalletAccount{},
pm_client_party:get_wallet_account_for_latest_version(?wallet(?WALLET_ID), Client)
).

get_account_state_for_latest_version(C) ->
Client = cfg(client, C),
DomainRevision = pm_domain:head(),
#domain_ShopAccount{settlement = AccountID} =
pm_client_party:get_shop_account(?shop(?SHOP_ID), DomainRevision, Client),
?assertMatch(
#payproc_AccountState{account_id = AccountID},
pm_client_party:get_account_state_for_latest_version(AccountID, Client)
).

get_shop_account(C) ->
Client = cfg(client, C),
DomainRevision = pm_domain:head(),
Expand Down
18 changes: 18 additions & 0 deletions apps/pm_client/src/pm_client_party.erl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
-export([compute_terms/4]).
-export([compute_payment_institution/4]).

-export([get_shop_account_for_latest_version/2]).
-export([get_wallet_account_for_latest_version/2]).
-export([get_account_state_for_latest_version/2]).
-export([get_shop_account/3]).
-export([get_wallet_account/3]).
-export([get_account_state/3]).
Expand Down Expand Up @@ -62,16 +65,31 @@ compute_terms(Ref, DomainRevision, Varset, Client) ->
compute_payment_institution(Ref, DomainRevision, Varset, Client) ->
call(Client, 'ComputePaymentInstitution', [Ref, DomainRevision, Varset]).

-spec get_account_state_for_latest_version(shop_account_id(), pid()) ->
dmsl_payproc_thrift:'AccountState'() | woody_error:business_error().
get_account_state_for_latest_version(AccountID, Client) ->
call(Client, 'GetAccountStateForLatestVersion', with_party_ref([AccountID])).

-spec get_account_state(shop_account_id(), domain_revision(), pid()) ->
dmsl_payproc_thrift:'AccountState'() | woody_error:business_error().
get_account_state(AccountID, DomainRevision, Client) ->
call(Client, 'GetAccountState', with_party_ref([AccountID, DomainRevision])).

-spec get_shop_account_for_latest_version(shop_ref(), pid()) ->
dmsl_domain_thrift:'ShopAccount'() | woody_error:business_error().
get_shop_account_for_latest_version(ShopRef, Client) ->
call(Client, 'GetShopAccountForLatestVersion', with_party_ref([ShopRef])).

-spec get_shop_account(shop_ref(), domain_revision(), pid()) ->
dmsl_domain_thrift:'ShopAccount'() | woody_error:business_error().
get_shop_account(ShopRef, DomainRevision, Client) ->
call(Client, 'GetShopAccount', with_party_ref([ShopRef, DomainRevision])).

-spec get_wallet_account_for_latest_version(wallet_ref(), pid()) ->
dmsl_domain_thrift:'WalletAccount'() | woody_error:business_error().
get_wallet_account_for_latest_version(WalletRef, Client) ->
call(Client, 'GetWalletAccountForLatestVersion', with_party_ref([WalletRef])).

-spec get_wallet_account(wallet_ref(), domain_revision(), pid()) ->
dmsl_domain_thrift:'WalletAccount'() | woody_error:business_error().
get_wallet_account(WalletRef, DomainRevision, Client) ->
Expand Down
2 changes: 1 addition & 1 deletion rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
{prometheus, "4.11.0"},
{prometheus_cowboy, "0.1.9"},
{woody, {git, "https://github.com/valitydev/woody_erlang.git", {tag, "v1.1.0"}}},
{damsel, {git, "https://github.com/valitydev/damsel.git", {tag, "v2.2.23"}}},
{damsel, {git, "https://github.com/valitydev/damsel.git", {branch, "BG-701/ft/optional-domain-revision"}}},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не забыть

{payproc_errors, {git, "https://github.com/valitydev/payproc-errors-erlang.git", {branch, "master"}}},
{dmt_client, {git, "https://github.com/valitydev/dmt_client.git", {tag, "v2.0.3"}}},
{scoper, {git, "https://github.com/valitydev/scoper.git", {tag, "v1.1.0"}}},
Expand Down
2 changes: 1 addition & 1 deletion rebar.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
{<<"ctx">>,{pkg,<<"ctx">>,<<"0.6.0">>},2},
{<<"damsel">>,
{git,"https://github.com/valitydev/damsel.git",
{ref,"b5c1dc423365397d8c2d123ba5766147551f19cc"}},
{ref,"b4088eab1e7b8d2b5e34626d314b80e86e9d4c68"}},
0},
{<<"dmt_client">>,
{git,"https://github.com/valitydev/dmt_client.git",
Expand Down
Loading