-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(refunds): update refunds filters #4409
Merged
Merged
Changes from 8 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
3fe934c
feat(refunds): update refunds filters
apoorvdixit88 1442701
Merge branch 'main' into refunds-filters-v2
apoorvdixit88 47d5636
feat(refunds): filter list by amount and merchant connector id
apoorvdixit88 23afdc5
fix: to shema for amount filter
apoorvdixit88 a1351ec
fix: change openspec api for amount filter
apoorvdixit88 4d4dbde
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] 07e18a4
fix: resove PR comments
apoorvdixit88 1641c82
fix: resolve review comments
apoorvdixit88 8bf601a
resolve review comments
apoorvdixit88 41adc02
Merge branch 'main' into refunds-filters-v2
apoorvdixit88 a7b2123
fix: change routes for v2
apoorvdixit88 b9b62cb
fix: change route for utoipa
apoorvdixit88 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
pub mod validator; | ||
|
||
#[cfg(feature = "olap")] | ||
use std::collections::HashMap; | ||
|
||
#[cfg(feature = "olap")] | ||
use api_models::admin::MerchantConnectorInfo; | ||
use common_utils::ext_traits::AsyncExt; | ||
use error_stack::{report, ResultExt}; | ||
use router_env::{instrument, tracing}; | ||
use scheduler::{consumer::types::process_data, utils as process_tracker_utils}; | ||
#[cfg(feature = "olap")] | ||
use strum::IntoEnumIterator; | ||
|
||
use crate::{ | ||
consts, | ||
|
@@ -767,6 +774,53 @@ pub async fn refund_filter_list( | |
Ok(services::ApplicationResponse::Json(filter_list)) | ||
} | ||
|
||
#[instrument(skip_all)] | ||
#[cfg(feature = "olap")] | ||
pub async fn get_filters_for_refunds( | ||
state: AppState, | ||
merchant_account: domain::MerchantAccount, | ||
) -> RouterResponse<api_models::refunds::RefundListFilters> { | ||
let merchant_connector_accounts = if let services::ApplicationResponse::Json(data) = | ||
super::admin::list_payment_connectors(state, merchant_account.merchant_id).await? | ||
{ | ||
data | ||
} else { | ||
return Err(errors::ApiErrorResponse::InternalServerError.into()); | ||
}; | ||
|
||
let connector_map = merchant_connector_accounts | ||
.iter() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use |
||
.filter_map(|merchant_connector_account| { | ||
merchant_connector_account | ||
.connector_label | ||
.as_ref() | ||
.map(|label| { | ||
let info = MerchantConnectorInfo { | ||
connector_label: label.clone(), | ||
merchant_connector_id: merchant_connector_account | ||
.merchant_connector_id | ||
.clone(), | ||
}; | ||
(merchant_connector_account.connector_name.clone(), info) | ||
}) | ||
}) | ||
.fold( | ||
HashMap::new(), | ||
|mut map: HashMap<String, Vec<MerchantConnectorInfo>>, (connector_name, info)| { | ||
map.entry(connector_name).or_default().push(info); | ||
map | ||
}, | ||
); | ||
|
||
Ok(services::ApplicationResponse::Json( | ||
api_models::refunds::RefundListFilters { | ||
connector: connector_map, | ||
currency: enums::Currency::iter().collect(), | ||
refund_status: enums::RefundStatus::iter().collect(), | ||
}, | ||
)) | ||
} | ||
|
||
impl ForeignFrom<storage::Refund> for api::RefundResponse { | ||
fn foreign_from(refund: storage::Refund) -> Self { | ||
let refund = refund; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -702,7 +702,8 @@ impl Refunds { | |
{ | ||
route = route | ||
.service(web::resource("/list").route(web::post().to(refunds_list))) | ||
.service(web::resource("/filter").route(web::post().to(refunds_filter_list))); | ||
.service(web::resource("/filter").route(web::post().to(refunds_filter_list))) | ||
.service(web::resource("/filter_v2").route(web::get().to(get_refunds_filters))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can be named with |
||
} | ||
#[cfg(feature = "oltp")] | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What will be the key in this hashmap?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please mention it in the doc comment.