mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-28 04:04:55 +08:00
fix(payments): add time range in list payment attempts query (#5959)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
use common_enums::{PaymentMethod, PaymentMethodType};
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::id_type;
|
||||
use crate::{id_type, types::TimeRange};
|
||||
|
||||
pub trait ApiEventMetric {
|
||||
fn get_api_event_type(&self) -> Option<ApiEventsType> {
|
||||
@ -139,3 +139,5 @@ impl<T: ApiEventMetric> ApiEventMetric for &T {
|
||||
T::get_api_event_type(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl ApiEventMetric for TimeRange {}
|
||||
|
||||
@ -28,6 +28,7 @@ use rust_decimal::{
|
||||
};
|
||||
use semver::Version;
|
||||
use serde::{de::Visitor, Deserialize, Deserializer, Serialize};
|
||||
use time::PrimitiveDateTime;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
use crate::{
|
||||
@ -582,6 +583,21 @@ impl StringMajorUnit {
|
||||
}
|
||||
}
|
||||
|
||||
/// A type representing a range of time for filtering, including a mandatory start time and an optional end time.
|
||||
#[derive(
|
||||
Debug, Clone, Copy, serde::Serialize, serde::Deserialize, PartialEq, Eq, Hash, ToSchema,
|
||||
)]
|
||||
pub struct TimeRange {
|
||||
/// The start time to filter payments list or to get list of filters. To get list of filters start time is needed to be passed
|
||||
#[serde(with = "crate::custom_serde::iso8601")]
|
||||
#[serde(alias = "startTime")]
|
||||
pub start_time: PrimitiveDateTime,
|
||||
/// The end time to filter payments list or to get list of filters. If not passed the default time is now
|
||||
#[serde(default, with = "crate::custom_serde::iso8601::option")]
|
||||
#[serde(alias = "endTime")]
|
||||
pub end_time: Option<PrimitiveDateTime>,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod amount_conversion_tests {
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
Reference in New Issue
Block a user