10000 check for optional params · balanced/balanced-python@c6a0f3c · GitHub
[go: up one dir, main page]

Skip to content

Commit c6a0f3c

Browse files
author
Marc Sherry
committed
check for optional params
1 parent 8575ae2 commit c6a0f3c

File tree

3 files changed

+27
-23
lines changed

3 files changed

+27
-23
lines changed

balanced/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = '0.8.8'
1+
__version__ = '0.8.9'
22
from collections import defaultdict
33
import contextlib
44

balanced/resources.py

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -480,12 +480,13 @@ def debit(self, amount=None, appears_on_statement_as=None,
480480
source_uri=source_uri,
481481
).save()
482482

483-
def hold(self, amount, meta=None, source_uri=None):
483+
def hold(self, amount, description=None, meta=None, source_uri=None):
484484
meta = meta or {}
485485
return Hold(
486486
uri=self.holds_uri,
487487
amount=amount,
488488
meta=meta,
489+
description=description,
489490
source_uri=source_uri,
490491
).save()
491492

@@ -561,30 +562,30 @@ def create_card(self,
561562
country_code=None,
562563
phone_number=None,
563564
):
564-
return Card(
565-
card_number=card_number,
566-
expiration_month=expiration_month,
567-
expiration_year=expiration_year,
568-
name=name,
569-
security_code=security_code,
570-
street_address=street_address,
571-
postal_code=postal_code,
572-
city=city,
573-
region=region,
574-
country_code=country_code,
575-
phone_number=phone_number,
576-
).save()
565+
return Card(
566+
card_number=card_number,
567+
expiration_month=expiration_month,
568+
expiration_year=expiration_year,
569+
name=name,
570+
security_code=security_code,
571+
street_address=street_address,
572+
postal_code=postal_code,
573+
city=city,
574+
region=region,
575+
country_code=country_code,
576+
phone_number=phone_number,
577+
).save()
577578

578579
def create_bank_account(self,
579580
name,
580581
account_number,
581582
bank_code,
582583
):
583-
return BankAccount(
584-
name=name,
585-
account_number=account_number,
586-
bank_code=bank_code,
587-
).save()
584+
return BankAccount(
585+
name=name,
586+
account_number=account_number,
587+
bank_code=bank_code,
588+
).save()
588589

589590
def create_buyer(self, email_address, card_uri, name=None, meta=None):
590591
meta = meta or {}
@@ -625,12 +626,14 @@ def save(self):
625626
class Debit(Resource):
626627
__metaclass__ = resource_base(collection='debits')
627628

628-
def refund(self, amount=None, description=None):
629+
def refund(self, amount=None, description=None, meta=None):
630+
meta = meta or {}
629631
return Refund(
630632
uri=self.refunds_uri,
631633
debit_uri=self.uri,
632634
amount=amount,
633-
description=description
635+
description=description,
636+
meta=meta,
634637
).save()
635638

636639

tests/suite.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,11 @@ def test_06_debit_buyer_account_and_refund(self):
223223

224224
def test_07_create_hold_and_void_it(self):
225225
account = self._find_account('buyer')
226-
hold = account.hold(amount=1500)
226+
hold = account.hold(amount=1500, description='Hold me')
227227
self.assertEqual(hold.fee, 35)
228228
self.assertEqual(hold.account.uri, account.uri)
229229
self.assertFalse(hold.is_void)
230+
self.assertEqual(hold.description, 'Hold me')
230231
hold.void()
231232
self.assertTrue(hold.is_void)
232233
self.assertEqual(hold.fee, 35) # fee still the same

0 commit comments

Comments
 (0)
291A
0