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
2 changes: 1 addition & 1 deletion rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -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"}}},
Expand Down
2 changes: 1 addition & 1 deletion rebar.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
25 changes: 22 additions & 3 deletions src/wapi_withdrawal_backend.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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,
Expand Down Expand Up @@ -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(
Expand All @@ -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)
)
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion test/wapi_wallet_dummy_data.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
11 changes: 10 additions & 1 deletion test/wapi_withdrawal_tests_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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) ->
Expand Down Expand Up @@ -617,6 +622,10 @@ create_withdrawal_call_api(C) ->
<<"body">> => #{
<<"amount">> => ?INTEGER,
<<"currency">> => ?RUB
},
<<"contactInfo">> => #{
<<"email">> => ?STRING,
<<"phoneNumber">> => ?STRING
}
})
},
Expand Down
Loading