mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 01:27:31 +08:00
chore: address Rust 1.73 clippy lints (#2474)
This commit is contained in:
@ -110,7 +110,7 @@ impl ConnectorCommon for Checkout {
|
|||||||
};
|
};
|
||||||
|
|
||||||
router_env::logger::info!(error_response=?response);
|
router_env::logger::info!(error_response=?response);
|
||||||
let errors_list = response.error_codes.clone().unwrap_or(vec![]);
|
let errors_list = response.error_codes.clone().unwrap_or_default();
|
||||||
let option_error_code_message = conn_utils::get_error_code_error_message_based_on_priority(
|
let option_error_code_message = conn_utils::get_error_code_error_message_based_on_priority(
|
||||||
self.clone(),
|
self.clone(),
|
||||||
errors_list
|
errors_list
|
||||||
|
|||||||
@ -101,7 +101,7 @@ impl ConnectorCommon for Cybersource {
|
|||||||
.response
|
.response
|
||||||
.parse_struct("Cybersource ErrorResponse")
|
.parse_struct("Cybersource ErrorResponse")
|
||||||
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
|
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
|
||||||
let details = response.details.unwrap_or(vec![]);
|
let details = response.details.unwrap_or_default();
|
||||||
let connector_reason = details
|
let connector_reason = details
|
||||||
.iter()
|
.iter()
|
||||||
.map(|det| format!("{} : {}", det.field, det.reason))
|
.map(|det| format!("{} : {}", det.field, det.reason))
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
pub mod transformers;
|
pub mod transformers;
|
||||||
use std::fmt::Debug;
|
use std::fmt::{Debug, Write};
|
||||||
|
|
||||||
use base64::Engine;
|
use base64::Engine;
|
||||||
use common_utils::ext_traits::ByteSliceExt;
|
use common_utils::ext_traits::ByteSliceExt;
|
||||||
@ -169,12 +169,26 @@ impl ConnectorCommon for Paypal {
|
|||||||
.parse_struct("Paypal ErrorResponse")
|
.parse_struct("Paypal ErrorResponse")
|
||||||
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
|
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
|
||||||
|
|
||||||
let error_reason = response.details.map(|error_details| {
|
let error_reason = response
|
||||||
error_details
|
.details
|
||||||
.iter()
|
.map(|error_details| {
|
||||||
.map(|error| format!("description - {} ; ", error.description))
|
error_details
|
||||||
.collect::<String>()
|
.iter()
|
||||||
});
|
.try_fold::<_, _, CustomResult<_, errors::ConnectorError>>(
|
||||||
|
String::new(),
|
||||||
|
|mut acc, error| {
|
||||||
|
write!(acc, "description - {} ;", error.description)
|
||||||
|
.into_report()
|
||||||
|
.change_context(
|
||||||
|
errors::ConnectorError::ResponseDeserializationFailed,
|
||||||
|
)
|
||||||
|
.attach_printable("Failed to concatenate error details")
|
||||||
|
.map(|_| acc)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.transpose()?;
|
||||||
|
|
||||||
Ok(ErrorResponse {
|
Ok(ErrorResponse {
|
||||||
status_code: res.status_code,
|
status_code: res.status_code,
|
||||||
code: response.name,
|
code: response.name,
|
||||||
|
|||||||
@ -1655,7 +1655,7 @@ fn get_headers(
|
|||||||
key: &'static str,
|
key: &'static str,
|
||||||
) -> CustomResult<String, errors::ConnectorError> {
|
) -> CustomResult<String, errors::ConnectorError> {
|
||||||
let header_value = header
|
let header_value = header
|
||||||
.get(key.clone())
|
.get(key)
|
||||||
.map(|value| value.to_str())
|
.map(|value| value.to_str())
|
||||||
.ok_or(errors::ConnectorError::MissingRequiredField { field_name: key })?
|
.ok_or(errors::ConnectorError::MissingRequiredField { field_name: key })?
|
||||||
.into_report()
|
.into_report()
|
||||||
|
|||||||
@ -977,9 +977,7 @@ pub async fn list_payment_methods(
|
|||||||
.0
|
.0
|
||||||
.get(&payment_method_type)
|
.get(&payment_method_type)
|
||||||
.map(|required_fields_hm_for_each_connector| {
|
.map(|required_fields_hm_for_each_connector| {
|
||||||
required_fields_hm
|
required_fields_hm.entry(payment_method).or_default();
|
||||||
.entry(payment_method)
|
|
||||||
.or_insert(HashMap::new());
|
|
||||||
required_fields_hm_for_each_connector
|
required_fields_hm_for_each_connector
|
||||||
.fields
|
.fields
|
||||||
.get(&connector_variant)
|
.get(&connector_variant)
|
||||||
|
|||||||
@ -121,7 +121,7 @@ pub async fn update_connector_customer_in_customers(
|
|||||||
.and_then(|customer| customer.connector_customer.as_ref())
|
.and_then(|customer| customer.connector_customer.as_ref())
|
||||||
.and_then(|connector_customer| connector_customer.as_object())
|
.and_then(|connector_customer| connector_customer.as_object())
|
||||||
.map(ToOwned::to_owned)
|
.map(ToOwned::to_owned)
|
||||||
.unwrap_or(serde_json::Map::new());
|
.unwrap_or_default();
|
||||||
|
|
||||||
let updated_connector_customer_map =
|
let updated_connector_customer_map =
|
||||||
connector_customer_id.as_ref().map(|connector_customer_id| {
|
connector_customer_id.as_ref().map(|connector_customer_id| {
|
||||||
|
|||||||
@ -423,7 +423,7 @@ where
|
|||||||
status_code.to_string(),
|
status_code.to_string(),
|
||||||
)]
|
)]
|
||||||
})
|
})
|
||||||
.unwrap_or(vec![]);
|
.unwrap_or_default();
|
||||||
if let Some(payment_confirm_source) = payment_intent.payment_confirm_source {
|
if let Some(payment_confirm_source) = payment_intent.payment_confirm_source {
|
||||||
headers.push((
|
headers.push((
|
||||||
"payment_confirm_source".to_string(),
|
"payment_confirm_source".to_string(),
|
||||||
|
|||||||
@ -1205,10 +1205,7 @@ pub async fn payout_create_db_entries(
|
|||||||
.set_recurring(req.recurring.unwrap_or(false))
|
.set_recurring(req.recurring.unwrap_or(false))
|
||||||
.set_auto_fulfill(req.auto_fulfill.unwrap_or(false))
|
.set_auto_fulfill(req.auto_fulfill.unwrap_or(false))
|
||||||
.set_return_url(req.return_url.to_owned())
|
.set_return_url(req.return_url.to_owned())
|
||||||
.set_entity_type(
|
.set_entity_type(req.entity_type.unwrap_or_default())
|
||||||
req.entity_type
|
|
||||||
.unwrap_or(api_enums::PayoutEntityType::default()),
|
|
||||||
)
|
|
||||||
.set_metadata(req.metadata.to_owned())
|
.set_metadata(req.metadata.to_owned())
|
||||||
.set_created_at(Some(common_utils::date_time::now()))
|
.set_created_at(Some(common_utils::date_time::now()))
|
||||||
.set_last_modified_at(Some(common_utils::date_time::now()))
|
.set_last_modified_at(Some(common_utils::date_time::now()))
|
||||||
|
|||||||
@ -472,11 +472,9 @@ pub async fn send_request(
|
|||||||
match request.content_type {
|
match request.content_type {
|
||||||
Some(ContentType::Json) => client.json(&request.payload),
|
Some(ContentType::Json) => client.json(&request.payload),
|
||||||
|
|
||||||
Some(ContentType::FormData) => client.multipart(
|
Some(ContentType::FormData) => {
|
||||||
request
|
client.multipart(request.form_data.unwrap_or_default())
|
||||||
.form_data
|
}
|
||||||
.unwrap_or_else(reqwest::multipart::Form::new),
|
|
||||||
),
|
|
||||||
|
|
||||||
// Currently this is not used remove this if not required
|
// Currently this is not used remove this if not required
|
||||||
// If using this then handle the serde_part
|
// If using this then handle the serde_part
|
||||||
|
|||||||
@ -453,7 +453,6 @@ impl ForeignTryFrom<api_models::webhooks::IncomingWebhookEvent> for storage_enum
|
|||||||
|
|
||||||
impl ForeignFrom<storage::Config> for api_types::Config {
|
impl ForeignFrom<storage::Config> for api_types::Config {
|
||||||
fn foreign_from(config: storage::Config) -> Self {
|
fn foreign_from(config: storage::Config) -> Self {
|
||||||
let config = config;
|
|
||||||
Self {
|
Self {
|
||||||
key: config.key,
|
key: config.key,
|
||||||
value: config.config,
|
value: config.config,
|
||||||
@ -472,7 +471,6 @@ impl<'a> ForeignFrom<&'a api_types::ConfigUpdate> for storage::ConfigUpdate {
|
|||||||
|
|
||||||
impl<'a> From<&'a domain::Address> for api_types::Address {
|
impl<'a> From<&'a domain::Address> for api_types::Address {
|
||||||
fn from(address: &domain::Address) -> Self {
|
fn from(address: &domain::Address) -> Self {
|
||||||
let address = address;
|
|
||||||
Self {
|
Self {
|
||||||
address: Some(api_types::AddressDetails {
|
address: Some(api_types::AddressDetails {
|
||||||
city: address.city.clone(),
|
city: address.city.clone(),
|
||||||
|
|||||||
Reference in New Issue
Block a user