Skip to content

Commit

Permalink
chore(code update): updated the connector events
Browse files Browse the repository at this point in the history
  • Loading branch information
sagarnaikjuspay committed Feb 2, 2024
1 parent dc31674 commit f583a67
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 39 deletions.
38 changes: 16 additions & 22 deletions crates/analytics/src/connector_events/events.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use api_models::analytics::{
connector_events::{ConnectorEventsRequest, QueryType},
Granularity,
};
use api_models::analytics::{connector_events::ConnectorEventsRequest, Granularity};
use common_utils::errors::ReportSwitchExt;
use error_stack::ResultExt;
use time::PrimitiveDateTime;
Expand Down Expand Up @@ -32,24 +29,21 @@ where
query_builder
.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::Refund {
payment_id,
refund_id,
} => {
query_builder
.add_filter_clause("payment_id", payment_id)
.switch()?;
query_builder
.add_filter_clause("refund_id", refund_id)
.switch()?;
}
QueryType::Dispute { dispute_id } => query_builder
.add_filter_clause("dispute_id", dispute_id)
.switch()?,

query_builder
.add_filter_clause("payment_id", query_param.payment_id)
.switch()?;

if let Some(refund_id) = query_param.refund_id {
query_builder
.add_filter_clause("refund_id", &refund_id)
.switch()?;
}

if let Some(dispute_id) = query_param.dispute_id {
query_builder
.add_filter_clause("dispute_id", &dispute_id)
.switch()?;
}

//TODO!: update the execute_query function to return reports instead of plain errors...
Expand Down
20 changes: 3 additions & 17 deletions crates/api_models/src/analytics/connector_events.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
#[serde(tag = "type")]
pub enum QueryType {
Payment {
payment_id: String,
},
Refund {
payment_id: String,
refund_id: String,
},
Dispute {
dispute_id: String,
},
}

#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
pub struct ConnectorEventsRequest {
#[serde(flatten)]
pub query_param: QueryType,
pub payment_id: String,
pub refund_id: Option<String>,
pub dispute_id: Option<String>,
}

0 comments on commit f583a67

Please sign in to comment.