pixelarraythirdparty 1.0.1__py3-none-any.whl → 1.0.3__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 +20 -5
- pixelarraythirdparty/client.py +5 -5
- pixelarraythirdparty/order/order.py +75 -55
- pixelarraythirdparty/product/product.py +24 -6
- pixelarraythirdparty/user/user.py +26 -6
- {pixelarraythirdparty-1.0.1.dist-info → pixelarraythirdparty-1.0.3.dist-info}/METADATA +1 -1
- pixelarraythirdparty-1.0.3.dist-info/RECORD +15 -0
- pixelarraythirdparty/order/pay.py +0 -35
- pixelarraythirdparty-1.0.1.dist-info/RECORD +0 -16
- {pixelarraythirdparty-1.0.1.dist-info → pixelarraythirdparty-1.0.3.dist-info}/WHEEL +0 -0
- {pixelarraythirdparty-1.0.1.dist-info → pixelarraythirdparty-1.0.3.dist-info}/licenses/LICENSE +0 -0
- {pixelarraythirdparty-1.0.1.dist-info → pixelarraythirdparty-1.0.3.dist-info}/top_level.txt +0 -0
pixelarraythirdparty/__init__.py
CHANGED
@@ -3,20 +3,35 @@ from pixelarraythirdparty.client import Client
|
|
3
3
|
|
4
4
|
class CeleryManager(Client):
|
5
5
|
def get_celery_status(self):
|
6
|
-
|
6
|
+
data, success = self._request("GET", "/api/celery/status")
|
7
|
+
if not success:
|
8
|
+
return {}, False
|
9
|
+
return data, True
|
7
10
|
|
8
11
|
def get_celery_tasks(self):
|
9
|
-
|
12
|
+
data, success = self._request("GET", "/api/celery/tasks")
|
13
|
+
if not success:
|
14
|
+
return {}, False
|
15
|
+
return data, True
|
10
16
|
|
11
17
|
def get_celery_tasks_scheduled(self):
|
12
|
-
|
18
|
+
data, success = self._request("GET", "/api/celery/tasks/scheduled")
|
19
|
+
if not success:
|
20
|
+
return {}, False
|
21
|
+
return data, True
|
13
22
|
|
14
23
|
def get_celery_tasks_detail(self, task_name: str):
|
15
|
-
|
24
|
+
data, success = self._request("GET", f"/api/celery/tasks/{task_name}")
|
25
|
+
if not success:
|
26
|
+
return {}, False
|
27
|
+
return data, True
|
16
28
|
|
17
29
|
def trigger_celery_task(self, task_name: str, args: list, kwargs: dict):
|
18
|
-
|
30
|
+
data, success = self._request(
|
19
31
|
"POST",
|
20
32
|
f"/api/celery/tasks/{task_name}/trigger",
|
21
33
|
json={"args": args, "kwargs": kwargs},
|
22
34
|
)
|
35
|
+
if not success:
|
36
|
+
return {}, False
|
37
|
+
return data, True
|
pixelarraythirdparty/client.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import requests
|
2
|
-
from typing import Dict, Any, Optional
|
2
|
+
from typing import Dict, Any, Optional, Tuple
|
3
3
|
|
4
4
|
|
5
5
|
class Client:
|
@@ -12,11 +12,11 @@ class Client:
|
|
12
12
|
"X-API-Key": self.api_key,
|
13
13
|
}
|
14
14
|
|
15
|
-
def _request(self, method: str, url: str, **kwargs) -> Dict[str, Any]:
|
15
|
+
def _request(self, method: str, url: str, **kwargs) -> Tuple[Dict[str, Any], bool]:
|
16
16
|
"""统一的请求方法"""
|
17
17
|
resp = requests.request(
|
18
18
|
method, f"{self.base_url}{url}", headers=self.headers, **kwargs
|
19
19
|
)
|
20
|
-
if resp.status_code == 200:
|
21
|
-
return resp.json().get("data", {})
|
22
|
-
return {}
|
20
|
+
if resp.status_code == 200 and resp.json().get("success") is True:
|
21
|
+
return resp.json().get("data", {}), True
|
22
|
+
return {}, False
|
@@ -1,90 +1,110 @@
|
|
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
|
-
product_name: str,
|
24
7
|
product_id: str,
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
payment_channel: str,
|
8
|
+
body: str = None,
|
9
|
+
remark: str = None,
|
10
|
+
payment_channel: str = "WECHAT",
|
29
11
|
):
|
30
12
|
data = {
|
31
|
-
"product_name": product_name,
|
32
13
|
"product_id": product_id,
|
33
|
-
"amount": amount,
|
34
14
|
"body": body,
|
35
15
|
"remark": remark,
|
36
16
|
"payment_channel": payment_channel,
|
37
17
|
}
|
38
|
-
|
18
|
+
data, success = self._request("POST", "/api/orders/create", json=data)
|
19
|
+
if not success:
|
20
|
+
return {}, False
|
21
|
+
return data, True
|
39
22
|
|
40
23
|
def list_order(
|
41
24
|
self,
|
42
25
|
page: int = 1,
|
43
26
|
page_size: int = 10,
|
44
27
|
payment_status: str = None,
|
45
|
-
|
28
|
+
out_trade_no: str = None,
|
46
29
|
):
|
47
30
|
params = {
|
48
31
|
"page": page,
|
49
32
|
"page_size": page_size,
|
50
33
|
"payment_status": payment_status,
|
51
|
-
"
|
34
|
+
"out_trade_no": out_trade_no,
|
52
35
|
}
|
53
|
-
|
36
|
+
data, success = self._request("GET", "/api/orders/list", params=params)
|
37
|
+
if not success:
|
38
|
+
return {}, False
|
39
|
+
return data, True
|
54
40
|
|
55
|
-
def get_order_detail(self,
|
56
|
-
|
41
|
+
def get_order_detail(self, out_trade_no: str):
|
42
|
+
data, success = self._request("GET", f"/api/orders/{out_trade_no}")
|
43
|
+
if not success:
|
44
|
+
return {}, False
|
45
|
+
return data, True
|
57
46
|
|
58
|
-
def
|
47
|
+
def update_order_status(
|
59
48
|
self,
|
60
|
-
|
49
|
+
out_trade_no: str,
|
61
50
|
payment_status: str,
|
62
|
-
wx_order_no: str,
|
63
|
-
transaction_id: str,
|
64
|
-
openid: str,
|
65
|
-
trade_type: str,
|
66
|
-
bank_type: str,
|
67
|
-
fee_type: str,
|
68
|
-
is_subscribe: str,
|
69
|
-
time_end: str,
|
70
|
-
remark: str,
|
71
51
|
):
|
72
52
|
data = {
|
73
53
|
"payment_status": payment_status,
|
74
|
-
"wx_order_no": wx_order_no,
|
75
|
-
"transaction_id": transaction_id,
|
76
|
-
"openid": openid,
|
77
|
-
"trade_type": trade_type,
|
78
|
-
"bank_type": bank_type,
|
79
|
-
"fee_type": fee_type,
|
80
|
-
"is_subscribe": is_subscribe,
|
81
|
-
"time_end": time_end,
|
82
|
-
"remark": remark,
|
83
54
|
}
|
84
|
-
|
55
|
+
data, success = self._request(
|
56
|
+
"PUT", f"/api/orders/{out_trade_no}/status", json=data
|
57
|
+
)
|
58
|
+
if not success:
|
59
|
+
return {}, False
|
60
|
+
return data, True
|
85
61
|
|
86
|
-
def delete_order(self,
|
87
|
-
|
62
|
+
def delete_order(self, out_trade_no: str):
|
63
|
+
data, success = self._request("DELETE", f"/api/orders/{out_trade_no}")
|
64
|
+
if not success:
|
65
|
+
return {}, False
|
66
|
+
return data, True
|
88
67
|
|
89
68
|
def get_order_stats(self):
|
90
|
-
|
69
|
+
data, success = self._request("GET", "/api/orders/stats/summary")
|
70
|
+
if not success:
|
71
|
+
return {}, False
|
72
|
+
return data, True
|
73
|
+
|
74
|
+
def generate_qr_code(
|
75
|
+
self,
|
76
|
+
out_trade_no: str,
|
77
|
+
payment_channel: str = "WECHAT",
|
78
|
+
):
|
79
|
+
if payment_channel == "WECHAT":
|
80
|
+
url = "/api/orders/wx_pay/generate_qr_code"
|
81
|
+
elif payment_channel == "ALIPAY":
|
82
|
+
url = "/api/orders/ali_pay/generate_qr_code"
|
83
|
+
else:
|
84
|
+
raise ValueError("Invalid payment channel")
|
85
|
+
data, success = self._request(
|
86
|
+
"POST",
|
87
|
+
url,
|
88
|
+
json={
|
89
|
+
"out_trade_no": out_trade_no,
|
90
|
+
},
|
91
|
+
)
|
92
|
+
if not success:
|
93
|
+
return {}, False
|
94
|
+
return data, True
|
95
|
+
|
96
|
+
def refund_order(self, out_trade_no: str, payment_channel: str = "WECHAT"):
|
97
|
+
if payment_channel == "WECHAT":
|
98
|
+
url = "/api/orders/wx_pay/refund"
|
99
|
+
elif payment_channel == "ALIPAY":
|
100
|
+
url = "/api/orders/ali_pay/refund"
|
101
|
+
else:
|
102
|
+
raise ValueError("Invalid payment channel")
|
103
|
+
data, success = self._request(
|
104
|
+
"POST",
|
105
|
+
url,
|
106
|
+
json={"out_trade_no": out_trade_no},
|
107
|
+
)
|
108
|
+
if not success:
|
109
|
+
return {}, False
|
110
|
+
return data, True
|
@@ -25,7 +25,10 @@ class ProductManager(Client):
|
|
25
25
|
"features": features,
|
26
26
|
"sort_order": sort_order,
|
27
27
|
}
|
28
|
-
|
28
|
+
data, success = self._request("POST", "/api/products/create", json=data)
|
29
|
+
if not success:
|
30
|
+
return {}, False
|
31
|
+
return data, True
|
29
32
|
|
30
33
|
def list_product(
|
31
34
|
self,
|
@@ -48,10 +51,16 @@ class ProductManager(Client):
|
|
48
51
|
params["category"] = category
|
49
52
|
if name is not None:
|
50
53
|
params["name"] = name
|
51
|
-
|
54
|
+
data, success = self._request("GET", "/api/products/list", params=params)
|
55
|
+
if not success:
|
56
|
+
return {}, False
|
57
|
+
return data, True
|
52
58
|
|
53
59
|
def get_product_detail(self, product_id: str):
|
54
|
-
|
60
|
+
data, success = self._request("GET", f"/api/products/{product_id}")
|
61
|
+
if not success:
|
62
|
+
return {}, False
|
63
|
+
return data, True
|
55
64
|
|
56
65
|
def update_product(
|
57
66
|
self,
|
@@ -77,10 +86,19 @@ class ProductManager(Client):
|
|
77
86
|
"features": features,
|
78
87
|
"sort_order": sort_order,
|
79
88
|
}
|
80
|
-
|
89
|
+
data, success = self._request("PUT", f"/api/products/{product_id}", json=data)
|
90
|
+
if not success:
|
91
|
+
return {}, False
|
92
|
+
return data, True
|
81
93
|
|
82
94
|
def delete_product(self, product_id: str):
|
83
|
-
|
95
|
+
data, success = self._request("DELETE", f"/api/products/{product_id}")
|
96
|
+
if not success:
|
97
|
+
return {}, False
|
98
|
+
return data, True
|
84
99
|
|
85
100
|
def get_product_categories(self):
|
86
|
-
|
101
|
+
data, success = self._request("GET", "/api/products/categories/list")
|
102
|
+
if not success:
|
103
|
+
return {}, False
|
104
|
+
return data, True
|
@@ -16,7 +16,10 @@ class UserManager(Client):
|
|
16
16
|
params["role"] = role
|
17
17
|
if is_active is not None:
|
18
18
|
params["is_active"] = is_active
|
19
|
-
|
19
|
+
data, success = self._request("GET", "/api/users/list", params=params)
|
20
|
+
if not success:
|
21
|
+
return {}, False
|
22
|
+
return data, True
|
20
23
|
|
21
24
|
def create_user(self, username: str, password: str, email: str, role: str):
|
22
25
|
data = {
|
@@ -25,7 +28,10 @@ class UserManager(Client):
|
|
25
28
|
"email": email,
|
26
29
|
"role": role,
|
27
30
|
}
|
28
|
-
|
31
|
+
data, success = self._request("POST", "/api/users/create", json=data)
|
32
|
+
if not success:
|
33
|
+
return {}, False
|
34
|
+
return data, True
|
29
35
|
|
30
36
|
def update_user(
|
31
37
|
self, user_id: int, username: str, email: str, role: str, is_active: bool
|
@@ -36,14 +42,28 @@ class UserManager(Client):
|
|
36
42
|
"role": role,
|
37
43
|
"is_active": is_active,
|
38
44
|
}
|
39
|
-
|
45
|
+
data, success = self._request("PUT", f"/api/users/{user_id}", json=data)
|
46
|
+
if not success:
|
47
|
+
return {}, False
|
48
|
+
return data, True
|
40
49
|
|
41
50
|
def delete_user(self, user_id: int):
|
42
|
-
|
51
|
+
data, success = self._request("DELETE", f"/api/users/{user_id}")
|
52
|
+
if not success:
|
53
|
+
return {}, False
|
54
|
+
return data, True
|
43
55
|
|
44
56
|
def get_user_detail(self, user_id: int):
|
45
|
-
|
57
|
+
data, success = self._request("GET", f"/api/users/{user_id}")
|
58
|
+
if not success:
|
59
|
+
return {}, False
|
60
|
+
return data, True
|
46
61
|
|
47
62
|
def reset_user_password(self, user_id: int, new_password: str):
|
48
63
|
data = {"new_password": new_password}
|
49
|
-
|
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,15 @@
|
|
1
|
+
pixelarraythirdparty/__init__.py,sha256=TYuj96ZwZ4VXhB9Xn4KoEWpoJVsChUjzoWSRZONmC-U,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=kmJNAvfiXxhjOhRbD3JTl1saE8aetMZ0TFR9NjPsaIM,3208
|
7
|
+
pixelarraythirdparty/product/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
8
|
+
pixelarraythirdparty/product/product.py,sha256=eHU0VKal1QpJs6F4_VxLoBYeeqQ19elEogH2Qpw7IDo,3029
|
9
|
+
pixelarraythirdparty/user/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
10
|
+
pixelarraythirdparty/user/user.py,sha256=tbcFsrNEdWz4op7V_zJ5o8neBuI4ogl4dgHS-uSIAX0,2155
|
11
|
+
pixelarraythirdparty-1.0.3.dist-info/licenses/LICENSE,sha256=O-g1dUr0U50rSIvmWE9toiVkSgFpVt72_MHITbWvAqA,1067
|
12
|
+
pixelarraythirdparty-1.0.3.dist-info/METADATA,sha256=_BcKEA0W8joCfUZcvDqyKBkBXKGyWUwIDVI16boT7s4,993
|
13
|
+
pixelarraythirdparty-1.0.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
14
|
+
pixelarraythirdparty-1.0.3.dist-info/top_level.txt,sha256=dzG2Ut8j7noUqj_0ZQjcIDAeHYCh_9WtlxjAxtoyufo,21
|
15
|
+
pixelarraythirdparty-1.0.3.dist-info/RECORD,,
|
@@ -1,35 +0,0 @@
|
|
1
|
-
from pixelarraythirdparty.client import Client
|
2
|
-
|
3
|
-
|
4
|
-
class WeChatPayManager(Client):
|
5
|
-
def generate_qr_code(
|
6
|
-
self,
|
7
|
-
out_trade_no: str,
|
8
|
-
total_fee: int,
|
9
|
-
body: str,
|
10
|
-
product_name: str,
|
11
|
-
product_id: str,
|
12
|
-
):
|
13
|
-
return self._request(
|
14
|
-
"POST",
|
15
|
-
"/api/wx_pay/generate_qr_code",
|
16
|
-
json={
|
17
|
-
"out_trade_no": out_trade_no,
|
18
|
-
"total_fee": total_fee,
|
19
|
-
"body": body,
|
20
|
-
"product_name": product_name,
|
21
|
-
"product_id": product_id,
|
22
|
-
},
|
23
|
-
)
|
24
|
-
|
25
|
-
def query_order(self, out_trade_no: str):
|
26
|
-
return self._request(
|
27
|
-
"POST", "/api/wx_pay/query_order", json={"out_trade_no": out_trade_no}
|
28
|
-
)
|
29
|
-
|
30
|
-
def refund(self, out_trade_no: str, total_fee: int):
|
31
|
-
return self._request(
|
32
|
-
"POST",
|
33
|
-
"/api/wx_pay/refund",
|
34
|
-
json={"out_trade_no": out_trade_no, "total_fee": total_fee},
|
35
|
-
)
|
@@ -1,16 +0,0 @@
|
|
1
|
-
pixelarraythirdparty/__init__.py,sha256=fk9_1IcETIUlA8F5IoMrexyHfxQ0ygyplTk8Ur2o1mM,458
|
2
|
-
pixelarraythirdparty/client.py,sha256=oob1iFWsLPPDiXic-H_5twxazQ-pEOHK98H-RaZvnSY,730
|
3
|
-
pixelarraythirdparty/celery/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
|
-
pixelarraythirdparty/celery/celery.py,sha256=NaLf5gJo8BTTJrC6a9f3TPfwaR9YArpcV-EM8HiJWhU,738
|
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=JpzWEQfq5v9gu9uFLjn5FNAnDNjYGQuZA5aeuEjfDcw,987
|
8
|
-
pixelarraythirdparty/product/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
9
|
-
pixelarraythirdparty/product/product.py,sha256=taX_UNsBJRB_KWCrszagh9TkiY_rybok57PBU-cLbEI,2501
|
10
|
-
pixelarraythirdparty/user/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
11
|
-
pixelarraythirdparty/user/user.py,sha256=nRtTahL1w-gic6vaS7Gh2CVWBvveL_yIuVf3U0eJCPA,1605
|
12
|
-
pixelarraythirdparty-1.0.1.dist-info/licenses/LICENSE,sha256=O-g1dUr0U50rSIvmWE9toiVkSgFpVt72_MHITbWvAqA,1067
|
13
|
-
pixelarraythirdparty-1.0.1.dist-info/METADATA,sha256=MZkNXMe8G6cMRAweo_JIoWM4ywZQcxlsZTFqSGXb_jw,993
|
14
|
-
pixelarraythirdparty-1.0.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
15
|
-
pixelarraythirdparty-1.0.1.dist-info/top_level.txt,sha256=dzG2Ut8j7noUqj_0ZQjcIDAeHYCh_9WtlxjAxtoyufo,21
|
16
|
-
pixelarraythirdparty-1.0.1.dist-info/RECORD,,
|
File without changes
|
{pixelarraythirdparty-1.0.1.dist-info → pixelarraythirdparty-1.0.3.dist-info}/licenses/LICENSE
RENAMED
File without changes
|
File without changes
|