Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

ensure we specify the funding instrument used on debits, credits, and…

… holds. pep8
  • Loading branch information...
commit dbd5eb5c9701f3e39903d2f9aec01dee4bf03677 1 parent 638e9e2
Balanced Marshall authored
View
4 balanced/__init__.py
@@ -1,4 +1,4 @@
-__version__ = '0.9.2'
+__version__ = '0.9.3'
from collections import defaultdict
import contextlib
@@ -25,7 +25,7 @@
Card.__name__,
BankAccount.__name__,
exc.__name__.partition('.')[-1],
- ]
+]
http_client = HTTPClient()
config = http_client.config
View
6 balanced/config.py
@@ -24,9 +24,9 @@ def __init__(self):
'Accept': 'application/json',
'Content-Type': 'application/json',
'User-agent': _make_user_agent(),
- },
- 'danger_mode': True,
- }
+ },
+ 'danger_mode': True,
+ }
@property
def uri(self):
View
18 balanced/http_client.py
@@ -10,12 +10,12 @@
serializers = {
'application/json': to_json
- }
+}
deserializers = {
'application/json': json.loads
- }
+}
REDIRECT_STATI = list(REDIRECT_STATI)
@@ -40,17 +40,17 @@ def wrapped():
raise redirection
deserialized = http_client.deserialize(
response_instance
- )
+ )
response_instance.deserialized = deserialized
extra = deserialized.get('additional') or ''
if extra:
extra = ' -- {}.'.format(extra)
error_msg = '{name}: {code}: {msg} {extra}'.format(
- name=deserialized['status'],
- code=deserialized['status_code'],
- msg=deserialized['description'].encode('utf8'),
- extra=extra.encode('utf8'),
- )
+ name=deserialized['status'],
+ code=deserialized['status_code'],
+ msg=deserialized['description'].encode('utf8'),
+ extra=extra.encode('utf8'),
+ )
http_error = HTTPError(error_msg)
for error, value in response_instance.deserialized.iteritems():
setattr(http_error, error, value)
@@ -94,7 +94,7 @@ def make_absolute_url(client, url, **kwargs):
kwargs['allow_redirects'] = False
kwargs['hooks'] = {
'response': wrap_raise_for_status(client)
- }
+ }
if client.config.api_key_secret:
kwargs['auth'] = (client.config.api_key_secret, None)
View
7 balanced/resources.py
@@ -927,6 +927,7 @@ def debit(self, amount=None, appears_on_statement_as=None,
hold_uri=hold_uri,
meta=meta,
description=description,
+ source_uri=self.uri,
).save()
def hold(self, amount, meta=None, description=None):
@@ -940,7 +941,8 @@ def hold(self, amount, meta=None, description=None):
uri=self.account.holds_uri,
amount=amount,
meta=meta,
- description=description
+ description=description,
+ source_uri=self.uri,
).save()
@@ -974,6 +976,7 @@ def debit(self, amount, appears_on_statement_as=None,
appears_on_statement_as=appears_on_statement_as,
meta=meta,
description=description,
+ source_uri=self.uri,
).save()
def credit(self, amount, description=None, meta=None):
@@ -992,12 +995,14 @@ def credit(self, amount, description=None, meta=None):
uri = self.account.credits_uri
else:
uri = self.credits_uri
+ destination_uri = self.uri
credit = Credit(
uri=uri,
amount=amount,
description=description,
meta=meta,
+ destination_uri=destination_uri,
)
credit.save()
return credit
View
8 balanced/utils.py
@@ -236,11 +236,11 @@ def __call__(self, serializable):
for serializer in self.serialization_chain:
result = serializer(serializable)
if ((not self.explicit_none_check and result) or
- (self.explicit_none_check and result is not None)):
+ (self.explicit_none_check and result is not None)):
return result
error_msg = _JSON_ERROR_MSG.format(type(serializable),
- repr(serializable))
+ repr(serializable))
raise TypeError(error_msg)
@@ -258,8 +258,8 @@ def handle_datetime(serializable):
def to_json(*args, **kwargs):
return json.dumps(dict(*args, **kwargs),
- use_decimal=True,
- default=json_serializer)
+ use_decimal=True,
+ default=json_serializer)
def urljoin(*args):

1 comment on commit dbd5eb5

@mahmoudimus

+1 looks good to me

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