refactor(business_profile): use concrete types for JSON fields (#5531)

This commit is contained in:
Sanchith Hegde
2024-08-07 13:57:35 +05:30
committed by GitHub
parent 52cada015e
commit a8ba21c1d1
18 changed files with 751 additions and 606 deletions

View File

@ -1,4 +1,3 @@
use common_utils::ext_traits::ValueExt;
use error_stack::ResultExt;
use hyperswitch_domain_models::router_data_v2::ExternalAuthenticationFlowData;
@ -269,24 +268,17 @@ pub async fn get_authentication_connector_data(
key_store: &domain::MerchantKeyStore,
business_profile: &storage::BusinessProfile,
) -> RouterResult<(
api_models::enums::AuthenticationConnectors,
common_enums::AuthenticationConnectors,
payments::helpers::MerchantConnectorAccountType,
)> {
let authentication_details: api_models::admin::AuthenticationConnectorDetails =
business_profile
.authentication_connector_details
.clone()
.get_required_value("authentication_details")
.change_context(errors::ApiErrorResponse::UnprocessableEntity {
message: "authentication_connector_details is not available in business profile"
.into(),
})
.attach_printable("authentication_connector_details not configured by the merchant")?
.parse_value("AuthenticationConnectorDetails")
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable(
"Error while parsing authentication_connector_details from business_profile",
)?;
let authentication_details = business_profile
.authentication_connector_details
.clone()
.get_required_value("authentication_details")
.change_context(errors::ApiErrorResponse::UnprocessableEntity {
message: "authentication_connector_details is not available in business profile".into(),
})
.attach_printable("authentication_connector_details not configured by the merchant")?;
let authentication_connector = authentication_details
.authentication_connectors
.first()