feat(webhook): add filter by event class and type (#7275)

Co-authored-by: Aishwariyaa Anand <aishwariyaa.anand@Aishwariyaa-Anand-C3PGW02T6Y.local>
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Aishwariyaa Anand
2025-04-11 15:45:23 +05:30
committed by GitHub
parent e677b1389f
commit 989b2c34e1
12 changed files with 346 additions and 219 deletions

View File

@ -681,6 +681,7 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::blocklist::ListBlocklistQuery,
api_models::enums::BlocklistDataKind,
api_models::enums::ErrorCategory,
api_models::webhook_events::EventListConstraints,
api_models::webhook_events::EventListItemResponse,
api_models::webhook_events::EventRetrieveResponse,
api_models::webhook_events::OutgoingWebhookRequestContent,

View File

@ -2,7 +2,7 @@
///
/// List all Events associated with a Merchant Account or Profile.
#[utoipa::path(
get,
post,
path = "/events/{merchant_id}",
params(
(
@ -10,46 +10,25 @@
Path,
description = "The unique identifier for the Merchant Account."
),
(
"created_after" = Option<PrimitiveDateTime>,
Query,
description = "Only include Events created after the specified time. \
Either only `object_id` must be specified, or one or more of `created_after`, `created_before`, `limit` and `offset` must be specified."
),
(
"created_before" = Option<PrimitiveDateTime>,
Query,
description = "Only include Events created before the specified time. \
Either only `object_id` must be specified, or one or more of `created_after`, `created_before`, `limit` and `offset` must be specified."
),
(
"limit" = Option<i64>,
Query,
description = "The maximum number of Events to include in the response. \
Either only `object_id` must be specified, or one or more of `created_after`, `created_before`, `limit` and `offset` must be specified."
),
(
"offset" = Option<i64>,
Query,
description = "The number of Events to skip when retrieving the list of Events.
Either only `object_id` must be specified, or one or more of `created_after`, `created_before`, `limit` and `offset` must be specified."
),
(
"object_id" = Option<String>,
Query,
description = "Only include Events associated with the specified object (Payment Intent ID, Refund ID, etc.). \
Either only `object_id` must be specified, or one or more of `created_after`, `created_before`, `limit` and `offset` must be specified."
),
(
"profile_id" = Option<String>,
Query,
description = "Only include Events associated with the Profile identified by the specified Profile ID."
),
(
"is_delivered" = Option<bool>,
Query,
description = "Only include Events which are ultimately delivered to the merchant."
),
),
request_body(
content = EventListConstraints,
description = "The constraints that can be applied when listing Events.",
examples (
("example" = (
value = json!({
"created_after": "2023-01-01T00:00:00",
"created_before": "2023-01-31T23:59:59",
"limit": 5,
"offset": 0,
"object_id": "{{object_id}}",
"profile_id": "{{profile_id}}",
"event_classes": ["payments", "refunds"],
"event_types": ["payment_succeeded"],
"is_delivered": true
})
)),
)
),
responses(
(status = 200, description = "List of Events retrieved successfully", body = TotalEventsResponse),
@ -64,42 +43,29 @@ pub fn list_initial_webhook_delivery_attempts() {}
///
/// List all Events associated with a Profile.
#[utoipa::path(
get,
post,
path = "/events/profile/list",
params(
(
"created_after" = Option<PrimitiveDateTime>,
Query,
description = "Only include Events created after the specified time. \
Either only `object_id` must be specified, or one or more of `created_after`, `created_before`, `limit` and `offset` must be specified."
),
(
"created_before" = Option<PrimitiveDateTime>,
Query,
description = "Only include Events created before the specified time. \
Either only `object_id` must be specified, or one or more of `created_after`, `created_before`, `limit` and `offset` must be specified."
),
(
"limit" = Option<i64>,
Query,
description = "The maximum number of Events to include in the response. \
Either only `object_id` must be specified, or one or more of `created_after`, `created_before`, `limit` and `offset` must be specified."
),
(
"offset" = Option<i64>,
Query,
description = "The number of Events to skip when retrieving the list of Events.
Either only `object_id` must be specified, or one or more of `created_after`, `created_before`, `limit` and `offset` must be specified."
),
(
"object_id" = Option<String>,
Query,
description = "Only include Events associated with the specified object (Payment Intent ID, Refund ID, etc.). \
Either only `object_id` must be specified, or one or more of `created_after`, `created_before`, `limit` and `offset` must be specified."
),
request_body(
content = EventListConstraints,
description = "The constraints that can be applied when listing Events.",
examples (
("example" = (
value = json!({
"created_after": "2023-01-01T00:00:00",
"created_before": "2023-01-31T23:59:59",
"limit": 5,
"offset": 0,
"object_id": "{{object_id}}",
"profile_id": "{{profile_id}}",
"event_classes": ["payments", "refunds"],
"event_types": ["payment_succeeded"],
"is_delivered": true
})
)),
)
),
responses(
(status = 200, description = "List of Events retrieved successfully", body = Vec<EventListItemResponse>),
(status = 200, description = "List of Events retrieved successfully", body = TotalEventsResponse),
),
tag = "Event",
operation_id = "List all Events associated with a Profile",