refactor(customers_v2): address panics and some bugs in customers v2 endpoints (#6836)

This commit is contained in:
Sanchith Hegde
2024-12-17 15:54:27 +05:30
committed by GitHub
parent 588ce408b4
commit dfbfce4e42
56 changed files with 909 additions and 478 deletions

View File

@ -1,12 +1,6 @@
use common_utils::events::{ApiEventMetric, ApiEventsType};
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
use crate::customers::CustomerId;
#[cfg(all(feature = "v2", feature = "customer_v2"))]
use crate::customers::GlobalId;
use crate::customers::{
CustomerDeleteResponse, CustomerRequest, CustomerResponse, CustomerUpdateRequest,
};
use crate::customers::{CustomerDeleteResponse, CustomerRequest, CustomerResponse};
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
impl ApiEventMetric for CustomerDeleteResponse {
@ -21,7 +15,7 @@ impl ApiEventMetric for CustomerDeleteResponse {
impl ApiEventMetric for CustomerDeleteResponse {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Customer {
id: self.id.clone(),
customer_id: Some(self.id.clone()),
})
}
}
@ -38,9 +32,7 @@ impl ApiEventMetric for CustomerRequest {
#[cfg(all(feature = "v2", feature = "customer_v2"))]
impl ApiEventMetric for CustomerRequest {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Customer {
id: "temp_id".to_string(),
})
Some(ApiEventsType::Customer { customer_id: None })
}
}
@ -57,44 +49,25 @@ impl ApiEventMetric for CustomerResponse {
impl ApiEventMetric for CustomerResponse {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Customer {
id: self.id.clone(),
customer_id: Some(self.id.clone()),
})
}
}
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
impl ApiEventMetric for CustomerId {
impl ApiEventMetric for crate::customers::CustomerUpdateRequestInternal {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Customer {
customer_id: self.get_merchant_reference_id().clone(),
customer_id: self.customer_id.clone(),
})
}
}
#[cfg(all(feature = "v2", feature = "customer_v2"))]
impl ApiEventMetric for GlobalId {
impl ApiEventMetric for crate::customers::CustomerUpdateRequestInternal {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Customer {
id: self.id.clone(),
customer_id: Some(self.id.clone()),
})
}
}
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
impl ApiEventMetric for CustomerUpdateRequest {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
self.get_merchant_reference_id()
.clone()
.map(|cid| ApiEventsType::Customer { customer_id: cid })
}
}
#[cfg(all(feature = "v2", feature = "customer_v2"))]
impl ApiEventMetric for CustomerUpdateRequest {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Customer {
id: "temo_id".to_string(),
})
}
}
// These needs to be fixed for v2