From e5be92a5e07d79ff59053012e99b9b6386fff3e6 Mon Sep 17 00:00:00 2001 From: Aleksey Kashapov Date: Tue, 4 Mar 2025 13:58:20 +0300 Subject: [PATCH 1/2] TECH-76: Upgrades to Erlang/OTP 27 --- .env | 4 +- apps/capi/src/capi_bouncer_context.erl | 10 +- .../src/capi_handler_decoder_invoicing.erl | 2 +- .../src/capi_handler_payment_institutions.erl | 2 +- apps/capi/src/capi_handler_payments.erl | 16 ++-- apps/capi/src/capi_handler_search.erl | 2 +- apps/capi/src/capi_handler_shops.erl | 2 +- apps/capi/src/capi_utils.erl | 8 +- .../test/capi_authorization_tests_SUITE.erl | 2 +- .../test/capi_base_api_token_tests_SUITE.erl | 2 +- apps/capi/test/capi_bouncer_data.hrl | 8 +- ...capi_customer_access_token_tests_SUITE.erl | 2 +- apps/capi/test/capi_deadline_tests_SUITE.erl | 2 +- .../test/capi_idempotency_tests_SUITE.erl | 2 +- .../capi_invoice_access_token_tests_SUITE.erl | 2 +- .../test/capi_magista_stat_tests_SUITE.erl | 2 +- apps/capi/test/capi_self_tests_SUITE.erl | 2 +- apps/capi/test/capi_woody_tests_SUITE.erl | 2 +- rebar.config | 43 ++++----- rebar.lock | 91 +++++++++---------- 20 files changed, 95 insertions(+), 111 deletions(-) diff --git a/.env b/.env index 369eeb6..9044c18 100644 --- a/.env +++ b/.env @@ -2,6 +2,6 @@ # You SHOULD specify point releases here so that build time and run time Erlang/OTPs # are the same. See: https://github.com/erlware/relx/pull/902 SERVICE_NAME=capi -OTP_VERSION=24.3.4 -REBAR_VERSION=3.18 +OTP_VERSION=27.1.2 +REBAR_VERSION=3.24 THRIFT_VERSION=0.14.2.3 diff --git a/apps/capi/src/capi_bouncer_context.erl b/apps/capi/src/capi_bouncer_context.erl index 098a939..7fe7a50 100644 --- a/apps/capi/src/capi_bouncer_context.erl +++ b/apps/capi/src/capi_bouncer_context.erl @@ -229,21 +229,21 @@ build_webhook_filter({Type, Filter}) -> build_webhook_filter_details(#webhooker_PartyEventFilter{}, Ctx) -> Ctx; build_webhook_filter_details(#webhooker_InvoiceEventFilter{shop_id = ShopID}, Ctx) -> - Ctx#ctx_v1_WebhookFilter{shop = maybe(ShopID, fun build_entity/1)}; + Ctx#ctx_v1_WebhookFilter{shop = 'maybe'(ShopID, fun build_entity/1)}; build_webhook_filter_details(#webhooker_CustomerEventFilter{shop_id = ShopID}, Ctx) -> - Ctx#ctx_v1_WebhookFilter{shop = maybe(ShopID, fun build_entity/1)}; + Ctx#ctx_v1_WebhookFilter{shop = 'maybe'(ShopID, fun build_entity/1)}; build_webhook_filter_details(#webhooker_WalletEventFilter{}, Ctx) -> Ctx. %% -maybe(undefined, _Then) -> +'maybe'(undefined, _Then) -> undefined; -maybe(V, Then) -> +'maybe'(V, Then) -> Then(V). maybe_with(Name, Params, Then) -> - maybe(maps:get(Name, Params, undefined), Then). + 'maybe'(maps:get(Name, Params, undefined), Then). maybe_with_woody_result(ServiceName, Function, Args, WoodyCtx, Then) -> % TODO diff --git a/apps/capi/src/capi_handler_decoder_invoicing.erl b/apps/capi/src/capi_handler_decoder_invoicing.erl index b70c63a..6298ea8 100644 --- a/apps/capi/src/capi_handler_decoder_invoicing.erl +++ b/apps/capi/src/capi_handler_decoder_invoicing.erl @@ -691,7 +691,7 @@ decode_bank_card_details(BankCard, V) -> <<"first6">> => Bin, <<"cardNumberMask">> => capi_handler_decoder_utils:decode_masked_pan(Bin, LastDigits), <<"paymentSystem">> => capi_handler_decoder_utils:decode_payment_system_ref(PaymentSystem), - <<"tokenProvider">> => capi_utils:maybe( + <<"tokenProvider">> => capi_utils:'maybe'( TokenProvider, fun capi_handler_decoder_utils:decode_bank_card_token_service_ref/1 ) diff --git a/apps/capi/src/capi_handler_payment_institutions.erl b/apps/capi/src/capi_handler_payment_institutions.erl index 672f2e9..b1694c4 100644 --- a/apps/capi/src/capi_handler_payment_institutions.erl +++ b/apps/capi/src/capi_handler_payment_institutions.erl @@ -151,7 +151,7 @@ decode_payment_service(ID, PaymentService = #domain_PaymentService{}) -> <<"id">> => ID, <<"brandName">> => PaymentService#domain_PaymentService.brand_name, <<"category">> => PaymentService#domain_PaymentService.category, - <<"metadata">> => capi_utils:maybe( + <<"metadata">> => capi_utils:'maybe'( PaymentService#domain_PaymentService.metadata, fun capi_handler_decoder_utils:decode_namespaced_metadata/1 ) diff --git a/apps/capi/src/capi_handler_payments.erl b/apps/capi/src/capi_handler_payments.erl index cfb461a..8c50f5b 100644 --- a/apps/capi/src/capi_handler_payments.erl +++ b/apps/capi/src/capi_handler_payments.erl @@ -106,12 +106,12 @@ prepare(OperationID, #{'partyID' := PartyID, 'externalID' := ExternalID}, Contex OperationID =:= 'GetPaymentByExternalIDForParty' -> InternalID = get_payment_by_external_id(PartyID, ExternalID, Context), - Invoice = maybe( + Invoice = 'maybe'( InternalID, fun({InvoiceID, _}) -> get_invoice_by_id(InvoiceID, Context) end ), - OperationPrototype = maybe( + OperationPrototype = 'maybe'( InternalID, fun({InvoiceID, PaymentID}) -> #{id => OperationID, invoice => InvoiceID, payment => PaymentID} @@ -374,11 +374,11 @@ prepare(OperationID, #{'partyID' := PartyID, 'externalID' := ExternalID}, Contex OperationID =:= 'GetRefundByExternalIDForParty' -> InternalID = get_refund_by_external_id(PartyID, ExternalID, Context), - Invoice = maybe( + Invoice = 'maybe'( InternalID, fun({InvoiceID, _PaymentID, _RefundID}) -> get_invoice_by_id(InvoiceID, Context) end ), - OperationPrototype = maybe( + OperationPrototype = 'maybe'( InternalID, fun({InvoiceID, PaymentID, RefundID}) -> #{id => OperationID, invoice => InvoiceID, payment => PaymentID, refund => RefundID} @@ -482,7 +482,7 @@ validate_refund(Params) -> create_payment(Invoice, PaymentParams, Context, OperationID) -> PaymentToken = decode_payment_token(PaymentParams), - PaymentTool = capi_utils:maybe(PaymentToken, fun(#{payment_tool := V}) -> V end), + PaymentTool = capi_utils:'maybe'(PaymentToken, fun(#{payment_tool := V}) -> V end), InvoiceID = Invoice#domain_Invoice.id, PaymentID = create_payment_id(Invoice, PaymentParams, Context, OperationID, PaymentTool), @@ -495,7 +495,7 @@ create_payment_id(Invoice, PaymentParams0, Context, OperationID, PaymentToolThri InvoiceID = Invoice#domain_Invoice.id, PartyID = Invoice#domain_Invoice.owner_id, Payer = maps:get(<<"payer">>, PaymentParams0), - PaymentTool = capi_utils:maybe(PaymentToolThrift, fun capi_handler_decoder_invoicing:decode_payment_tool/1), + PaymentTool = capi_utils:'maybe'(PaymentToolThrift, fun capi_handler_decoder_invoicing:decode_payment_tool/1), PaymentParams = PaymentParams0#{ % Требуется для последующей кодировки параметров плательщика <<"invoiceID">> => InvoiceID, @@ -759,7 +759,7 @@ create_sequence_id([Identifier | Rest], BenderPrefix) -> create_sequence_id([], BenderPrefix) -> genlib:to_binary(BenderPrefix). -maybe(undefined, _) -> +'maybe'(undefined, _) -> undefined; -maybe(V, Fun) -> +'maybe'(V, Fun) -> Fun(V). diff --git a/apps/capi/src/capi_handler_search.erl b/apps/capi/src/capi_handler_search.erl index 19e3d4a..79fad77 100644 --- a/apps/capi/src/capi_handler_search.erl +++ b/apps/capi/src/capi_handler_search.erl @@ -419,7 +419,7 @@ decode_bank_card_details(BankCard, V) -> LastDigits = BankCard#domain_BankCard.last_digits, Bin = capi_handler_decoder_utils:decode_bank_card_bin(BankCard#domain_BankCard.bin), PaymentSystem = capi_handler_decoder_utils:decode_payment_system_ref(BankCard#domain_BankCard.payment_system), - BankCardTokenServiceRef = capi_utils:maybe( + BankCardTokenServiceRef = capi_utils:'maybe'( BankCard#domain_BankCard.payment_token, fun capi_handler_decoder_utils:decode_bank_card_token_service_ref/1 ), diff --git a/apps/capi/src/capi_handler_shops.erl b/apps/capi/src/capi_handler_shops.erl index 2606698..4b3498e 100644 --- a/apps/capi/src/capi_handler_shops.erl +++ b/apps/capi/src/capi_handler_shops.erl @@ -174,7 +174,7 @@ decode_shops_map(Shops) -> capi_handler_decoder_utils:decode_map(Shops, fun decode_shop/1). decode_shop(Shop) -> - Currency = capi_utils:maybe( + Currency = capi_utils:'maybe'( Shop#domain_Shop.account, fun(#domain_ShopAccount{currency = Currency}) -> capi_handler_decoder_utils:decode_currency(Currency) diff --git a/apps/capi/src/capi_utils.erl b/apps/capi/src/capi_utils.erl index 8b7a2d8..9336010 100644 --- a/apps/capi/src/capi_utils.erl +++ b/apps/capi/src/capi_utils.erl @@ -24,7 +24,7 @@ -export([get_unique_id/0]). --export([maybe/2]). +-export(['maybe'/2]). % 1 min -define(MAX_REQUEST_DEADLINE_TIME, timer:minutes(1)). @@ -203,10 +203,10 @@ get_unique_id() -> <> = snowflake:new(), genlib_format:format_int_base(ID, 62). --spec maybe(T | undefined, fun((T) -> R)) -> R | undefined. -maybe(undefined, _Fun) -> +-spec 'maybe'(T | undefined, fun((T) -> R)) -> R | undefined. +'maybe'(undefined, _Fun) -> undefined; -maybe(V, Fun) -> +'maybe'(V, Fun) -> Fun(V). %% diff --git a/apps/capi/test/capi_authorization_tests_SUITE.erl b/apps/capi/test/capi_authorization_tests_SUITE.erl index f00c3fb..9277fb1 100644 --- a/apps/capi/test/capi_authorization_tests_SUITE.erl +++ b/apps/capi/test/capi_authorization_tests_SUITE.erl @@ -104,7 +104,7 @@ init_per_group(GroupName, Config) -> -spec end_per_group(group_name(), config()) -> _. end_per_group(_Group, C) -> - _ = capi_utils:maybe(?config(group_test_sup, C), fun capi_ct_helper:stop_mocked_service_sup/1), + _ = capi_utils:'maybe'(?config(group_test_sup, C), fun capi_ct_helper:stop_mocked_service_sup/1), ok. %%% Tests diff --git a/apps/capi/test/capi_base_api_token_tests_SUITE.erl b/apps/capi/test/capi_base_api_token_tests_SUITE.erl index 4103723..9be9d13 100644 --- a/apps/capi/test/capi_base_api_token_tests_SUITE.erl +++ b/apps/capi/test/capi_base_api_token_tests_SUITE.erl @@ -284,7 +284,7 @@ end_per_group(Group, C) when Group =:= operations_by_api_key_token; Group =:= operations_by_user_session_token -> - capi_utils:maybe(?config(group_test_sup, C), fun capi_ct_helper:stop_mocked_service_sup/1); + capi_utils:'maybe'(?config(group_test_sup, C), fun capi_ct_helper:stop_mocked_service_sup/1); end_per_group(_Group, _C) -> ok. diff --git a/apps/capi/test/capi_bouncer_data.hrl b/apps/capi/test/capi_bouncer_data.hrl index 50ebbc5..145432b 100644 --- a/apps/capi/test/capi_bouncer_data.hrl +++ b/apps/capi/test/capi_bouncer_data.hrl @@ -118,10 +118,10 @@ id = ID, party = ?CTX_ENTITY(PartyID), shop = ?CTX_ENTITY(ShopID), - invoice = capi_utils:maybe(InvoiceID, fun(V) -> ?CTX_ENTITY(V) end), - payment = capi_utils:maybe(PaymentID, fun(V) -> ?CTX_ENTITY(V) end), - customer = capi_utils:maybe(CustomerID, fun(V) -> ?CTX_ENTITY(V) end), - refund = capi_utils:maybe(RefundID, fun(V) -> ?CTX_ENTITY(V) end) + invoice = capi_utils:'maybe'(InvoiceID, fun(V) -> ?CTX_ENTITY(V) end), + payment = capi_utils:'maybe'(PaymentID, fun(V) -> ?CTX_ENTITY(V) end), + customer = capi_utils:'maybe'(CustomerID, fun(V) -> ?CTX_ENTITY(V) end), + refund = capi_utils:'maybe'(RefundID, fun(V) -> ?CTX_ENTITY(V) end) } ). diff --git a/apps/capi/test/capi_customer_access_token_tests_SUITE.erl b/apps/capi/test/capi_customer_access_token_tests_SUITE.erl index 72d034a..d75b445 100644 --- a/apps/capi/test/capi_customer_access_token_tests_SUITE.erl +++ b/apps/capi/test/capi_customer_access_token_tests_SUITE.erl @@ -136,7 +136,7 @@ init_per_group(_, Config) -> -spec end_per_group(group_name(), config()) -> _. end_per_group(_Group, C) -> - _ = capi_utils:maybe(?config(group_test_sup, C), fun capi_ct_helper:stop_mocked_service_sup/1), + _ = capi_utils:'maybe'(?config(group_test_sup, C), fun capi_ct_helper:stop_mocked_service_sup/1), ok. -spec init_per_testcase(test_case_name(), config()) -> config(). diff --git a/apps/capi/test/capi_deadline_tests_SUITE.erl b/apps/capi/test/capi_deadline_tests_SUITE.erl index 71f6b42..a3670c3 100644 --- a/apps/capi/test/capi_deadline_tests_SUITE.erl +++ b/apps/capi/test/capi_deadline_tests_SUITE.erl @@ -76,7 +76,7 @@ init_per_group(_, Config) -> -spec end_per_group(group_name(), config()) -> _. end_per_group(_Group, C) -> - _ = capi_utils:maybe(?config(group_test_sup, C), fun capi_ct_helper:stop_mocked_service_sup/1), + _ = capi_utils:'maybe'(?config(group_test_sup, C), fun capi_ct_helper:stop_mocked_service_sup/1), ok. -spec init_per_testcase(test_case_name(), config()) -> config(). diff --git a/apps/capi/test/capi_idempotency_tests_SUITE.erl b/apps/capi/test/capi_idempotency_tests_SUITE.erl index 74678be..0f12db1 100644 --- a/apps/capi/test/capi_idempotency_tests_SUITE.erl +++ b/apps/capi/test/capi_idempotency_tests_SUITE.erl @@ -181,7 +181,7 @@ init_per_group(_, Config) -> -spec end_per_group(group_name(), config()) -> _. end_per_group(_Group, C) -> - _ = capi_utils:maybe(?config(group_test_sup, C), fun capi_ct_helper:stop_mocked_service_sup/1), + _ = capi_utils:'maybe'(?config(group_test_sup, C), fun capi_ct_helper:stop_mocked_service_sup/1), ok. -spec init_per_testcase(test_case_name(), config()) -> config(). diff --git a/apps/capi/test/capi_invoice_access_token_tests_SUITE.erl b/apps/capi/test/capi_invoice_access_token_tests_SUITE.erl index 1cf932e..a3547cb 100644 --- a/apps/capi/test/capi_invoice_access_token_tests_SUITE.erl +++ b/apps/capi/test/capi_invoice_access_token_tests_SUITE.erl @@ -161,7 +161,7 @@ init_per_group(_, Config) -> -spec end_per_group(group_name(), config()) -> _. end_per_group(_Group, C) -> - _ = capi_utils:maybe(?config(group_test_sup, C), fun capi_ct_helper:stop_mocked_service_sup/1), + _ = capi_utils:'maybe'(?config(group_test_sup, C), fun capi_ct_helper:stop_mocked_service_sup/1), ok. -spec init_per_testcase(test_case_name(), config()) -> config(). diff --git a/apps/capi/test/capi_magista_stat_tests_SUITE.erl b/apps/capi/test/capi_magista_stat_tests_SUITE.erl index 6f73335..5e799ff 100644 --- a/apps/capi/test/capi_magista_stat_tests_SUITE.erl +++ b/apps/capi/test/capi_magista_stat_tests_SUITE.erl @@ -106,7 +106,7 @@ end_per_group(Group, C) when Group =:= operations_by_api_key_token; Group =:= operations_by_user_session_token -> - capi_utils:maybe(?config(group_test_sup, C), fun capi_ct_helper:stop_mocked_service_sup/1); + capi_utils:'maybe'(?config(group_test_sup, C), fun capi_ct_helper:stop_mocked_service_sup/1); end_per_group(_Group, _C) -> ok. diff --git a/apps/capi/test/capi_self_tests_SUITE.erl b/apps/capi/test/capi_self_tests_SUITE.erl index 6f67c5c..2039c3a 100644 --- a/apps/capi/test/capi_self_tests_SUITE.erl +++ b/apps/capi/test/capi_self_tests_SUITE.erl @@ -85,7 +85,7 @@ init_per_group(_, Config) -> -spec end_per_group(group_name(), config()) -> _. end_per_group(_Group, C) -> - _ = capi_utils:maybe(?config(group_test_sup, C), fun capi_ct_helper:stop_mocked_service_sup/1), + _ = capi_utils:'maybe'(?config(group_test_sup, C), fun capi_ct_helper:stop_mocked_service_sup/1), ok. -spec init_per_testcase(test_case_name(), config()) -> config(). diff --git a/apps/capi/test/capi_woody_tests_SUITE.erl b/apps/capi/test/capi_woody_tests_SUITE.erl index 444978f..3702f2c 100644 --- a/apps/capi/test/capi_woody_tests_SUITE.erl +++ b/apps/capi/test/capi_woody_tests_SUITE.erl @@ -76,7 +76,7 @@ init_per_group(_, Config) -> -spec end_per_group(group_name(), config()) -> _. end_per_group(_Group, C) -> - _ = capi_utils:maybe(?config(group_test_sup, C), fun capi_ct_helper:stop_mocked_service_sup/1), + _ = capi_utils:'maybe'(?config(group_test_sup, C), fun capi_ct_helper:stop_mocked_service_sup/1), ok. -spec init_per_testcase(test_case_name(), config()) -> config(). diff --git a/rebar.config b/rebar.config index 55eda3c..97d6aa4 100644 --- a/rebar.config +++ b/rebar.config @@ -26,29 +26,29 @@ %% Common project dependencies. {deps, [ - {prometheus, "4.8.1"}, - {prometheus_cowboy, "0.1.8"}, + {prometheus, "4.11.0"}, + {prometheus_cowboy, "0.1.9"}, {cowboy, "2.9.0"}, %% NOTE %% Pinning to version "1.11.2" from hex here causes constant upgrading and recompilation of the entire project {jose, {git, "https://github.com/potatosalad/erlang-jose.git", {tag, "1.11.2"}}}, - {genlib, {git, "https://github.com/valitydev/genlib.git", {branch, "master"}}}, + {genlib, {git, "https://github.com/valitydev/genlib.git", {tag, "v1.1.0"}}}, {cowboy_draining_server, {git, "https://github.com/valitydev/cowboy_draining_server.git", {branch, "master"}}}, - {woody, {git, "https://github.com/valitydev/woody_erlang.git", {branch, master}}}, + {woody, {git, "https://github.com/valitydev/woody_erlang.git", {tag, "v1.1.0"}}}, {woody_user_identity, {git, "https://github.com/valitydev/woody_erlang_user_identity.git", {branch, "master"}}}, {damsel, {git, "https://github.com/valitydev/damsel.git", {branch, "master"}}}, {bender_proto, {git, "https://github.com/valitydev/bender-proto.git", {branch, "master"}}}, - {bender_client, {git, "https://github.com/valitydev/bender-client-erlang.git", {branch, "master"}}}, + {bender_client, {git, "https://github.com/valitydev/bender-client-erlang.git", {tag, "v1.1.0"}}}, {dmt_client, {git, "https://github.com/valitydev/dmt_client.git", {branch, "master"}}}, {cowboy_cors, {git, "https://github.com/valitydev/cowboy_cors.git", {branch, "master"}}}, {cowboy_access_log, {git, "https://github.com/valitydev/cowboy_access_log.git", {branch, "master"}}}, {payproc_errors, {git, "https://github.com/valitydev/payproc-errors-erlang.git", {branch, "master"}}}, - {scoper, {git, "https://github.com/valitydev/scoper.git", {branch, "master"}}}, + {scoper, {git, "https://github.com/valitydev/scoper.git", {tag, "v1.1.0"}}}, {erl_health, {git, "https://github.com/valitydev/erlang-health.git", {branch, master}}}, - {lechiffre, {git, "https://github.com/valitydev/lechiffre.git", {branch, master}}}, + {lechiffre, {git, "https://github.com/valitydev/lechiffre.git", {tag, "v0.1.0"}}}, {bouncer_proto, {git, "https://github.com/valitydev/bouncer-proto.git", {branch, master}}}, - {bouncer_client, {git, "https://github.com/valitydev/bouncer-client-erlang.git", {branch, master}}}, - {token_keeper_client, {git, "https://github.com/valitydev/token-keeper-client.git", {branch, master}}}, + {bouncer_client, {git, "https://github.com/valitydev/bouncer-client-erlang.git", {tag, "v1.1.0"}}}, + {token_keeper_client, {git, "https://github.com/valitydev/token-keeper-client.git", {tag, "v1.1.0"}}}, {party_client, {git, "https://github.com/valitydev/party-client-erlang.git", {branch, master}}}, {payout_manager_proto, {git, "https://github.com/valitydev/payout-manager-proto.git", {branch, master}}}, {feat, {git, "https://github.com/valitydev/feat.git", {branch, master}}}, @@ -57,9 +57,9 @@ {swag_server, {git, "https://github.com/valitydev/swag-payments", {branch, "release/erlang/server/v2"}}}, {swag_client, {git, "https://github.com/valitydev/swag-payments", {branch, "release/erlang/client/v2"}}}, %% OpenTelemetry deps - {opentelemetry_api, "1.2.1"}, - {opentelemetry, "1.3.0"}, - {opentelemetry_exporter, "1.3.0"} + {opentelemetry_api, "1.4.0"}, + {opentelemetry, "1.5.0"}, + {opentelemetry_exporter, "1.8.0"} ]}. %% XRef checks @@ -82,7 +82,6 @@ % mandatory unmatched_returns, error_handling, - % race_conditions, unknown ]}, {plt_apps, all_deps} @@ -97,12 +96,10 @@ %% https://github.com/valitydev/hellgate/pull/2/commits/884724c1799703cee4d1033850fe32c17f986d9e {recon, "2.3.6"}, {logger_logstash_formatter, - {git, "https://github.com/valitydev/logger_logstash_formatter.git", {ref, "08a66a6"}}}, - {iosetopts, {git, "https://github.com/valitydev/iosetopts.git", {ref, "edb445c"}}} + {git, "https://github.com/valitydev/logger_logstash_formatter.git", {ref, "08a66a6"}}} ]}, {relx, [ {release, {capi, "0.1.0"}, [ - iosetopts, % tools for introspection {recon, load}, % debugger @@ -128,9 +125,9 @@ ]}. {plugins, [ - {covertool, "2.0.4"}, - {erlfmt, "1.0.0"}, - {rebar3_lint, "1.0.1"} + {covertool, "2.0.7"}, + {erlfmt, "1.5.0"}, + {rebar3_lint, "3.2.6"} ]}. {erlfmt, [ @@ -144,11 +141,3 @@ "ct.coverdata" ]} ]}. - -%% NOTE -%% It is needed to use rebar3 lint plugin -{overrides, [ - {del, accept, [{plugins, [{rebar3_archive_plugin, "0.0.2"}]}]}, - {del, prometheus_cowboy, [{plugins, [{rebar3_archive_plugin, "0.0.1"}]}]}, - {del, prometheus_httpd, [{plugins, [{rebar3_archive_plugin, "0.0.1"}]}]} -]}. diff --git a/rebar.lock b/rebar.lock index 0fa2a9f..20c2f37 100644 --- a/rebar.lock +++ b/rebar.lock @@ -1,9 +1,9 @@ {"1.2.0", -[{<<"accept">>,{pkg,<<"accept">>,<<"0.3.5">>},2}, +[{<<"accept">>,{pkg,<<"accept">>,<<"0.3.6">>},2}, {<<"acceptor_pool">>,{pkg,<<"acceptor_pool">>,<<"1.0.0">>},2}, {<<"bender_client">>, {git,"https://github.com/valitydev/bender-client-erlang.git", - {ref,"d8837617c8dc36216ce8c4ffc9a56a34e423ca5e"}}, + {ref,"2fceffde5deac85d3bd3f071187041d84c8c3af4"}}, 0}, {<<"bender_proto">>, {git,"https://github.com/valitydev/bender-proto.git", @@ -11,7 +11,7 @@ 0}, {<<"bouncer_client">>, {git,"https://github.com/valitydev/bouncer-client-erlang.git", - {ref,"4f89634d9a009cac807cf86a0eff9e80d33318ea"}}, + {ref,"10835206f1deca28d6b900f73d635a15f078a123"}}, 0}, {<<"bouncer_proto">>, {git,"https://github.com/valitydev/bouncer-proto.git", @@ -23,7 +23,7 @@ {git,"https://github.com/rbkmoney/cg_mon.git", {ref,"5a87a37694e42b6592d3b4164ae54e0e87e24e18"}}, 1}, - {<<"chatterbox">>,{pkg,<<"ts_chatterbox">>,<<"0.13.0">>},2}, + {<<"chatterbox">>,{pkg,<<"ts_chatterbox">>,<<"0.15.1">>},2}, {<<"cowboy">>,{pkg,<<"cowboy">>,<<"2.9.0">>},0}, {<<"cowboy_access_log">>, {git,"https://github.com/valitydev/cowboy_access_log.git", @@ -62,16 +62,16 @@ 0}, {<<"genlib">>, {git,"https://github.com/valitydev/genlib.git", - {ref,"f6074551d6586998e91a97ea20acb47241254ff3"}}, + {ref,"d2324089afbbd9630e85fac554620f1de0b33dfe"}}, 0}, {<<"gproc">>,{pkg,<<"gproc">>,<<"0.9.0">>},1}, - {<<"grpcbox">>,{pkg,<<"grpcbox">>,<<"0.16.0">>},1}, + {<<"grpcbox">>,{pkg,<<"grpcbox">>,<<"0.17.1">>},1}, {<<"gun">>, {git,"https://github.com/ninenines/gun.git", {ref,"e7dd9f227e46979d8073e71c683395a809b78cb4"}}, 1}, {<<"hackney">>,{pkg,<<"hackney">>,<<"1.17.4">>},1}, - {<<"hpack">>,{pkg,<<"hpack_erl">>,<<"0.2.3">>},3}, + {<<"hpack">>,{pkg,<<"hpack_erl">>,<<"0.3.0">>},3}, {<<"idna">>,{pkg,<<"idna">>,<<"6.1.1">>},2}, {<<"jesse">>, {git,"https://github.com/valitydev/jesse.git", @@ -84,7 +84,7 @@ {<<"jsx">>,{pkg,<<"jsx">>,<<"3.1.0">>},1}, {<<"lechiffre">>, {git,"https://github.com/valitydev/lechiffre.git", - {ref,"ab894bc7c0e830f4372d302036f044d20c76ca73"}}, + {ref,"3f9c136ae2f70b9830f46c990e00d75dacfd73d9"}}, 0}, {<<"magista_proto">>, {git,"https://github.com/valitydev/magista-proto.git", @@ -96,17 +96,14 @@ {git,"https://github.com/valitydev/msgpack-proto.git", {ref,"7e447496aa5df4a5f1ace7ef2e3c31248b2a3ed0"}}, 1}, - {<<"opentelemetry">>,{pkg,<<"opentelemetry">>,<<"1.3.0">>},0}, - {<<"opentelemetry_api">>,{pkg,<<"opentelemetry_api">>,<<"1.2.1">>},0}, + {<<"opentelemetry">>,{pkg,<<"opentelemetry">>,<<"1.5.0">>},0}, + {<<"opentelemetry_api">>,{pkg,<<"opentelemetry_api">>,<<"1.4.0">>},0}, {<<"opentelemetry_exporter">>, - {pkg,<<"opentelemetry_exporter">>,<<"1.3.0">>}, + {pkg,<<"opentelemetry_exporter">>,<<"1.8.0">>}, 0}, - {<<"opentelemetry_semantic_conventions">>, - {pkg,<<"opentelemetry_semantic_conventions">>,<<"0.2.0">>}, - 1}, {<<"org_management_proto">>, {git,"https://github.com/valitydev/org-management-proto", - {ref,"03a269df4805fa604e8fd2d04241619a739e2ae3"}}, + {ref,"04de2f4ad697430c75f8efa04716d30753bd7c4b"}}, 1}, {<<"parse_trans">>,{pkg,<<"parse_trans">>,<<"3.4.1">>},1}, {<<"party_client">>, @@ -121,14 +118,14 @@ {git,"https://github.com/valitydev/payproc-errors-erlang.git", {ref,"a19e716966b7206e96fbd767661d6fd3bab3119d"}}, 0}, - {<<"prometheus">>,{pkg,<<"prometheus">>,<<"4.8.1">>},0}, - {<<"prometheus_cowboy">>,{pkg,<<"prometheus_cowboy">>,<<"0.1.8">>},0}, - {<<"prometheus_httpd">>,{pkg,<<"prometheus_httpd">>,<<"2.1.11">>},1}, + {<<"prometheus">>,{pkg,<<"prometheus">>,<<"4.11.0">>},0}, + {<<"prometheus_cowboy">>,{pkg,<<"prometheus_cowboy">>,<<"0.1.9">>},0}, + {<<"prometheus_httpd">>,{pkg,<<"prometheus_httpd">>,<<"2.1.14">>},1}, {<<"quantile_estimator">>,{pkg,<<"quantile_estimator">>,<<"0.2.1">>},1}, {<<"ranch">>,{pkg,<<"ranch">>,<<"1.8.0">>},1}, {<<"scoper">>, {git,"https://github.com/valitydev/scoper.git", - {ref,"41a14a558667316998af9f49149ee087ffa8bef2"}}, + {ref,"0e7aa01e9632daa39727edd62d4656ee715b4569"}}, 0}, {<<"snowflake">>, {git,"https://github.com/valitydev/snowflake.git", @@ -145,23 +142,23 @@ 0}, {<<"thrift">>, {git,"https://github.com/valitydev/thrift_erlang.git", - {ref,"846a0819d9b6d09d0c31f160e33a78dbad2067b4"}}, + {ref,"3a60e5dc5bbd709495024f26e100b041c3547fd9"}}, 1}, {<<"tls_certificate_check">>, - {pkg,<<"tls_certificate_check">>,<<"1.19.0">>}, + {pkg,<<"tls_certificate_check">>,<<"1.27.0">>}, 1}, {<<"token_keeper_client">>, {git,"https://github.com/valitydev/token-keeper-client.git", - {ref,"417916aab09baf0cd7f1a2a174945446203ea0bf"}}, + {ref,"00aaba5e0ef2a6eb35eeecd12dcafe475031e200"}}, 0}, {<<"token_keeper_proto">>, {git,"https://github.com/valitydev/token-keeper-proto.git", - {ref,"094b4f05a4e220df79911c25093feffea1cb868b"}}, + {ref,"8b8bb4333828350301ae2fe801c0c8de61c6529c"}}, 1}, {<<"unicode_util_compat">>,{pkg,<<"unicode_util_compat">>,<<"0.7.0">>},2}, {<<"woody">>, {git,"https://github.com/valitydev/woody_erlang.git", - {ref,"072825ee7179825a4078feb0649df71303c74157"}}, + {ref,"cc983a9423325ba1d6a509775eb6ff7ace721539"}}, 0}, {<<"woody_user_identity">>, {git,"https://github.com/valitydev/woody_erlang_user_identity.git", @@ -169,65 +166,63 @@ 0}]}. [ {pkg_hash,[ - {<<"accept">>, <<"B33B127ABCA7CC948BBE6CAA4C263369ABF1347CFA9D8E699C6D214660F10CD1">>}, + {<<"accept">>, <<"AD44AC7D704BF70EF8FB2E313EF5B978F9D1330BDDAC64509E93AFDA13281215">>}, {<<"acceptor_pool">>, <<"43C20D2ACAE35F0C2BCD64F9D2BDE267E459F0F3FD23DAB26485BF518C281B21">>}, {<<"cache">>, <<"B23A5FE7095445A88412A6E614C933377E0137B44FFED77C9B3FEF1A731A20B2">>}, {<<"certifi">>, <<"DBAB8E5E155A0763EEA978C913CA280A6B544BFA115633FA20249C3D396D9493">>}, - {<<"chatterbox">>, <<"6F059D97BCAA758B8EA6FFFE2B3B81362BD06B639D3EA2BB088335511D691EBF">>}, + {<<"chatterbox">>, <<"5CAC4D15DD7AD61FC3C4415CE4826FC563D4643DEE897A558EC4EA0B1C835C9C">>}, {<<"cowboy">>, <<"865DD8B6607E14CF03282E10E934023A1BD8BE6F6BACF921A7E2A96D800CD452">>}, {<<"cowlib">>, <<"0B9FF9C346629256C42EBE1EEB769A83C6CB771A6EE5960BD110AB0B9B872063">>}, {<<"ctx">>, <<"8FF88B70E6400C4DF90142E7F130625B82086077A45364A78D208ED3ED53C7FE">>}, {<<"email_validator">>, <<"7E09A862E9AA99AE2CA6FD2A718D2B94360E32940A1339B53DFEE6B774BCDB03">>}, {<<"gproc">>, <<"853CCB7805E9ADA25D227A157BA966F7B34508F386A3E7E21992B1B484230699">>}, - {<<"grpcbox">>, <<"B83F37C62D6EECA347B77F9B1EC7E9F62231690CDFEB3A31BE07CD4002BA9C82">>}, + {<<"grpcbox">>, <<"6E040AB3EF16FE699FFB513B0EF8E2E896DA7B18931A1EF817143037C454BCCE">>}, {<<"hackney">>, <<"99DA4674592504D3FB0CFEF0DB84C3BA02B4508BAE2DFF8C0108BAA0D6E0977C">>}, - {<<"hpack">>, <<"17670F83FF984AE6CD74B1C456EDDE906D27FF013740EE4D9EFAA4F1BF999633">>}, + {<<"hpack">>, <<"2461899CC4AB6A0EF8E970C1661C5FC6A52D3C25580BC6DD204F84CE94669926">>}, {<<"idna">>, <<"8A63070E9F7D0C62EB9D9FCB360A7DE382448200FBBD1B106CC96D3D8099DF8D">>}, {<<"jsx">>, <<"D12516BAA0BB23A59BB35DCCAF02A1BD08243FCBB9EFE24F2D9D056CCFF71268">>}, {<<"metrics">>, <<"25F094DEA2CDA98213CECC3AEFF09E940299D950904393B2A29D191C346A8486">>}, {<<"mimerl">>, <<"D0CD9FC04B9061F82490F6581E0128379830E78535E017F7780F37FEA7545726">>}, - {<<"opentelemetry">>, <<"988AC3C26ACAC9720A1D4FB8D9DC52E95B45ECFEC2D5B5583276A09E8936BC5E">>}, - {<<"opentelemetry_api">>, <<"7B69ED4F40025C005DE0B74FCE8C0549625D59CB4DF12D15C32FE6DC5076FF42">>}, - {<<"opentelemetry_exporter">>, <<"1D8809C0D4F4ACF986405F7700ED11992BCBDB6A4915DD11921E80777FFA7167">>}, - {<<"opentelemetry_semantic_conventions">>, <<"B67FE459C2938FCAB341CB0951C44860C62347C005ACE1B50F8402576F241435">>}, + {<<"opentelemetry">>, <<"7DDA6551EDFC3050EA4B0B40C0D2570423D6372B97E9C60793263EF62C53C3C2">>}, + {<<"opentelemetry_api">>, <<"63CA1742F92F00059298F478048DFB826F4B20D49534493D6919A0DB39B6DB04">>}, + {<<"opentelemetry_exporter">>, <<"5D546123230771EF4174E37BEDFD77E3374913304CD6EA3CA82A2ADD49CD5D56">>}, {<<"parse_trans">>, <<"6E6AA8167CB44CC8F39441D05193BE6E6F4E7C2946CB2759F015F8C56B76E5FF">>}, - {<<"prometheus">>, <<"FA76B152555273739C14B06F09F485CF6D5D301FE4E9D31B7FF803D26025D7A0">>}, - {<<"prometheus_cowboy">>, <<"CFCE0BC7B668C5096639084FCD873826E6220EA714BF60A716F5BD080EF2A99C">>}, - {<<"prometheus_httpd">>, <<"F616ED9B85B536B195D94104063025A91F904A4CFC20255363F49A197D96C896">>}, + {<<"prometheus">>, <<"B95F8DE8530F541BD95951E18E355A840003672E5EDA4788C5FA6183406BA29A">>}, + {<<"prometheus_cowboy">>, <<"D9D5B300516A61ED5AE31391F8EEEEB202230081D32A1813F2D78772B6F274E1">>}, + {<<"prometheus_httpd">>, <<"529A63CA2A451FC5D28C77020787A75AF661DADF721E7EC14B5842412FB67A32">>}, {<<"quantile_estimator">>, <<"EF50A361F11B5F26B5F16D0696E46A9E4661756492C981F7B2229EF42FF1CD15">>}, {<<"ranch">>, <<"8C7A100A139FD57F17327B6413E4167AC559FBC04CA7448E9BE9057311597A1D">>}, {<<"ssl_verify_fun">>, <<"354C321CF377240C7B8716899E182CE4890C5938111A1296ADD3EC74CF1715DF">>}, - {<<"tls_certificate_check">>, <<"C76C4C5D79EE79A2B11C84F910C825D6F024A78427C854F515748E9BD025E987">>}, + {<<"tls_certificate_check">>, <<"2C1C7FC922A329B9EB45DDF39113C998BBDEB28A534219CD884431E2AEE1811E">>}, {<<"unicode_util_compat">>, <<"BC84380C9AB48177092F43AC89E4DFA2C6D62B40B8BD132B1059ECC7232F9A78">>}]}, {pkg_hash_ext,[ - {<<"accept">>, <<"11B18C220BCC2EAB63B5470C038EF10EB6783BCB1FCDB11AA4137DEFA5AC1BB8">>}, + {<<"accept">>, <<"A5167FA1AE90315C3F1DD189446312F8A55D00EFA357E9C569BDA47736B874C3">>}, {<<"acceptor_pool">>, <<"0CBCD83FDC8B9AD2EEE2067EF8B91A14858A5883CB7CD800E6FCD5803E158788">>}, {<<"cache">>, <<"44516CE6FA03594D3A2AF025DD3A87BFE711000EB730219E1DDEFC816E0AA2F4">>}, {<<"certifi">>, <<"524C97B4991B3849DD5C17A631223896272C6B0AF446778BA4675A1DFF53BB7E">>}, - {<<"chatterbox">>, <<"B93D19104D86AF0B3F2566C4CBA2A57D2E06D103728246BA1AC6C3C0FF010AA7">>}, + {<<"chatterbox">>, <<"4F75B91451338BC0DA5F52F3480FA6EF6E3A2AEECFC33686D6B3D0A0948F31AA">>}, {<<"cowboy">>, <<"2C729F934B4E1AA149AFF882F57C6372C15399A20D54F65C8D67BEF583021BDE">>}, {<<"cowlib">>, <<"2B3E9DA0B21C4565751A6D4901C20D1B4CC25CBB7FD50D91D2AB6DD287BC86A9">>}, {<<"ctx">>, <<"A14ED2D1B67723DBEBBE423B28D7615EB0BDCBA6FF28F2D1F1B0A7E1D4AA5FC2">>}, {<<"email_validator">>, <<"2B1E6DF7BB14155C8D7D131F1C95CF4676200BC056EEBA82123396833FF94DA2">>}, {<<"gproc">>, <<"587E8AF698CCD3504CF4BA8D90F893EDE2B0F58CABB8A916E2BF9321DE3CF10B">>}, - {<<"grpcbox">>, <<"294DF743AE20A7E030889F00644001370A4F7CE0121F3BBDAF13CF3169C62913">>}, + {<<"grpcbox">>, <<"4A3B5D7111DAABC569DC9CBD9B202A3237D81C80BF97212FBC676832CB0CEB17">>}, {<<"hackney">>, <<"DE16FF4996556C8548D512F4DBE22DD58A587BF3332E7FD362430A7EF3986B16">>}, - {<<"hpack">>, <<"06F580167C4B8B8A6429040DF36CC93BBA6D571FAEAEC1B28816523379CBB23A">>}, + {<<"hpack">>, <<"D6137D7079169D8C485C6962DFE261AF5B9EF60FBC557344511C1E65E3D95FB0">>}, {<<"idna">>, <<"92376EB7894412ED19AC475E4A86F7B413C1B9FBB5BD16DCCD57934157944CEA">>}, {<<"jsx">>, <<"0C5CC8FDC11B53CC25CF65AC6705AD39E54ECC56D1C22E4ADB8F5A53FB9427F3">>}, {<<"metrics">>, <<"69B09ADDDC4F74A40716AE54D140F93BEB0FB8978D8636EADED0C31B6F099F16">>}, {<<"mimerl">>, <<"A1E15A50D1887217DE95F0B9B0793E32853F7C258A5CD227650889B38839FE9D">>}, - {<<"opentelemetry">>, <<"8E09EDC26AAD11161509D7ECAD854A3285D88580F93B63B0B1CF0BAC332BFCC0">>}, - {<<"opentelemetry_api">>, <<"6D7A27B7CAD2AD69A09CABF6670514CAFCEC717C8441BEB5C96322BAC3D05350">>}, - {<<"opentelemetry_exporter">>, <<"2B40007F509D38361744882FD060A8841AF772AB83BB542AA5350908B303AD65">>}, - {<<"opentelemetry_semantic_conventions">>, <<"D61FA1F5639EE8668D74B527E6806E0503EFC55A42DB7B5F39939D84C07D6895">>}, + {<<"opentelemetry">>, <<"CDF4F51D17B592FC592B9A75F86A6F808C23044BA7CF7B9534DEBBCC5C23B0EE">>}, + {<<"opentelemetry_api">>, <<"3DFBBFAA2C2ED3121C5C483162836C4F9027DEF469C41578AF5EF32589FCFC58">>}, + {<<"opentelemetry_exporter">>, <<"A1F9F271F8D3B02B81462A6BFEF7075FD8457FDB06ADFF5D2537DF5E2264D9AF">>}, {<<"parse_trans">>, <<"620A406CE75DADA827B82E453C19CF06776BE266F5A67CFF34E1EF2CBB60E49A">>}, - {<<"prometheus">>, <<"6EDFBE928D271C7F657A6F2C46258738086584BD6CAE4A000B8B9A6009BA23A5">>}, - {<<"prometheus_cowboy">>, <<"BA286BECA9302618418892D37BCD5DC669A6CC001F4EB6D6AF85FF81F3F4F34C">>}, - {<<"prometheus_httpd">>, <<"0BBE831452CFDF9588538EB2F570B26F30C348ADAE5E95A7D87F35A5910BCF92">>}, + {<<"prometheus">>, <<"719862351AABF4DF7079B05DC085D2BBCBE3AC0AC3009E956671B1D5AB88247D">>}, + {<<"prometheus_cowboy">>, <<"5F71C039DEB9E9FF9DD6366BC74C907A463872B85286E619EFF0BDA15111695A">>}, + {<<"prometheus_httpd">>, <<"8B39F8CB6467B80D648FB982FDEB796BAB006BB43B1C95279289F311DB562D4E">>}, {<<"quantile_estimator">>, <<"282A8A323CA2A845C9E6F787D166348F776C1D4A41EDE63046D72D422E3DA946">>}, {<<"ranch">>, <<"49FBCFD3682FAB1F5D109351B61257676DA1A2FDBE295904176D5E521A2DDFE5">>}, {<<"ssl_verify_fun">>, <<"FE4C190E8F37401D30167C8C405EDA19469F34577987C76DDE613E838BBC67F8">>}, - {<<"tls_certificate_check">>, <<"4083B4A298ADD534C96125337CB01161C358BB32DD870D5A893AAE685FD91D70">>}, + {<<"tls_certificate_check">>, <<"51A5AD3DBD72D4694848965F3B5076E8B55D70EB8D5057FCDDD536029AB8A23C">>}, {<<"unicode_util_compat">>, <<"25EEE6D67DF61960CF6A794239566599B09E17E668D3700247BC498638152521">>}]} ]. From 420e5d86c95ca2790ac2759df84c141a40bfb877 Mon Sep 17 00:00:00 2001 From: Aleksey Kashapov Date: Tue, 4 Mar 2025 18:30:26 +0300 Subject: [PATCH 2/2] Fixes codestyle --- apps/capi/src/capi_auth.erl | 4 +- apps/capi/src/capi_bender.erl | 14 ++--- apps/capi/src/capi_bouncer_context.erl | 6 +-- apps/capi/src/capi_domain.erl | 2 +- apps/capi/src/capi_feature_schemas.erl | 6 +-- apps/capi/src/capi_handler.erl | 2 +- apps/capi/src/capi_handler_categories.erl | 4 +- apps/capi/src/capi_handler_contracts.erl | 17 +++---- apps/capi/src/capi_handler_countries.erl | 4 +- apps/capi/src/capi_handler_customers.erl | 5 +- .../src/capi_handler_decoder_invoicing.erl | 8 +-- .../src/capi_handler_invoice_templates.erl | 4 +- .../src/capi_handler_payment_institutions.erl | 10 ++-- apps/capi/src/capi_handler_payments.erl | 28 +++++----- apps/capi/src/capi_handler_shops.erl | 16 +++--- apps/capi/src/capi_merchant_id.erl | 7 +-- apps/capi/src/capi_sup.erl | 2 +- apps/capi/src/capi_swagger_server.erl | 2 +- .../test/capi_base_api_token_tests_SUITE.erl | 51 +++++++++++-------- apps/capi/test/capi_ct_helper_bouncer.erl | 2 +- .../capi/test/capi_ct_helper_token_keeper.erl | 6 +-- apps/capi/test/capi_dummy_data.hrl | 24 +++++---- .../test/capi_idempotency_tests_SUITE.erl | 4 +- apps/capi_client/src/capi_client_lib.erl | 2 +- .../src/capi_woody_client.erl | 2 +- elvis.config | 12 +++-- rebar.lock | 16 +++--- 27 files changed, 134 insertions(+), 126 deletions(-) diff --git a/apps/capi/src/capi_auth.erl b/apps/capi/src/capi_auth.erl index 6e475c1..2092f36 100644 --- a/apps/capi/src/capi_auth.erl +++ b/apps/capi/src/capi_auth.erl @@ -54,8 +54,8 @@ -spec get_subject_id(auth_context()) -> binary() | undefined. get_subject_id(AuthContext) -> case get_party_id(AuthContext) of - PartyId when is_binary(PartyId) -> - PartyId; + PartyID when is_binary(PartyID) -> + PartyID; undefined -> get_user_id(AuthContext) end. diff --git a/apps/capi/src/capi_bender.erl b/apps/capi/src/capi_bender.erl index 3b04367..f1cfad4 100644 --- a/apps/capi/src/capi_bender.erl +++ b/apps/capi/src/capi_bender.erl @@ -147,8 +147,8 @@ build_bender_ctx(Features, Ctx) -> get_external_id({_BenderPrefix, _PartyOrUserID, ExternalID}) -> ExternalID. -try_generate_id(BenderIdSchema, IdempotentKey, Identity, WoodyContext, CtxData) -> - case generate_id(BenderIdSchema, IdempotentKey, Identity, WoodyContext, CtxData) of +try_generate_id(BenderIDSchema, IdempotentKey, Identity, WoodyContext, CtxData) -> + case generate_id(BenderIDSchema, IdempotentKey, Identity, WoodyContext, CtxData) of {ok, ID} -> ID; {error, {external_id_conflict, ID, Difference, Schema}} -> @@ -158,14 +158,14 @@ try_generate_id(BenderIdSchema, IdempotentKey, Identity, WoodyContext, CtxData) throw({external_id_conflict, ID, SourceID, Schema}) end. -generate_id(BenderIdSchema, IdempKeyParams, Identity, WoodyContext, CtxData) -> +generate_id(BenderIDSchema, IdempKeyParams, Identity, WoodyContext, CtxData) -> IdempKey = make_idempotent_key(IdempKeyParams), case IdempKey of undefined -> - ID = generator_generate_id(BenderIdSchema, WoodyContext), + ID = generator_generate_id(BenderIDSchema, WoodyContext), {ok, ID}; IdempKey -> - bender_generate_id(BenderIdSchema, IdempKey, Identity, WoodyContext, CtxData) + bender_generate_id(BenderIDSchema, IdempKey, Identity, WoodyContext, CtxData) end. -spec make_idempotent_key(idempotent_key_params()) -> idempotent_key() | undefined. @@ -177,10 +177,10 @@ make_idempotent_key({_Prefix, _PartyID, undefined}) -> make_idempotent_key({Prefix, PartyID, ExternalID}) -> bender_client:get_idempotent_key(?BENDER_NAMESPACE, Prefix, PartyID, ExternalID). -bender_generate_id(BenderIdSchema, IdempKey, Identity, WoodyContext, CtxData) -> +bender_generate_id(BenderIDSchema, IdempKey, Identity, WoodyContext, CtxData) -> {identity, Features, Schema} = Identity, BenderCtx = build_bender_ctx(Features, CtxData), - case bender_client:gen_id(IdempKey, BenderIdSchema, WoodyContext, BenderCtx) of + case bender_client:gen_id(IdempKey, BenderIDSchema, WoodyContext, BenderCtx) of {ok, ID} -> {ok, ID}; {ok, ID, #{<<"version">> := ?SCHEMA_VER3} = SavedBenderCtx} -> diff --git a/apps/capi/src/capi_bouncer_context.erl b/apps/capi/src/capi_bouncer_context.erl index 7fe7a50..ee48b1a 100644 --- a/apps/capi/src/capi_bouncer_context.erl +++ b/apps/capi/src/capi_bouncer_context.erl @@ -86,7 +86,7 @@ build(Prototypes, {Acc0, External}, WoodyCtx) -> Acc1 = lists:foldl(fun({T, Params}, Acc) -> build(T, Params, Acc, WoodyCtx) end, Acc0, Prototypes), {Acc1, External}. -build(operation, Params = #{id := OperationID}, Acc, _WoodyCtx) -> +build(operation, #{id := OperationID} = Params, Acc, _WoodyCtx) -> Acc#ctx_v1_ContextFragment{ capi = #ctx_v1_ContextCommonAPI{ op = #ctx_v1_CommonAPIOperation{ @@ -105,7 +105,7 @@ build(operation, Params = #{id := OperationID}, Acc, _WoodyCtx) -> } } }; -build(payproc, Params = #{}, Acc, WoodyCtx) -> +build(payproc, #{} = Params, Acc, WoodyCtx) -> Acc#ctx_v1_ContextFragment{ payment_processing = #ctx_v1_ContextPaymentProcessing{ invoice = maybe_with( @@ -125,7 +125,7 @@ build(payproc, Params = #{}, Acc, WoodyCtx) -> ) } }; -build(webhooks, Params = #{}, Acc, WoodyCtx) -> +build(webhooks, #{} = Params, Acc, WoodyCtx) -> Acc#ctx_v1_ContextFragment{ webhooks = #ctx_v1_ContextWebhooks{ webhook = maybe_with( diff --git a/apps/capi/src/capi_domain.erl b/apps/capi/src/capi_domain.erl index c37d307..287dc3b 100644 --- a/apps/capi/src/capi_domain.erl +++ b/apps/capi/src/capi_domain.erl @@ -102,7 +102,7 @@ extract_type(Name) when is_atom(Name) -> {dmsl_domain_thrift, Name}; extract_type({_ID, _Kind, TypeInfo, _Field, _Default}) -> extract_type(TypeInfo); -extract_type(Type = {Module, Name}) when is_atom(Module), is_atom(Name) -> +extract_type({Module, Name} = Type) when is_atom(Module), is_atom(Name) -> Type; extract_type({struct, struct, Type = {Module, Name}}) when is_atom(Module), is_atom(Name) -> Type; diff --git a/apps/capi/src/capi_feature_schemas.erl b/apps/capi/src/capi_feature_schemas.erl index 1a0e3b8..709fb64 100644 --- a/apps/capi/src/capi_feature_schemas.erl +++ b/apps/capi/src/capi_feature_schemas.erl @@ -699,7 +699,7 @@ compare_customer_binding_features_test() -> Request1 = payment_resource(Session1, Tool1), Session2 = ?TEST_PAYMENT_SESSION(<<"Session2">>), - Tool2 = ?TEST_PAYMENT_TOOL(<<"mastercard">>)#{<<"exp_date">> => <<"01/2020">>}, + Tool2 = maps:merge(?TEST_PAYMENT_TOOL(<<"mastercard">>), #{<<"exp_date">> => <<"01/2020">>}), Request2 = payment_resource(Session2, Tool2), common_compare_tests(customer_binding(), Request1, Request2, [ @@ -864,7 +864,7 @@ read_allocation_transaction_test_() -> -spec compare_allocation_transaction_test() -> _. compare_allocation_transaction_test() -> Request1 = ?ALLOCATION_TRANSACTION_PARAMS, - Request2 = ?ALLOCATION_TRANSACTION_PARAMS#{ + Request2 = maps:merge(?ALLOCATION_TRANSACTION_PARAMS, #{ <<"total">> => 1024, <<"amount">> => 512, <<"fee">> => #{ @@ -873,7 +873,7 @@ compare_allocation_transaction_test() -> <<"amount">> => ?INTEGER, <<"share">> => undefined } - }, + }), %% Request3 = #{ %% <<"target">> => ?ALLOCATION_TARGET#{<<"shopID">> => <<"SomeShop">>}, %% <<"allocationBodyType">> => <<"AllocationBodyAmount">>, diff --git a/apps/capi/src/capi_handler.erl b/apps/capi/src/capi_handler.erl index 361d36d..6791548 100644 --- a/apps/capi/src/capi_handler.erl +++ b/apps/capi/src/capi_handler.erl @@ -224,7 +224,7 @@ respond_if_forbidden(allowed, _Response) -> get_auth_context(#{auth_context := AuthContext}) -> AuthContext. -do_authorize_api_key(SwagContext = #{auth_context := PreAuthContext}, WoodyContext) -> +do_authorize_api_key(#{auth_context := PreAuthContext} = SwagContext, WoodyContext) -> case capi_auth:authorize_api_key(PreAuthContext, make_token_context(SwagContext), WoodyContext) of {ok, AuthContext} -> SwagContext#{auth_context => AuthContext}; diff --git a/apps/capi/src/capi_handler_categories.erl b/apps/capi/src/capi_handler_categories.erl index bb201ce..2b6c3ed 100644 --- a/apps/capi/src/capi_handler_categories.erl +++ b/apps/capi/src/capi_handler_categories.erl @@ -13,7 +13,7 @@ Req :: capi_handler:request_data(), Context :: capi_handler:processing_context() ) -> {ok, capi_handler:request_state()} | {error, noimpl}. -prepare(OperationID = 'GetCategories', _Req, Context) -> +prepare('GetCategories' = OperationID, _Req, Context) -> Authorize = fun() -> Prototypes = [{operation, #{id => OperationID}}], {ok, capi_auth:authorize_operation(Prototypes, Context)} @@ -23,7 +23,7 @@ prepare(OperationID = 'GetCategories', _Req, Context) -> {ok, {200, #{}, [decode_category(C) || C <- Categories]}} end, {ok, #{authorize => Authorize, process => Process}}; -prepare(OperationID = 'GetCategoryByRef', Req, Context) -> +prepare('GetCategoryByRef' = OperationID, Req, Context) -> Authorize = fun() -> Prototypes = [{operation, #{id => OperationID}}], {ok, capi_auth:authorize_operation(Prototypes, Context)} diff --git a/apps/capi/src/capi_handler_contracts.erl b/apps/capi/src/capi_handler_contracts.erl index 1898a04..cb1c4dc 100644 --- a/apps/capi/src/capi_handler_contracts.erl +++ b/apps/capi/src/capi_handler_contracts.erl @@ -2,7 +2,6 @@ -include_lib("damsel/include/dmsl_payproc_thrift.hrl"). -include_lib("damsel/include/dmsl_domain_thrift.hrl"). --include_lib("damsel/include/dmsl_base_thrift.hrl"). -behaviour(capi_handler). @@ -15,7 +14,7 @@ Req :: capi_handler:request_data(), Context :: capi_handler:processing_context() ) -> {ok, capi_handler:request_state()} | {error, noimpl}. -prepare(OperationID = 'GetContracts', _Req, Context) -> +prepare('GetContracts' = OperationID, _Req, Context) -> PartyID = capi_handler_utils:get_party_id(Context), Authorize = fun() -> Prototypes = [ @@ -28,7 +27,7 @@ prepare(OperationID = 'GetContracts', _Req, Context) -> {ok, {200, #{}, decode_contracts_map(Party#domain_Party.contracts, Party#domain_Party.contractors)}} end, {ok, #{authorize => Authorize, process => Process}}; -prepare(OperationID = 'GetContractByID', Req, Context) -> +prepare('GetContractByID' = OperationID, Req, Context) -> ContractID = maps:get('contractID', Req), PartyID = capi_handler_utils:get_party_id(Context), Authorize = fun() -> @@ -48,7 +47,7 @@ prepare(OperationID = 'GetContractByID', Req, Context) -> end end, {ok, #{authorize => Authorize, process => Process}}; -prepare(OperationID = 'GetContractAdjustments', Req, Context) -> +prepare('GetContractAdjustments' = OperationID, Req, Context) -> ContractID = maps:get('contractID', Req), PartyID = capi_handler_utils:get_party_id(Context), Authorize = fun() -> @@ -63,7 +62,7 @@ prepare(OperationID = 'GetContractAdjustments', Req, Context) -> {ok, {200, #{}, Resp}} end, {ok, #{authorize => Authorize, process => Process}}; -prepare(OperationID = 'GetContractAdjustmentByID', Req, Context) -> +prepare('GetContractAdjustmentByID' = OperationID, Req, Context) -> ContractID = maps:get('contractID', Req), PartyID = capi_handler_utils:get_party_id(Context), Authorize = fun() -> @@ -84,7 +83,7 @@ prepare(OperationID = 'GetContractAdjustmentByID', Req, Context) -> end end, {ok, #{authorize => Authorize, process => Process}}; -prepare(OperationID = 'GetContractsForParty', Req, Context) -> +prepare('GetContractsForParty' = OperationID, Req, Context) -> PartyID = maps:get('partyID', Req), Authorize = fun() -> Prototypes = [ @@ -101,7 +100,7 @@ prepare(OperationID = 'GetContractsForParty', Req, Context) -> end end, {ok, #{authorize => Authorize, process => Process}}; -prepare(OperationID = 'GetContractByIDForParty', Req, Context) -> +prepare('GetContractByIDForParty' = OperationID, Req, Context) -> ContractID = maps:get('contractID', Req), PartyID = maps:get('partyID', Req), Authorize = fun() -> @@ -117,7 +116,7 @@ prepare(OperationID = 'GetContractByIDForParty', Req, Context) -> {ok, {200, #{}, decode_contract(Contract, Party#domain_Party.contractors)}} end, {ok, #{authorize => Authorize, process => Process}}; -prepare(OperationID = 'GetContractAdjustmentsForParty', Req, Context) -> +prepare('GetContractAdjustmentsForParty' = OperationID, Req, Context) -> ContractID = maps:get('contractID', Req), PartyID = maps:get('partyID', Req), Authorize = fun() -> @@ -132,7 +131,7 @@ prepare(OperationID = 'GetContractAdjustmentsForParty', Req, Context) -> {ok, {200, #{}, Resp}} end, {ok, #{authorize => Authorize, process => Process}}; -prepare(OperationID = 'GetContractAdjustmentByIDForParty', Req, Context) -> +prepare('GetContractAdjustmentByIDForParty' = OperationID, Req, Context) -> ContractID = maps:get('contractID', Req), PartyID = maps:get('partyID', Req), Authorize = fun() -> diff --git a/apps/capi/src/capi_handler_countries.erl b/apps/capi/src/capi_handler_countries.erl index ffcc6a4..1ded40b 100644 --- a/apps/capi/src/capi_handler_countries.erl +++ b/apps/capi/src/capi_handler_countries.erl @@ -51,8 +51,8 @@ decode_trade_bloc_refs(undefined) -> undefined; decode_trade_bloc_refs(TradeBlocRefs) -> lists:map( - fun(#domain_TradeBlocRef{id = Id}) -> - Id + fun(#domain_TradeBlocRef{id = ID}) -> + ID end, ordsets:to_list(TradeBlocRefs) ). diff --git a/apps/capi/src/capi_handler_customers.erl b/apps/capi/src/capi_handler_customers.erl index aa1e85f..13aaa86 100644 --- a/apps/capi/src/capi_handler_customers.erl +++ b/apps/capi/src/capi_handler_customers.erl @@ -2,7 +2,6 @@ -include_lib("damsel/include/dmsl_payproc_thrift.hrl"). -include_lib("damsel/include/dmsl_domain_thrift.hrl"). --include_lib("damsel/include/dmsl_base_thrift.hrl"). -behaviour(capi_handler). @@ -302,7 +301,7 @@ encode_customer_params(CustomerID, PartyID, Params) -> encode_customer_metadata(Meta) -> capi_json_marshalling:marshal(Meta). -generate_binding_ids(OperationID, CustomerBindingParams, Context = #{woody_context := WoodyContext}) -> +generate_binding_ids(OperationID, CustomerBindingParams, #{woody_context := WoodyContext} = Context) -> ExternalID = maps:get(<<"externalID">>, CustomerBindingParams, undefined), PartyID = capi_handler_utils:get_party_id(Context), @@ -424,7 +423,7 @@ decode_customer_binding_status({Status, StatusInfo}) -> <<"error">> => Error }. -decode_customer_event(Event = #payproc_Event{source = {customer_id, _}, payload = Payload}) -> +decode_customer_event(#payproc_Event{source = {customer_id, _}, payload = Payload} = Event) -> case decode_customer_changes(Payload) of [_Something | _] = Changes -> {true, #{ diff --git a/apps/capi/src/capi_handler_decoder_invoicing.erl b/apps/capi/src/capi_handler_decoder_invoicing.erl index 6298ea8..393a2af 100644 --- a/apps/capi/src/capi_handler_decoder_invoicing.erl +++ b/apps/capi/src/capi_handler_decoder_invoicing.erl @@ -97,7 +97,7 @@ decode_crypto_amount(#'user_interaction_CryptoCurrencyTransferRequest'{crypto_ca ensure_correct_exponent(#base_Rational{q = Q}) -> Log = math:log10(Q), case Log - trunc(Log) of - 0.0 -> ok; + V when V == 0 -> ok; _ -> error('expected a power of 10 denominator') end. @@ -111,7 +111,7 @@ decode_fractional_part(#base_Rational{p = P, q = Q}) -> get_exponent(Q) -> erlang:trunc(math:log10(Q)). -build_fractional(_Fractional, _Exponent = 0) -> +build_fractional(_Fractional, 0 = _Exponent) -> <<>>; build_fractional(Fractional, Exponent) -> BinaryFractional = erlang:integer_to_binary(Fractional), @@ -177,7 +177,7 @@ decode_payment(InvoiceID, Payment, Context) -> -spec decode_invoice_payment(binary(), capi_handler_encoder:encode_data(), processing_context()) -> decode_data(). -decode_invoice_payment(InvoiceID, InvoicePayment = #payproc_InvoicePayment{payment = Payment}, Context) -> +decode_invoice_payment(InvoiceID, #payproc_InvoicePayment{payment = Payment} = InvoicePayment, Context) -> capi_handler_utils:merge_and_compact( decode_payment(InvoiceID, Payment, Context), #{ @@ -528,7 +528,7 @@ decode_invoice_cart(#domain_InvoiceCart{lines = Lines}) -> decode_invoice_cart(undefined) -> undefined. -decode_invoice_line(InvoiceLine = #domain_InvoiceLine{quantity = Quantity, price = #domain_Cash{amount = Price}}) -> +decode_invoice_line(#domain_InvoiceLine{quantity = Quantity, price = #domain_Cash{amount = Price}} = InvoiceLine) -> genlib_map:compact(#{ <<"product">> => InvoiceLine#domain_InvoiceLine.product, <<"quantity">> => Quantity, diff --git a/apps/capi/src/capi_handler_invoice_templates.erl b/apps/capi/src/capi_handler_invoice_templates.erl index cb4f85f..7978b87 100644 --- a/apps/capi/src/capi_handler_invoice_templates.erl +++ b/apps/capi/src/capi_handler_invoice_templates.erl @@ -301,7 +301,7 @@ get_product_from_tpl_details({cart, #domain_InvoiceCart{lines = [FirstLine | _]} get_product_from_tpl_details(undefined) -> undefined. -encode_optional_context(Params = #{<<"metadata">> := _}) -> +encode_optional_context(#{<<"metadata">> := _} = Params) -> capi_handler_encoder:encode_invoice_context(Params); encode_optional_context(#{}) -> undefined. @@ -340,7 +340,7 @@ encode_invoice_tpl_product(Details) -> metadata = capi_handler_encoder:encode_invoice_line_meta(Details) }. -encode_optional_invoice_cost(Params = #{<<"amount">> := _, <<"currency">> := _}) -> +encode_optional_invoice_cost(#{<<"amount">> := _, <<"currency">> := _} = Params) -> capi_handler_encoder:encode_cash(Params); encode_optional_invoice_cost(#{<<"amount">> := _}) -> throw({bad_invoice_params, amount_no_currency}); diff --git a/apps/capi/src/capi_handler_payment_institutions.erl b/apps/capi/src/capi_handler_payment_institutions.erl index b1694c4..1e3c03d 100644 --- a/apps/capi/src/capi_handler_payment_institutions.erl +++ b/apps/capi/src/capi_handler_payment_institutions.erl @@ -16,7 +16,7 @@ Req :: capi_handler:request_data(), Context :: capi_handler:processing_context() ) -> {ok, capi_handler:request_state()} | {error, noimpl}. -prepare(OperationID = 'GetPaymentInstitutions', Req, Context) -> +prepare('GetPaymentInstitutions' = OperationID, Req, Context) -> Authorize = mk_authorize_operation(OperationID, Context), Process = fun() -> try @@ -31,7 +31,7 @@ prepare(OperationID = 'GetPaymentInstitutions', Req, Context) -> end end, {ok, #{authorize => Authorize, process => Process}}; -prepare(OperationID = 'GetPaymentInstitutionByRef', Req, Context) -> +prepare('GetPaymentInstitutionByRef' = OperationID, Req, Context) -> Authorize = mk_authorize_operation(OperationID, Context), Process = fun() -> PaymentInstitutionID = genlib:to_int(maps:get('paymentInstitutionID', Req)), @@ -44,7 +44,7 @@ prepare(OperationID = 'GetPaymentInstitutionByRef', Req, Context) -> end end, {ok, #{authorize => Authorize, process => Process}}; -prepare(OperationID = 'GetPaymentInstitutionPaymentTerms', Req, Context) -> +prepare('GetPaymentInstitutionPaymentTerms' = OperationID, Req, Context) -> Authorize = mk_authorize_operation(OperationID, Context), Process = fun() -> PaymentInstitutionID = genlib:to_int(maps:get('paymentInstitutionID', Req)), @@ -56,7 +56,7 @@ prepare(OperationID = 'GetPaymentInstitutionPaymentTerms', Req, Context) -> end end, {ok, #{authorize => Authorize, process => Process}}; -prepare(OperationID = 'GetServiceProviderByID', Req, Context) -> +prepare('GetServiceProviderByID' = OperationID, Req, Context) -> Authorize = mk_authorize_operation(OperationID, Context), Process = fun() -> ServiceProviderID = maps:get('serviceProviderID', Req), @@ -146,7 +146,7 @@ decode_payment_terms(_, _) -> %% -decode_payment_service(ID, PaymentService = #domain_PaymentService{}) -> +decode_payment_service(ID, #domain_PaymentService{} = PaymentService) -> genlib_map:compact(#{ <<"id">> => ID, <<"brandName">> => PaymentService#domain_PaymentService.brand_name, diff --git a/apps/capi/src/capi_handler_payments.erl b/apps/capi/src/capi_handler_payments.erl index 8c50f5b..a91cea5 100644 --- a/apps/capi/src/capi_handler_payments.erl +++ b/apps/capi/src/capi_handler_payments.erl @@ -17,7 +17,7 @@ Req :: capi_handler:request_data(), Context :: capi_handler:processing_context() ) -> {ok, capi_handler:request_state()} | {error, noimpl}. -prepare(OperationID = 'CreatePayment', Req, Context) -> +prepare('CreatePayment' = OperationID, Req, Context) -> InvoiceID = maps:get('invoiceID', Req), Invoice = get_invoice_by_id(InvoiceID, Context), PaymentParams = maps:get('PaymentParams', Req), @@ -64,7 +64,7 @@ prepare(OperationID = 'CreatePayment', Req, Context) -> end end, {ok, #{authorize => Authorize, process => Process}}; -prepare(OperationID = 'GetPayments', Req, Context) -> +prepare('GetPayments' = OperationID, Req, Context) -> InvoiceID = maps:get('invoiceID', Req), Invoice = get_invoice_by_id(InvoiceID, Context), Authorize = fun() -> @@ -80,7 +80,7 @@ prepare(OperationID = 'GetPayments', Req, Context) -> {ok, {200, #{}, [decode_invoice_payment(InvoiceID, P, Context) || P <- Payments]}} end, {ok, #{authorize => Authorize, process => Process}}; -prepare(OperationID = 'GetPaymentByID', Req, Context) -> +prepare('GetPaymentByID' = OperationID, Req, Context) -> InvoiceID = maps:get('invoiceID', Req), PaymentID = maps:get('paymentID', Req), Invoice = get_invoice_by_id(InvoiceID, Context), @@ -137,11 +137,11 @@ prepare(OperationID, #{'partyID' := PartyID, 'externalID' := ExternalID}, Contex end end, {ok, #{authorize => Authorize, process => Process}}; -prepare(OperationID = 'GetPaymentByExternalID', Req, Context) -> +prepare('GetPaymentByExternalID' = OperationID, Req, Context) -> PartyID = capi_handler_utils:get_party_id(Context), Req1 = maps:put('partyID', PartyID, Req), prepare(OperationID, Req1, Context); -prepare(OperationID = 'CapturePayment', Req, Context) -> +prepare('CapturePayment' = OperationID, Req, Context) -> InvoiceID = maps:get('invoiceID', Req), PaymentID = maps:get('paymentID', Req), Invoice = get_invoice_by_id(InvoiceID, Context), @@ -214,7 +214,7 @@ prepare(OperationID = 'CapturePayment', Req, Context) -> end end, {ok, #{authorize => Authorize, process => Process}}; -prepare(OperationID = 'CancelPayment', Req, Context) -> +prepare('CancelPayment' = OperationID, Req, Context) -> InvoiceID = maps:get('invoiceID', Req), PaymentID = maps:get('paymentID', Req), Authorize = fun() -> @@ -249,7 +249,7 @@ prepare(OperationID = 'CancelPayment', Req, Context) -> end end, {ok, #{authorize => Authorize, process => Process}}; -prepare(OperationID = 'CreateRefund', Req, Context) -> +prepare('CreateRefund' = OperationID, Req, Context) -> InvoiceID = maps:get('invoiceID', Req), PaymentID = maps:get('paymentID', Req), RefundParams = maps:get('RefundParams', Req), @@ -319,7 +319,7 @@ prepare(OperationID = 'CreateRefund', Req, Context) -> end end, {ok, #{authorize => Authorize, process => Process}}; -prepare(OperationID = 'GetRefunds', Req, Context) -> +prepare('GetRefunds' = OperationID, Req, Context) -> InvoiceID = maps:get('invoiceID', Req), PaymentID = maps:get('paymentID', Req), Invoice = get_invoice_by_id(InvoiceID, Context), @@ -344,7 +344,7 @@ prepare(OperationID = 'GetRefunds', Req, Context) -> end end, {ok, #{authorize => Authorize, process => Process}}; -prepare(OperationID = 'GetRefundByID', Req, Context) -> +prepare('GetRefundByID' = OperationID, Req, Context) -> InvoiceID = maps:get('invoiceID', Req), PaymentID = maps:get('paymentID', Req), RefundID = maps:get('refundID', Req), @@ -407,11 +407,11 @@ prepare(OperationID, #{'partyID' := PartyID, 'externalID' := ExternalID}, Contex end end, {ok, #{authorize => Authorize, process => Process}}; -prepare(OperationID = 'GetRefundByExternalID', Req, Context) -> +prepare('GetRefundByExternalID' = OperationID, Req, Context) -> PartyID = capi_handler_utils:get_party_id(Context), Req1 = maps:put('partyID', PartyID, Req), prepare(OperationID, Req1, Context); -prepare(OperationID = 'GetChargebacks', Req, Context) -> +prepare('GetChargebacks' = OperationID, Req, Context) -> InvoiceID = maps:get('invoiceID', Req), PaymentID = maps:get('paymentID', Req), Invoice = get_invoice_by_id(InvoiceID, Context), @@ -435,7 +435,7 @@ prepare(OperationID = 'GetChargebacks', Req, Context) -> end end, {ok, #{authorize => Authorize, process => Process}}; -prepare(OperationID = 'GetChargebackByID', Req, Context) -> +prepare('GetChargebackByID' = OperationID, Req, Context) -> InvoiceID = maps:get('invoiceID', Req), PaymentID = maps:get('paymentID', Req), ChargebackID = maps:get('chargebackID', Req), @@ -629,9 +629,9 @@ encode_flow(#{<<"type">> := <<"PaymentFlowHold">>} = Entity) -> on_hold_expiration = binary_to_existing_atom(OnHoldExpiration, utf8) }}. -encode_optional_cash(Params = #{<<"amount">> := _, <<"currency">> := _}, _, _, _) -> +encode_optional_cash(#{<<"amount">> := _, <<"currency">> := _} = Params, _, _, _) -> capi_handler_encoder:encode_cash(Params); -encode_optional_cash(Params = #{<<"amount">> := _}, InvoiceID, PaymentID, Context) -> +encode_optional_cash(#{<<"amount">> := _} = Params, InvoiceID, PaymentID, Context) -> {ok, #payproc_InvoicePayment{ payment = #domain_InvoicePayment{ cost = #domain_Cash{currency = Currency} diff --git a/apps/capi/src/capi_handler_shops.erl b/apps/capi/src/capi_handler_shops.erl index 4b3498e..538dd2c 100644 --- a/apps/capi/src/capi_handler_shops.erl +++ b/apps/capi/src/capi_handler_shops.erl @@ -14,7 +14,7 @@ Req :: capi_handler:request_data(), Context :: capi_handler:processing_context() ) -> {ok, capi_handler:request_state()} | {error, noimpl}. -prepare(OperationID = 'ActivateShop', Req, Context) -> +prepare('ActivateShop' = OperationID, Req, Context) -> PartyID = capi_handler_utils:get_party_id(Context), ShopID = maps:get('shopID', Req), Authorize = fun() -> @@ -32,7 +32,7 @@ prepare(OperationID = 'ActivateShop', Req, Context) -> end end, {ok, #{authorize => Authorize, process => Process}}; -prepare(OperationID = 'SuspendShop', Req, Context) -> +prepare('SuspendShop' = OperationID, Req, Context) -> PartyID = capi_handler_utils:get_party_id(Context), ShopID = maps:get('shopID', Req), Authorize = fun() -> @@ -50,7 +50,7 @@ prepare(OperationID = 'SuspendShop', Req, Context) -> end end, {ok, #{authorize => Authorize, process => Process}}; -prepare(OperationID = 'GetShops', _Req, Context) -> +prepare('GetShops' = OperationID, _Req, Context) -> PartyID = capi_handler_utils:get_party_id(Context), Authorize = fun() -> Prototypes = [{operation, #{id => OperationID, party => PartyID}}], @@ -61,7 +61,7 @@ prepare(OperationID = 'GetShops', _Req, Context) -> {ok, {200, #{}, decode_shops_map(Party#domain_Party.shops)}} end, {ok, #{authorize => Authorize, process => Process}}; -prepare(OperationID = 'GetShopByID', Req, Context) -> +prepare('GetShopByID' = OperationID, Req, Context) -> PartyID = capi_handler_utils:get_party_id(Context), ShopID = maps:get('shopID', Req), Authorize = fun() -> @@ -79,7 +79,7 @@ prepare(OperationID = 'GetShopByID', Req, Context) -> end end, {ok, #{authorize => Authorize, process => Process}}; -prepare(OperationID = 'GetShopsForParty', Req, Context) -> +prepare('GetShopsForParty' = OperationID, Req, Context) -> PartyID = maps:get('partyID', Req), Authorize = fun() -> Prototypes = [{operation, #{id => OperationID, party => PartyID}}], @@ -103,7 +103,7 @@ prepare(OperationID = 'GetShopsForParty', Req, Context) -> end end, {ok, #{authorize => Authorize, process => Process, process_restricted => ProcessRestricted}}; -prepare(OperationID = 'GetShopByIDForParty', Req, Context) -> +prepare('GetShopByIDForParty' = OperationID, Req, Context) -> PartyID = maps:get('partyID', Req), ShopID = maps:get('shopID', Req), Authorize = fun() -> @@ -121,7 +121,7 @@ prepare(OperationID = 'GetShopByIDForParty', Req, Context) -> end end, {ok, #{authorize => Authorize, process => Process}}; -prepare(OperationID = 'ActivateShopForParty', Req, Context) -> +prepare('ActivateShopForParty' = OperationID, Req, Context) -> PartyID = maps:get('partyID', Req), ShopID = maps:get('shopID', Req), Authorize = fun() -> @@ -141,7 +141,7 @@ prepare(OperationID = 'ActivateShopForParty', Req, Context) -> end end, {ok, #{authorize => Authorize, process => Process}}; -prepare(OperationID = 'SuspendShopForParty', Req, Context) -> +prepare('SuspendShopForParty' = OperationID, Req, Context) -> PartyID = maps:get('partyID', Req), ShopID = maps:get('shopID', Req), Authorize = fun() -> diff --git a/apps/capi/src/capi_merchant_id.erl b/apps/capi/src/capi_merchant_id.erl index 64dd613..b207048 100644 --- a/apps/capi/src/capi_merchant_id.erl +++ b/apps/capi/src/capi_merchant_id.erl @@ -40,11 +40,8 @@ encode(Realm, PartyID, ShopID) -> -spec encode(merchant_data()) -> merchant_id(). encode(MerchantData) -> Codec = thrift_strict_binary_codec:new(), - Data = - case thrift_strict_binary_codec:write(Codec, ?THRIFT_TYPE, MerchantData) of - {ok, Codec1} -> - thrift_strict_binary_codec:close(Codec1) - end, + {ok, Codec1} = thrift_strict_binary_codec:write(Codec, ?THRIFT_TYPE, MerchantData), + Data = thrift_strict_binary_codec:close(Codec1), jose_base64url:encode(Data, #{padding => false}). -spec decode(merchant_id()) -> merchant_data() | undefined. diff --git a/apps/capi/src/capi_sup.erl b/apps/capi/src/capi_sup.erl index bc54bee..72d0575 100644 --- a/apps/capi/src/capi_sup.erl +++ b/apps/capi/src/capi_sup.erl @@ -46,7 +46,7 @@ get_logic_handler_info(HandlerOpts) -> -spec enable_health_logging(erl_health:check()) -> erl_health:check(). enable_health_logging(Check) -> EvHandler = {erl_health_event_handler, []}, - maps:map(fun(_, V = {_, _, _}) -> #{runner => V, event_handler => EvHandler} end, Check). + maps:map(fun(_, {_, _, _} = V) -> #{runner => V, event_handler => EvHandler} end, Check). -spec get_prometheus_route() -> {iodata(), module(), _Opts :: any()}. get_prometheus_route() -> diff --git a/apps/capi/src/capi_swagger_server.erl b/apps/capi/src/capi_swagger_server.erl index 526666c..e70db7e 100644 --- a/apps/capi/src/capi_swagger_server.erl +++ b/apps/capi/src/capi_swagger_server.erl @@ -74,7 +74,7 @@ mk_operation_id_getter(#{env := Env}) -> %% NOTE: Be careful when upgrade cowboy in this project %% because cowboy_router:execute/2 call can change. fun - (Req = #{host := _Host, path := _Path}) -> + (#{host := _Host, path := _Path} = Req) -> case cowboy_router:execute(Req, Env) of {ok, _, #{handler_opts := {_Operations, _LogicHandler, _SwaggerHandlerOpts} = HandlerOpts}} -> try_get_operation_id(Req, HandlerOpts); diff --git a/apps/capi/test/capi_base_api_token_tests_SUITE.erl b/apps/capi/test/capi_base_api_token_tests_SUITE.erl index 9be9d13..feb74a6 100644 --- a/apps/capi/test/capi_base_api_token_tests_SUITE.erl +++ b/apps/capi/test/capi_base_api_token_tests_SUITE.erl @@ -314,10 +314,11 @@ create_invoice_ok_test(Config) -> -spec create_invoice_rand_amount_ok_test(config()) -> _. create_invoice_rand_amount_ok_test(Config) -> RandomizedAmount = ?INTEGER + ?SMALLER_INTEGER, - ExpectedInvoice = ?INVOICE#domain_Invoice{ - cost = ?CASH(RandomizedAmount), - mutations = [{amount, #domain_InvoiceAmountMutation{original = ?INTEGER, mutated = RandomizedAmount}}] - }, + ExpectedInvoice = ?RECORD_UPDATE( + #domain_Invoice.mutations, + [{amount, #domain_InvoiceAmountMutation{original = ?INTEGER, mutated = RandomizedAmount}}], + ?RECORD_UPDATE(#domain_Invoice.cost, ?CASH(RandomizedAmount), ?INVOICE) + ), _ = capi_ct_helper:mock_services( [ {invoicing, fun('Create', _) -> {ok, ?PAYPROC_INVOICE(ExpectedInvoice, [])} end}, @@ -326,11 +327,14 @@ create_invoice_rand_amount_ok_test(Config) -> Config ), _ = capi_ct_helper_bouncer:mock_assert_shop_op_ctx(<<"CreateInvoice">>, ?STRING, ?STRING, Config), - {ok, Response} = capi_client_invoices:create_invoice(?config(context, Config), ?INVOICE_PARAMS#{ - <<"randomizeAmount">> => #{ - <<"deviation">> => ?SMALLER_INTEGER - } - }), + {ok, Response} = capi_client_invoices:create_invoice( + ?config(context, Config), + maps:merge(?INVOICE_PARAMS, #{ + <<"randomizeAmount">> => #{ + <<"deviation">> => ?SMALLER_INTEGER + } + }) + ), ?assertMatch( #{ <<"invoice">> := #{ @@ -360,7 +364,7 @@ create_invoice_autorization_error_test(Config) -> {error, {400, #{<<"code">> := <<"invalidPartyID">>}}}, capi_client_invoices:create_invoice( ?config(context, Config), - ?INVOICE_PARAMS#{<<"partyID">> => <<"WrongPartyID">>} + maps:merge(?INVOICE_PARAMS, #{<<"partyID">> => <<"WrongPartyID">>}) ) ). @@ -486,16 +490,19 @@ create_invoice_template_w_randomization_ok_test(Config) -> _ = capi_ct_helper:mock_services( [ {invoice_templating, fun('Create', {#payproc_InvoiceTemplateCreateParams{party_id = ?STRING}}) -> - {ok, (?INVOICE_TPL)#domain_InvoiceTemplate{ - mutations = [ - {amount, - {randomization, #domain_RandomizationMutationParams{ - deviation = ?SMALLER_INTEGER, - precision = 2, - direction = both - }}} - ] - }} + {ok, + ?RECORD_UPDATE( + #domain_InvoiceTemplate.mutations, + [ + {amount, + {randomization, #domain_RandomizationMutationParams{ + deviation = ?SMALLER_INTEGER, + precision = 2, + direction = both + }}} + ], + ?INVOICE_TPL + )} end}, {generator, fun('GenerateID', _) -> capi_ct_helper_bender:generate_id(<<"bender_key">>) end} ], @@ -672,9 +679,9 @@ create_customer_autorization_error_test(Config) -> {error, {400, #{<<"code">> := <<"invalidPartyID">>}}}, capi_client_customers:create_customer( ?config(context, Config), - ?CUSTOMER_PARAMS#{ + maps:merge(?CUSTOMER_PARAMS, #{ <<"partyID">> => <<"WrongPartyID">> - } + }) ) ). diff --git a/apps/capi/test/capi_ct_helper_bouncer.erl b/apps/capi/test/capi_ct_helper_bouncer.erl index 6d588e5..56bf612 100644 --- a/apps/capi/test/capi_ct_helper_bouncer.erl +++ b/apps/capi/test/capi_ct_helper_bouncer.erl @@ -283,7 +283,7 @@ combine_fragments(Fragments) -> [Fragment | Rest] = maps:values(Fragments), lists:foldl(fun combine_fragments/2, Fragment, Rest). -combine_fragments(Fragment1 = #ctx_v1_ContextFragment{}, Fragment2 = #ctx_v1_ContextFragment{}) -> +combine_fragments(#ctx_v1_ContextFragment{} = Fragment1, #ctx_v1_ContextFragment{} = Fragment2) -> combine_records(Fragment1, Fragment2). combine_records(Record1, Record2) -> diff --git a/apps/capi/test/capi_ct_helper_token_keeper.erl b/apps/capi/test/capi_ct_helper_token_keeper.erl index cf3aedb..c390337 100644 --- a/apps/capi/test/capi_ct_helper_token_keeper.erl +++ b/apps/capi/test/capi_ct_helper_token_keeper.erl @@ -210,10 +210,8 @@ encode_context(Context) -> encode_context_content(Context) -> Type = {struct, struct, {bouncer_ctx_v1_thrift, 'ContextFragment'}}, Codec = thrift_strict_binary_codec:new(), - case thrift_strict_binary_codec:write(Codec, Type, Context) of - {ok, Codec1} -> - thrift_strict_binary_codec:close(Codec1) - end. + {ok, Codec1} = thrift_strict_binary_codec:write(Codec, Type, Context), + thrift_strict_binary_codec:close(Codec1). %% diff --git a/apps/capi/test/capi_dummy_data.hrl b/apps/capi/test/capi_dummy_data.hrl index 824966f..6175f35 100644 --- a/apps/capi/test/capi_dummy_data.hrl +++ b/apps/capi/test/capi_dummy_data.hrl @@ -7,9 +7,10 @@ -include_lib("damsel/include/dmsl_webhooker_thrift.hrl"). -include_lib("damsel/include/dmsl_domain_conf_thrift.hrl"). -include_lib("damsel/include/dmsl_user_interaction_thrift.hrl"). --include_lib("payout_manager_proto/include/payouts_payout_manager_thrift.hrl"). -include_lib("magista_proto/include/magista_magista_thrift.hrl"). +-define(RECORD_UPDATE(FieldIndex, Value, Record), erlang:setelement(FieldIndex, Record, Value)). + -define(STRING, <<"TEST">>). -define(RUB, <<"RUB">>). -define(USD, <<"USD">>). @@ -466,7 +467,7 @@ -define(SUSPENTION, {active, #domain_Active{since = ?TIMESTAMP}}). --define(SHOP, #domain_Shop{ +-define(SHOP(Account), #domain_Shop{ id = ?STRING, created_at = ?TIMESTAMP, blocking = ?BLOCKING, @@ -474,16 +475,17 @@ details = ?SHOP_DETAILS, location = ?SHOP_LOCATION, category = #domain_CategoryRef{id = ?INTEGER}, - contract_id = ?STRING + contract_id = ?STRING, + account = Account }). --define(SHOP(Currency), (?SHOP)#domain_Shop{ - account = #domain_ShopAccount{ - currency = #domain_CurrencyRef{symbolic_code = Currency}, - settlement = ?INTEGER, - guarantee = ?INTEGER, - payout = ?INTEGER - } +-define(SHOP, ?SHOP(undefined)). + +-define(SHOP_ACCOUNT(Currency), #domain_ShopAccount{ + currency = #domain_CurrencyRef{symbolic_code = Currency}, + settlement = ?INTEGER, + guarantee = ?INTEGER, + payout = ?INTEGER }). -define(SHOP_CONTRACT, #payproc_ShopContract{ @@ -544,7 +546,7 @@ }, shops = #{ ?STRING => ?SHOP, - ?USD => ?SHOP(?USD) + ?USD => ?SHOP(?SHOP_ACCOUNT(?USD)) }, contractors = #{?STRING => ?PARTY_CONTRACTOR}, wallets = #{?STRING => ?WALLET}, diff --git a/apps/capi/test/capi_idempotency_tests_SUITE.erl b/apps/capi/test/capi_idempotency_tests_SUITE.erl index 0f12db1..903bf4e 100644 --- a/apps/capi/test/capi_idempotency_tests_SUITE.erl +++ b/apps/capi/test/capi_idempotency_tests_SUITE.erl @@ -635,7 +635,7 @@ create_refund_idemp_fail_test(Config) -> -spec create_customer_ok_test(config()) -> _. create_customer_ok_test(Config) -> BenderKey = <<"create_customer_ok_test">>, - Req1 = ?CUSTOMER_PARAMS#{<<"externalID">> => genlib:unique()}, + Req1 = maps:merge(?CUSTOMER_PARAMS, #{<<"externalID">> => genlib:unique()}), Req2 = Req1#{<<"externalID">> => genlib:unique()}, UnusedFeatures = [[<<"externalID">>], [<<"metadata">>, <<"text">>, 0], [<<"metadata">>, <<"text">>, 1]], @@ -652,7 +652,7 @@ create_customer_ok_test(Config) -> create_customer_fail_test(Config) -> BenderKey = <<"create_customer_fail_test">>, ExternalID = genlib:unique(), - Req1 = ?CUSTOMER_PARAMS#{<<"externalID">> => ExternalID, <<"shopID">> => <<"1">>}, + Req1 = maps:merge(?CUSTOMER_PARAMS, #{<<"externalID">> => ExternalID, <<"shopID">> => <<"1">>}), Req2 = Req1#{<<"shopID">> => <<"2">>}, [CustomerResult1, CustomerResult2] = create_customers(BenderKey, [Req1, Req2], Config), diff --git a/apps/capi_client/src/capi_client_lib.erl b/apps/capi_client/src/capi_client_lib.erl index 310548c..18026d3 100644 --- a/apps/capi_client/src/capi_client_lib.erl +++ b/apps/capi_client/src/capi_client_lib.erl @@ -168,7 +168,7 @@ x_request_id_header() -> -spec x_request_deadline_header(iodata() | undefined, list()) -> list(). x_request_deadline_header(undefined, Headers) -> Headers; -x_request_deadline_header(WoodyDeadline = {_, _}, Headers) -> +x_request_deadline_header({_, _} = WoodyDeadline, Headers) -> [{<<"X-Request-Deadline">>, woody_deadline:to_binary(WoodyDeadline)} | Headers]; x_request_deadline_header(Time, Headers) -> [{<<"X-Request-Deadline">>, Time} | Headers]. diff --git a/apps/capi_woody_client/src/capi_woody_client.erl b/apps/capi_woody_client/src/capi_woody_client.erl index e36db5e..fec65ab 100644 --- a/apps/capi_woody_client/src/capi_woody_client.erl +++ b/apps/capi_woody_client/src/capi_woody_client.erl @@ -46,7 +46,7 @@ call_service(ServiceName, Function, Args, Context, EventHandler, Retry) -> get_service_options(ServiceName) -> construct_opts(maps:get(ServiceName, genlib_app:env(?MODULE, services))). -construct_opts(Opts = #{url := Url}) -> +construct_opts(#{url := Url} = Opts) -> Opts#{url := genlib:to_binary(Url)}; construct_opts(Url) -> #{url => genlib:to_binary(Url)}. diff --git a/elvis.config b/elvis.config index b2144c5..7e974ae 100644 --- a/elvis.config +++ b/elvis.config @@ -39,7 +39,10 @@ % Abuses lowercase macros too much capi_feature_schemas ] - }} + }}, + {elvis_style, no_import, disable}, + {elvis_style, no_throw, disable}, + {elvis_style, export_used_types, disable} ] }, #{ @@ -57,7 +60,9 @@ {elvis_style, used_ignored_variable, disable}, % Tests are usually more comprehensible when a bit more verbose. {elvis_style, dont_repeat_yourself, #{min_complexity => 50}}, - {elvis_style, god_modules, disable} + {elvis_style, god_modules, disable}, + {elvis_style, export_used_types, disable}, + {elvis_style, no_throw, disable} ] }, #{ @@ -79,7 +84,8 @@ {elvis_text_style, no_tabs}, {elvis_text_style, no_trailing_whitespace}, %% Temporarily disabled till regex pattern is available - {elvis_project, no_deps_master_rebar, disable} + {elvis_project, no_deps_master_rebar, disable}, + {elvis_project, no_branch_deps, disable} ] }, #{ diff --git a/rebar.lock b/rebar.lock index 20c2f37..2895942 100644 --- a/rebar.lock +++ b/rebar.lock @@ -7,7 +7,7 @@ 0}, {<<"bender_proto">>, {git,"https://github.com/valitydev/bender-proto.git", - {ref,"71c56878c1cf154cdfab9bbc563ddba25abe7259"}}, + {ref,"753b935b52a52e41b571d6e580f7dfe1377364f1"}}, 0}, {<<"bouncer_client">>, {git,"https://github.com/valitydev/bouncer-client-erlang.git", @@ -54,7 +54,7 @@ {<<"email_validator">>,{pkg,<<"email_validator">>,<<"1.1.0">>},1}, {<<"erl_health">>, {git,"https://github.com/valitydev/erlang-health.git", - {ref,"7ffbc855bdbe79e23efad1803b0b185c9ea8d2f1"}}, + {ref,"49716470d0e8dab5e37db55d52dea78001735a3d"}}, 0}, {<<"feat">>, {git,"https://github.com/valitydev/feat.git", @@ -75,7 +75,7 @@ {<<"idna">>,{pkg,<<"idna">>,<<"6.1.1">>},2}, {<<"jesse">>, {git,"https://github.com/valitydev/jesse.git", - {ref,"f4ff58e79ebe65650f9c445e730ad4c8d7f463a0"}}, + {ref,"640392b30ff0076809231ac2e145e656ff70b3d8"}}, 1}, {<<"jose">>, {git,"https://github.com/potatosalad/erlang-jose.git", @@ -88,7 +88,7 @@ 0}, {<<"magista_proto">>, {git,"https://github.com/valitydev/magista-proto.git", - {ref,"ec1bdb95b29d1562372b2178b277278054acb264"}}, + {ref,"e49ad10f49d50c746f7017412ba5409411731e89"}}, 0}, {<<"metrics">>,{pkg,<<"metrics">>,<<"1.0.1">>},2}, {<<"mimerl">>,{pkg,<<"mimerl">>,<<"1.3.0">>},2}, @@ -112,11 +112,11 @@ 0}, {<<"payout_manager_proto">>, {git,"https://github.com/valitydev/payout-manager-proto.git", - {ref,"b6cd2286a438685fceb1f020e24dc42750b74a3e"}}, + {ref,"eb4091aff7c11c6c825cbe4b43ab44250d00a09a"}}, 0}, {<<"payproc_errors">>, {git,"https://github.com/valitydev/payproc-errors-erlang.git", - {ref,"a19e716966b7206e96fbd767661d6fd3bab3119d"}}, + {ref,"8ae8586239ef68098398acf7eb8363d9ec3b3234"}}, 0}, {<<"prometheus">>,{pkg,<<"prometheus">>,<<"4.11.0">>},0}, {<<"prometheus_cowboy">>,{pkg,<<"prometheus_cowboy">>,<<"0.1.9">>},0}, @@ -134,11 +134,11 @@ {<<"ssl_verify_fun">>,{pkg,<<"ssl_verify_fun">>,<<"1.1.7">>},2}, {<<"swag_client">>, {git,"https://github.com/valitydev/swag-payments", - {ref,"09f10e9ad8d73e8ec8aeb7bb29d4d4dbdff4d08e"}}, + {ref,"c69fe919595791304c861925cfddc4448785a4a2"}}, 0}, {<<"swag_server">>, {git,"https://github.com/valitydev/swag-payments", - {ref,"ccda42f457771049198632685779bcbecf3b4e7e"}}, + {ref,"5d9b348a8f9cfeaea85a2f259e13f19a248e2aef"}}, 0}, {<<"thrift">>, {git,"https://github.com/valitydev/thrift_erlang.git",