mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-27 19:46:48 +08:00
feat(payouts): Add profile level payout filter API (#5808)
This commit is contained in:
@ -947,10 +947,11 @@ pub async fn payouts_filtered_list_core(
|
|||||||
pub async fn payouts_list_available_filters_core(
|
pub async fn payouts_list_available_filters_core(
|
||||||
state: SessionState,
|
state: SessionState,
|
||||||
merchant_account: domain::MerchantAccount,
|
merchant_account: domain::MerchantAccount,
|
||||||
|
profile_id_list: Option<Vec<common_utils::id_type::ProfileId>>,
|
||||||
time_range: api::TimeRange,
|
time_range: api::TimeRange,
|
||||||
) -> RouterResponse<api::PayoutListFilters> {
|
) -> RouterResponse<api::PayoutListFilters> {
|
||||||
let db = state.store.as_ref();
|
let db = state.store.as_ref();
|
||||||
let payout = db
|
let payouts = db
|
||||||
.filter_payouts_by_time_range_constraints(
|
.filter_payouts_by_time_range_constraints(
|
||||||
merchant_account.get_id(),
|
merchant_account.get_id(),
|
||||||
&time_range,
|
&time_range,
|
||||||
@ -959,9 +960,11 @@ pub async fn payouts_list_available_filters_core(
|
|||||||
.await
|
.await
|
||||||
.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;
|
.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;
|
||||||
|
|
||||||
|
let payouts = core_utils::filter_objects_based_on_profile_id_list(profile_id_list, payouts);
|
||||||
|
|
||||||
let filters = db
|
let filters = db
|
||||||
.get_filters_for_payouts(
|
.get_filters_for_payouts(
|
||||||
payout.as_slice(),
|
payouts.as_slice(),
|
||||||
merchant_account.get_id(),
|
merchant_account.get_id(),
|
||||||
storage_enums::MerchantStorageScheme::PostgresOnly,
|
storage_enums::MerchantStorageScheme::PostgresOnly,
|
||||||
)
|
)
|
||||||
|
|||||||
@ -1034,7 +1034,12 @@ impl Payouts {
|
|||||||
.route(web::post().to(payouts_list_by_filter_profile)),
|
.route(web::post().to(payouts_list_by_filter_profile)),
|
||||||
)
|
)
|
||||||
.service(
|
.service(
|
||||||
web::resource("/filter").route(web::post().to(payouts_list_available_filters)),
|
web::resource("/filter")
|
||||||
|
.route(web::post().to(payouts_list_available_filters_for_merchant)),
|
||||||
|
)
|
||||||
|
.service(
|
||||||
|
web::resource("/profile/filter")
|
||||||
|
.route(web::post().to(payouts_list_available_filters_for_profile)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
route = route
|
route = route
|
||||||
|
|||||||
@ -320,10 +320,10 @@ pub async fn payouts_list_by_filter_profile(
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Payouts - Available filters
|
/// Payouts - Available filters for Merchant
|
||||||
#[cfg(feature = "olap")]
|
#[cfg(feature = "olap")]
|
||||||
#[instrument(skip_all, fields(flow = ?Flow::PayoutsFilter))]
|
#[instrument(skip_all, fields(flow = ?Flow::PayoutsFilter))]
|
||||||
pub async fn payouts_list_available_filters(
|
pub async fn payouts_list_available_filters_for_merchant(
|
||||||
state: web::Data<AppState>,
|
state: web::Data<AppState>,
|
||||||
req: HttpRequest,
|
req: HttpRequest,
|
||||||
json_payload: web::Json<payment_types::TimeRange>,
|
json_payload: web::Json<payment_types::TimeRange>,
|
||||||
@ -337,7 +337,41 @@ pub async fn payouts_list_available_filters(
|
|||||||
&req,
|
&req,
|
||||||
payload,
|
payload,
|
||||||
|state, auth, req, _| {
|
|state, auth, req, _| {
|
||||||
payouts_list_available_filters_core(state, auth.merchant_account, req)
|
payouts_list_available_filters_core(state, auth.merchant_account, None, req)
|
||||||
|
},
|
||||||
|
auth::auth_type(
|
||||||
|
&auth::HeaderAuth(auth::ApiKeyAuth),
|
||||||
|
&auth::JWTAuth(Permission::PayoutRead),
|
||||||
|
req.headers(),
|
||||||
|
),
|
||||||
|
api_locking::LockAction::NotApplicable,
|
||||||
|
))
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Payouts - Available filters for Profile
|
||||||
|
#[cfg(feature = "olap")]
|
||||||
|
#[instrument(skip_all, fields(flow = ?Flow::PayoutsFilter))]
|
||||||
|
pub async fn payouts_list_available_filters_for_profile(
|
||||||
|
state: web::Data<AppState>,
|
||||||
|
req: HttpRequest,
|
||||||
|
json_payload: web::Json<payment_types::TimeRange>,
|
||||||
|
) -> HttpResponse {
|
||||||
|
let flow = Flow::PayoutsFilter;
|
||||||
|
let payload = json_payload.into_inner();
|
||||||
|
|
||||||
|
Box::pin(api::server_wrap(
|
||||||
|
flow,
|
||||||
|
state,
|
||||||
|
&req,
|
||||||
|
payload,
|
||||||
|
|state, auth, req, _| {
|
||||||
|
payouts_list_available_filters_core(
|
||||||
|
state,
|
||||||
|
auth.merchant_account,
|
||||||
|
auth.profile_id.map(|profile_id| vec![profile_id]),
|
||||||
|
req,
|
||||||
|
)
|
||||||
},
|
},
|
||||||
auth::auth_type(
|
auth::auth_type(
|
||||||
&auth::HeaderAuth(auth::ApiKeyAuth),
|
&auth::HeaderAuth(auth::ApiKeyAuth),
|
||||||
|
|||||||
Reference in New Issue
Block a user