diff --git a/apps/party_management/src/pm_party_handler.erl b/apps/party_management/src/pm_party_handler.erl index 642b1f6..1e85763 100644 --- a/apps/party_management/src/pm_party_handler.erl +++ b/apps/party_management/src/pm_party_handler.erl @@ -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 @@ -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); diff --git a/apps/party_management/test/pm_party_tests_SUITE.erl b/apps/party_management/test/pm_party_tests_SUITE.erl index ae4fd6f..7946fd1 100644 --- a/apps/party_management/test/pm_party_tests_SUITE.erl +++ b/apps/party_management/test/pm_party_tests_SUITE.erl @@ -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]). @@ -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]). @@ -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, @@ -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(). @@ -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(), diff --git a/apps/pm_client/src/pm_client_party.erl b/apps/pm_client/src/pm_client_party.erl index 6b5b3e1..025f756 100644 --- a/apps/pm_client/src/pm_client_party.erl +++ b/apps/pm_client/src/pm_client_party.erl @@ -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]). @@ -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) -> diff --git a/rebar.config b/rebar.config index 9269aad..458d05e 100644 --- a/rebar.config +++ b/rebar.config @@ -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"}}}, {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"}}}, diff --git a/rebar.lock b/rebar.lock index 8b1e47a..b730250 100644 --- a/rebar.lock +++ b/rebar.lock @@ -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",