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

Code before:
{
    type Error = error_stack::Report<errors::ConnectorError>;
    fn try_from(
        item: ResponseRouterData<
            RecoveryRecordBack,
            ChargebeeRecordbackResponse,
            RevenueRecoveryRecordBackRequest,
            RevenueRecoveryRecordBackResponse,
        >,
    ) -> Result<Self, Self::Error> {
        let merchant_reference_id = item.response.invoice.id;
        Ok(Self {
            response: Ok(RevenueRecoveryRecordBackResponse {
                merchant_reference_id,
            }),
            ..item.data
        })
    }
}

#[derive(Debug, Serialize)]
pub struct ChargebeeCustomerCreateRequest {
    #[serde(rename = "id")]
    pub customer_id: CustomerId,
    #[serde(rename = "first_name")]
    pub name: Option<String>,
    pub email: Option<pii::Email>,
    pub billing_address: Option<api_models::payments::AddressDetails>,
}

impl TryFrom<&ChargebeeRouterData<&hyperswitch_domain_models::types::CreateCustomerRouterData>>
    for ChargebeeCustomerCreateRequest
{
    type Error = error_stack::Report<errors::ConnectorError>;

    fn try_from(
        item: &ChargebeeRouterData<&hyperswitch_domain_models::types::CreateCustomerRouterData>,
    ) -> Result<Self, Self::Error> {
        let req = &item.router_data.request;

        Ok(Self {
            customer_id: req
                .customer_id
                .as_ref()
                .ok_or_else(|| errors::ConnectorError::MissingRequiredField {
                    field_name: "customer_id",
                })?
                .clone(),
            name: req.name.as_ref().map(|n| n.clone().expose()),
            email: req.email.clone(),
            billing_address: req.billing_address.clone(),

Review comment (security):
```suggestion
    pub name: Option<Secret<String>>,
```

Code after:
            InvoiceRecordBackResponse,
        >,
    > for InvoiceRecordBackRouterData
{
    type Error = error_stack::Report<errors::ConnectorError>;
    fn try_from(
        item: ResponseRouterData<
            InvoiceRecordBack,
            ChargebeeRecordbackResponse,
            InvoiceRecordBackRequest,
            InvoiceRecordBackResponse,
        >,
    ) -> Result<Self, Self::Error> {
        let merchant_reference_id = item.response.invoice.id;
        Ok(Self {
            response: Ok(InvoiceRecordBackResponse {
                merchant_reference_id,
            }),
            ..item.data
        })
    }
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ChargebeeListPlansResponse {
    pub list: Vec<ChargebeeItemList>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ChargebeeItemList {
    pub item: ChargebeeItem,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ChargebeeItem {
    pub id: String,
    pub name: String,
    #[serde(rename = "type")]
    pub plan_type: String,
    pub is_giftable: bool,
    pub enabled_for_checkout: bool,
    pub enabled_in_portal: bool,
    pub metered: bool,
    pub deleted: bool,
    pub description: Option<String>,
}

impl<F, T>
    TryFrom<ResponseRouterData<F, ChargebeeListPlansResponse, T, GetSubscriptionPlansResponse>>
    for RouterData<F, T, GetSubscriptionPlansResponse>
{