Skip to content

Commit

Permalink
bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
saleweaver committed Mar 14, 2023
1 parent 880e0ba commit 625876f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion rest_client/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.0.3'
__version__ = '0.0.4'
14 changes: 10 additions & 4 deletions rest_client/base/client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import json
import logging
import os
from json import JSONDecodeError
from urllib.parse import urljoin
from requests import request

Expand All @@ -11,7 +13,7 @@
from rest_client.__version__ import __version__
from rest_client.base.exceptions import ApiException

log = logger_config(__name__)
log = logger_config(__name__, logging.INFO)


class NoEndpointsExceptions(Exception):
Expand Down Expand Up @@ -73,9 +75,14 @@ def _request(self, data: dict, *args, **kwargs) -> ApiResponse:

self._log_response(res)

try:
response = res.json()
except JSONDecodeError:
response = res.content

if 200 <= res.status_code < 400:
return ApiResponse(res.json(), res.headers, res.status_code)
raise ApiException(res.json(), res.headers, res.status_code)
return ApiResponse(response, res.headers, res.status_code)
raise ApiException(response, res.headers, res.status_code)

def _log_request(self, args, data, kwargs, request_config):
log.debug('Requesting %s', (self._path(request_config.path)))
Expand All @@ -89,7 +96,6 @@ def _log_response(self, res):
log.debug(res.request.headers)
log.debug(res.status_code)
log.debug(res.headers)
log.debug(res.json())

def __getattr__(self, item):
log.debug(f'Requesting endpoint: {item}')
Expand Down

0 comments on commit 625876f

Please sign in to comment.