feat(connector_events): added api to fetch connector event logs (#3319)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
Co-authored-by: harsh-sharma-juspay <125131007+harsh-sharma-juspay@users.noreply.github.com>
This commit is contained in:
ivor-juspay
2024-01-17 15:07:41 +05:30
committed by GitHub
parent 01c2de223f
commit 68a3a28067
12 changed files with 160 additions and 2 deletions

View File

@ -3,7 +3,8 @@ pub use analytics::*;
pub mod routes {
use actix_web::{web, Responder, Scope};
use analytics::{
api_event::api_events_core, errors::AnalyticsError, lambda_utils::invoke_lambda,
api_event::api_events_core, connector_events::connector_events_core,
errors::AnalyticsError, lambda_utils::invoke_lambda,
outgoing_webhook_event::outgoing_webhook_events_core, sdk_events::sdk_events_core,
};
use api_models::analytics::{
@ -71,6 +72,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("connector_event_logs")
.route(web::get().to(get_connector_events)),
)
.service(
web::resource("outgoing_webhook_event_logs")
.route(web::get().to(get_outgoing_webhook_events)),
@ -585,4 +590,26 @@ pub mod routes {
))
.await
}
pub async fn get_connector_events(
state: web::Data<AppState>,
req: actix_web::HttpRequest,
json_payload: web::Query<api_models::analytics::connector_events::ConnectorEventsRequest>,
) -> impl Responder {
let flow = AnalyticsFlow::GetConnectorEvents;
Box::pin(api::server_wrap(
flow,
state,
&req,
json_payload.into_inner(),
|state, auth: AuthenticationData, req| async move {
connector_events_core(&state.pool, req, auth.merchant_account.merchant_id)
.await
.map(ApplicationResponse::Json)
},
&auth::JWTAuth(Permission::Analytics),
api_locking::LockAction::NotApplicable,
))
.await
}
}