feat(payments): support sort criteria in payments list (#5389)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Apoorv Dixit
2024-07-26 19:19:49 +05:30
committed by GitHub
parent 08334dae82
commit 043ea6d8dc
3 changed files with 55 additions and 2 deletions

View File

@ -4063,6 +4063,9 @@ pub struct PaymentListFilterConstraints {
pub authentication_type: Option<Vec<enums::AuthenticationType>>,
/// The list of merchant connector ids to filter payments list for selected label
pub merchant_connector_id: Option<Vec<String>>,
/// The order in which payments list should be sorted
#[serde(default)]
pub order: Order,
}
#[derive(Clone, Debug, serde::Serialize)]
pub struct PaymentListFilters {
@ -4102,6 +4105,34 @@ pub struct AmountFilter {
pub end_amount: Option<i64>,
}
#[derive(Clone, Debug, Default, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)]
pub struct Order {
/// The field to sort, such as Amount or Created etc.
pub on: SortOn,
/// The order in which to sort the items, either Ascending or Descending
pub by: SortBy,
}
#[derive(Clone, Debug, Default, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)]
#[serde(rename_all = "snake_case")]
pub enum SortOn {
/// Sort by the amount field
Amount,
/// Sort by the created_at field
#[default]
Created,
}
#[derive(Clone, Debug, Default, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)]
#[serde(rename_all = "snake_case")]
pub enum SortBy {
/// Sort in ascending order
Asc,
/// Sort in descending order
#[default]
Desc,
}
#[derive(
Debug, Clone, Copy, serde::Serialize, serde::Deserialize, PartialEq, Eq, Hash, ToSchema,
)]