Bug: feat(analytics): refunds and disputes audit rail




diff --git a/crates/analytics/src/api_event/events.rs b/crates/analytics/src/api_event/events.rs
index eb9b2d561c5..4be3a3420da 100644
--- a/crates/analytics/src/api_event/events.rs
+++ b/crates/analytics/src/api_event/events.rs
@@ -33,9 +33,30 @@ where
         .add_filter_clause("merchant_id", merchant_id)
         .switch()?;
     match query_param.query_param {
-        QueryType::Payment { payment_id } => query_builder
-            .add_filter_clause("payment_id", payment_id)
-            .switch()?,
+        QueryType::Payment { payment_id } => {
+            query_builder
+                .add_filter_clause("payment_id", payment_id)
+                .switch()?;
+            query_builder
+                .add_filter_in_range_clause(
+                    "api_flow",
+                    &[
+                        Flow::PaymentsCancel,
+                        Flow::PaymentsCapture,
+                        Flow::PaymentsConfirm,
+                        Flow::PaymentsCreate,
+                        Flow::PaymentsStart,
+                        Flow::PaymentsUpdate,
+                        Flow::RefundsCreate,
+                        Flow::RefundsUpdate,
+                        Flow::DisputesEvidenceSubmit,
+                        Flow::AttachDisputeEvidence,
+                        Flow::RetrieveDisputeEvidence,
+                        Flow::IncomingWebhookReceive,
+                    ],
+                )
+                .switch()?;
+        }
         QueryType::Refund {
             payment_id,
             refund_id,
@@ -46,28 +67,31 @@ where
             query_builder
                 .add_filter_clause("refund_id", refund_id)
                 .switch()?;
+            query_builder
+                .add_filter_in_range_clause("api_flow", &[Flow::RefundsCreate, Flow::RefundsUpdate])
+                .switch()?;
+        }
+        QueryType::Dispute {
+            payment_id,
+            dispute_id,
+        } => {
+            query_builder
+                .add_filter_clause("payment_id", payment_id)
+                .switch()?;
+            query_builder
+                .add_filter_clause("dispute_id", dispute_id)
+                .switch()?;
+            query_builder
+                .add_filter_in_range_clause(
+                    "api_flow",
+                    &[
+                        Flow::DisputesEvidenceSubmit,
+                        Flow::AttachDisputeEvidence,
+                        Flow::RetrieveDisputeEvidence,
+                    ],
+                )
+                .switch()?;
         }
-    }
-    if let Some(list_api_name) = query_param.api_name_filter {
-        query_builder
-            .add_filter_in_range_clause("api_flow", &list_api_name)
-            .switch()?;
-    } else {
-        query_builder
-            .add_filter_in_range_clause(
-                "api_flow",
-                &[
-                    Flow::PaymentsCancel,
-                    Flow::PaymentsCapture,
-                    Flow::PaymentsConfirm,
-                    Flow::PaymentsCreate,
-                    Flow::PaymentsStart,
-                    Flow::PaymentsUpdate,
-                    Flow::RefundsCreate,
-                    Flow::IncomingWebhookReceive,
-                ],
-            )
-            .switch()?;
     }
     //TODO!: update the execute_query function to return reports instead of plain errors...
     query_builder
diff --git a/crates/api_models/src/analytics/api_event.rs b/crates/api_models/src/analytics/api_event.rs
index 62fe829f01b..5fe8e4ff3a7 100644
--- a/crates/api_models/src/analytics/api_event.rs
+++ b/crates/api_models/src/analytics/api_event.rs
@@ -8,7 +8,6 @@ use super::{NameDescription, TimeRange};
 pub struct ApiLogsRequest {
     #[serde(flatten)]
     pub query_param: QueryType,
-    pub api_name_filter: Option<Vec<String>>,
 }
 
 pub enum FilterType {
@@ -27,6 +26,10 @@ pub enum QueryType {
         payment_id: String,
         refund_id: String,
     },
+    Dispute {
+        payment_id: String,
+        dispute_id: String,
+    },
 }
 
 #[derive(

## Type of Change
<!-- Put an `x` in the boxes that apply -->

- [ ] Bugfix
- [x] New feature
- [ ] Enhancement
- [ ] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD

## Description
<!-- Describe your changes in detail -->
added api_logs for refunds and disputes and same for connector_outgoing_events and webhook_events logs.


### Additional Changes

- [x] This PR modifies the API contract
- [ ] This PR modifies the database schema
- [ ] This PR modifies application configuration/environment variables

<!--
Provide links to the files with corresponding changes.

Following are the paths where you can find config files:
1. `config`
2. `crates/router/src/configs`
3. `loadtest/config`
-->


## Motivation and Context
<!--
Why is this change required? What problem does it solve?
If it fixes an open issue, please link to the issue here.

If you don't have an issue, we'd recommend starting with one first so the PR
can focus on the implementation (unless it is an obvious bug or documentation fix
that will have little conversation).
-->


## How did you test it?
<!--
Did you write an integration/unit/API test to verify the code changes?
Or did you test this change manually (provide relevant screenshots)?
-->
to test api_events for refunds 
```curl
curl --location '<base_url>/analytics/v1/api_event_logs?type=Refund&payment_id=<payment_id>&refund_id=<refund_id>' \
--header 'Accept: */*' \
--header 'Accept-Language: en-GB,en-US;q=0.9,en;q=0.8' \
--header 'Connection: keep-alive' \
--header 'Content-Type: application/json' \
--header 'Origin: http://localhost:9000' \
--header 'Referer: http://localhost:9000/' \
--header 'Sec-Fetch-Dest: empty' \
--header 'Sec-Fetch-Mode: cors' \
--header 'Sec-Fetch-Site: same-site' \
--header 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36' \
--header 'api-key: hyperswitch' \
--header 'authorization: Bearer <token>"' \
--header 'sec-ch-ua-mobile: ?0' \
--header 'sec-ch-ua-platform: "macOS"'`
<img width="1132" alt="Screenshot 2024-01-31 at 1 50 21 PM" src="https://github.com/juspay/hyperswitch/assets/126486299/318b9a07-d350-4741-8c78-8c1922e014db">
```
for disputes 

```curl
curl --location '<base_url>/analytics/v1/api_event_logs?type=Dispute&dispute_id=<dispute_id>' \
--header 'Accept: */*' \
--header 'Accept-Language: en-GB,en-US;q=0.9,en;q=0.8' \
--header 'Connection: keep-alive' \
--header 'Content-Type: application/json' \
--header 'Origin: http://localhost:9000' \
--header 'Referer: http://localhost:9000/' \
--header 'Sec-Fetch-Dest: empty' \
--header 'Sec-Fetch-Mode: cors' \
--header 'Sec-Fetch-Site: same-site' \
--header 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36' \
--header 'api-key: hyperswitch' \
--header 'authorization: Bearer <token>"' \
--header 'sec-ch-ua-mobile: ?0' \
--header 'sec-ch-ua-platform: "macOS"'
```

## Checklist
<!-- Put an `x` in the boxes that apply -->

- [x] I formatted the code `cargo +nightly fmt --all`
- [x] I addressed lints thrown by `cargo clippy`
- [x] I reviewed the submitted code
- [ ] I added unit tests for my changes where possible
- [ ] I added a [CHANGELOG](/CHANGELOG.md) entry if applicable
