Skip to content

Commit fe06e19

Browse files
committed
PEP 8 updates and start rewriting HttpClient and adding tests
1 parent ad29c7d commit fe06e19

10 files changed

Lines changed: 341 additions & 248 deletions

File tree

samples.md

Lines changed: 108 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
from synapse_pay_rest import Client
66

77
options = {
8-
'oauth_key':USER_OAUTH KEY, # Optional
9-
'fingerprint':USER_FINGERPRINT,
10-
'client_id': YOUR_CLIENT_ID,
11-
'client_secret': YOUR_CLIENT_SECRET,
12-
'ip_address': USER_IP_ADDRESS,
13-
'development_mode': True #True will ping sandbox.synapsepay.com while False will ping synapsepay.com
8+
'oauth_key':USER_OAUTH KEY, # Optional
9+
'fingerprint':USER_FINGERPRINT,
10+
'client_id': YOUR_CLIENT_ID,
11+
'client_secret': YOUR_CLIENT_SECRET,
12+
'ip_address': USER_IP_ADDRESS,
13+
'development_mode': True #True will ping sandbox.synapsepay.com while False will ping synapsepay.com
1414
}
1515

1616
USER_ID = ID_OF_USER # Optional
@@ -31,24 +31,24 @@ users_response = client.Users.get()
3131
#Create a User
3232

3333
create_payload = {
34-
"logins": [
35-
{
36-
"email": "pythonTest@synapsepay.com",
37-
"password": "test1234",
38-
"read_only":False
39-
}
40-
],
41-
"phone_numbers": [
42-
"901.111.1111"
43-
],
44-
"legal_names": [
45-
"PYTHON TEST USER"
46-
],
47-
"extra": {
48-
"note": "Interesting user",
49-
"supp_id": "122eddfgbeafrfvbbb",
50-
"is_business": False
51-
}
34+
"logins": [
35+
{
36+
"email": "pythonTest@synapsepay.com",
37+
"password": "test1234",
38+
"read_only":False
39+
}
40+
],
41+
"phone_numbers": [
42+
"901.111.1111"
43+
],
44+
"legal_names": [
45+
"PYTHON TEST USER"
46+
],
47+
"extra": {
48+
"note": "Interesting user",
49+
"supp_id": "122eddfgbeafrfvbbb",
50+
"is_business": False
51+
}
5252
}
5353

5454
create_response = client.Users.create(payload=create_payload)
@@ -61,16 +61,16 @@ user_response = client.Users.get(user_id=USER_ID)
6161
# Update User
6262

6363
update_payload = {
64-
"refresh_token": "REFRESH_TOKEN",
65-
"update":{
66-
"login": {
67-
"email": "test2python@email.com",
68-
"password": "test1234",
69-
"read_only": True
70-
},
71-
"phone_number": "9019411111",
72-
"legal_name": "Some new name"
73-
}
64+
"refresh_token": "REFRESH_TOKEN",
65+
"update":{
66+
"login": {
67+
"email": "test2python@email.com",
68+
"password": "test1234",
69+
"read_only": True
70+
},
71+
"phone_number": "9019411111",
72+
"legal_name": "Some new name"
73+
}
7474
}
7575

7676
update_response = client.Users.update(payload=update_payload)
@@ -79,18 +79,18 @@ update_response = client.Users.update(payload=update_payload)
7979
# Add Document
8080

8181
ssn_payload = {
82-
"doc":{
83-
"birth_day":4,
84-
"birth_month":2,
85-
"birth_year":1940,
86-
"name_first":"John",
87-
"name_last":"doe",
88-
"address_street1":"1 Infinite Loop",
89-
"address_postal_code":"95014",
90-
"address_country_code":"US",
91-
"document_value":"3333",
92-
"document_type":"SSN"
93-
}
82+
"doc":{
83+
"birth_day":4,
84+
"birth_month":2,
85+
"birth_year":1940,
86+
"name_first":"John",
87+
"name_last":"doe",
88+
"address_street1":"1 Infinite Loop",
89+
"address_postal_code":"95014",
90+
"address_country_code":"US",
91+
"document_value":"3333",
92+
"document_type":"SSN"
93+
}
9494
}
9595

9696
ssn_response = client.Users.add_doc(payload=ssn_payload)
@@ -99,16 +99,16 @@ ssn_response = client.Users.add_doc(payload=ssn_payload)
9999
# Answer KBA Questions
100100

101101
kba_payload = {
102-
"doc":{
103-
"question_set_id":"557520ad343463000300005a",
104-
"answers":[
105-
{ "question_id": 1, "answer_id": 1 },
106-
{ "question_id": 2, "answer_id": 1 },
107-
{ "question_id": 3, "answer_id": 1 },
108-
{ "question_id": 4, "answer_id": 1 },
109-
{ "question_id": 5, "answer_id": 1 }
110-
]
111-
}
102+
"doc":{
103+
"question_set_id":"557520ad343463000300005a",
104+
"answers":[
105+
{ "question_id": 1, "answer_id": 1 },
106+
{ "question_id": 2, "answer_id": 1 },
107+
{ "question_id": 3, "answer_id": 1 },
108+
{ "question_id": 4, "answer_id": 1 },
109+
{ "question_id": 5, "answer_id": 1 }
110+
]
111+
}
112112
}
113113

114114
kba_response = client.Users.answer_kba(payload=kba_payload)
@@ -122,7 +122,7 @@ file_response = client.Users.attach_file(file='https://s3.amazonaws.com/synapse_
122122
# Get Oauth Key
123123

124124
oauth_payload = {
125-
"refresh_token": USER_REFRESH_TOKEN
125+
"refresh_token": USER_REFRESH_TOKEN
126126
}
127127

128128
oauth_response = client.Users.refresh(payload=oauth_payload)
@@ -143,13 +143,13 @@ nodes_response = client.Nodes.get()
143143
# Add SYNAPSE-US Node
144144

145145
synapse_node_payload = {
146-
"type":"SYNAPSE-US",
147-
"info":{
148-
"nickname":"My Synapse Wallet"
149-
},
150-
"extra":{
151-
"supp_id":"123sa"
152-
}
146+
"type":"SYNAPSE-US",
147+
"info":{
148+
"nickname":"My Synapse Wallet"
149+
},
150+
"extra":{
151+
"supp_id":"123sa"
152+
}
153153
}
154154

155155
synapse_node_response = client.Nodes.add(payload=synapse_node_payload)
@@ -158,12 +158,12 @@ synapse_node_response = client.Nodes.add(payload=synapse_node_payload)
158158
# Add ACH-US node through account login
159159

160160
login_payload = {
161-
"type":"ACH-US",
162-
"info":{
163-
"bank_id":"synapse_good",
164-
"bank_pw":"test1234",
165-
"bank_name":"fake"
166-
}
161+
"type":"ACH-US",
162+
"info":{
163+
"bank_id":"synapse_good",
164+
"bank_pw":"test1234",
165+
"bank_name":"fake"
166+
}
167167
}
168168

169169
login_response = client.Nodes.add(payload=login_payload)
@@ -172,8 +172,8 @@ login_response = client.Nodes.add(payload=login_payload)
172172
# Verify ACH-US Node via MFA
173173

174174
mfa_payload = {
175-
"access_token":ACCESS_TOKEN_IN_LOGIN_RESPONSE,
176-
"mfa_answer":"test_answer"
175+
"access_token":ACCESS_TOKEN_IN_LOGIN_RESPONSE,
176+
"mfa_answer":"test_answer"
177177
}
178178

179179
mfa_response = client.Nodes.verify(payload=mfa_payload)
@@ -182,18 +182,18 @@ mfa_response = client.Nodes.verify(payload=mfa_payload)
182182
# Add ACH-US Node through Account and Routing Number Details
183183

184184
acct_rout_payload = {
185-
"type":"ACH-US",
186-
"info":{
187-
"nickname":"Python Library Savings Account",
188-
"name_on_account":"Python Library",
189-
"account_num":"72347235423",
190-
"routing_num":"051000017",
191-
"type":"PERSONAL",
192-
"class":"CHECKING"
193-
},
194-
"extra":{
195-
"supp_id":"123sa"
196-
}
185+
"type":"ACH-US",
186+
"info":{
187+
"nickname":"Python Library Savings Account",
188+
"name_on_account":"Python Library",
189+
"account_num":"72347235423",
190+
"routing_num":"051000017",
191+
"type":"PERSONAL",
192+
"class":"CHECKING"
193+
},
194+
"extra":{
195+
"supp_id":"123sa"
196+
}
197197
}
198198

199199
acct_rout_response = client.Nodes.add(payload=acct_rout_payload)
@@ -202,7 +202,7 @@ acct_rout_response = client.Nodes.add(payload=acct_rout_payload)
202202
# Verify ACH-US Node via Micro-Deposits
203203

204204
micro_payload = {
205-
"micro":[0.1,0.1]
205+
"micro":[0.1,0.1]
206206
}
207207

208208
micro_response = client.Nodes.verify(node_id=NODE_ID, payload=micro_payload)
@@ -227,28 +227,28 @@ transactions_response = client.Trans.get(node_id=NODE_ID)
227227
#Create a Transaction
228228

229229
trans_payload = {
230-
"to":{
231-
"type":"SYNAPSE-US",
232-
"id":"560adb4e86c27331bb5ac86e"
233-
},
234-
"amount":{
235-
"amount":1.10,
236-
"currency":"USD"
237-
},
238-
"extra":{
239-
"supp_id":"1283764wqwsdd34wd13212",
240-
"note":"Deposit to bank account",
241-
"webhook":"http://requestb.in/q94kxtq9",
242-
"process_on":1,
243-
"ip":"192.168.0.1"
244-
},
245-
"fees":[{
246-
"fee":1.00,
247-
"note":"Facilitator Fee",
248-
"to":{
249-
"id":"55d9287486c27365fe3776fb"
250-
}
251-
}]
230+
"to":{
231+
"type":"SYNAPSE-US",
232+
"id":"560adb4e86c27331bb5ac86e"
233+
},
234+
"amount":{
235+
"amount":1.10,
236+
"currency":"USD"
237+
},
238+
"extra":{
239+
"supp_id":"1283764wqwsdd34wd13212",
240+
"note":"Deposit to bank account",
241+
"webhook":"http://requestb.in/q94kxtq9",
242+
"process_on":1,
243+
"ip":"192.168.0.1"
244+
},
245+
"fees":[{
246+
"fee":1.00,
247+
"note":"Facilitator Fee",
248+
"to":{
249+
"id":"55d9287486c27365fe3776fb"
250+
}
251+
}]
252252
}
253253

254254
create_response = client.Trans.create(node_id=NODE_ID, payload=trans_payload)
@@ -262,7 +262,7 @@ transaction_response = client.Trans.get(node_id=NODE_ID, trans_id=TRANS_ID)
262262
# Update Transaction
263263

264264
update_payload = {
265-
"comment": "hi"
265+
"comment": "hi"
266266
}
267267

268268
update_response = client.Trans.update(node_id=NODE_ID, trans_id=TRANS_ID, payload=update_payload)

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# Versions should comply with PEP440. For a discussion on single-sourcing
1818
# the version across setup.py and the project code, see
1919
# https://packaging.python.org/en/latest/single_source_version.html
20-
version='0.0.26',
20+
version='1.0.0',
2121

2222
description='SynapsePay Rest Python Library',
2323

@@ -37,7 +37,7 @@
3737
# 3 - Alpha
3838
# 4 - Beta
3939
# 5 - Production/Stable
40-
'Development Status :: 3 - Alpha',
40+
'Development Status :: 5 - Production/Stable',
4141

4242
# Indicate who your project is intended for
4343
'Intended Audience :: Developers',

synapse_pay_rest/api/HelperFunctions.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ def checkKwargs(keys, kwargs):
1111
return True, None
1212

1313

14-
'''
15-
Converts a file object into a correctly padded base64 representation
16-
for the SynapsePay API. Mimetype padding is done by file
17-
extension not by content(for now).
18-
'''
14+
"""
15+
Converts a file object into a correctly padded base64 representation
16+
for the SynapsePay API. Mimetype padding is done by file
17+
extension not by content(for now).
18+
"""
1919

2020

2121
def convert_file_to_base64(file_path):
@@ -38,11 +38,11 @@ def convert_file_to_base64(file_path):
3838
return None
3939

4040

41-
'''
42-
Used to create JSON formatted error messages that occur at the
43-
library level. This allows for no exceptions to ever be raised
44-
for the user.
45-
'''
41+
"""
42+
Used to create JSON formatted error messages that occur at the
43+
library level. This allows for no exceptions to ever be raised
44+
for the user.
45+
"""
4646

4747

4848
def create_custom_error_message(error_message):
@@ -54,15 +54,15 @@ def create_custom_error_message(error_message):
5454
}
5555

5656

57-
'''
58-
If we ever wanted to make a different response for the
59-
user(i.e. just the string message) we could change it here.
60-
However, for now it just forwards the json response.
57+
"""
58+
If we ever wanted to make a different response for the
59+
user(i.e. just the string message) we could change it here.
60+
However, for now it just forwards the json response.
6161
62-
:param response The JSON response from the api call.
62+
:param response The JSON response from the api call.
6363
64-
:return response Returns the JSON response.
65-
'''
64+
:return response Returns the JSON response.
65+
"""
6666

6767

6868
def analyze_response(response):

0 commit comments

Comments
 (0)