Skip to content

Commit d2cc8bb

Browse files
authored
BG-411: Add contact info to withdrawal (#41)
1 parent 10a40f4 commit d2cc8bb

5 files changed

Lines changed: 39 additions & 7 deletions

File tree

rebar.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
{dmt_client, {git, "https://github.com/valitydev/dmt-client.git", {tag, "v2.0.3"}}},
3535
{damsel, {git, "https://github.com/valitydev/damsel.git", {tag, "v2.2.12"}}},
3636
{identdocstore_proto, {git, "https://github.com/valitydev/identdocstore-proto.git", {branch, "master"}}},
37-
{fistful_proto, {git, "https://github.com/valitydev/fistful-proto.git", {tag, "v2.0.0"}}},
37+
{fistful_proto, {git, "https://github.com/valitydev/fistful-proto.git", {tag, "v2.0.1"}}},
3838
{fistful_reporter_proto, {git, "https://github.com/valitydev/fistful-reporter-proto.git", {branch, "master"}}},
3939
{file_storage_proto, {git, "https://github.com/valitydev/file-storage-proto.git", {branch, "master"}}},
4040
{bender_client, {git, "https://github.com/valitydev/bender-client-erlang.git", {tag, "v1.1.0"}}},

rebar.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
0},
3434
{<<"fistful_proto">>,
3535
{git,"https://github.com/valitydev/fistful-proto.git",
36-
{ref,"8b04c7faca7393b9a6a5509205be383d68039907"}},
36+
{ref,"7c61ac50ddb658bee477538f32133f815bc45876"}},
3737
0},
3838
{<<"fistful_reporter_proto">>,
3939
{git,"https://github.com/valitydev/fistful-reporter-proto.git",

src/wapi_withdrawal_backend.erl

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ marshal(
371371
ExternalID = maps:get(<<"externalID">>, Params, undefined),
372372
Metadata = maps:get(<<"metadata">>, Params, undefined),
373373
Quote = maps:get(<<"quote">>, Params, undefined),
374+
ContactInfo = maps:get(<<"contactInfo">>, Params, undefined),
374375
PartyID = maps:get(<<"party">>, Params, <<>>),
375376
#wthd_WithdrawalParams{
376377
id = marshal(id, ID),
@@ -380,7 +381,15 @@ marshal(
380381
quote = Quote,
381382
external_id = maybe_marshal(id, ExternalID),
382383
metadata = maybe_marshal(context, Metadata),
383-
party_id = PartyID
384+
party_id = PartyID,
385+
contact_info = maybe_marshal(contact_info, ContactInfo)
386+
};
387+
marshal(contact_info, ContactInfo) ->
388+
PhoneNumber = maps:get(<<"phoneNumber">>, ContactInfo, undefined),
389+
Email = maps:get(<<"email">>, ContactInfo, undefined),
390+
#fistful_base_ContactInfo{
391+
phone_number = PhoneNumber,
392+
email = Email
384393
};
385394
marshal(
386395
create_quote_params,
@@ -445,7 +454,8 @@ unmarshal(withdrawal, #wthd_WithdrawalState{
445454
status = Status,
446455
created_at = CreatedAt,
447456
metadata = Metadata,
448-
quote = Quote
457+
quote = Quote,
458+
contact_info = ContactInfo
449459
}) ->
450460
UnmarshaledMetadata = maybe_unmarshal(context, Metadata),
451461
genlib_map:compact(
@@ -459,7 +469,8 @@ unmarshal(withdrawal, #wthd_WithdrawalState{
459469
<<"createdAt">> => CreatedAt,
460470
<<"externalID">> => ExternalID,
461471
<<"metadata">> => UnmarshaledMetadata,
462-
<<"quote">> => maybe_unmarshal(quote_state, Quote)
472+
<<"quote">> => maybe_unmarshal(quote_state, Quote),
473+
<<"contactInfo">> => maybe_unmarshal(contact_info, ContactInfo)
463474
},
464475
unmarshal_status(Status)
465476
)
@@ -488,6 +499,14 @@ unmarshal(quote_state, #wthd_QuoteState{
488499
<<"createdAt">> => CreatedAt,
489500
<<"expiresOn">> => ExpiresOn
490501
};
502+
unmarshal(contact_info, #fistful_base_ContactInfo{
503+
phone_number = PhoneNumber,
504+
email = Email
505+
}) ->
506+
genlib_map:compact(#{
507+
<<"phoneNumber">> => maybe_unmarshal(string, PhoneNumber),
508+
<<"email">> => maybe_unmarshal(string, Email)
509+
});
491510
unmarshal(event, ?EVENT(EventId, OccuredAt, ?STATUS_CHANGE(Status))) ->
492511
genlib_map:compact(#{
493512
<<"eventID">> => EventId,

test/wapi_wallet_dummy_data.hrl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,11 @@
100100
context = ?DEFAULT_CONTEXT(PartyID),
101101
quote = ?WITHDRAWAL_QUOTE_STATE,
102102
party_id = PartyID,
103-
domain_revision = 123
103+
domain_revision = 123,
104+
contact_info = #fistful_base_ContactInfo{
105+
phone_number = ?STRING,
106+
email = ?STRING
107+
}
104108
}).
105109

106110
-define(WITHDRAWAL_QUOTE_STATE, #wthd_QuoteState{

test/wapi_withdrawal_tests_SUITE.erl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,12 @@ end_per_testcase(_Name, C) ->
149149
create_ok(C) ->
150150
PartyID = ?config(party, C),
151151
_ = create_withdrawal_start_mocks(C, fun() -> {ok, ?WITHDRAWAL(PartyID)} end),
152-
{ok, _} = create_withdrawal_call_api(C).
152+
{ok, #{
153+
<<"contactInfo">> := #{
154+
<<"phoneNumber">> := ?STRING,
155+
<<"email">> := ?STRING
156+
}
157+
}} = create_withdrawal_call_api(C).
153158

154159
-spec create_fail_wallet_notfound(config()) -> _.
155160
create_fail_wallet_notfound(C) ->
@@ -617,6 +622,10 @@ create_withdrawal_call_api(C) ->
617622
<<"body">> => #{
618623
<<"amount">> => ?INTEGER,
619624
<<"currency">> => ?RUB
625+
},
626+
<<"contactInfo">> => #{
627+
<<"email">> => ?STRING,
628+
<<"phoneNumber">> => ?STRING
620629
}
621630
})
622631
},

0 commit comments

Comments
 (0)