Skip to content

Commit

Permalink
chore: run formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
hyperswitch-bot[bot] committed May 14, 2024
1 parent e1bf5ff commit 638a4d6
Show file tree
Hide file tree
Showing 23 changed files with 312 additions and 139 deletions.
10 changes: 5 additions & 5 deletions crates/diesel_models/src/customers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ pub struct CustomerNew {
pub created_at: PrimitiveDateTime,
pub modified_at: PrimitiveDateTime,
pub address_id: Option<String>,
pub updated_by : Option<String>,
pub updated_by: Option<String>,
}

impl CustomerNew{
pub fn update_storage_scheme(&mut self, storage_scheme: MerchantStorageScheme){
impl CustomerNew {
pub fn update_storage_scheme(&mut self, storage_scheme: MerchantStorageScheme) {
self.updated_by = Some(storage_scheme.to_string());
}
}
Expand All @@ -48,7 +48,7 @@ impl From<CustomerNew> for Customer {
modified_at: customer_new.modified_at,
address_id: customer_new.address_id,
default_payment_method_id: None,
updated_by : customer_new.updated_by
updated_by: customer_new.updated_by,
}
}
}
Expand All @@ -70,7 +70,7 @@ pub struct Customer {
pub modified_at: PrimitiveDateTime,
pub address_id: Option<String>,
pub default_payment_method_id: Option<String>,
pub updated_by : Option<String>,
pub updated_by: Option<String>,
}

#[derive(
Expand Down
25 changes: 14 additions & 11 deletions crates/diesel_models/src/mandate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ pub struct MandateNew {
pub connector_mandate_ids: Option<pii::SecretSerdeValue>,
pub original_payment_id: Option<String>,
pub merchant_connector_id: Option<String>,
pub updated_by : Option<String>
pub updated_by: Option<String>,
}

impl MandateNew{
pub fn update_storage_scheme(&mut self, storage_scheme: MerchantStorageScheme){
impl MandateNew {
pub fn update_storage_scheme(&mut self, storage_scheme: MerchantStorageScheme) {
self.updated_by = Some(storage_scheme.to_string());
}
}
Expand All @@ -99,8 +99,11 @@ pub enum MandateUpdate {
},
}

impl MandateUpdate{
pub fn convert_to_mandate_update(self, storage_scheme: MerchantStorageScheme) -> MandateUpdateInternal{
impl MandateUpdate {
pub fn convert_to_mandate_update(
self,
storage_scheme: MerchantStorageScheme,
) -> MandateUpdateInternal {
let mut updated_object = MandateUpdateInternal::from(self);
updated_object.updated_by = Some(storage_scheme.to_string());
updated_object
Expand Down Expand Up @@ -130,7 +133,7 @@ pub struct MandateUpdateInternal {
connector_mandate_id: Option<String>,
payment_method_id: Option<String>,
original_payment_id: Option<String>,
updated_by : Option<String>
updated_by: Option<String>,
}

impl From<MandateUpdate> for MandateUpdateInternal {
Expand All @@ -143,7 +146,7 @@ impl From<MandateUpdate> for MandateUpdateInternal {
connector_mandate_id: None,
payment_method_id: None,
original_payment_id: None,
updated_by : None
updated_by: None,
},
MandateUpdate::CaptureAmountUpdate { amount_captured } => Self {
mandate_status: None,
Expand All @@ -152,7 +155,7 @@ impl From<MandateUpdate> for MandateUpdateInternal {
connector_mandate_id: None,
payment_method_id: None,
original_payment_id: None,
updated_by : None
updated_by: None,
},
MandateUpdate::ConnectorReferenceUpdate {
connector_mandate_ids,
Expand Down Expand Up @@ -185,7 +188,7 @@ impl MandateUpdateInternal {
connector_mandate_id,
payment_method_id,
original_payment_id,
updated_by
updated_by,
} = self;

Mandate {
Expand All @@ -195,7 +198,7 @@ impl MandateUpdateInternal {
connector_mandate_id: connector_mandate_id.map_or(source.connector_mandate_id, Some),
payment_method_id: payment_method_id.unwrap_or(source.payment_method_id),
original_payment_id: original_payment_id.map_or(source.original_payment_id, Some),
updated_by : updated_by.map_or(source.updated_by, Some),
updated_by: updated_by.map_or(source.updated_by, Some),
..source
}
}
Expand Down Expand Up @@ -230,7 +233,7 @@ impl From<&MandateNew> for Mandate {
connector_mandate_ids: mandate_new.connector_mandate_ids.clone(),
original_payment_id: mandate_new.original_payment_id.clone(),
merchant_connector_id: mandate_new.merchant_connector_id.clone(),
updated_by : mandate_new.updated_by.clone(),
updated_by: mandate_new.updated_by.clone(),
}
}
}
35 changes: 19 additions & 16 deletions crates/diesel_models/src/payment_method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub struct PaymentMethod {
pub status: storage_enums::PaymentMethodStatus,
pub network_transaction_id: Option<String>,
pub client_secret: Option<String>,
pub updated_by : Option<String>,
pub updated_by: Option<String>,
pub payment_method_billing_address: Option<Encryption>,
}

Expand Down Expand Up @@ -79,11 +79,11 @@ pub struct PaymentMethodNew {
pub network_transaction_id: Option<String>,
pub client_secret: Option<String>,
pub payment_method_billing_address: Option<Encryption>,
pub updated_by : Option<String>,
pub updated_by: Option<String>,
}

impl PaymentMethodNew {
pub fn update_storage_scheme(&mut self, storage_scheme : MerchantStorageScheme){
pub fn update_storage_scheme(&mut self, storage_scheme: MerchantStorageScheme) {
self.updated_by = Some(storage_scheme.to_string());
}
}
Expand Down Expand Up @@ -120,7 +120,7 @@ impl Default for PaymentMethodNew {
status: storage_enums::PaymentMethodStatus::Active,
network_transaction_id: Option::default(),
client_secret: Option::default(),
updated_by : Option::default(),
updated_by: Option::default(),
payment_method_billing_address: Option::default(),
}
}
Expand Down Expand Up @@ -163,9 +163,12 @@ pub enum PaymentMethodUpdate {
},
}

impl PaymentMethodUpdate{
pub fn convert_to_payment_method_update(self, storage_scheme : MerchantStorageScheme) -> PaymentMethodUpdateInternal{
let mut update_internal : PaymentMethodUpdateInternal = self.into();
impl PaymentMethodUpdate {
pub fn convert_to_payment_method_update(
self,
storage_scheme: MerchantStorageScheme,
) -> PaymentMethodUpdateInternal {
let mut update_internal: PaymentMethodUpdateInternal = self.into();
update_internal.updated_by = Some(storage_scheme.to_string());
update_internal
}
Expand All @@ -184,7 +187,7 @@ pub struct PaymentMethodUpdateInternal {
locker_id: Option<String>,
payment_method: Option<storage_enums::PaymentMethod>,
connector_mandate_details: Option<serde_json::Value>,
updated_by : Option<String>,
updated_by: Option<String>,
payment_method_type: Option<storage_enums::PaymentMethodType>,
payment_method_issuer: Option<String>,
}
Expand Down Expand Up @@ -217,7 +220,7 @@ impl PaymentMethodUpdateInternal {
status: status.unwrap_or(source.status),
connector_mandate_details: connector_mandate_details
.map_or(source.connector_mandate_details, Some),
updated_by : updated_by.map_or(source.updated_by, Some),
updated_by: updated_by.map_or(source.updated_by, Some),
..source
}
}
Expand All @@ -235,7 +238,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {
locker_id: None,
payment_method: None,
connector_mandate_details: None,
updated_by : None,
updated_by: None,
payment_method_issuer: None,
payment_method_type: None,
},
Expand Down Expand Up @@ -263,7 +266,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {
locker_id: None,
payment_method: None,
connector_mandate_details: None,
updated_by : None,
updated_by: None,
payment_method_issuer: None,
payment_method_type: None,
},
Expand All @@ -279,7 +282,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {
locker_id: None,
payment_method: None,
connector_mandate_details: None,
updated_by : None,
updated_by: None,
payment_method_issuer: None,
payment_method_type: None,
},
Expand All @@ -292,7 +295,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {
locker_id: None,
payment_method: None,
connector_mandate_details: None,
updated_by : None,
updated_by: None,
payment_method_issuer: None,
payment_method_type: None,
},
Expand All @@ -312,7 +315,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {
locker_id,
payment_method,
connector_mandate_details: None,
updated_by : None,
updated_by: None,
payment_method_issuer,
payment_method_type,
},
Expand All @@ -327,7 +330,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {
payment_method: None,
connector_mandate_details,
network_transaction_id: None,
updated_by : None,
updated_by: None,
payment_method_issuer: None,
payment_method_type: None,
},
Expand Down Expand Up @@ -367,7 +370,7 @@ impl From<&PaymentMethodNew> for PaymentMethod {
status: payment_method_new.status,
network_transaction_id: payment_method_new.network_transaction_id.clone(),
client_secret: payment_method_new.client_secret.clone(),
updated_by : payment_method_new.updated_by.clone(),
updated_by: payment_method_new.updated_by.clone(),
payment_method_billing_address: payment_method_new
.payment_method_billing_address
.clone(),
Expand Down
5 changes: 4 additions & 1 deletion crates/router/src/configs/defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@ impl Default for super::settings::DrainerSettings {
#[cfg(feature = "kv_store")]
impl Default for super::settings::KvConfig {
fn default() -> Self {
Self { ttl: 900 , soft_kill : Some(false)}
Self {
ttl: 900,
soft_kill: Some(false),
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/core/customers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ pub async fn create_customer(
created_at: common_utils::date_time::now(),
modified_at: common_utils::date_time::now(),
default_payment_method_id: None,
updated_by : None,
updated_by: None,
})
}
.await
Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/core/payment_methods/cards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ pub async fn create_payment_method(
last_modified: current_time,
last_used_at: current_time,
payment_method_billing_address,
updated_by : None,
updated_by: None,
},
storage_scheme,
)
Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/core/payments/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1590,7 +1590,7 @@ pub async fn create_customer_if_not_exist<'a, F: Clone, R, Ctx>(
connector_customer: None,
address_id: None,
default_payment_method_id: None,
updated_by : None
updated_by: None,
},
)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/core/payouts/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ pub async fn get_or_create_customer_details(
modified_at: common_utils::date_time::now(),
address_id: None,
default_payment_method_id: None,
updated_by : None,
updated_by: None,
};

Ok(Some(
Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/core/pm_auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ async fn store_bank_details_in_payment_methods(
network_transaction_id: None,
client_secret: None,
payment_method_billing_address: None,
updated_by : None,
updated_by: None,
};

new_entries.push(pm_new);
Expand Down
22 changes: 18 additions & 4 deletions crates/router/src/db/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,9 @@ mod storage {
use error_stack::{report, ResultExt};
use redis_interface::HsetnxReply;
use router_env::{instrument, tracing};
use storage_impl::redis::kv_store::{kv_wrapper, KvOperation, PartitionKey, Op, decide_storage_scheme};
use storage_impl::redis::kv_store::{
decide_storage_scheme, kv_wrapper, KvOperation, Op, PartitionKey,
};

use super::AddressInterface;
use crate::{
Expand Down Expand Up @@ -332,7 +334,9 @@ mod storage {
.await
.map_err(|error| report!(errors::StorageError::from(error)))
};
let storage_scheme = decide_storage_scheme::<_,storage_types::Address>(&self,storage_scheme, Op::Find).await;
let storage_scheme =
decide_storage_scheme::<_, storage_types::Address>(&self, storage_scheme, Op::Find)
.await;
let address = match storage_scheme {
MerchantStorageScheme::PostgresOnly => database_call().await,
MerchantStorageScheme::RedisKv => {
Expand Down Expand Up @@ -401,7 +405,12 @@ mod storage {
payment_id: &payment_id,
};
let field = format!("add_{}", address.address_id);
let storage_scheme = decide_storage_scheme::<_,storage_types::Address>(&self,storage_scheme, Op::Update(key.clone(), &field, Some((&address).updated_by.as_str()))).await;
let storage_scheme = decide_storage_scheme::<_, storage_types::Address>(
&self,
storage_scheme,
Op::Update(key.clone(), &field, Some((&address).updated_by.as_str())),
)
.await;
match storage_scheme {
MerchantStorageScheme::PostgresOnly => {
address
Expand Down Expand Up @@ -468,7 +477,12 @@ mod storage {
.await
.change_context(errors::StorageError::EncryptionError)?;
let merchant_id = address_new.merchant_id.clone();
let storage_scheme = decide_storage_scheme::<_,storage_types::Address>(&self,storage_scheme, Op::Insert).await;
let storage_scheme = decide_storage_scheme::<_, storage_types::Address>(
&self,
storage_scheme,
Op::Insert,
)
.await;
match storage_scheme {
MerchantStorageScheme::PostgresOnly => {
let conn = connection::pg_connection_write(self).await?;
Expand Down

0 comments on commit 638a4d6

Please sign in to comment.