Skip to content

Commit

Permalink
refactor: undo status mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
swangi-kumari committed Mar 5, 2024
1 parent 2cb0bf8 commit 6f3005d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 29 deletions.
4 changes: 2 additions & 2 deletions crates/router/src/connector/authorizedotnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -685,8 +685,8 @@ impl ConnectorIntegration<api::RSync, types::RefundsData, types::RefundsResponse
let intermediate_response =
bytes::Bytes::copy_from_slice(intermediate_response.0.as_bytes());

let response: authorizedotnet::AuthorizedotnetRSyncResponse = intermediate_response
.parse_struct("AuthorizedotnetRSyncResponse")
let response: authorizedotnet::AuthorizedotnetSyncResponse = intermediate_response
.parse_struct("AuthorizedotnetSyncResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
Expand Down
34 changes: 7 additions & 27 deletions crates/router/src/connector/authorizedotnet/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -933,13 +933,6 @@ pub enum SyncStatus {
FDSPendingReview,
}

#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub enum RSyncStatus {
RefundSettledSuccessfully,
RefundPendingSettlement,
}

#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SyncTransactionResponse {
Expand All @@ -954,25 +947,12 @@ pub struct AuthorizedotnetSyncResponse {
messages: ResponseMessages,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct AuthorizedotnetRSyncResponse {
transaction: Option<RSyncTransactionResponse>,
messages: ResponseMessages,
}

#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct RSyncTransactionResponse {
#[serde(rename = "transId")]
transaction_id: String,
transaction_status: RSyncStatus,
}

impl From<RSyncStatus> for enums::RefundStatus {
fn from(transaction_status: RSyncStatus) -> Self {
impl From<SyncStatus> for enums::RefundStatus {
fn from(transaction_status: SyncStatus) -> Self {
match transaction_status {
RSyncStatus::RefundSettledSuccessfully => Self::Success,
RSyncStatus::RefundPendingSettlement => Self::Pending,
SyncStatus::RefundSettledSuccessfully => Self::Success,
SyncStatus::RefundPendingSettlement => Self::Pending,
_ => Self::Failure,
}
}
}
Expand All @@ -994,13 +974,13 @@ impl From<SyncStatus> for enums::AttemptStatus {
}
}

impl TryFrom<types::RefundsResponseRouterData<api::RSync, AuthorizedotnetRSyncResponse>>
impl TryFrom<types::RefundsResponseRouterData<api::RSync, AuthorizedotnetSyncResponse>>
for types::RefundsRouterData<api::RSync>
{
type Error = error_stack::Report<errors::ConnectorError>;

fn try_from(
item: types::RefundsResponseRouterData<api::RSync, AuthorizedotnetRSyncResponse>,
item: types::RefundsResponseRouterData<api::RSync, AuthorizedotnetSyncResponse>,
) -> Result<Self, Self::Error> {
match item.response.transaction {
Some(transaction) => {
Expand Down

0 comments on commit 6f3005d

Please sign in to comment.