feat(outgoingwebhookevent): adding api for query to fetch outgoing webhook events log (#3310)

Co-authored-by: Sampras Lopes <lsampras@pm.me>
This commit is contained in:
harsh-sharma-juspay
2024-01-11 18:42:09 +05:30
committed by GitHub
parent bb096138b5
commit 54d44bef73
12 changed files with 192 additions and 3 deletions

View File

@ -4,7 +4,7 @@ pub mod routes {
use actix_web::{web, Responder, Scope};
use analytics::{
api_event::api_events_core, errors::AnalyticsError, lambda_utils::invoke_lambda,
sdk_events::sdk_events_core,
outgoing_webhook_event::outgoing_webhook_events_core, sdk_events::sdk_events_core,
};
use api_models::analytics::{
GenerateReportRequest, GetApiEventFiltersRequest, GetApiEventMetricRequest,
@ -71,6 +71,10 @@ pub mod routes {
)
.service(web::resource("api_event_logs").route(web::get().to(get_api_events)))
.service(web::resource("sdk_event_logs").route(web::post().to(get_sdk_events)))
.service(
web::resource("outgoing_webhook_event_logs")
.route(web::get().to(get_outgoing_webhook_events)),
)
.service(
web::resource("filters/api_events")
.route(web::post().to(get_api_event_filters)),
@ -314,6 +318,30 @@ pub mod routes {
.await
}
pub async fn get_outgoing_webhook_events(
state: web::Data<AppState>,
req: actix_web::HttpRequest,
json_payload: web::Query<
api_models::analytics::outgoing_webhook_event::OutgoingWebhookLogsRequest,
>,
) -> impl Responder {
let flow = AnalyticsFlow::GetOutgoingWebhookEvents;
Box::pin(api::server_wrap(
flow,
state,
&req,
json_payload.into_inner(),
|state, auth: AuthenticationData, req| async move {
outgoing_webhook_events_core(&state.pool, req, auth.merchant_account.merchant_id)
.await
.map(ApplicationResponse::Json)
},
&auth::JWTAuth(Permission::Analytics),
api_locking::LockAction::NotApplicable,
))
.await
}
pub async fn get_sdk_events(
state: web::Data<AppState>,
req: actix_web::HttpRequest,