pixelarraythirdparty 1.0.0__py3-none-any.whl → 1.0.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pixelarraythirdparty/__init__.py +1 -1
- pixelarraythirdparty/celery/celery.py +22 -23
- pixelarraythirdparty/client.py +22 -0
- pixelarraythirdparty/order/order.py +26 -24
- pixelarraythirdparty/order/pay.py +14 -21
- pixelarraythirdparty/product/product.py +26 -24
- pixelarraythirdparty/user/user.py +28 -24
- {pixelarraythirdparty-1.0.0.dist-info → pixelarraythirdparty-1.0.2.dist-info}/METADATA +1 -1
- pixelarraythirdparty-1.0.2.dist-info/RECORD +16 -0
- pixelarraythirdparty/auth.py +0 -0
- pixelarraythirdparty-1.0.0.dist-info/RECORD +0 -16
- {pixelarraythirdparty-1.0.0.dist-info → pixelarraythirdparty-1.0.2.dist-info}/WHEEL +0 -0
- {pixelarraythirdparty-1.0.0.dist-info → pixelarraythirdparty-1.0.2.dist-info}/licenses/LICENSE +0 -0
- {pixelarraythirdparty-1.0.0.dist-info → pixelarraythirdparty-1.0.2.dist-info}/top_level.txt +0 -0
pixelarraythirdparty/__init__.py
CHANGED
@@ -1,38 +1,37 @@
|
|
1
|
-
import
|
1
|
+
from pixelarraythirdparty.client import Client
|
2
2
|
|
3
3
|
|
4
|
-
class CeleryManager:
|
5
|
-
def __init__(self, api_key: str):
|
6
|
-
self.base_url = "https://thirdparty.pixelarrayai.com"
|
7
|
-
self.api_key = api_key
|
8
|
-
self.headers = {
|
9
|
-
"Content-Type": "application/json",
|
10
|
-
"X-API-Key": self.api_key,
|
11
|
-
}
|
12
|
-
|
13
|
-
def _request(self, method, url, **kwargs):
|
14
|
-
resp = requests.request(
|
15
|
-
method, f"{self.base_url}{url}", headers=self.headers, **kwargs
|
16
|
-
)
|
17
|
-
if resp.status_code == 200:
|
18
|
-
return resp.json().get("data", {})
|
19
|
-
return {}
|
20
|
-
|
4
|
+
class CeleryManager(Client):
|
21
5
|
def get_celery_status(self):
|
22
|
-
|
6
|
+
data, success = self._request("GET", "/api/celery/status")
|
7
|
+
if not success:
|
8
|
+
return {}, False
|
9
|
+
return data, True
|
23
10
|
|
24
11
|
def get_celery_tasks(self):
|
25
|
-
|
12
|
+
data, success = self._request("GET", "/api/celery/tasks")
|
13
|
+
if not success:
|
14
|
+
return {}, False
|
15
|
+
return data, True
|
26
16
|
|
27
17
|
def get_celery_tasks_scheduled(self):
|
28
|
-
|
18
|
+
data, success = self._request("GET", "/api/celery/tasks/scheduled")
|
19
|
+
if not success:
|
20
|
+
return {}, False
|
21
|
+
return data, True
|
29
22
|
|
30
23
|
def get_celery_tasks_detail(self, task_name: str):
|
31
|
-
|
24
|
+
data, success = self._request("GET", f"/api/celery/tasks/{task_name}")
|
25
|
+
if not success:
|
26
|
+
return {}, False
|
27
|
+
return data, True
|
32
28
|
|
33
29
|
def trigger_celery_task(self, task_name: str, args: list, kwargs: dict):
|
34
|
-
|
30
|
+
data, success = self._request(
|
35
31
|
"POST",
|
36
32
|
f"/api/celery/tasks/{task_name}/trigger",
|
37
33
|
json={"args": args, "kwargs": kwargs},
|
38
34
|
)
|
35
|
+
if not success:
|
36
|
+
return {}, False
|
37
|
+
return data, True
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import requests
|
2
|
+
from typing import Dict, Any, Optional, Tuple
|
3
|
+
|
4
|
+
|
5
|
+
class Client:
|
6
|
+
"""基础认证类,提供公共的 API key 认证和请求方法"""
|
7
|
+
def __init__(self, api_key: str):
|
8
|
+
self.base_url = "https://thirdparty.pixelarrayai.com"
|
9
|
+
self.api_key = api_key
|
10
|
+
self.headers = {
|
11
|
+
"Content-Type": "application/json",
|
12
|
+
"X-API-Key": self.api_key,
|
13
|
+
}
|
14
|
+
|
15
|
+
def _request(self, method: str, url: str, **kwargs) -> Tuple[Dict[str, Any], bool]:
|
16
|
+
"""统一的请求方法"""
|
17
|
+
resp = requests.request(
|
18
|
+
method, f"{self.base_url}{url}", headers=self.headers, **kwargs
|
19
|
+
)
|
20
|
+
if resp.status_code == 200 and resp.json().get("success") is True:
|
21
|
+
return resp.json().get("data", {}), True
|
22
|
+
return {}, False
|
@@ -1,23 +1,7 @@
|
|
1
|
-
import
|
1
|
+
from pixelarraythirdparty.client import Client
|
2
2
|
|
3
3
|
|
4
|
-
class OrderManager:
|
5
|
-
def __init__(self, api_key: str):
|
6
|
-
self.base_url = "https://thirdparty.pixelarrayai.com"
|
7
|
-
self.api_key = api_key
|
8
|
-
self.headers = {
|
9
|
-
"Content-Type": "application/json",
|
10
|
-
"X-API-Key": self.api_key,
|
11
|
-
}
|
12
|
-
|
13
|
-
def _request(self, method, url, **kwargs):
|
14
|
-
resp = requests.request(
|
15
|
-
method, f"{self.base_url}{url}", headers=self.headers, **kwargs
|
16
|
-
)
|
17
|
-
if resp.status_code == 200:
|
18
|
-
return resp.json().get("data", {})
|
19
|
-
return {}
|
20
|
-
|
4
|
+
class OrderManager(Client):
|
21
5
|
def create_order(
|
22
6
|
self,
|
23
7
|
product_name: str,
|
@@ -35,7 +19,10 @@ class OrderManager:
|
|
35
19
|
"remark": remark,
|
36
20
|
"payment_channel": payment_channel,
|
37
21
|
}
|
38
|
-
|
22
|
+
data, success = self._request("POST", "/api/orders/create", json=data)
|
23
|
+
if not success:
|
24
|
+
return {}, False
|
25
|
+
return data, True
|
39
26
|
|
40
27
|
def list_order(
|
41
28
|
self,
|
@@ -50,10 +37,16 @@ class OrderManager:
|
|
50
37
|
"payment_status": payment_status,
|
51
38
|
"order_no": order_no,
|
52
39
|
}
|
53
|
-
|
40
|
+
data, success = self._request("GET", "/api/orders/list", params=params)
|
41
|
+
if not success:
|
42
|
+
return {}, False
|
43
|
+
return data, True
|
54
44
|
|
55
45
|
def get_order_detail(self, order_no: str):
|
56
|
-
|
46
|
+
data, success = self._request("GET", f"/api/orders/{order_no}")
|
47
|
+
if not success:
|
48
|
+
return {}, False
|
49
|
+
return data, True
|
57
50
|
|
58
51
|
def update_order(
|
59
52
|
self,
|
@@ -81,10 +74,19 @@ class OrderManager:
|
|
81
74
|
"time_end": time_end,
|
82
75
|
"remark": remark,
|
83
76
|
}
|
84
|
-
|
77
|
+
data, success = self._request("PUT", f"/api/orders/{order_no}", json=data)
|
78
|
+
if not success:
|
79
|
+
return {}, False
|
80
|
+
return data, True
|
85
81
|
|
86
82
|
def delete_order(self, order_no: str):
|
87
|
-
|
83
|
+
data, success = self._request("DELETE", f"/api/orders/{order_no}")
|
84
|
+
if not success:
|
85
|
+
return {}, False
|
86
|
+
return data, True
|
88
87
|
|
89
88
|
def get_order_stats(self):
|
90
|
-
|
89
|
+
data, success = self._request("GET", "/api/orders/stats/summary")
|
90
|
+
if not success:
|
91
|
+
return {}, False
|
92
|
+
return data, True
|
@@ -1,23 +1,7 @@
|
|
1
|
-
import
|
1
|
+
from pixelarraythirdparty.client import Client
|
2
2
|
|
3
3
|
|
4
|
-
class WeChatPayManager:
|
5
|
-
def __init__(self, api_key: str):
|
6
|
-
self.base_url = "https://thirdparty.pixelarrayai.com"
|
7
|
-
self.api_key = api_key
|
8
|
-
self.headers = {
|
9
|
-
"Content-Type": "application/json",
|
10
|
-
"X-API-Key": self.api_key,
|
11
|
-
}
|
12
|
-
|
13
|
-
def _request(self, method, url, **kwargs):
|
14
|
-
resp = requests.request(
|
15
|
-
method, f"{self.base_url}{url}", headers=self.headers, **kwargs
|
16
|
-
)
|
17
|
-
if resp.status_code == 200:
|
18
|
-
return resp.json().get("data", {})
|
19
|
-
return {}
|
20
|
-
|
4
|
+
class WeChatPayManager(Client):
|
21
5
|
def generate_qr_code(
|
22
6
|
self,
|
23
7
|
out_trade_no: str,
|
@@ -26,7 +10,7 @@ class WeChatPayManager:
|
|
26
10
|
product_name: str,
|
27
11
|
product_id: str,
|
28
12
|
):
|
29
|
-
|
13
|
+
data, success = self._request(
|
30
14
|
"POST",
|
31
15
|
"/api/wx_pay/generate_qr_code",
|
32
16
|
json={
|
@@ -37,15 +21,24 @@ class WeChatPayManager:
|
|
37
21
|
"product_id": product_id,
|
38
22
|
},
|
39
23
|
)
|
24
|
+
if not success:
|
25
|
+
return {}, False
|
26
|
+
return data, True
|
40
27
|
|
41
28
|
def query_order(self, out_trade_no: str):
|
42
|
-
|
29
|
+
data, success = self._request(
|
43
30
|
"POST", "/api/wx_pay/query_order", json={"out_trade_no": out_trade_no}
|
44
31
|
)
|
32
|
+
if not success:
|
33
|
+
return {}, False
|
34
|
+
return data, True
|
45
35
|
|
46
36
|
def refund(self, out_trade_no: str, total_fee: int):
|
47
|
-
|
37
|
+
data, success = self._request(
|
48
38
|
"POST",
|
49
39
|
"/api/wx_pay/refund",
|
50
40
|
json={"out_trade_no": out_trade_no, "total_fee": total_fee},
|
51
41
|
)
|
42
|
+
if not success:
|
43
|
+
return {}, False
|
44
|
+
return data, True
|
@@ -1,23 +1,7 @@
|
|
1
|
-
import
|
1
|
+
from pixelarraythirdparty.client import Client
|
2
2
|
|
3
3
|
|
4
|
-
class ProductManager:
|
5
|
-
def __init__(self, api_key: str):
|
6
|
-
self.base_url = "https://thirdparty.pixelarrayai.com"
|
7
|
-
self.api_key = api_key
|
8
|
-
self.headers = {
|
9
|
-
"Content-Type": "application/json",
|
10
|
-
"X-API-Key": self.api_key,
|
11
|
-
}
|
12
|
-
|
13
|
-
def _request(self, method, url, **kwargs):
|
14
|
-
resp = requests.request(
|
15
|
-
method, f"{self.base_url}{url}", headers=self.headers, **kwargs
|
16
|
-
)
|
17
|
-
if resp.status_code == 200:
|
18
|
-
return resp.json().get("data", {})
|
19
|
-
return {}
|
20
|
-
|
4
|
+
class ProductManager(Client):
|
21
5
|
def create_product(
|
22
6
|
self,
|
23
7
|
name: str,
|
@@ -41,7 +25,10 @@ class ProductManager:
|
|
41
25
|
"features": features,
|
42
26
|
"sort_order": sort_order,
|
43
27
|
}
|
44
|
-
|
28
|
+
data, success = self._request("POST", "/api/products/create", json=data)
|
29
|
+
if not success:
|
30
|
+
return {}, False
|
31
|
+
return data, True
|
45
32
|
|
46
33
|
def list_product(
|
47
34
|
self,
|
@@ -64,10 +51,16 @@ class ProductManager:
|
|
64
51
|
params["category"] = category
|
65
52
|
if name is not None:
|
66
53
|
params["name"] = name
|
67
|
-
|
54
|
+
data, success = self._request("GET", "/api/products/list", params=params)
|
55
|
+
if not success:
|
56
|
+
return {}, False
|
57
|
+
return data, True
|
68
58
|
|
69
59
|
def get_product_detail(self, product_id: str):
|
70
|
-
|
60
|
+
data, success = self._request("GET", f"/api/products/{product_id}")
|
61
|
+
if not success:
|
62
|
+
return {}, False
|
63
|
+
return data, True
|
71
64
|
|
72
65
|
def update_product(
|
73
66
|
self,
|
@@ -93,10 +86,19 @@ class ProductManager:
|
|
93
86
|
"features": features,
|
94
87
|
"sort_order": sort_order,
|
95
88
|
}
|
96
|
-
|
89
|
+
data, success = self._request("PUT", f"/api/products/{product_id}", json=data)
|
90
|
+
if not success:
|
91
|
+
return {}, False
|
92
|
+
return data, True
|
97
93
|
|
98
94
|
def delete_product(self, product_id: str):
|
99
|
-
|
95
|
+
data, success = self._request("DELETE", f"/api/products/{product_id}")
|
96
|
+
if not success:
|
97
|
+
return {}, False
|
98
|
+
return data, True
|
100
99
|
|
101
100
|
def get_product_categories(self):
|
102
|
-
|
101
|
+
data, success = self._request("GET", "/api/products/categories/list")
|
102
|
+
if not success:
|
103
|
+
return {}, False
|
104
|
+
return data, True
|
@@ -1,25 +1,9 @@
|
|
1
|
-
import requests
|
2
1
|
import aiohttp
|
3
2
|
from typing import Optional
|
3
|
+
from pixelarraythirdparty.client import Client
|
4
4
|
|
5
5
|
|
6
|
-
class UserManager:
|
7
|
-
def __init__(self, api_key: str):
|
8
|
-
self.base_url = "https://thirdparty.pixelarrayai.com"
|
9
|
-
self.api_key = api_key
|
10
|
-
self.headers = {
|
11
|
-
"Content-Type": "application/json",
|
12
|
-
"X-API-Key": self.api_key,
|
13
|
-
}
|
14
|
-
|
15
|
-
def _request(self, method, url, **kwargs):
|
16
|
-
resp = requests.request(
|
17
|
-
method, f"{self.base_url}{url}", headers=self.headers, **kwargs
|
18
|
-
)
|
19
|
-
if resp.status_code == 200:
|
20
|
-
return resp.json().get("data", {})
|
21
|
-
return {}
|
22
|
-
|
6
|
+
class UserManager(Client):
|
23
7
|
def list_user(
|
24
8
|
self,
|
25
9
|
page: int = 1,
|
@@ -32,7 +16,10 @@ class UserManager:
|
|
32
16
|
params["role"] = role
|
33
17
|
if is_active is not None:
|
34
18
|
params["is_active"] = is_active
|
35
|
-
|
19
|
+
data, success = self._request("GET", "/api/users/list", params=params)
|
20
|
+
if not success:
|
21
|
+
return {}, False
|
22
|
+
return data, True
|
36
23
|
|
37
24
|
def create_user(self, username: str, password: str, email: str, role: str):
|
38
25
|
data = {
|
@@ -41,7 +28,10 @@ class UserManager:
|
|
41
28
|
"email": email,
|
42
29
|
"role": role,
|
43
30
|
}
|
44
|
-
|
31
|
+
data, success = self._request("POST", "/api/users/create", json=data)
|
32
|
+
if not success:
|
33
|
+
return {}, False
|
34
|
+
return data, True
|
45
35
|
|
46
36
|
def update_user(
|
47
37
|
self, user_id: int, username: str, email: str, role: str, is_active: bool
|
@@ -52,14 +42,28 @@ class UserManager:
|
|
52
42
|
"role": role,
|
53
43
|
"is_active": is_active,
|
54
44
|
}
|
55
|
-
|
45
|
+
data, success = self._request("PUT", f"/api/users/{user_id}", json=data)
|
46
|
+
if not success:
|
47
|
+
return {}, False
|
48
|
+
return data, True
|
56
49
|
|
57
50
|
def delete_user(self, user_id: int):
|
58
|
-
|
51
|
+
data, success = self._request("DELETE", f"/api/users/{user_id}")
|
52
|
+
if not success:
|
53
|
+
return {}, False
|
54
|
+
return data, True
|
59
55
|
|
60
56
|
def get_user_detail(self, user_id: int):
|
61
|
-
|
57
|
+
data, success = self._request("GET", f"/api/users/{user_id}")
|
58
|
+
if not success:
|
59
|
+
return {}, False
|
60
|
+
return data, True
|
62
61
|
|
63
62
|
def reset_user_password(self, user_id: int, new_password: str):
|
64
63
|
data = {"new_password": new_password}
|
65
|
-
|
64
|
+
data, success = self._request(
|
65
|
+
"POST", f"/api/users/{user_id}/reset-password", json=data
|
66
|
+
)
|
67
|
+
if not success:
|
68
|
+
return {}, False
|
69
|
+
return data, True
|
@@ -0,0 +1,16 @@
|
|
1
|
+
pixelarraythirdparty/__init__.py,sha256=WVQdADzRD3tqhJvfxOm3qUInd9L0KRW-u5u37u6xq2c,458
|
2
|
+
pixelarraythirdparty/client.py,sha256=dJlIrMlr1M4AGHvaLw191uaPnQbQ12_BGx8DTDTPkZQ,802
|
3
|
+
pixelarraythirdparty/celery/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
|
+
pixelarraythirdparty/celery/celery.py,sha256=Oaa7pBztL-FM0X5NSCjjfZP80AUsnnme5Z3RxXIJsZg,1178
|
5
|
+
pixelarraythirdparty/order/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
|
+
pixelarraythirdparty/order/order.py,sha256=51KcwBGfXS9Ico_0jlwcLUqcAgc9xgRutozqtlWwyHY,2616
|
7
|
+
pixelarraythirdparty/order/pay.py,sha256=Fq7HKeYS_jk9CWdPldXE5OzuHl66SHHQW4sYlG6yODM,1251
|
8
|
+
pixelarraythirdparty/product/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
9
|
+
pixelarraythirdparty/product/product.py,sha256=eHU0VKal1QpJs6F4_VxLoBYeeqQ19elEogH2Qpw7IDo,3029
|
10
|
+
pixelarraythirdparty/user/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
11
|
+
pixelarraythirdparty/user/user.py,sha256=tbcFsrNEdWz4op7V_zJ5o8neBuI4ogl4dgHS-uSIAX0,2155
|
12
|
+
pixelarraythirdparty-1.0.2.dist-info/licenses/LICENSE,sha256=O-g1dUr0U50rSIvmWE9toiVkSgFpVt72_MHITbWvAqA,1067
|
13
|
+
pixelarraythirdparty-1.0.2.dist-info/METADATA,sha256=DQSV5A4aLGQ4FVKmol3IgYsZYKLLgyb2zXC4YnhLJPY,993
|
14
|
+
pixelarraythirdparty-1.0.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
15
|
+
pixelarraythirdparty-1.0.2.dist-info/top_level.txt,sha256=dzG2Ut8j7noUqj_0ZQjcIDAeHYCh_9WtlxjAxtoyufo,21
|
16
|
+
pixelarraythirdparty-1.0.2.dist-info/RECORD,,
|
pixelarraythirdparty/auth.py
DELETED
File without changes
|
@@ -1,16 +0,0 @@
|
|
1
|
-
pixelarraythirdparty/__init__.py,sha256=XcGFz8LtH_OWAIVGfT7aymjYiG7F_utG576HIBx3gsw,458
|
2
|
-
pixelarraythirdparty/auth.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
|
-
pixelarraythirdparty/celery/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
|
-
pixelarraythirdparty/celery/celery.py,sha256=jcK42Qt6KAmWlxVBS4G0saT8nzL2yTcDmPAukYclG8Q,1221
|
5
|
-
pixelarraythirdparty/order/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
|
-
pixelarraythirdparty/order/order.py,sha256=K_uhC9CFvzdW33mFoz5aRypi21V5rd58Q5WyCfe6Wes,2571
|
7
|
-
pixelarraythirdparty/order/pay.py,sha256=hIsrOZfzY0wGHDvggac-JoIxQjZpxxw-wiRx-BwGqtE,1470
|
8
|
-
pixelarraythirdparty/product/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
9
|
-
pixelarraythirdparty/product/product.py,sha256=HA9xKLmv-kINmvSSf-5G86NtmsEWYcR6I5Asa1nIV8k,2984
|
10
|
-
pixelarraythirdparty/user/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
11
|
-
pixelarraythirdparty/user/user.py,sha256=xHyyypMLzEMbbn-TzhYANc3JftGFi3wAFMdk8qTdakk,2088
|
12
|
-
pixelarraythirdparty-1.0.0.dist-info/licenses/LICENSE,sha256=O-g1dUr0U50rSIvmWE9toiVkSgFpVt72_MHITbWvAqA,1067
|
13
|
-
pixelarraythirdparty-1.0.0.dist-info/METADATA,sha256=cz1IOAwa3bOzhDEQrVsAD_-1QyiSybdf7nmz2mTuz4g,993
|
14
|
-
pixelarraythirdparty-1.0.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
15
|
-
pixelarraythirdparty-1.0.0.dist-info/top_level.txt,sha256=dzG2Ut8j7noUqj_0ZQjcIDAeHYCh_9WtlxjAxtoyufo,21
|
16
|
-
pixelarraythirdparty-1.0.0.dist-info/RECORD,,
|
File without changes
|
{pixelarraythirdparty-1.0.0.dist-info → pixelarraythirdparty-1.0.2.dist-info}/licenses/LICENSE
RENAMED
File without changes
|
File without changes
|