Skip to content
Browse files

Merge pull request #30 from stripe/expand

Support expand in python retrieval.
  • Loading branch information...
2 parents 82d4da3 + f62df7a commit 1500228abf794e6631331b431e4fddffe342a047 @boucher boucher committed
Showing with 22 additions and 6 deletions.
  1. +5 −0 CHANGELOG
  2. +1 −1 VERSION
  3. +15 −4 stripe/__init__.py
  4. +1 −1 stripe/version.py
View
5 CHANGELOG
@@ -1,3 +1,8 @@
+=== 1.7.9 2013-02-01
+
+* Add support for passing options when retrieving Stripe objects
+ e.g., stripe.Charge.retrieve("foo", params={"expand":["customer"]})
+
=== 1.7.8 2013-01-15
* Add support for setting a Stripe API version override.
View
2 VERSION
@@ -1 +1 @@
-1.7.8
+1.7.9
View
19 stripe/__init__.py
@@ -156,6 +156,14 @@ def encode_dict(cls, stk, key, dictvalue):
n["%s[%s]" % (key, k)] = v
stk.extend(cls._encode_inner(n))
+
+ @classmethod
+ def encode_list(cls, stk, key, listvalue):
+ n = []
+ for v in listvalue:
+ v = cls._utf8(v)
+ stk.append(("%s[]" % (key), v))
+
@classmethod
def encode_datetime(cls, stk, key, dttime):
utc_timestamp = int(time.mktime(dttime.timetuple()))
@@ -175,6 +183,7 @@ def _encode_inner(cls, d):
"""
# special case value encoding
ENCODERS = {
+ list: cls.encode_list,
dict: cls.encode_dict,
datetime.datetime: cls.encode_datetime,
types.NoneType: cls.encode_none,
@@ -456,10 +465,12 @@ def handle_urllib2_error(self, e, abs_url):
class StripeObject(object):
_permanent_attributes = set(['api_key'])
- def __init__(self, id=None, api_key=None):
+ def __init__(self, id=None, api_key=None, **params):
self.__dict__['_values'] = set()
self.__dict__['_unsaved_values'] = set()
self.__dict__['_transient_values'] = set()
+ self.__dict__['_retrieve_params'] = params
+
self.__dict__['api_key'] = api_key
if id:
@@ -588,15 +599,15 @@ def _ident(self):
return [self.get('id')]
@classmethod
- def retrieve(cls, id, api_key=None):
- instance = cls(id, api_key)
+ def retrieve(cls, id, api_key=None, **params):
+ instance = cls(id, api_key, **params)
instance.refresh()
return instance
def refresh(self):
requestor = APIRequestor(self.api_key)
url = self.instance_url()
- response, api_key = requestor.request('get', url)
+ response, api_key = requestor.request('get', url, self._retrieve_params)
self.refresh_from(response, api_key)
return self
View
2 stripe/version.py
@@ -1 +1 @@
-VERSION = '1.7.8'
+VERSION = '1.7.9'

0 comments on commit 1500228

Please sign in to comment.
Something went wrong with that request. Please try again.