mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-27 11:24:45 +08:00
feat(revenue_recovery): Implement redis API to update the lock status for connector customer id (#9403)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -23,6 +23,11 @@ pub struct RevenueRecoveryBackfillRequest {
|
||||
pub daily_retry_history: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct UnlockStatusResponse {
|
||||
pub unlocked: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct RevenueRecoveryDataBackfillResponse {
|
||||
pub processed_records: usize,
|
||||
@ -59,6 +64,12 @@ impl ApiEventMetric for RevenueRecoveryDataBackfillResponse {
|
||||
}
|
||||
}
|
||||
|
||||
impl ApiEventMetric for UnlockStatusResponse {
|
||||
fn get_api_event_type(&self) -> Option<common_utils::events::ApiEventsType> {
|
||||
Some(common_utils::events::ApiEventsType::Miscellaneous)
|
||||
}
|
||||
}
|
||||
|
||||
impl ApiEventMetric for CsvParsingResult {
|
||||
fn get_api_event_type(&self) -> Option<common_utils::events::ApiEventsType> {
|
||||
Some(common_utils::events::ApiEventsType::Miscellaneous)
|
||||
|
||||
@ -2,7 +2,7 @@ use std::collections::HashMap;
|
||||
|
||||
use api_models::revenue_recovery_data_backfill::{
|
||||
BackfillError, ComprehensiveCardData, RevenueRecoveryBackfillRequest,
|
||||
RevenueRecoveryDataBackfillResponse,
|
||||
RevenueRecoveryDataBackfillResponse, UnlockStatusResponse,
|
||||
};
|
||||
use common_enums::{CardNetwork, PaymentMethodType};
|
||||
use hyperswitch_domain_models::api::ApplicationResponse;
|
||||
@ -60,6 +60,33 @@ pub async fn revenue_recovery_data_backfill(
|
||||
Ok(ApplicationResponse::Json(response))
|
||||
}
|
||||
|
||||
pub async fn unlock_connector_customer_status(
|
||||
state: SessionState,
|
||||
connector_customer_id: String,
|
||||
) -> RouterResult<ApplicationResponse<UnlockStatusResponse>> {
|
||||
let unlocked = storage::revenue_recovery_redis_operation::
|
||||
RedisTokenManager::unlock_connector_customer_status(&state, &connector_customer_id)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
logger::error!(
|
||||
"Failed to unlock connector customer status for {}: {}",
|
||||
connector_customer_id,
|
||||
e
|
||||
);
|
||||
errors::ApiErrorResponse::InternalServerError
|
||||
})?;
|
||||
|
||||
let response = UnlockStatusResponse { unlocked };
|
||||
|
||||
logger::info!(
|
||||
"Unlock operation completed for connector customer {}: {}",
|
||||
connector_customer_id,
|
||||
unlocked
|
||||
);
|
||||
|
||||
Ok(ApplicationResponse::Json(response))
|
||||
}
|
||||
|
||||
async fn process_payment_method_record(
|
||||
state: &SessionState,
|
||||
record: &RevenueRecoveryBackfillRequest,
|
||||
|
||||
@ -3002,5 +3002,10 @@ impl RecoveryDataBackfill {
|
||||
.to(super::revenue_recovery_data_backfill::revenue_recovery_data_backfill),
|
||||
),
|
||||
)
|
||||
.service(web::resource("/status/{token_id}").route(
|
||||
web::post().to(
|
||||
super::revenue_recovery_data_backfill::revenue_recovery_data_backfill_status,
|
||||
),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@ use crate::{
|
||||
core::{api_locking, revenue_recovery_data_backfill},
|
||||
routes::AppState,
|
||||
services::{api, authentication as auth},
|
||||
types::domain,
|
||||
types::{domain, storage},
|
||||
};
|
||||
|
||||
#[instrument(skip_all, fields(flow = ?Flow::RecoveryDataBackfill))]
|
||||
@ -65,3 +65,26 @@ pub async fn revenue_recovery_data_backfill(
|
||||
))
|
||||
.await
|
||||
}
|
||||
|
||||
#[instrument(skip_all, fields(flow = ?Flow::RecoveryDataBackfill))]
|
||||
pub async fn revenue_recovery_data_backfill_status(
|
||||
state: web::Data<AppState>,
|
||||
req: HttpRequest,
|
||||
path: web::Path<String>,
|
||||
) -> HttpResponse {
|
||||
let flow = Flow::RecoveryDataBackfill;
|
||||
let connector_customer_id = path.into_inner();
|
||||
|
||||
Box::pin(api::server_wrap(
|
||||
flow,
|
||||
state,
|
||||
&req,
|
||||
connector_customer_id,
|
||||
|state, _: (), id, _| {
|
||||
revenue_recovery_data_backfill::unlock_connector_customer_status(state, id)
|
||||
},
|
||||
&auth::V2AdminApiAuth,
|
||||
api_locking::LockAction::NotApplicable,
|
||||
))
|
||||
.await
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user