refactor(pm_list): modify pm list to support new api contract (#657)

Co-authored-by: Sangamesh <sangamesh.kulkarni@juspay.in>
This commit is contained in:
Narayan Bhat
2023-02-27 00:51:29 +05:30
committed by GitHub
parent d1c9305ebb
commit a2616d87b1
12 changed files with 422 additions and 252 deletions

View File

@ -260,7 +260,7 @@ pub async fn create_payment_connector(
let payment_methods_enabled = match req.payment_methods_enabled {
Some(val) => {
for pm in val.into_iter() {
let pm_value = utils::Encode::<api::PaymentMethods>::encode_to_value(&pm)
let pm_value = utils::Encode::<api::PaymentMethodsEnabled>::encode_to_value(&pm)
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable(
"Failed while encoding to serde_json::Value, PaymentMethod",
@ -345,7 +345,7 @@ pub async fn list_payment_connectors(
})?;
let merchant_connector_accounts = store
.find_merchant_connector_account_by_merchant_id_list(&merchant_id)
.find_merchant_connector_account_by_merchant_id_and_disabled_list(&merchant_id, true)
.await
.map_err(|error| {
error.to_not_found_response(errors::ApiErrorResponse::MerchantConnectorAccountNotFound)
@ -387,7 +387,7 @@ pub async fn update_payment_connector(
pm_enabled
.iter()
.flat_map(|payment_method| {
utils::Encode::<api::PaymentMethods>::encode_to_value(payment_method)
utils::Encode::<api::PaymentMethodsEnabled>::encode_to_value(payment_method)
})
.collect::<Vec<serde_json::Value>>()
});
@ -415,12 +415,12 @@ pub async fn update_payment_connector(
let updated_pm_enabled = updated_mca.payment_methods_enabled.map(|pm| {
pm.into_iter()
.flat_map(|pm_value| {
ValueExt::<api_models::admin::PaymentMethods>::parse_value(
ValueExt::<api_models::admin::PaymentMethodsEnabled>::parse_value(
pm_value,
"PaymentMethods",
)
})
.collect::<Vec<api_models::admin::PaymentMethods>>()
.collect::<Vec<api_models::admin::PaymentMethodsEnabled>>()
});
let response = api::PaymentConnectorCreate {