def request(<EOL>self, method, endpoint=None, headers=None, use_auth=True,<EOL>_url=None, _kwargs=None, **kwargs):
full_url = _url if _url else "<STR_LIT>".format(self.base_url, endpoint)<EOL>if not headers:<EOL><INDENT>headers = {}<EOL><DEDENT>if use_auth:<EOL><INDENT>auth_header = {'<STR_LIT>': '<STR_LIT>'.format(self.access_token)}<EOL>headers.update(auth_header)<EOL><DEDENT>_kwargs = _kwargs or []<EOL>_kwargs.extend(kwargs.items())<EOL>for i, kwarg in enumerate(_kwargs):<EOL><INDENT>kw, arg = kwarg<EOL>if isinstance(arg, bool):<EOL><INDENT>_kwargs[i] = (kw, str(arg).lower())<EOL><DEDENT>elif isinstance(arg, datetime):<EOL><INDENT>_kwargs[i] = (kw, arg.isoformat())<EOL><DEDENT><DEDENT>if method == '<STR_LIT:GET>':<EOL><INDENT>req_method = self._get_request<EOL><DEDENT>elif method == '<STR_LIT:POST>':<EOL><INDENT>req_method = self._post_request<EOL><DEDENT>elif method == '<STR_LIT>':<EOL><INDENT>req_method = self._delete_request<EOL><DEDENT>elif method == '<STR_LIT>':<EOL><INDENT>req_method = self._put_request<EOL><DEDENT>response = req_method(full_url, headers, _kwargs)<EOL>if len(self._cache) > <NUM_LIT:4>:<EOL><INDENT>self._cache.pop()<EOL><DEDENT>self._cache.insert(<NUM_LIT:0>, response)<EOL>if response.status_code == <NUM_LIT>:<EOL><INDENT>raise BadRequest(response.text)<EOL><DEDENT>elif response.status_code == <NUM_LIT>:<EOL><INDENT>if '<STR_LIT>' in response.headers:<EOL><INDENT>raise InvalidAccessToken(response.json())<EOL><DEDENT>else:<EOL><INDENT>raise Unauthorized(response.json())<EOL><DEDENT><DEDENT>elif response.status_code == <NUM_LIT>:<EOL><INDENT>raise Forbidden(response.text)<EOL><DEDENT>elif response.status_code == <NUM_LIT>:<EOL><INDENT>raise ResourceDoesNotExist('<STR_LIT>')<EOL><DEDENT>elif response.status_code == <NUM_LIT>:<EOL><INDENT>raise Conflict(response.text)<EOL><DEDENT>elif response.status_code == <NUM_LIT>:<EOL><INDENT>raise CanvasException("<STR_LIT>")<EOL><DEDENT>return response<EOL>
Make a request to the Canvas API and return the response.

:param method: The HTTP method for the request.
:type method: str
:param endpoint: The endpoint to call.
:type endpoint: str
:param headers: Optional HTTP headers to be sent with the request.
:type headers: dict
:param use_auth: Optional flag to remove the authentication
    header from the request.
:type use_auth: bool
:param _url: Optional argument to send a request to a URL
    outside of the Canvas API. If this is selected and an
    endpoint is provided, the endpoint will be ignored and
    only the _url argument will be used.
:type _url: str
:param _kwargs: A list of 2-tuples representing processed
    keyword arguments to be sent to Canvas as params or data.
:type _kwargs: `list`
:rtype: str