diff --git a/rebar.config b/rebar.config index 4b857ab..4f457f9 100644 --- a/rebar.config +++ b/rebar.config @@ -34,7 +34,7 @@ {dmt_client, {git, "https://github.com/valitydev/dmt-client.git", {tag, "v2.0.3"}}}, {damsel, {git, "https://github.com/valitydev/damsel.git", {tag, "v2.2.43"}}}, {identdocstore_proto, {git, "https://github.com/valitydev/identdocstore-proto.git", {branch, "master"}}}, - {fistful_proto, {git, "https://github.com/valitydev/fistful-proto.git", {tag, "v2.0.1"}}}, + {fistful_proto, {git, "https://github.com/valitydev/fistful-proto.git", {branch, "master"}}}, {fistful_reporter_proto, {git, "https://github.com/valitydev/fistful-reporter-proto.git", {branch, "master"}}}, {file_storage_proto, {git, "https://github.com/valitydev/file-storage-proto.git", {branch, "master"}}}, {bender_client, {git, "https://github.com/valitydev/bender-client-erlang.git", {tag, "v1.1.0"}}}, diff --git a/rebar.lock b/rebar.lock index 1d8b679..c347224 100644 --- a/rebar.lock +++ b/rebar.lock @@ -33,7 +33,7 @@ 0}, {<<"fistful_proto">>, {git,"https://github.com/valitydev/fistful-proto.git", - {ref,"7c61ac50ddb658bee477538f32133f815bc45876"}}, + {ref,"360c737c83b627af5084a1e47e31755fb30c2239"}}, 0}, {<<"fistful_reporter_proto">>, {git,"https://github.com/valitydev/fistful-reporter-proto.git", diff --git a/src/wapi_withdrawal_backend.erl b/src/wapi_withdrawal_backend.erl index 47b44fe..d707adc 100644 --- a/src/wapi_withdrawal_backend.erl +++ b/src/wapi_withdrawal_backend.erl @@ -450,17 +450,19 @@ unmarshal(withdrawal, #wthd_WithdrawalState{ wallet_id = WalletID, party_id = PartyID, destination_id = DestinationID, - body = Body, + body = Body0, external_id = ExternalID, status = Status, created_at = CreatedAt, metadata = Metadata, quote = Quote, contact_info = ContactInfo, - effective_final_cash_flow = EffectiveFinalCashFlow + effective_final_cash_flow = EffectiveFinalCashFlow, + new_body = NewBody }) -> UnmarshaledMetadata = maybe_unmarshal(context, Metadata), Fee = maybe_unmarshal_fee(Status, EffectiveFinalCashFlow), + Body = genlib:define(NewBody, Body0), genlib_map:compact( maps:merge( #{ diff --git a/test/wapi_wallet_dummy_data.hrl b/test/wapi_wallet_dummy_data.hrl index dad30fd..4d16fbf 100644 --- a/test/wapi_wallet_dummy_data.hrl +++ b/test/wapi_wallet_dummy_data.hrl @@ -44,8 +44,10 @@ -define(PAYMENT_SERVICE_REF(ID), #'fistful_base_PaymentServiceRef'{id = ID}). -define(CRYPTO_CURRENCY_REF(ID), #'fistful_base_CryptoCurrencyRef'{id = ID}). --define(CASH, #'fistful_base_Cash'{ - amount = ?INTEGER, +-define(CASH, ?CASH(?INTEGER)). + +-define(CASH(Amount), #'fistful_base_Cash'{ + amount = Amount, currency = #'fistful_base_CurrencyRef'{ symbolic_code = ?RUB } diff --git a/test/wapi_withdrawal_tests_SUITE.erl b/test/wapi_withdrawal_tests_SUITE.erl index 7c43da6..1e1c3c0 100644 --- a/test/wapi_withdrawal_tests_SUITE.erl +++ b/test/wapi_withdrawal_tests_SUITE.erl @@ -41,6 +41,7 @@ get_failed_wo_colon/1, get_fail_withdrawal_notfound/1, get_by_external_id_ok/1, + get_with_new_body_ok/1, create_quote_ok/1, get_quote_fail_wallet_notfound/1, get_quote_fail_destination_notfound/1, @@ -90,6 +91,7 @@ groups() -> get_failed_wo_colon, get_fail_withdrawal_notfound, get_by_external_id_ok, + get_with_new_body_ok, create_quote_ok, get_quote_fail_wallet_notfound, get_quote_fail_destination_notfound, @@ -436,6 +438,38 @@ get_by_external_id_ok(C) -> wapi_ct_helper:cfg(context, C) ). +-spec get_with_new_body_ok(config()) -> _. +get_with_new_body_ok(C) -> + PartyID = ?config(party, C), + Withdrawal0 = ?WITHDRAWAL(PartyID), + Withdrawal = Withdrawal0#wthd_WithdrawalState{ + new_body = ?CASH(100500) + }, + _ = wapi_ct_helper_bouncer:mock_assert_withdrawal_op_ctx(<<"GetWithdrawal">>, ?STRING, PartyID, C), + _ = wapi_ct_helper:mock_services( + [ + {fistful_withdrawal, fun + ('GetContext', _) -> {ok, ?DEFAULT_CONTEXT(PartyID)}; + ('Get', _) -> {ok, Withdrawal} + end} + ], + C + ), + {ok, #{ + <<"body">> := #{ + <<"amount">> := 100500, + <<"currency">> := <<"RUB">> + } + }} = call_api( + fun swag_client_wallet_withdrawals_api:get_withdrawal/3, + #{ + binding => #{ + <<"withdrawalID">> => ?STRING + } + }, + wapi_ct_helper:cfg(context, C) + ). + -spec create_quote_ok(config()) -> _. create_quote_ok(C) -> _ = get_quote_start_mocks(C, fun() -> {ok, ?WITHDRAWAL_QUOTE} end),