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

Code before:
        Ok(RequestContent::FormUrlEncoded(Box::new(connector_req)))
    }

    fn build_request(
        &self,
        req: &hyperswitch_domain_models::types::CreateCustomerRouterData,
        connectors: &Connectors,
    ) -> CustomResult<Option<Request>, errors::ConnectorError> {
        Ok(Some(
            RequestBuilder::new()
                .method(Method::Post)
                .url(&types::CreateCustomerType::get_url(self, req, connectors)?)
                .attach_default_headers()
                .headers(types::CreateCustomerType::get_headers(
                    self, req, connectors,
                )?)
                .set_body(types::CreateCustomerType::get_request_body(
                    self, req, connectors,
                )?)
                .build(),
        ))
    }

    fn handle_response(
        &self,
        data: &hyperswitch_domain_models::types::CreateCustomerRouterData,
        event_builder: Option<&mut ConnectorEvent>,
        res: Response,
    ) -> CustomResult<
        hyperswitch_domain_models::types::CreateCustomerRouterData,
        errors::ConnectorError,
    > {
        let response: chargebee::ChargebeeCustomerCreateResponse = res
            .response
            .parse_struct("ChargebeeCustomerCreateResponse")
            .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)

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

Code after:
    fn get_url(
        &self,
        req: &GetSubscriptionPlansRouterData,
        connectors: &Connectors,
    ) -> CustomResult<String, errors::ConnectorError> {
        let query_params = get_chargebee_plans_query_params(req)?;
        let metadata: chargebee::ChargebeeMetadata =
            utils::to_connector_meta_from_secret(req.connector_meta_data.clone())?;

        let site = metadata.site.peek();

        let mut base = self.base_url(connectors).to_string();

        base = base.replace("{{merchant_endpoint_prefix}}", site);
        base = base.replace("$", site);

        if base.contains("{{merchant_endpoint_prefix}}") || base.contains('$') {
            return Err(errors::ConnectorError::InvalidConnectorConfig {
                config: "Chargebee base_url has an unresolved placeholder (expected `$` or `{{merchant_endpoint_prefix}}`).",
            }
            .into());
        }

        if !base.ends_with('/') {
            base.push('/');
        }

        let url = format!("{base}v2/items{query_params}");
        Ok(url)
    }

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

    fn build_request(
        &self,
        req: &GetSubscriptionPlansRouterData,
        connectors: &Connectors,
    ) -> CustomResult<Option<Request>, errors::ConnectorError> {
        Ok(Some(
            RequestBuilder::new()
                .method(Method::Get)
                .url(&types::GetSubscriptionPlansType::get_url(
                    self, req, connectors,
                )?)
                .attach_default_headers()
                .headers(types::GetSubscriptionPlansType::get_headers(
                    self, req, connectors,
                )?)
                .build(),