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

Code before:
            .parse_struct("chargebee ChargebeeRecordbackResponse")
            .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
        event_builder.map(|i| i.set_response_body(&response));
        router_env::logger::info!(connector_response=?response);
        RouterData::try_from(ResponseRouterData {
            response,
            data: data.clone(),
            http_code: res.status_code,
        })
    }

    fn get_error_response(
        &self,
        res: Response,
        event_builder: Option<&mut ConnectorEvent>,
    ) -> CustomResult<ErrorResponse, errors::ConnectorError> {
        self.build_error_response(res, event_builder)
    }
}

impl ConnectorIntegration<CreateConnectorCustomer, ConnectorCustomerData, PaymentsResponseData>
    for Chargebee
{
    fn get_headers(
        &self,
        req: &hyperswitch_domain_models::types::CreateCustomerRouterData,
        connectors: &Connectors,
    ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
        self.build_headers(req, connectors)
    }

    fn get_url(
        &self,
        _req: &hyperswitch_domain_models::types::CreateCustomerRouterData,
        connectors: &Connectors,
    ) -> CustomResult<String, errors::ConnectorError> {
        let url = self
            .base_url(connectors)
            .to_string()
            .replace("$", "hyperswitch-juspay-test"); // TODO: replace with metadata.site
        Ok(format!("{url}v2/customers"))
    }

    fn get_content_type(&self) -> &'static str {
        self.common_get_content_type()
    }

    fn get_request_body(
        &self,
        req: &hyperswitch_domain_models::types::CreateCustomerRouterData,
        _connectors: &Connectors,

Review comment (suggestion):
```suggestion
        req: &CreateCustomerRouterData,
```

Code after:
        res: Response,
    ) -> CustomResult<InvoiceRecordBackRouterData, errors::ConnectorError> {
        let response: chargebee::ChargebeeRecordbackResponse = res
            .response
            .parse_struct("chargebee ChargebeeRecordbackResponse")
            .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
        event_builder.map(|i| i.set_response_body(&response));
        router_env::logger::info!(connector_response=?response);
        RouterData::try_from(ResponseRouterData {
            response,
            data: data.clone(),
            http_code: res.status_code,
        })
    }

    fn get_error_response(
        &self,
        res: Response,
        event_builder: Option<&mut ConnectorEvent>,
    ) -> CustomResult<ErrorResponse, errors::ConnectorError> {
        self.build_error_response(res, event_builder)
    }
}

fn get_chargebee_plans_query_params(
    _req: &RouterData<
        GetSubscriptionPlans,
        GetSubscriptionPlansRequest,
        GetSubscriptionPlansResponse,
    >,
) -> CustomResult<String, errors::ConnectorError> {
    // Try to get limit from request, else default to 10
    let limit = _req.request.limit.unwrap_or(10);
    let param = format!("?limit={}&type[is]={}", limit, constants::PLAN_ITEM_TYPE);
    Ok(param)
}

impl api::subscriptions::Subscriptions for Chargebee {}
impl api::subscriptions::GetSubscriptionPlansFlow for Chargebee {}

impl
    ConnectorIntegration<
        GetSubscriptionPlans,
        GetSubscriptionPlansRequest,
        GetSubscriptionPlansResponse,
    > for Chargebee
{
    fn get_headers(
        &self,
        req: &GetSubscriptionPlansRouterData,
        connectors: &Connectors,