feat(revenue_recovery): Add token active status filtering and account update history tracking (#10056)

Co-authored-by: sagarnaikjuspay <sagar.naik@juspay.net>
This commit is contained in:
Sagar naik
2025-10-31 14:03:28 +05:30
committed by GitHub
parent 5600887665
commit 804302762d
5 changed files with 82 additions and 2 deletions

View File

@ -9,6 +9,8 @@ use masking::Secret;
use serde::{Deserialize, Serialize};
use time::{Date, PrimitiveDateTime};
use crate::payments;
#[derive(Debug, Deserialize, Serialize)]
pub struct RevenueRecoveryBackfillRequest {
pub bin_number: Option<Secret<String>>,
@ -21,6 +23,30 @@ pub struct RevenueRecoveryBackfillRequest {
pub clean_bank_name: Option<String>,
pub country_name: Option<String>,
pub daily_retry_history: Option<String>,
pub is_active: Option<bool>,
#[serde(
default,
deserialize_with = "RevenueRecoveryBackfillRequest::deserialize_history_vec_opt"
)]
pub account_update_history: Option<Vec<AccountUpdateHistoryRecord>>,
}
impl RevenueRecoveryBackfillRequest {
pub fn deserialize_history_vec_opt<'de, D>(
deserializer: D,
) -> Result<Option<Vec<AccountUpdateHistoryRecord>>, D::Error>
where
D: serde::Deserializer<'de>,
{
use serde::Deserialize;
let val = Option::<String>::deserialize(deserializer)?;
match val.as_deref().map(str::trim) {
None | Some("") => Ok(None),
Some(s) => serde_json::from_str::<Vec<AccountUpdateHistoryRecord>>(s)
.map(Some)
.map_err(serde::de::Error::custom),
}
}
}
#[derive(Debug, Serialize)]
@ -46,6 +72,16 @@ pub struct CsvParsingError {
pub error: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AccountUpdateHistoryRecord {
pub old_token: String,
pub new_token: String,
#[serde(with = "common_utils::custom_serde::iso8601")]
pub updated_at: PrimitiveDateTime,
pub old_token_info: Option<payments::AdditionalCardInfo>,
pub new_token_info: Option<payments::AdditionalCardInfo>,
}
/// Comprehensive card
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ComprehensiveCardData {
@ -56,6 +92,8 @@ pub struct ComprehensiveCardData {
pub card_issuer: Option<String>,
pub card_issuing_country: Option<String>,
pub daily_retry_history: Option<HashMap<Date, i32>>,
pub is_active: Option<bool>,
pub account_update_history: Option<Vec<AccountUpdateHistoryRecord>>,
}
impl ApiEventMetric for RevenueRecoveryDataBackfillResponse {