Repository: juspay/hyperswitch
File: crates/hyperswitch_connectors/src/connectors/facilitapay/transformers.rs (Rust)

Code before:
            phone_area_code: None,
            phone_number: None,
            address_city: None,
            address_state: None,
            address_complement: None,
            address_country: None,
            address_number: None,
            address_postal_code: None,
            address_street: None,
            net_monthly_average_income: None,
        };

        Ok(Self { person })
    }
}

impl<F, T> TryFrom<ResponseRouterData<F, FacilitapayCustomerResponse, T, PaymentsResponseData>>
    for RouterData<F, T, PaymentsResponseData>
{
    type Error = Error;
    fn try_from(
        item: ResponseRouterData<F, FacilitapayCustomerResponse, T, PaymentsResponseData>,
    ) -> Result<Self, Self::Error> {
        Ok(Self {
            response: Ok(PaymentsResponseData::ConnectorCustomerResponse(
                ConnectorCustomerResponseData {
                    connector_customer_id: item.response.data.customer_id.expose(),
                    name: None,
                    email: None,
                    billing_address: None,
                },
            )),
            ..item.data
        })
    }
}

impl From<FacilitapayPaymentStatus> for common_enums::AttemptStatus {
    fn from(item: FacilitapayPaymentStatus) -> Self {
        match item {
            FacilitapayPaymentStatus::Pending => Self::Pending,
            FacilitapayPaymentStatus::Identified
            | FacilitapayPaymentStatus::Exchanged
            | FacilitapayPaymentStatus::Wired => Self::Charged,
            FacilitapayPaymentStatus::Cancelled => Self::Failure,
        }
    }
}

impl<F, T> TryFrom<ResponseRouterData<F, FacilitapayAuthResponse, T, AccessToken>>
    for RouterData<F, T, AccessToken>

Review comment (suggestion):
This way, any new field addition to `ConnectorCustomerResponseData` will not lead to changes in these connector code.

```suggestion
                ConnectorCustomerResponseData::new_with_customer_id(item.response.data.customer_id.expose())
```

Code after:
            phone_area_code: None,
            phone_number: None,
            address_city: None,
            address_state: None,
            address_complement: None,
            address_country: None,
            address_number: None,
            address_postal_code: None,
            address_street: None,
            net_monthly_average_income: None,
        };

        Ok(Self { person })
    }
}

impl<F, T> TryFrom<ResponseRouterData<F, FacilitapayCustomerResponse, T, PaymentsResponseData>>
    for RouterData<F, T, PaymentsResponseData>
{
    type Error = Error;
    fn try_from(
        item: ResponseRouterData<F, FacilitapayCustomerResponse, T, PaymentsResponseData>,
    ) -> Result<Self, Self::Error> {
        Ok(Self {
            response: Ok(PaymentsResponseData::ConnectorCustomerResponse(
                ConnectorCustomerResponseData::new_with_customer_id(
                    item.response.data.customer_id.expose(),
                ),
            )),
            ..item.data
        })
    }
}

impl From<FacilitapayPaymentStatus> for common_enums::AttemptStatus {
    fn from(item: FacilitapayPaymentStatus) -> Self {
        match item {
            FacilitapayPaymentStatus::Pending => Self::Pending,
            FacilitapayPaymentStatus::Identified
            | FacilitapayPaymentStatus::Exchanged
            | FacilitapayPaymentStatus::Wired => Self::Charged,
            FacilitapayPaymentStatus::Cancelled => Self::Failure,
        }
    }
}

impl<F, T> TryFrom<ResponseRouterData<F, FacilitapayAuthResponse, T, AccessToken>>
    for RouterData<F, T, AccessToken>
{
    type Error = Error;
    fn try_from(