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.
Files changed (49) hide show
  1. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/PKG-INFO +1 -1
  2. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/pyproject.toml +1 -1
  3. fmconsult_utils_python_sdk-2.0.8/src/fmconsult/exceptions/bad_request_exception.py +13 -0
  4. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/http/api.py +27 -6
  5. {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
  6. fmconsult_utils_python_sdk-2.0.6/src/fmconsult/exceptions/bad_request_exception.py +0 -7
  7. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/LICENSE +0 -0
  8. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/README.md +0 -0
  9. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/setup.cfg +0 -0
  10. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/__init__.py +0 -0
  11. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/__init__.py +0 -0
  12. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/auth/__init__.py +0 -0
  13. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/auth/decorator.py +0 -0
  14. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/auth/profile_builder.py +0 -0
  15. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/auth/token_manager.py +0 -0
  16. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/database/__init__.py +0 -0
  17. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/database/connection.py +0 -0
  18. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/database/models/__init__.py +0 -0
  19. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/database/models/application.py +0 -0
  20. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/database/models/base.py +0 -0
  21. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/database/models/city.py +0 -0
  22. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/database/models/country.py +0 -0
  23. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/database/models/state.py +0 -0
  24. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/decorators/__init__.py +0 -0
  25. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/decorators/auth.py +0 -0
  26. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/exceptions/__init__.py +0 -0
  27. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/exceptions/authorization.py +0 -0
  28. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/exceptions/conflict_exception.py +0 -0
  29. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/exceptions/forbidden_exception.py +0 -0
  30. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/exceptions/not_found_exception.py +0 -0
  31. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/exceptions/not_implemented_exception.py +0 -0
  32. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/exceptions/unauthorized_exception.py +0 -0
  33. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/exceptions/unavailable_exception.py +0 -0
  34. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/http/__init__.py +0 -0
  35. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/utils/__init__.py +0 -0
  36. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/utils/cast.py +0 -0
  37. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/utils/cnpj.py +0 -0
  38. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/utils/configs.py +0 -0
  39. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/utils/cpf.py +0 -0
  40. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/utils/date.py +0 -0
  41. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/utils/enum.py +0 -0
  42. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/utils/haversine.py +0 -0
  43. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/utils/object.py +0 -0
  44. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/utils/pagination.py +0 -0
  45. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/utils/string.py +0 -0
  46. {fmconsult_utils_python_sdk-2.0.6 → fmconsult_utils_python_sdk-2.0.8}/src/fmconsult/utils/url.py +0 -0
  47. {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
  48. {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
  49. {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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fmconsult-utils-python-sdk
3
- Version: 2.0.6
3
+ Version: 2.0.8
4
4
  Summary: Canivete suiço da FMConsult
5
5
  Author-email: Filipe Coelho <filipe@fmconsult.com.br>
6
6
  License: MIT License
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "fmconsult-utils-python-sdk"
7
- version = "2.0.6"
7
+ version = "2.0.8"
8
8
  description = "Canivete suiço da FMConsult"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -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)
@@ -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(res.content)
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 res
126
+ return res_data
127
+
110
128
  except UnavailableException as e:
111
129
  raise e
112
- except BadRequestException as e:
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fmconsult-utils-python-sdk
3
- Version: 2.0.6
3
+ Version: 2.0.8
4
4
  Summary: Canivete suiço da FMConsult
5
5
  Author-email: Filipe Coelho <filipe@fmconsult.com.br>
6
6
  License: MIT License
@@ -1,7 +0,0 @@
1
- class BadRequestException(Exception):
2
-
3
- def __init__(self, message="he request is malformed or missing required parameters"):
4
- self.message = message
5
- self.status_code = 400
6
- self.status = 'bad request'
7
- super().__init__(self.message)