Skip to content

Commit

Permalink
Fix urlencoding for bool params
Browse files Browse the repository at this point in the history
  • Loading branch information
bhelx committed Nov 17, 2017
1 parent 47c081b commit 5b16f4d
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions recurly/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
from six.moves import http_client
from six.moves.urllib.parse import urlencode, urlsplit, quote

def urlencode_params(args):
# Need to make bools lowercase
for k, v in six.iteritems(args):
if isinstance(v, bool):
args[k] = str(v).lower()
return urlencode(args)

class Money(object):

"""An amount of money in one or more currencies."""
Expand Down Expand Up @@ -514,7 +521,7 @@ def update_from_element(self, elem):
def _make_actionator(self, url, method, extra_handler=None):
def actionator(*args, **kwargs):
if kwargs:
full_url = '%s?%s' % (url, urlencode(kwargs))
full_url = '%s?%s' % (url, urlencode_params(kwargs))
else:
full_url = url

Expand Down Expand Up @@ -574,7 +581,7 @@ def __getattr__(self, name):
def make_relatitator(url):
def relatitator(**kwargs):
if kwargs:
full_url = '%s?%s' % (url, urlencode(kwargs))
full_url = '%s?%s' % (url, urlencode_params(kwargs))
else:
full_url = url

Expand Down Expand Up @@ -608,7 +615,7 @@ def all(cls, **kwargs):
"""
url = recurly.base_uri() + cls.collection_path
if kwargs:
url = '%s?%s' % (url, urlencode(kwargs))
url = '%s?%s' % (url, urlencode_params(kwargs))
return Page.page_for_url(url)

@classmethod
Expand All @@ -618,7 +625,7 @@ def count(cls, **kwargs):
"""
url = recurly.base_uri() + cls.collection_path
if kwargs:
url = '%s?%s' % (url, urlencode(kwargs))
url = '%s?%s' % (url, urlencode_params(kwargs))
return Page.count_for_url(url)

def save(self):
Expand Down

0 comments on commit 5b16f4d

Please sign in to comment.