Skip to content

Commit 5680ccf

Browse files
committed
Add support for boolean query params
1 parent dcc59d2 commit 5680ccf

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

chartmogul/api/data_source.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,6 @@ class DataSource(Resource):
4242
defaults=[None, None, None]
4343
)
4444

45-
@classmethod
46-
def _preProcessParams(cls, params):
47-
params = super()._preProcessParams(params)
48-
49-
for query_param in cls._bool_query_params:
50-
if query_param in params and isinstance(params[query_param], bool):
51-
if params[query_param] is True:
52-
params[query_param] = 'true'
53-
else:
54-
del params[query_param]
55-
56-
return params
57-
5845
class _Schema(Schema):
5946
uuid = fields.String()
6047
name = fields.String()

chartmogul/api/invoice.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ class Invoice(Resource):
4040

4141
_path = "/import/customers{/uuid}/invoices"
4242
_root_key = "invoices"
43+
_bool_query_params = [
44+
'include_edit_histories',
45+
'with_disabled'
46+
]
4347
_many = namedtuple(
4448
"Invoices",
4549
[_root_key, "cursor", "has_more", "customer_uuid"],

chartmogul/resource.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,15 @@ def _preProcessParams(cls, params):
121121
if key in params:
122122
params[replacement] = params[key]
123123
del params[key]
124+
125+
if hasattr(cls, '_bool_query_params'):
126+
for query_param in cls._bool_query_params:
127+
if query_param in params and isinstance(params[query_param], bool):
128+
if params[query_param] is True:
129+
params[query_param] = 'true'
130+
elif params[query_param] is False:
131+
params[query_param] = 'false'
132+
124133
return params
125134

126135
@classmethod

0 commit comments

Comments
 (0)