-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
130 lines (110 loc) · 2.98 KB
/
test.py
File metadata and controls
130 lines (110 loc) · 2.98 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
from websockets.sync.client import connect
import requests
TOKEN = "rs.vHGzpkVPfVFao7LG9EiSV86k2"
MASTER_TOKEN = "1234"
DOMEN = "http://localhost:5050"
API_URL = f"{DOMEN}/api/v1"
def create_token():
print("create_token")
headers = {
"Authorization": f"Bearer {MASTER_TOKEN}"
}
params = {
"ttl": 1000000,
"op_limit": 20000,
"tc_limit": 20
}
res = requests.post(f"{API_URL}/create_token/", headers=headers, params=params)
print(res.json())
def update_token():
print("update_token")
headers = {
"Authorization": f"Bearer {MASTER_TOKEN}"
}
params = {
"id": "rs.SUyISUT06JWFY8AWEDLNVnvZHnLJU65K4",
"ttl": 1090009,
"op_limit": 21000,
"tc_limit": 19
}
res = requests.post(f"{API_URL}/update_token/", headers=headers, params=params)
print(res.json())
def cutout_token():
print("cutout_token")
headers = {
"Authorization": f"Bearer {MASTER_TOKEN}"
}
res = requests.delete(f"{API_URL}/cutout_token/rs.c8zY0IJpwoMQPw6neiJntdbJwRUOufl3h", headers=headers)
print(res.json())
def token_info():
print("token_info")
headers = {
"Authorization": f"Bearer {TOKEN}"
}
res = requests.get(f"{API_URL}/token_info", headers=headers)
print(res.json())
def token_info_():
print("token_info_")
res = requests.get(f"{API_URL}/token_info/rs.SUyISUT06JWFY8AWEDLNVnvZHnLJU65K4")
print(res.json())
def test_token():
print("test_token")
res = requests.get(f"{API_URL}/test-token")
print(res.text)
def state():
print("state")
res = requests.get(f"{API_URL}/state")
print(res.json())
def markets():
print("markets")
res = requests.get(f"{API_URL}/markets")
print(res.text)
def ping():
print("ping")
res = requests.get(f"{API_URL}/ping")
print(res.json())
def myip():
print("myip")
res = requests.get(f"{API_URL}/myip")
print(res.json())
def task_ws(order_hash):
headers = {
"Authorization": f"Bearer {TOKEN}"
}
with connect(f"ws://localhost:5050/api/v1/task_ws/{order_hash}", additional_headers=headers) as task_ws:
try:
while (task := task_ws.recv()):
print(task)
except Exception as _:
print("Connection closed...")
def task_(order_hash):
print("task")
headers = {
"Authorization": f"Bearer {TOKEN}"
}
res = requests.post(f"{API_URL}/task/{order_hash}", headers=headers)
print(res.text)
return res.text
def order():
print("order")
headers = {
"Authorization": f"Bearer {TOKEN}"
}
order = {
"products": [
"ym/1732949807-100352880819-5997015",
"oz/1596079870",
"oz/1793879666",
"wb/145700662",
],
"proxyPool": [
"1kpF8S:GPnFUb@147.45.62.117:8000"
]
}
res = requests.post(f"{API_URL}/order", headers=headers, json=order)
print(res.text)
return res.text
if __name__ == "__main__":
import time
order()
#task_ws(order_hash)