From f956a628994f2b8164210c0ed34f6144ef5c86af Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Fri, 20 Dec 2024 15:08:38 +0530 Subject: [PATCH] chore: fix clippy error --- crates/hyperswitch_interfaces/src/api.rs | 9 +++++---- crates/router/src/routes/feature_matrix.rs | 15 +++++++++------ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/crates/hyperswitch_interfaces/src/api.rs b/crates/hyperswitch_interfaces/src/api.rs index c7956c871244..ca2d806762ad 100644 --- a/crates/hyperswitch_interfaces/src/api.rs +++ b/crates/hyperswitch_interfaces/src/api.rs @@ -433,8 +433,9 @@ pub trait ConnectorValidation: ConnectorCommon + ConnectorSpecifications { pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); - let default_capture_method = - vec![CaptureMethod::Automatic, CaptureMethod::SequentialAutomatic]; + let is_default_capture_method = + [CaptureMethod::Automatic, CaptureMethod::SequentialAutomatic] + .contains(&capture_method); let is_feature_supported = match self.get_supported_payment_methods() { Some(supported_payment_methods) => { let connector_payment_method_type_info = get_connector_payment_method_type_info( @@ -450,9 +451,9 @@ pub trait ConnectorValidation: ConnectorCommon + ConnectorSpecifications { .supported_capture_methods .contains(&capture_method) }) - .unwrap_or_else(|| default_capture_method.contains(&capture_method)) + .unwrap_or_else(|| is_default_capture_method) } - None => default_capture_method.contains(&capture_method), + None => is_default_capture_method, }; if is_feature_supported { diff --git a/crates/router/src/routes/feature_matrix.rs b/crates/router/src/routes/feature_matrix.rs index a157439322f2..08dd7d0d7b2b 100644 --- a/crates/router/src/routes/feature_matrix.rs +++ b/crates/router/src/routes/feature_matrix.rs @@ -52,6 +52,9 @@ pub async fn generate_feature_matrix( .into_iter() .filter_map(|connector_name| { api_types::ConnectorData::convert_connector(&connector_name.to_string()) + .inspect_err(|_| { + router_env::logger::warn!("Failed to fetch {:?} details", connector_name) + }) .ok() .and_then(|connector| { build_connector_feature_details( @@ -79,12 +82,12 @@ fn build_connector_feature_details( let connector_integration_features = connector.get_supported_payment_methods(); connector_integration_features.map(|connector_integration_feature_data| { let supported_payment_methods = connector_integration_feature_data - .into_iter() + .iter() .flat_map(|(payment_method, supported_payment_method_types)| { build_payment_method_wise_feature_details( state, &connector_name, - payment_method, + *payment_method, supported_payment_method_types, ) }) @@ -97,7 +100,7 @@ fn build_connector_feature_details( feature_matrix::ConnectorFeatureMatrixResponse { name: connector_name, description: connector_about.map(|about| about.description.clone()), - category: connector_about.map(|about| about.connector_type.clone()), + category: connector_about.map(|about| about.connector_type), supported_webhook_flows, supported_payment_methods, } @@ -107,11 +110,11 @@ fn build_connector_feature_details( fn build_payment_method_wise_feature_details( state: &app::SessionState, connector_name: &str, - payment_method: &enums::PaymentMethod, + payment_method: enums::PaymentMethod, supported_payment_method_types: &PaymentMethodTypeMetadata, ) -> Vec { supported_payment_method_types - .into_iter() + .iter() .map(|(payment_method_type, feature_metadata)| { let payment_method_type_config = state @@ -134,7 +137,7 @@ fn build_payment_method_wise_feature_details( payment_method_type_config.and_then(|config| config.currency.clone()); feature_matrix::SupportedPaymentMethod { - payment_method: *payment_method, + payment_method, payment_method_type: *payment_method_type, mandates: feature_metadata.mandates, refunds: feature_metadata.refunds,