feat(customer_v2): customer v2 refactor customer v2 update endpoint (#5490)

Co-authored-by: Narayan Bhat <narayan.bhat@juspay.in>
Co-authored-by: hrithikesh026 <hrithikesh.vm@juspay.in>
Co-authored-by: Prajjwal Kumar <prajjwal.kumar@juspay.in>
Co-authored-by: Sanchith Hegde <sanchith.hegde@juspay.in>
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Sahkal Poddar
2024-08-14 14:56:34 +05:30
committed by GitHub
parent 8bcda2cea4
commit 17703fe2cb
28 changed files with 1813 additions and 768 deletions

View File

@ -1,14 +1,14 @@
#[cfg(feature = "olap")]
use async_bb8_diesel::{AsyncConnection, AsyncRunQueryDsl};
use common_utils::ext_traits::Encode;
#[cfg(feature = "olap")]
use diesel::{associations::HasTable, ExpressionMethods, QueryDsl};
#[cfg(all(
feature = "olap",
any(feature = "v1", feature = "v2"),
not(feature = "customer_v2")
))]
use diesel::JoinOnDsl;
#[cfg(feature = "olap")]
use diesel::{associations::HasTable, ExpressionMethods, NullableExpressionMethods, QueryDsl};
use diesel::{JoinOnDsl, NullableExpressionMethods};
#[cfg(feature = "olap")]
use diesel_models::{
customers::Customer as DieselCustomer, query::generics::db_metrics,
@ -47,12 +47,15 @@ use router_env::logger;
use router_env::{instrument, tracing};
#[cfg(feature = "olap")]
use crate::{
connection,
store::schema::{
customers::all_columns as cust_all_columns, payout_attempt::all_columns as poa_all_columns,
payouts::all_columns as po_all_columns,
},
use crate::connection;
#[cfg(all(
feature = "olap",
any(feature = "v1", feature = "v2"),
not(feature = "customer_v2")
))]
use crate::store::schema::{
customers::all_columns as cust_all_columns, payout_attempt::all_columns as poa_all_columns,
payouts::all_columns as po_all_columns,
};
use crate::{
diesel_error_to_data_error,

View File

@ -34,6 +34,11 @@ pub enum PartitionKey<'a> {
merchant_id: &'a common_utils::id_type::MerchantId,
customer_id: &'a str,
},
#[cfg(all(feature = "v2", feature = "customer_v2"))]
MerchantIdMerchantReferenceId {
merchant_id: &'a common_utils::id_type::MerchantId,
merchant_reference_id: &'a str,
},
MerchantIdPayoutId {
merchant_id: &'a common_utils::id_type::MerchantId,
payout_id: &'a str,
@ -46,6 +51,10 @@ pub enum PartitionKey<'a> {
merchant_id: &'a common_utils::id_type::MerchantId,
mandate_id: &'a str,
},
#[cfg(all(feature = "v2", feature = "customer_v2"))]
GlobalId {
id: &'a str,
},
}
// PartitionKey::MerchantIdPaymentId {merchant_id, payment_id}
impl<'a> std::fmt::Display for PartitionKey<'a> {
@ -66,6 +75,14 @@ impl<'a> std::fmt::Display for PartitionKey<'a> {
"mid_{}_cust_{customer_id}",
merchant_id.get_string_repr()
)),
#[cfg(all(feature = "v2", feature = "customer_v2"))]
PartitionKey::MerchantIdMerchantReferenceId {
merchant_id,
merchant_reference_id,
} => f.write_str(&format!(
"mid_{}_cust_{merchant_reference_id}",
merchant_id.get_string_repr()
)),
PartitionKey::MerchantIdPayoutId {
merchant_id,
payout_id,
@ -87,6 +104,9 @@ impl<'a> std::fmt::Display for PartitionKey<'a> {
"mid_{}_mandate_{mandate_id}",
merchant_id.get_string_repr()
)),
#[cfg(all(feature = "v2", feature = "customer_v2"))]
PartitionKey::GlobalId { id } => f.write_str(&format!("cust_{id}",)),
}
}
}