Skip to content
Merged
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_('GetShopAccountSimple', {PartyRef, ShopRef}, Opts) ->
DomainRevision = dmt_client:get_latest_version(),
handle_function('GetShopAccount', {PartyRef, ShopRef, DomainRevision}, Opts);
handle_function_('GetWalletAccountSimple', {PartyRef, WalletRef}, Opts) ->
DomainRevision = dmt_client:get_latest_version(),
handle_function_('GetWalletAccount', {PartyRef, WalletRef, DomainRevision}, Opts);
handle_function_('GetAccountStateSimple', {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_simple/1]).
-export([get_wallet_account_simple/1]).
-export([get_account_state_simple/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_simple,
get_wallet_account_simple,
get_account_state_simple,
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_simple(config()) -> _ | no_return().
-spec get_wallet_account_simple(config()) -> _ | no_return().
-spec get_account_state_simple(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_simple(C) ->
Client = cfg(client, C),
?assertMatch(
#domain_ShopAccount{},
pm_client_party:get_shop_account_simple(?shop(?SHOP_ID), Client)
).

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

get_account_state_simple(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_simple(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_simple/2]).
-export([get_wallet_account_simple/2]).
-export([get_account_state_simple/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_simple(shop_account_id(), pid()) ->
dmsl_payproc_thrift:'AccountState'() | woody_error:business_error().
get_account_state_simple(AccountID, Client) ->
call(Client, 'GetAccountStateSimple', 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_simple(shop_ref(), pid()) ->
dmsl_domain_thrift:'ShopAccount'() | woody_error:business_error().
get_shop_account_simple(ShopRef, Client) ->
call(Client, 'GetShopAccountSimple', 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_simple(wallet_ref(), pid()) ->
dmsl_domain_thrift:'WalletAccount'() | woody_error:business_error().
get_wallet_account_simple(WalletRef, Client) ->
call(Client, 'GetWalletAccountSimple', 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", {tag, "v2.2.26"}}},
{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,"dfd664826a7d9a8728af6e97f4b63c1c277d7884"}},
0},
{<<"dmt_client">>,
{git,"https://github.com/valitydev/dmt_client.git",
Expand Down
Loading