Skip to content

Commit

Permalink
feat: adding refunds type to api_event_logs api to fetch refunds audi…
Browse files Browse the repository at this point in the history
…t trail (#3503)

Co-authored-by: harsh-sharma-juspay <[email protected]>
Co-authored-by: oscar2d2 <[email protected]>
Co-authored-by: swangi-kumari <[email protected]>
Co-authored-by: Apoorv Dixit <[email protected]>
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
Co-authored-by: Kartikeya Hegde <[email protected]>
  • Loading branch information
7 people authored Feb 8, 2024
1 parent 014c2d5 commit c2b2b65
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 25 deletions.
72 changes: 48 additions & 24 deletions crates/analytics/src/api_event/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
5 changes: 4 additions & 1 deletion crates/api_models/src/analytics/api_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -27,6 +26,10 @@ pub enum QueryType {
payment_id: String,
refund_id: String,
},
Dispute {
payment_id: String,
dispute_id: String,
},
}

#[derive(
Expand Down

0 comments on commit c2b2b65

Please sign in to comment.