Skip to content

Commit 6d50f73

Browse files
committed
fix(mca): Fixed some errors
1 parent cc1fba3 commit 6d50f73

File tree

2 files changed

+21
-64
lines changed

2 files changed

+21
-64
lines changed

crates/router/src/types.rs

Lines changed: 12 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -606,65 +606,6 @@ pub struct ResponseRouterData<Flow, R, Request, Response> {
606606
pub http_code: u16,
607607
}
608608

609-
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize)]
610-
#[serde(rename_all = "snake_case")]
611-
pub enum MerchantAccountDataResponse {
612-
Iban {
613-
iban: Secret<String>,
614-
name: String,
615-
#[serde(skip_serializing_if = "Option::is_none")]
616-
connector_recipient_id: Option<Secret<String>>,
617-
},
618-
Bacs {
619-
account_number: Secret<String>,
620-
sort_code: Secret<String>,
621-
name: String,
622-
#[serde(skip_serializing_if = "Option::is_none")]
623-
connector_recipient_id: Option<Secret<String>>,
624-
},
625-
}
626-
627-
impl From<MerchantAccountData> for MerchantAccountDataResponse {
628-
fn from(value: MerchantAccountData) -> Self {
629-
match value {
630-
MerchantAccountData::Bacs {
631-
account_number,
632-
sort_code,
633-
name,
634-
connector_recipient_id,
635-
} => Self::Bacs {
636-
account_number,
637-
sort_code,
638-
name,
639-
connector_recipient_id: if let Some(conn) = connector_recipient_id {
640-
match conn {
641-
RecipientIdType::ConnectorId(id) => Some(id),
642-
RecipientIdType::LockerId(_id) => None,
643-
}
644-
} else {
645-
None
646-
},
647-
},
648-
MerchantAccountData::Iban {
649-
iban,
650-
name,
651-
connector_recipient_id,
652-
} => Self::Iban {
653-
iban,
654-
name,
655-
connector_recipient_id: if let Some(conn) = connector_recipient_id {
656-
match conn {
657-
RecipientIdType::ConnectorId(id) => Some(id),
658-
RecipientIdType::LockerId(_id) => None,
659-
}
660-
} else {
661-
None
662-
},
663-
},
664-
}
665-
}
666-
}
667-
668609
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize)]
669610
pub enum RecipientIdType {
670611
ConnectorId(Secret<String>),
@@ -673,7 +614,6 @@ pub enum RecipientIdType {
673614

674615
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize)]
675616
#[serde(rename_all = "snake_case")]
676-
#[serde(into = "MerchantAccountDataResponse")]
677617
pub enum MerchantAccountData {
678618
Iban {
679619
iban: Secret<String>,
@@ -798,6 +738,18 @@ impl ForeignFrom<api_models::admin::AdditionalMerchantData> for AdditionalMercha
798738
}
799739
}
800740

741+
impl ForeignFrom<AdditionalMerchantData> for api_models::admin::AdditionalMerchantData {
742+
fn foreign_from(value: AdditionalMerchantData) -> Self {
743+
match value {
744+
AdditionalMerchantData::OpenBankingRecipientData(data) => {
745+
Self::OpenBankingRecipientData(
746+
api_models::admin::MerchantRecipientData::foreign_from(data),
747+
)
748+
}
749+
}
750+
}
751+
}
752+
801753
impl ForeignFrom<api_models::admin::ConnectorAuthType> for ConnectorAuthType {
802754
fn foreign_from(value: api_models::admin::ConnectorAuthType) -> Self {
803755
match value {

crates/router/src/types/transformers.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use crate::{
2626
},
2727
services::authentication::get_header_value_by_key,
2828
types::{
29+
self as router_types,
2930
api::{self as api_types, routing as routing_types},
3031
storage,
3132
},
@@ -981,11 +982,15 @@ impl TryFrom<domain::MerchantConnectorAccount> for api_models::admin::MerchantCo
981982
.additional_merchant_data
982983
.map(|data| {
983984
let data = data.into_inner();
984-
serde_json::Value::parse_value(data.expose(), "AdditionalMerchantData")
985-
.attach_printable("Unable to deserialize additional_merchant_data")
986-
.change_context(errors::ApiErrorResponse::InternalServerError)
985+
serde_json::Value::parse_value::<router_types::AdditionalMerchantData>(
986+
data.expose(),
987+
"AdditionalMerchantData",
988+
)
989+
.attach_printable("Unable to deserialize additional_merchant_data")
990+
.change_context(errors::ApiErrorResponse::InternalServerError)
987991
})
988-
.transpose()?,
992+
.transpose()?
993+
.map(api_models::admin::AdditionalMerchantData::foreign_from),
989994
})
990995
}
991996
}

0 commit comments

Comments
 (0)