diff --git a/rebar.config b/rebar.config index bd1fe96..702deb4 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.12"}}}, {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.0"}}}, + {fistful_proto, {git, "https://github.com/valitydev/fistful-proto.git", {tag, "v2.0.1"}}}, {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 0aadf7e..ee162f5 100644 --- a/rebar.lock +++ b/rebar.lock @@ -33,7 +33,7 @@ 0}, {<<"fistful_proto">>, {git,"https://github.com/valitydev/fistful-proto.git", - {ref,"8b04c7faca7393b9a6a5509205be383d68039907"}}, + {ref,"7c61ac50ddb658bee477538f32133f815bc45876"}}, 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 989b107..cdedb35 100644 --- a/src/wapi_withdrawal_backend.erl +++ b/src/wapi_withdrawal_backend.erl @@ -371,6 +371,7 @@ marshal( ExternalID = maps:get(<<"externalID">>, Params, undefined), Metadata = maps:get(<<"metadata">>, Params, undefined), Quote = maps:get(<<"quote">>, Params, undefined), + ContactInfo = maps:get(<<"contactInfo">>, Params, undefined), PartyID = maps:get(<<"party">>, Params, <<>>), #wthd_WithdrawalParams{ id = marshal(id, ID), @@ -380,7 +381,15 @@ marshal( quote = Quote, external_id = maybe_marshal(id, ExternalID), metadata = maybe_marshal(context, Metadata), - party_id = PartyID + party_id = PartyID, + contact_info = maybe_marshal(contact_info, ContactInfo) + }; +marshal(contact_info, ContactInfo) -> + PhoneNumber = maps:get(<<"phoneNumber">>, ContactInfo, undefined), + Email = maps:get(<<"email">>, ContactInfo, undefined), + #fistful_base_ContactInfo{ + phone_number = PhoneNumber, + email = Email }; marshal( create_quote_params, @@ -445,7 +454,8 @@ unmarshal(withdrawal, #wthd_WithdrawalState{ status = Status, created_at = CreatedAt, metadata = Metadata, - quote = Quote + quote = Quote, + contact_info = ContactInfo }) -> UnmarshaledMetadata = maybe_unmarshal(context, Metadata), genlib_map:compact( @@ -459,7 +469,8 @@ unmarshal(withdrawal, #wthd_WithdrawalState{ <<"createdAt">> => CreatedAt, <<"externalID">> => ExternalID, <<"metadata">> => UnmarshaledMetadata, - <<"quote">> => maybe_unmarshal(quote_state, Quote) + <<"quote">> => maybe_unmarshal(quote_state, Quote), + <<"contactInfo">> => maybe_unmarshal(contact_info, ContactInfo) }, unmarshal_status(Status) ) @@ -488,6 +499,14 @@ unmarshal(quote_state, #wthd_QuoteState{ <<"createdAt">> => CreatedAt, <<"expiresOn">> => ExpiresOn }; +unmarshal(contact_info, #fistful_base_ContactInfo{ + phone_number = PhoneNumber, + email = Email +}) -> + genlib_map:compact(#{ + <<"phoneNumber">> => maybe_unmarshal(string, PhoneNumber), + <<"email">> => maybe_unmarshal(string, Email) + }); unmarshal(event, ?EVENT(EventId, OccuredAt, ?STATUS_CHANGE(Status))) -> genlib_map:compact(#{ <<"eventID">> => EventId, diff --git a/test/wapi_wallet_dummy_data.hrl b/test/wapi_wallet_dummy_data.hrl index ea01965..817d0c7 100644 --- a/test/wapi_wallet_dummy_data.hrl +++ b/test/wapi_wallet_dummy_data.hrl @@ -100,7 +100,11 @@ context = ?DEFAULT_CONTEXT(PartyID), quote = ?WITHDRAWAL_QUOTE_STATE, party_id = PartyID, - domain_revision = 123 + domain_revision = 123, + contact_info = #fistful_base_ContactInfo{ + phone_number = ?STRING, + email = ?STRING + } }). -define(WITHDRAWAL_QUOTE_STATE, #wthd_QuoteState{ diff --git a/test/wapi_withdrawal_tests_SUITE.erl b/test/wapi_withdrawal_tests_SUITE.erl index 4f13526..b094a3e 100644 --- a/test/wapi_withdrawal_tests_SUITE.erl +++ b/test/wapi_withdrawal_tests_SUITE.erl @@ -149,7 +149,12 @@ end_per_testcase(_Name, C) -> create_ok(C) -> PartyID = ?config(party, C), _ = create_withdrawal_start_mocks(C, fun() -> {ok, ?WITHDRAWAL(PartyID)} end), - {ok, _} = create_withdrawal_call_api(C). + {ok, #{ + <<"contactInfo">> := #{ + <<"phoneNumber">> := ?STRING, + <<"email">> := ?STRING + } + }} = create_withdrawal_call_api(C). -spec create_fail_wallet_notfound(config()) -> _. create_fail_wallet_notfound(C) -> @@ -617,6 +622,10 @@ create_withdrawal_call_api(C) -> <<"body">> => #{ <<"amount">> => ?INTEGER, <<"currency">> => ?RUB + }, + <<"contactInfo">> => #{ + <<"email">> => ?STRING, + <<"phoneNumber">> => ?STRING } }) },