fmconsult-utils-python-sdk 2.0.6__tar.gz → 2.0.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/PKG-INFO +1 -1
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/pyproject.toml +1 -1
- fmconsult_utils_python_sdk-2.0.8/src/fmconsult/exceptions/bad_request_exception.py +13 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/http/api.py +27 -6
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult_utils_python_sdk.egg-info/PKG-INFO +1 -1
- fmconsult_utils_python_sdk-2.0.6/src/fmconsult/exceptions/bad_request_exception.py +0 -7
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/LICENSE +0 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/README.md +0 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/setup.cfg +0 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/__init__.py +0 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/__init__.py +0 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/auth/__init__.py +0 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/auth/decorator.py +0 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/auth/profile_builder.py +0 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/auth/token_manager.py +0 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/database/__init__.py +0 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/database/connection.py +0 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/database/models/__init__.py +0 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/database/models/application.py +0 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/database/models/base.py +0 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/database/models/city.py +0 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/database/models/country.py +0 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/database/models/state.py +0 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/decorators/__init__.py +0 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/decorators/auth.py +0 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/exceptions/__init__.py +0 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/exceptions/authorization.py +0 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/exceptions/conflict_exception.py +0 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/exceptions/forbidden_exception.py +0 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/exceptions/not_found_exception.py +0 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/exceptions/not_implemented_exception.py +0 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/exceptions/unauthorized_exception.py +0 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/exceptions/unavailable_exception.py +0 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/http/__init__.py +0 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/utils/__init__.py +0 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/utils/cast.py +0 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/utils/cnpj.py +0 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/utils/configs.py +0 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/utils/cpf.py +0 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/utils/date.py +0 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/utils/enum.py +0 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/utils/haversine.py +0 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/utils/object.py +0 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/utils/pagination.py +0 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/utils/string.py +0 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/utils/url.py +0 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult_utils_python_sdk.egg-info/SOURCES.txt +0 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult_utils_python_sdk.egg-info/dependency_links.txt +0 -0
- {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult_utils_python_sdk.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
class BadRequestException(Exception):
|
|
2
|
+
|
|
3
|
+
def __init__(self,
|
|
4
|
+
message="he request is malformed or missing required parameters",
|
|
5
|
+
response_body=None,
|
|
6
|
+
request_details=None
|
|
7
|
+
):
|
|
8
|
+
self.status = 'bad request'
|
|
9
|
+
self.message = message
|
|
10
|
+
self.status_code = 400
|
|
11
|
+
self.response_body = response_body
|
|
12
|
+
self.request_details = request_details
|
|
13
|
+
super().__init__(self.message)
|
{fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/http/api.py
RENAMED
|
@@ -34,11 +34,13 @@ class ApiBase(object):
|
|
|
34
34
|
res = requests.request(**req_args, timeout=60)
|
|
35
35
|
res.raise_for_status() # Verifica se ocorreu algum erro HTTP
|
|
36
36
|
return res
|
|
37
|
+
|
|
37
38
|
except (ConnectionError, ChunkedEncodingError) as e:
|
|
38
39
|
logging.error(e)
|
|
39
40
|
logging.error(f"Connection error occurred: {e}. Retrying {attempt + 1}/{max_retries}...")
|
|
40
41
|
if attempt == max_retries - 1:
|
|
41
42
|
raise # Lança a exceção se o limite de tentativas for atingido
|
|
43
|
+
|
|
42
44
|
except requests.exceptions.RequestException as e:
|
|
43
45
|
logging.error(e)
|
|
44
46
|
logging.error(f"An error occurred: {e}")
|
|
@@ -87,31 +89,50 @@ class ApiBase(object):
|
|
|
87
89
|
logging.info(req_args)
|
|
88
90
|
|
|
89
91
|
res = self.__make_request(req_args)
|
|
92
|
+
|
|
93
|
+
res_data = None
|
|
94
|
+
try:
|
|
95
|
+
res_data = res.json()
|
|
96
|
+
except ValueError:
|
|
97
|
+
res_data = res.text
|
|
98
|
+
|
|
99
|
+
logging.info(res_data)
|
|
90
100
|
|
|
91
101
|
if res.status_code == 503:
|
|
92
102
|
raise UnavailableException()
|
|
103
|
+
|
|
93
104
|
elif res.status_code == 404:
|
|
94
105
|
raise NotFoundException(res.content)
|
|
106
|
+
|
|
95
107
|
elif res.status_code == 409:
|
|
96
108
|
raise ConflictException(res.content)
|
|
109
|
+
|
|
97
110
|
elif res.status_code == 401:
|
|
98
111
|
raise UnauthorizedException(res.content)
|
|
112
|
+
|
|
99
113
|
elif res.status_code == 400:
|
|
100
|
-
raise BadRequestException(
|
|
114
|
+
raise BadRequestException(
|
|
115
|
+
message='Bad request from API',
|
|
116
|
+
response_body=res_data,
|
|
117
|
+
request_details=req_args
|
|
118
|
+
)
|
|
119
|
+
|
|
101
120
|
elif res.status_code != 200:
|
|
102
121
|
raise Exception(res.content)
|
|
103
122
|
|
|
104
|
-
res = res.content.decode('utf-8')
|
|
105
|
-
|
|
106
123
|
logging.info(f'{str(http_method).upper()} response:')
|
|
107
124
|
logging.info(jsonpickle.encode(res))
|
|
108
125
|
|
|
109
|
-
return
|
|
126
|
+
return res_data
|
|
127
|
+
|
|
110
128
|
except UnavailableException as e:
|
|
111
129
|
raise e
|
|
112
|
-
|
|
113
|
-
raise e
|
|
130
|
+
|
|
114
131
|
except NotFoundException as e:
|
|
115
132
|
raise e
|
|
133
|
+
|
|
134
|
+
except BadRequestException as e:
|
|
135
|
+
raise e
|
|
136
|
+
|
|
116
137
|
except Exception as e:
|
|
117
138
|
raise e
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/__init__.py
RENAMED
|
File without changes
|
{fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/auth/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/http/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/utils/cast.py
RENAMED
|
File without changes
|
{fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/utils/cnpj.py
RENAMED
|
File without changes
|
{fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/utils/configs.py
RENAMED
|
File without changes
|
{fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/utils/cpf.py
RENAMED
|
File without changes
|
{fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/utils/date.py
RENAMED
|
File without changes
|
{fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/utils/enum.py
RENAMED
|
File without changes
|
|
File without changes
|
{fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/utils/object.py
RENAMED
|
File without changes
|
|
File without changes
|
{fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/utils/string.py
RENAMED
|
File without changes
|
{fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/utils/url.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|