feat(refunds): update refunds filters (#4409)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Apoorv Dixit
2024-05-13 18:47:29 +05:30
committed by GitHub
parent 1602eb541d
commit cfab2af7d4
14 changed files with 254 additions and 12 deletions

View File

@ -523,7 +523,7 @@ pub struct MerchantConnectorWebhookDetails {
pub additional_secret: Option<Secret<String>>,
}
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize, ToSchema)]
pub struct MerchantConnectorInfo {
pub connector_label: String,
pub merchant_connector_id: String,

View File

@ -1,8 +1,8 @@
use common_utils::events::{ApiEventMetric, ApiEventsType};
use crate::refunds::{
RefundListMetaData, RefundListRequest, RefundListResponse, RefundRequest, RefundResponse,
RefundUpdateRequest, RefundsRetrieveRequest,
RefundListFilters, RefundListMetaData, RefundListRequest, RefundListResponse, RefundRequest,
RefundResponse, RefundUpdateRequest, RefundsRetrieveRequest,
};
impl ApiEventMetric for RefundRequest {
@ -61,3 +61,9 @@ impl ApiEventMetric for RefundListMetaData {
Some(ApiEventsType::ResourceListAPI)
}
}
impl ApiEventMetric for RefundListFilters {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::ResourceListAPI)
}
}

View File

@ -3576,9 +3576,11 @@ pub struct PaymentListFiltersV2 {
pub authentication_type: Vec<enums::AuthenticationType>,
}
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
#[derive(Clone, Debug, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)]
pub struct AmountFilter {
/// The start amount to filter list of transactions which are greater than or equal to the start amount
pub start_amount: Option<i64>,
/// The end amount to filter list of transactions which are less than or equal to the end amount
pub end_amount: Option<i64>,
}

View File

@ -1,10 +1,15 @@
use std::collections::HashMap;
use common_utils::pii;
use serde::{Deserialize, Serialize};
use time::PrimitiveDateTime;
use utoipa::ToSchema;
use super::payments::TimeRange;
use crate::{admin, enums};
use super::payments::{AmountFilter, TimeRange};
use crate::{
admin::{self, MerchantConnectorInfo},
enums,
};
#[derive(Default, Debug, ToSchema, Clone, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
@ -146,11 +151,15 @@ pub struct RefundListRequest {
pub limit: Option<i64>,
/// The starting point within a list of objects
pub offset: Option<i64>,
/// The time range for which objects are needed. TimeRange has two fields start_time and end_time from which objects can be filtered as per required scenarios (created_at, time less than, greater than etc).
/// The time range for which objects are needed. TimeRange has two fields start_time and end_time from which objects can be filtered as per required scenarios (created_at, time less than, greater than etc)
#[serde(flatten)]
pub time_range: Option<TimeRange>,
/// The amount to filter reufnds list. Amount takes two option fields start_amount and end_amount from which objects can be filtered as per required scenarios (less_than, greater_than, equal_to and range)
pub amount_filter: Option<AmountFilter>,
/// The list of connectors to filter refunds list
pub connector: Option<Vec<String>>,
/// The list of merchant connector ids to filter the refunds list for selected label
pub merchant_connector_id: Option<Vec<String>>,
/// The list of currencies to filter refunds list
#[schema(value_type = Option<Vec<Currency>>)]
pub currency: Option<Vec<enums::Currency>>,
@ -181,6 +190,18 @@ pub struct RefundListMetaData {
pub refund_status: Vec<enums::RefundStatus>,
}
#[derive(Clone, Debug, serde::Serialize, ToSchema)]
pub struct RefundListFilters {
/// The map of available connector filters, where the key is the connector name and the value is a list of MerchantConnectorInfo instances
pub connector: HashMap<String, Vec<MerchantConnectorInfo>>,
/// The list of available currency filters
#[schema(value_type = Vec<Currency>)]
pub currency: Vec<enums::Currency>,
/// The list of available refund status filters
#[schema(value_type = Vec<RefundStatus>)]
pub refund_status: Vec<enums::RefundStatus>,
}
/// The status for refunds
#[derive(
Debug,