def METHOD_NAME(
    self, url, accepted_status_codes, function, data, retry_count
):
    while True:
        try:
            if data is None:
                r = function(
                    url,
                    headers=self._headers,
                    auth=self._auth,
                    verify=self.verify_ssl,
                )
            else:
                r = function(
                    url,
                    headers=self._headers,
                    auth=self._auth,
                    data=json.dumps(data),
                    verify=self.verify_ssl,
                )
        except requests.exceptions.RequestException as e:
            error = True
            r = None
            status = None
            text = None
            self.logger.error("Request to '{}' failed with '{}'".format(url, e))
        else:
            error = False
            status = r.status_code
            text = r.text
        if error or status not in accepted_status_codes:
            if self._retry_policy.should_retry(status, error, retry_count):
                sleep(self._retry_policy.seconds_to_sleep(retry_count))
                retry_count += 1
                continue
            if error:
                raise HttpClientException(
                    "Error sending http request and maximum retry encountered."
                )
            else:
                raise HttpClientException(
                    "Invalid status code '{}' from {} with error payload: {}".format(
                        status, url, text
                    )
                )
        return r