mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-10-31 01:57:45 +08:00 
			
		
		
		
	refactor(customers_v2): address panics and some bugs in customers v2 endpoints (#6836)
This commit is contained in:
		| @ -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 | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Sanchith Hegde
					Sanchith Hegde