-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRequest.py
executable file
·32 lines (28 loc) · 1.4 KB
/
Request.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import json
import sys
from .PaycomException import PaycomException
from .Format import Format
class Request:
id = None
method = None
payload = None
amount = None
params = None
def __init__(self, request):
try:
# !!!!!!!!!!!!!! Uncomment if request.body exists and it contains binary text !!!!!!!!!!!!!!!!!!!!!
# payload = request.body.decode("utf-8")
# self.payload = json.loads(payload)
# !!!!!!!!!!!!!! Uncomment if request.data exists and it contains python dictionary !!!!!!!!!!!!!!!!!!!!!
# self.payload = request.data
if self.payload is None:
PaycomException(None, message='ERROR INVALID JSON RPC OBJECT',
code=PaycomException.ERROR_INVALID_JSON_RPC_OBJECT)
except TypeError or ValueError:
PaycomException(None, message='ERROR INVALID JSON RPC OBJECT',
code=PaycomException.ERROR_INVALID_JSON_RPC_OBJECT)
self.id = self.payload['id'] if 'id' in self.payload else None
self.method = self.payload['method'] if 'method' in self.payload else None
self.params = self.payload['params'] if 'params' in self.payload else []
self.amount = self.payload['params']['amount'] if 'amount' in self.payload['params'] and not \
Format.is_not_numeric(self.payload['params']['amount']) else None