CAPI-282: add private entity to public api (#246)

* CAPI-282: add private entity to public api

* add encoding for private entity
This commit is contained in:
Evgeny Levenets 2018-08-16 12:18:08 +03:00 committed by GitHub
parent aaa0bcce08
commit 5ad33b4661
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 44 additions and 2 deletions

View File

@ -1861,12 +1861,23 @@ encode_international_bank_account(Acc) ->
local_bank_code = genlib_map:get(<<"localBankCode">>, Acc)
}.
encode_contractor(#{<<"contractorType">> := <<"PrivateEntity">>} = Contractor) ->
{private_entity, encode_private_entity(Contractor)};
encode_contractor(#{<<"contractorType">> := <<"LegalEntity">>} = Contractor) ->
{legal_entity, encode_legal_entity(Contractor)};
encode_contractor(#{<<"contractorType">> := <<"RegisteredUser">>} = Contractor) ->
{registered_user, encode_registered_user(Contractor)}.
encode_private_entity(#{<<"entityType">> := <<"RussianPrivateEntity">>} = Entity) ->
{russian_private_entity, #domain_RussianPrivateEntity{
first_name = maps:get(<<"firstName">>, Entity),
second_name = maps:get(<<"secondName">>, Entity),
middle_name = maps:get(<<"middleName">>, Entity),
contact_info = encode_contact_info(maps:get(<<"contactInfo">>, Entity))
}}.
encode_legal_entity(#{<<"entityType">> := <<"RussianLegalEntity">>} = Entity) ->
{russian_legal_entity , #domain_RussianLegalEntity{
registered_name = maps:get(<<"registeredName">>, Entity),
@ -2683,6 +2694,9 @@ decode_shop_location({url, Location}) ->
decode_contractor({legal_entity, LegalEntity}) ->
maps:merge(#{<<"contractorType">> => <<"LegalEntity">>}, decode_legal_entity(LegalEntity));
decode_contractor({private_entity, PrivateEntity}) ->
maps:merge(#{<<"contractorType">> => <<"PrivateEntity">>}, decode_private_entity(PrivateEntity));
decode_contractor({registered_user, RegisteredUser}) ->
maps:merge(#{<<"contractorType">> => <<"RegisteredUser">>}, decode_registered_user(RegisteredUser)).
@ -2710,6 +2724,15 @@ decode_legal_entity({international_legal_entity, LegalEntity}) ->
<<"registeredNumber" >> => LegalEntity#domain_InternationalLegalEntity.registered_number
}).
decode_private_entity({russian_private_entity, PrivateEntity}) ->
#{
<<"entityType">> => <<"RussianPrivateEntity">>,
<<"firstName">> => PrivateEntity#domain_RussianPrivateEntity.first_name,
<<"secondName">> => PrivateEntity#domain_RussianPrivateEntity.second_name,
<<"middleName">> => PrivateEntity#domain_RussianPrivateEntity.middle_name,
<<"contactInfo">> => decode_contact_info(PrivateEntity#domain_RussianPrivateEntity.contact_info)
}.
decode_registered_user(#domain_RegisteredUser{email = Email}) ->
#{<<"email">> => Email}.

View File

@ -195,7 +195,12 @@
-define(PARTY_CONTRACTOR, #domain_PartyContractor{
id = ?STRING,
contractor = ?CONTRACTOR,
contractor = {private_entity, {russian_private_entity, #domain_RussianPrivateEntity{
first_name = ?STRING,
second_name = ?STRING,
middle_name = ?STRING,
contact_info = #domain_ContactInfo{}
}}},
status = none,
identity_documents = []
}).

View File

@ -1115,6 +1115,20 @@ create_claim_ok_test(Config) ->
},
<<"paymentInstitutionID">> => ?INTEGER
},
#{
<<"partyModificationType">> => <<"ContractModification">>,
<<"contractID">> => <<"PrivateEntityContract">>,
<<"contractModificationType">> => <<"ContractCreation">>,
<<"contractor">> => #{
<<"contractorType">> => <<"PrivateEntity">>,
<<"entityType">> => <<"RussianPrivateEntity">>,
<<"firstName">> => ?STRING,
<<"secondName">> => ?STRING,
<<"middleName">> => ?STRING,
<<"contactInfo">> => #{}
},
<<"paymentInstitutionID">> => ?INTEGER
},
#{
<<"partyModificationType">> => <<"ContractModification">>,
<<"contractID">> => ?STRING,

@ -1 +1 @@
Subproject commit d5a9d260fddbf42f7548841ea9ee7c33729861bb
Subproject commit 1e5552751d5920314e961059378676b2d31abcb9