-
Notifications
You must be signed in to change notification settings - Fork 1
/
Base_API_Call.py
47 lines (36 loc) · 1.19 KB
/
Base_API_Call.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import json
import http.client
class API:
def Call(call,payload,content,conn):
headers = { 'content-type': "application/json" }
conn.request(call, content, payload, headers)
res = conn.getresponse()
data = res.read()
return data.decode("utf-8")
def Request_formatter(JSON):
Item = json.loads(JSON)
jsonrpc = Item["jsonrpc"]
id = Item["id"]
result = Item["result"]
return result
def Format(Call,Payload,Content,conn,form):
#Try
if conn == "test":
conn = "test"
if form == "JSON":
return API.Call(Call,Payload,Content,conn)
else:
JSON = API.Call(Call,Payload,Content,conn)
return API.clientVersion_formatter(JSON)
else:
if form == "JSON":
return API.Call(Call,Payload,Content,conn)
else:
JSON = API.Call(Call,Payload,Content,conn)
return API.Request_formatter(JSON)
#Except
##ERROR Handling
def Tatum_Format():
print("Base API")
def Tatum_Request_Formater():
print("Base API")