Skip to content

Commit 1805217

Browse files
author
Tushar Shukla
committed
minor fix
1 parent 05fbf5d commit 1805217

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

backend/connector-integration/src/connectors/globalpay.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::fmt::Debug;
44

55
use common_enums::CurrencyUnit;
66
use common_utils::{
7-
errors::CustomResult, ext_traits::ByteSliceExt, request::RequestContent, types::StringMinorUnit,
7+
errors::CustomResult, events, ext_traits::ByteSliceExt, request::RequestContent, types::StringMinorUnit,
88
};
99
use domain_types::{
1010
connector_flow::{
@@ -34,7 +34,6 @@ use error_stack::ResultExt;
3434
use hyperswitch_masking::{Mask, Maskable};
3535
use interfaces::{
3636
api::ConnectorCommon, connector_integration_v2::ConnectorIntegrationV2, connector_types,
37-
events::connector_api_logs::ConnectorEvent,
3837
};
3938
use serde::Serialize;
4039
use transformers as globalpay;
@@ -46,6 +45,8 @@ use transformers::{
4645

4746
use crate::connectors::macros;
4847
use crate::types::ResponseRouterData;
48+
use crate::with_error_response_body;
49+
use crate::with_response_body;
4950

5051
pub(crate) mod headers {
5152
pub(crate) const CONTENT_TYPE: &str = "Content-Type";
@@ -745,7 +746,7 @@ impl<T: PaymentMethodDataTypes + Debug + Sync + Send + 'static + Serialize>
745746
AccessTokenRequestData,
746747
AccessTokenResponseData,
747748
>,
748-
event_builder: Option<&mut ConnectorEvent>,
749+
event_builder: Option<&mut events::Event>,
749750
res: Response,
750751
) -> CustomResult<
751752
RouterDataV2<
@@ -761,9 +762,7 @@ impl<T: PaymentMethodDataTypes + Debug + Sync + Send + 'static + Serialize>
761762
.parse_struct("GlobalpayAccessTokenResponse")
762763
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
763764

764-
if let Some(i) = event_builder {
765-
i.set_response_body(&response)
766-
}
765+
with_response_body!(event_builder, response);
767766

768767
RouterDataV2::try_from(ResponseRouterData {
769768
response,
@@ -775,7 +774,7 @@ impl<T: PaymentMethodDataTypes + Debug + Sync + Send + 'static + Serialize>
775774
fn get_error_response_v2(
776775
&self,
777776
res: Response,
778-
event_builder: Option<&mut ConnectorEvent>,
777+
event_builder: Option<&mut events::Event>,
779778
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
780779
self.build_error_response(res, event_builder)
781780
}
@@ -1062,17 +1061,15 @@ impl<T: PaymentMethodDataTypes + Debug + Sync + Send + 'static + Serialize> Conn
10621061
fn build_error_response(
10631062
&self,
10641063
res: Response,
1065-
event_builder: Option<&mut ConnectorEvent>,
1064+
event_builder: Option<&mut events::Event>,
10661065
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
10671066
// Try to parse as structured error first
10681067
let error_response = match res
10691068
.response
10701069
.parse_struct::<globalpay::GlobalpayErrorResponse>("GlobalpayErrorResponse")
10711070
{
10721071
Ok(response) => {
1073-
if let Some(i) = event_builder {
1074-
i.set_error_response_body(&response)
1075-
}
1072+
with_error_response_body!(event_builder, response);
10761073
ErrorResponse {
10771074
status_code: res.status_code,
10781075
code: response.code.unwrap_or_else(|| "UNKNOWN_ERROR".to_string()),

0 commit comments

Comments
 (0)