Skip to content

Commit da697dd

Browse files
committed
Remove key
1 parent 305eeaf commit da697dd

File tree

2 files changed

+387
-0
lines changed

2 files changed

+387
-0
lines changed

sample_app/helpers.py

Lines changed: 373 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,373 @@
1+
import json
2+
3+
import dwollav2
4+
5+
6+
def display_options():
7+
print('Choose from the following actions: ')
8+
action_menu = '''
9+
Root (R)
10+
Retrieve account details (RAD)
11+
Create account funding source (CAFS)
12+
Create account VAN (CAVAN)
13+
List account funding sources (LAFS)
14+
List and search account transfers (LASAT)
15+
List account mass payments (LAMP)
16+
Create receive only customer (CROC)
17+
Create unverified customer (CUVC)
18+
Create verified personal customer (CVP)
19+
Retrieve customer (RC)
20+
List and search customers (LASC)
21+
Update customer (UC)
22+
List customer business classifications (LCBC)
23+
retrieve business classification (RBC)
24+
initiate KBA (IKBA)
25+
retrieve KBA (RKBA)
26+
verify KBA (VKBA)
27+
Create beneficial owner (CBO)
28+
Reterieve beneficial owner (RBO)
29+
list beneficial owners (LBO)
30+
update beneficial owner (UBO)
31+
Remove beneficial owner (DBO)
32+
Retrieve beneficial ownership status (RBOS)
33+
Certify beneficial ownership (CBOS)
34+
'''
35+
print(action_menu)
36+
37+
def get_user_input():
38+
return input('Enter your action: ')
39+
40+
def handle_input(input, pk, sk):
41+
client = dwollav2.Client(key = pk, secret = sk, environment = 'sandbox')
42+
application_token = client.Auth.client()
43+
if input == 'R':
44+
root(application_token)
45+
elif input == 'RAD':
46+
get_account_details(application_token)
47+
elif input == 'CAFS':
48+
create_account_funding_source(application_token)
49+
elif input == 'CAVAN':
50+
create_account_van(application_token)
51+
elif input == 'LAFS':
52+
list_account_funding_sources(application_token)
53+
elif input == 'LASAT':
54+
list_and_search_account_transfers(application_token)
55+
elif input == 'LAMP':
56+
list_account_mass_payments(application_token)
57+
elif input == 'CROC':
58+
create_receive_only_customer(application_token)
59+
elif input == 'CUVC':
60+
create_unverified_customer(application_token)
61+
elif input == 'CVP':
62+
create_verified_personal_customer(application_token)
63+
elif input == 'RC':
64+
retrieve_customer(application_token)
65+
elif input == 'LASC':
66+
list_and_search_customers(application_token)
67+
elif input == 'UC':
68+
update_customer(application_token)
69+
elif input == 'LCBC':
70+
list_customer_business_classifications(application_token)
71+
elif input == 'RBC':
72+
retrieve_business_classification(application_token)
73+
elif input == 'IKBA':
74+
initiate_kba(application_token)
75+
elif input == 'RKBA':
76+
retrieve_kba(application_token)
77+
elif input == 'VKBA':
78+
verify_kba(application_token)
79+
elif input == 'CBO':
80+
create_beneficial_owner(application_token)
81+
elif input == 'RBO':
82+
retrieve_beneficial_owner(application_token)
83+
elif input == 'LBO':
84+
list_beneficial_owners(application_token)
85+
elif input == 'UBO':
86+
update_beneficial_owner(application_token)
87+
elif input == 'DBO':
88+
remove_beneficial_owner(application_token)
89+
elif input == 'RBOS':
90+
retrieve_beneficial_ownership_status(application_token)
91+
elif input == 'CBOS':
92+
certify_beneficial_ownership(application_token)
93+
94+
95+
def print_response(res):
96+
print(json.dumps(res.body, indent = 4))
97+
98+
# ROOT RESOURCE
99+
def root(token):
100+
res = token.get('/')
101+
print_response(res)
102+
103+
# ACCOUNT RESOURCE
104+
def get_account_details(token):
105+
id = input('Enter your account ID: ')
106+
res = token.get(f'accounts/{id}')
107+
print_response(res)
108+
109+
def create_account_funding_source(token):
110+
accountNumber = input('Enter your account number: ')
111+
routingNumber = input('Enter your routing number: ')
112+
bankAccountType = input('Enter your bank account type: ')
113+
name = input('Enter your funding source nickname: ')
114+
115+
has_channels = input('Does your funding source have channels? (y/n): ')
116+
117+
body = {
118+
'routingNumber': routingNumber,
119+
'accountNumber': accountNumber,
120+
'type': bankAccountType,
121+
'name': name
122+
}
123+
124+
if has_channels == 'y':
125+
channels = input('Enter your channels seperated by commas: ')
126+
channels = channels.split(',')
127+
body['channels'] = channels
128+
129+
130+
res = token.post(f'/funding-sources', body)
131+
print_response(res)
132+
133+
def create_account_van(token):
134+
name = input('Enter your account name: ')
135+
bankAccountType = input('Enter your bank account type: ')
136+
137+
body = {
138+
'name': name,
139+
'type': 'virtual',
140+
'bankAccountType': bankAccountType
141+
}
142+
143+
res = token.post(f'/funding-sources', body)
144+
print_response(res)
145+
146+
def list_account_funding_sources(token):
147+
id = input('Enter your account ID: ')
148+
res = token.get(f'/accounts/{id}/funding-sources')
149+
print_response(res)
150+
151+
def list_and_search_account_transfers(token):
152+
id = input('Enter your account ID: ')
153+
res = token.get(f'/accounts/{id}/transfers')
154+
print_response(res)
155+
156+
def list_account_mass_payments(token):
157+
id = input('Enter your account ID: ')
158+
res = token.get(f'/accounts/{id}/mass-payments')
159+
print_response(res)
160+
161+
# CUSTOMER RESOURCE
162+
def create_receive_only_customer(token):
163+
firstName = input('Enter customer first name: ')
164+
lastName = input('Enter customer last name: ')
165+
email = input('Enter customer email: ')
166+
type = 'receive-only'
167+
168+
body = {
169+
'firstName': firstName,
170+
'lastName': lastName,
171+
'email': email,
172+
'type': type
173+
}
174+
175+
res = token.post(f'/customers', body)
176+
print_response(res)
177+
178+
def create_unverified_customer(token):
179+
firstName = input('Enter customer first name: ')
180+
lastName = input('Enter customer last name: ')
181+
email = input('Enter customer email: ')
182+
183+
body = {
184+
'firstName': firstName,
185+
'lastName': lastName,
186+
'email': email,
187+
}
188+
189+
res = token.post(f'/customers', body)
190+
print_response(res)
191+
192+
def create_verified_personal_customer(token):
193+
firstName = input('Enter customer first name: ')
194+
lastName = input('Enter customer last name: ')
195+
email = input('Enter customer email: ')
196+
address1 = input('Enter customer address 1: ')
197+
city = input('Enter customer city: ')
198+
state = input('Enter customer state: ')
199+
postalCode = input('Enter customer postal code: ')
200+
dateOfBirth = input('Enter customer date of birth: ')
201+
ssn = input('Enter customer ssn: ')
202+
type = 'personal'
203+
204+
body = {
205+
'firstName': firstName,
206+
'lastName': lastName,
207+
'email': email,
208+
'address1': address1,
209+
'city': city,
210+
'state': state,
211+
'postalCode': postalCode,
212+
'dateOfBirth': dateOfBirth,
213+
'ssn': ssn,
214+
'type': type
215+
}
216+
217+
res = token.post(f'/customers', body)
218+
print_response(res)
219+
220+
def retrieve_customer(token):
221+
id = input('Enter customer ID: ')
222+
res = token.get(f'/customers/{id}')
223+
print_response(res)
224+
225+
def list_and_search_customers(token):
226+
res = token.get('/customers')
227+
print_response(res)
228+
229+
def update_customer(token):
230+
id = input('Enter customer ID: ')
231+
firstName = input('Enter customer first name: ')
232+
lastName = input('Enter customer last name: ')
233+
email = input('Enter customer email: ')
234+
address1 = input('Enter customer address 1: ')
235+
city = input('Enter customer city: ')
236+
state = input('Enter customer state: ')
237+
postalCode = input('Enter customer postal code: ')
238+
dateOfBirth = input('Enter customer date of birth: ')
239+
ssn = input('Enter customer ssn: ')
240+
241+
body = {
242+
'firstName': firstName,
243+
'lastName': lastName,
244+
'email': email,
245+
'address1': address1,
246+
'city': city,
247+
'state': state,
248+
'postalCode': postalCode,
249+
'dateOfBirth': dateOfBirth,
250+
'ssn': ssn,
251+
}
252+
253+
res = token.post(f'/customers/{id}', body)
254+
print_response(res)
255+
256+
def list_customer_business_classifications(token):
257+
res = token.get('/business-classifications')
258+
print_response(res)
259+
260+
def retrieve_business_classification(token):
261+
id = input('Enter business classification ID: ')
262+
res = token.get(f'/business-classifications/{id}')
263+
print_response(res)
264+
265+
# KBA RESOURCE
266+
def initiate_kba(token):
267+
id = input('Enter customer ID: ')
268+
res = token.post(f'/customers/{id}/kba')
269+
print_response(res)
270+
271+
def retrieve_kba(token):
272+
id = input('Enter KBA session ID: ')
273+
res = token.get(f'/kba/{id}')
274+
print_response(res)
275+
276+
def verify_kba(token):
277+
id = input('Enter KBA session ID: ')
278+
279+
answers = []
280+
for i in range(4):
281+
obj = {}
282+
question_id = input(f'Enter question ID for question {i+1}: ')
283+
answer_id = input(f'Enter answer ID for answer {i+1}: ')
284+
obj['questionId'] = question_id
285+
obj['answerId'] = answer_id
286+
answers.append(obj)
287+
288+
body = {
289+
'answers': answers
290+
}
291+
292+
res = token.post(f'/kba/{id}', body)
293+
print_response(res)
294+
295+
# BENEFICIAL OWNERS RESOURCE
296+
def create_beneficial_owner(token):
297+
id = input('Enter customer ID: ')
298+
firstName = input('Enter beneficial owner first name: ')
299+
lastName = input('Enter beneficial owner last name: ')
300+
dateOfBirth = input('Enter beneficial owner date of birth: ')
301+
ssn = input('Enter beneficial owner ssn: ')
302+
address1 = input('Enter beneficial owner address 1: ')
303+
city = input('Enter beneficial owner city: ')
304+
state = input('Enter beneficial owner state: ')
305+
postalCode = input('Enter beneficial owner postal code: ')
306+
307+
body = {
308+
'firstName': firstName,
309+
'lastName': lastName,
310+
'dateOfBirth': dateOfBirth,
311+
'ssn': ssn,
312+
'address1': address1,
313+
'city': city,
314+
'state': state,
315+
'postalCode': postalCode
316+
}
317+
318+
res = token.post(f'/customers/{id}/beneficial-owners', body)
319+
print_response(res)
320+
321+
def retrieve_beneficial_owner(token):
322+
id = input('Enter beneficial owner ID: ')
323+
res = token.get(f'/beneficial-owners/{id}')
324+
print_response(res)
325+
326+
def list_beneficial_owners(token):
327+
id = input('Enter customer ID: ')
328+
res = token.get(f'/customers/{id}/beneficial-owners')
329+
print_response(res)
330+
331+
def update_beneficial_owner(token):
332+
id = input('Enter beneficial owner ID: ')
333+
firstName = input('Enter beneficial owner first name: ')
334+
lastName = input('Enter beneficial owner last name: ')
335+
dateOfBirth = input('Enter beneficial owner date of birth: ')
336+
ssn = input('Enter beneficial owner ssn: ')
337+
address1 = input('Enter beneficial owner address 1: ')
338+
city = input('Enter beneficial owner city: ')
339+
state = input('Enter beneficial owner state: ')
340+
postalCode = input('Enter beneficial owner postal code: ')
341+
342+
body = {
343+
'firstName': firstName,
344+
'lastName': lastName,
345+
'dateOfBirth': dateOfBirth,
346+
'ssn': ssn,
347+
'address1': address1,
348+
'city': city,
349+
'state': state,
350+
'postalCode': postalCode
351+
}
352+
353+
res = token.post(f'/beneficial-owners/{id}', body)
354+
print_response(res)
355+
356+
def remove_beneficial_owner(token):
357+
id = input('Enter beneficial owner ID: ')
358+
res = token.delete(f'/beneficial-owners/{id}')
359+
print_response(res)
360+
361+
def retrieve_beneficial_ownership_status(token):
362+
id = input('Enter customer ID: ')
363+
res = token.get(f'/customers/{id}/beneficial-ownership')
364+
print_response(res)
365+
366+
def certify_beneficial_ownership(token):
367+
id = input('Enter customer ID: ')
368+
body = {
369+
'status': 'certified'
370+
}
371+
res = token.post(f'/customers/{id}/beneficial-ownership', body)
372+
print_response(res)
373+

sample_app/main.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from helpers import *
2+
3+
exit = False
4+
5+
pk = input('Enter your Dwolla public key: ')
6+
sk = input('Enter your Dwolla secret key: ')
7+
8+
while not exit:
9+
display_options()
10+
input = get_user_input()
11+
if input == 'exit':
12+
exit = True
13+
else:
14+
handle_input(input, pk, sk)

0 commit comments

Comments
 (0)