Repository: juspay/hyperswitch
File: crates/api_models/src/webhook_events.rs (Rust)

Code before:
use serde::{Deserialize, Serialize};
use time::PrimitiveDateTime;
use utoipa::ToSchema;

/// The constraints to apply when filtering events.
#[derive(Clone, Debug, Serialize, Deserialize, ToSchema)]
pub struct EventListConstraints {
    /// Filter events created after the specified time.
    #[serde(default, with = "common_utils::custom_serde::iso8601::option")]
    pub created_after: Option<PrimitiveDateTime>,

    /// Filter events created before the specified time.
    #[serde(default, with = "common_utils::custom_serde::iso8601::option")]
    pub created_before: Option<PrimitiveDateTime>,

    /// Include at most the specified number of events.
    pub limit: Option<u16>,

    /// Include events after the specified offset.
    pub offset: Option<u16>,

    /// Filter all events associated with the specified object identifier (Payment Intent ID,
    /// Refund ID, etc.)
    pub object_id: Option<String>,

    // Filter all events associated with the specified Event_id
    pub event_id: Option<String>,

    /// Filter all events associated with the specified business profile ID.
    #[schema(value_type = Option<String>)]
    pub profile_id: Option<common_utils::id_type::ProfileId>,

    /// Filter events by their class.
    pub event_classes: Option<HashSet<EventClass>>,

    /// Filter events by their type.
    pub event_types: Option<HashSet<EventType>>,
    /// Filter all events by `is_overall_delivery_successful` field of the event.
    pub is_delivered: Option<bool>,
}

#[derive(Debug)]
pub enum EventListConstraintsInternal {
    GenericFilter {
        created_after: Option<PrimitiveDateTime>,
        created_before: Option<PrimitiveDateTime>,
        limit: Option<i64>,
        offset: Option<i64>,
        event_classes: Option<HashSet<EventClass>>,
        event_types: Option<HashSet<EventType>>,
        is_delivered: Option<bool>,

Review comment (suggestion):
please use documentation comment, that will update the description in openapi_spec.json, thats why its null right now , use triple ///

Code after:
use serde::{Deserialize, Serialize};
use time::PrimitiveDateTime;
use utoipa::ToSchema;

/// The constraints to apply when filtering events.
#[derive(Clone, Debug, Serialize, Deserialize, ToSchema)]
pub struct EventListConstraints {
    /// Filter events created after the specified time.
    #[serde(default, with = "common_utils::custom_serde::iso8601::option")]
    pub created_after: Option<PrimitiveDateTime>,

    /// Filter events created before the specified time.
    #[serde(default, with = "common_utils::custom_serde::iso8601::option")]
    pub created_before: Option<PrimitiveDateTime>,

    /// Include at most the specified number of events.
    pub limit: Option<u16>,

    /// Include events after the specified offset.
    pub offset: Option<u16>,

    /// Filter all events associated with the specified object identifier (Payment Intent ID,
    /// Refund ID, etc.)
    pub object_id: Option<String>,

    /// Filter all events associated with the specified Event_id
    pub event_id: Option<String>,

    /// Filter all events associated with the specified business profile ID.
    #[schema(value_type = Option<String>)]
    pub profile_id: Option<common_utils::id_type::ProfileId>,

    /// Filter events by their class.
    pub event_classes: Option<HashSet<EventClass>>,

    /// Filter events by their type.
    pub event_types: Option<HashSet<EventType>>,
    /// Filter all events by `is_overall_delivery_successful` field of the event.
    pub is_delivered: Option<bool>,
}

#[derive(Debug)]
pub enum EventListConstraintsInternal {
    GenericFilter {
        created_after: Option<PrimitiveDateTime>,
        created_before: Option<PrimitiveDateTime>,
        limit: Option<i64>,
        offset: Option<i64>,
        event_classes: Option<HashSet<EventClass>>,
        event_types: Option<HashSet<EventType>>,
        is_delivered: Option<bool>,