Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion examples/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,23 @@
print "======================================================="
print "\n"

# Creating a Check using the previously created bank account
# Verifying a Bank Account with the microdeposit amounts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens when you try to verify an account that has already been verified?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It errors

On Mon, Apr 20, 2015 at 12:38 PM, Leore Avidar notifications@github.com
wrote:

@@ -47,7 +47,23 @@
print "======================================================="
print "\n"

-# Creating a Check using the previously created bank account
+# Verifying a Bank Account with the microdeposit amounts

what happens when you try to verify an account that has already been verified?

Reply to this email directly or view it on GitHub:
https://github.com/lob/lob-python/pull/64/files#r28721371

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pon @elnaz having the verify process in the check example might be weird if you cannot verify a bank over and over again

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think this will work then.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will - the bank account is created above

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh yep.


example_bank_account = lob.BankAccount.verify(
id = example_bank_account.id,
amounts = [23, 77]
)

print "Bank Account Verify Response"
print "\n"
print "======================================================="
print "\n"
print example_bank_account
print "\n"
print "======================================================="
print "\n"

# Creating a Check using the previously created and verified bank account

example_check = lob.Check.create(
name = 'Example Check',
Expand Down
9 changes: 8 additions & 1 deletion lob/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ def create(cls, **params):
response = requestor.request('post', cls.endpoint, params)
return lob_format(response)

class VerifiableAPIResource(APIResource):
@classmethod
def verify(cls, id, **params):
requestor = api_requestor.APIRequestor()
response = requestor.request('post', '%s/%s/verify' % (cls.endpoint, id), params)
return lob_format(response)

class Address(ListableAPIResource, DeleteableAPIResource, CreateableAPIResource):
endpoint = '/addresses'

Expand All @@ -127,7 +134,7 @@ def create(cls, **params):
params['routes'] = routes
return super(Area, cls).create(**params)

class BankAccount(ListableAPIResource, DeleteableAPIResource, CreateableAPIResource):
class BankAccount(ListableAPIResource, DeleteableAPIResource, CreateableAPIResource, VerifiableAPIResource):
endpoint = '/bank_accounts'

class Check(ListableAPIResource, CreateableAPIResource):
Expand Down
25 changes: 24 additions & 1 deletion tests/test_bankaccount.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,32 @@ def test_retrieve_bankAccount(self):
def test_retrieve_bankAccount_fail(self):
self.assertRaises(lob.error.InvalidRequestError, lob.BankAccount.retrieve, id='test')


def test_delete_bankAccount(self):
ba = lob.BankAccount.list().data[0].id
delBa = lob.BankAccount.delete(id=ba)
self.assertEqual(ba, delBa.id)

def test_verify_bankAccount(self):
ba = lob.BankAccount.create(
routing_number='122100024',
account_number='223456789',
bank_address= {
'name': 'Lob1',
'address_line1': '185 Berry Street',
'address_line2': 'Suite 1510',
'address_city': 'San Francisco',
'address_zip': '94107',
'address_state': 'CA'
},
account_address= {
'name': 'Lob2',
'address_line1': '185 Berry Street',
'address_line2': 'Suite 1510',
'address_city': 'San Francisco',
'address_zip': '94107',
'address_state': 'CA'
},
signatory='John Doe'
)
verBa = lob.BankAccount.verify(id=ba.id, amounts=[25, 75])
self.assertTrue(verBa.verified)
2 changes: 2 additions & 0 deletions tests/test_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ def setUp(self):
lob.api_key = 'test_0dc8d51e0acffcb1880e0f19c79b2f5b0cc'
self.addr = lob.Address.list(count=1).data[0]
self.ba = lob.BankAccount.list(count=1).data[0]
if self.ba.verified == False:
lob.BankAccount.verify(id=self.ba.id, amounts=[20,80])

def test_list_checks(self):
checks = lob.Check.list()
Expand Down