Skip to content

Commit 8915bb8

Browse files
authored
Chore/new exception type (#95)
* new exception type addition * Bug Fix: double parsing of json request one by chargebee-python and other by httpx
1 parent fe8de83 commit 8915bb8

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

chargebee/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
PaymentError,
44
InvalidRequestError,
55
OperationFailedError,
6+
UbbBatchIngestionInvalidRequestError,
67
)
78
from chargebee.filters import Filters
89
from chargebee.main import Chargebee

chargebee/api_error.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
class APIError(Exception):
2+
23
def __init__(self, http_code, json_obj, headers=None):
34
Exception.__init__(self, json_obj.get("message"))
45
self.json_obj = json_obj
@@ -27,3 +28,10 @@ def __init__(self, http_code, json_obj, headers=None):
2728
class OperationFailedError(APIError):
2829
def __init__(self, http_code, json_obj, headers=None):
2930
APIError.__init__(self, http_code, json_obj, headers)
31+
32+
33+
class UbbBatchIngestionInvalidRequestError(APIError):
34+
def __init__(self, http_code, json_obj, headers=None):
35+
APIError.__init__(self, http_code, json_obj, headers)
36+
self.batch_id = json_obj.get("batch_id")
37+
self.failed_events = json_obj.get("failed_events")

chargebee/http_request.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
PaymentError,
1515
InvalidRequestError,
1616
OperationFailedError,
17+
UbbBatchIngestionInvalidRequestError,
1718
)
1819
from chargebee import compat, util, environment
1920
from chargebee.main import Chargebee
@@ -365,5 +366,9 @@ def handle_api_resp_error(url, http_code, resp_json, response_headers=None):
365366
raise OperationFailedError(http_code, resp_json, response_headers)
366367
elif "invalid_request" == resp_json.get("type"):
367368
raise InvalidRequestError(http_code, resp_json, response_headers)
369+
elif "ubb_batch_ingestion_invalid_request" == resp_json.get("type"):
370+
raise UbbBatchIngestionInvalidRequestError(
371+
http_code, resp_json, response_headers
372+
)
368373
else:
369374
raise APIError(http_code, resp_json, response_headers)

chargebee/request.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def send(
7070
params = {}
7171

7272
ser_params = (
73-
json.dumps(params)
73+
params
7474
if isJsonRequest
7575
else util.serialize(params, None, None, jsonKeys)
7676
)

0 commit comments

Comments
 (0)