pixelarraythirdparty 1.0.1__tar.gz → 1.0.2__tar.gz

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.
Files changed (22) hide show
  1. {pixelarraythirdparty-1.0.1 → pixelarraythirdparty-1.0.2}/PKG-INFO +1 -1
  2. {pixelarraythirdparty-1.0.1 → pixelarraythirdparty-1.0.2}/pixelarraythirdparty/__init__.py +1 -1
  3. pixelarraythirdparty-1.0.2/pixelarraythirdparty/celery/celery.py +37 -0
  4. {pixelarraythirdparty-1.0.1 → pixelarraythirdparty-1.0.2}/pixelarraythirdparty/client.py +5 -5
  5. {pixelarraythirdparty-1.0.1 → pixelarraythirdparty-1.0.2}/pixelarraythirdparty/order/order.py +26 -24
  6. {pixelarraythirdparty-1.0.1 → pixelarraythirdparty-1.0.2}/pixelarraythirdparty/order/pay.py +12 -3
  7. {pixelarraythirdparty-1.0.1 → pixelarraythirdparty-1.0.2}/pixelarraythirdparty/product/product.py +24 -6
  8. {pixelarraythirdparty-1.0.1 → pixelarraythirdparty-1.0.2}/pixelarraythirdparty/user/user.py +26 -6
  9. {pixelarraythirdparty-1.0.1 → pixelarraythirdparty-1.0.2}/pixelarraythirdparty.egg-info/PKG-INFO +1 -1
  10. {pixelarraythirdparty-1.0.1 → pixelarraythirdparty-1.0.2}/pyproject.toml +1 -1
  11. pixelarraythirdparty-1.0.1/pixelarraythirdparty/celery/celery.py +0 -22
  12. {pixelarraythirdparty-1.0.1 → pixelarraythirdparty-1.0.2}/LICENSE +0 -0
  13. {pixelarraythirdparty-1.0.1 → pixelarraythirdparty-1.0.2}/MANIFEST.in +0 -0
  14. {pixelarraythirdparty-1.0.1 → pixelarraythirdparty-1.0.2}/pixelarraythirdparty/celery/__init__.py +0 -0
  15. {pixelarraythirdparty-1.0.1 → pixelarraythirdparty-1.0.2}/pixelarraythirdparty/order/__init__.py +0 -0
  16. {pixelarraythirdparty-1.0.1 → pixelarraythirdparty-1.0.2}/pixelarraythirdparty/product/__init__.py +0 -0
  17. {pixelarraythirdparty-1.0.1 → pixelarraythirdparty-1.0.2}/pixelarraythirdparty/user/__init__.py +0 -0
  18. {pixelarraythirdparty-1.0.1 → pixelarraythirdparty-1.0.2}/pixelarraythirdparty.egg-info/SOURCES.txt +0 -0
  19. {pixelarraythirdparty-1.0.1 → pixelarraythirdparty-1.0.2}/pixelarraythirdparty.egg-info/dependency_links.txt +0 -0
  20. {pixelarraythirdparty-1.0.1 → pixelarraythirdparty-1.0.2}/pixelarraythirdparty.egg-info/requires.txt +0 -0
  21. {pixelarraythirdparty-1.0.1 → pixelarraythirdparty-1.0.2}/pixelarraythirdparty.egg-info/top_level.txt +0 -0
  22. {pixelarraythirdparty-1.0.1 → pixelarraythirdparty-1.0.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pixelarraythirdparty
3
- Version: 1.0.1
3
+ Version: 1.0.2
4
4
  Summary: PixelArray 第三方微服务客户端
5
5
  Author-email: Lu qi <qi.lu@pixelarrayai.com>
6
6
  License-Expression: MIT
@@ -10,7 +10,7 @@ PixelArray 第三方微服务客户端
10
10
  - user: 用户管理模块
11
11
  """
12
12
 
13
- __version__ = "1.0.1"
13
+ __version__ = "1.0.2"
14
14
  __author__ = "Lu qi"
15
15
  __email__ = "qi.lu@pixelarrayai.com"
16
16
 
@@ -0,0 +1,37 @@
1
+ from pixelarraythirdparty.client import Client
2
+
3
+
4
+ class CeleryManager(Client):
5
+ def get_celery_status(self):
6
+ data, success = self._request("GET", "/api/celery/status")
7
+ if not success:
8
+ return {}, False
9
+ return data, True
10
+
11
+ def get_celery_tasks(self):
12
+ data, success = self._request("GET", "/api/celery/tasks")
13
+ if not success:
14
+ return {}, False
15
+ return data, True
16
+
17
+ def get_celery_tasks_scheduled(self):
18
+ data, success = self._request("GET", "/api/celery/tasks/scheduled")
19
+ if not success:
20
+ return {}, False
21
+ return data, True
22
+
23
+ def get_celery_tasks_detail(self, task_name: str):
24
+ data, success = self._request("GET", f"/api/celery/tasks/{task_name}")
25
+ if not success:
26
+ return {}, False
27
+ return data, True
28
+
29
+ def trigger_celery_task(self, task_name: str, args: list, kwargs: dict):
30
+ data, success = self._request(
31
+ "POST",
32
+ f"/api/celery/tasks/{task_name}/trigger",
33
+ json={"args": args, "kwargs": kwargs},
34
+ )
35
+ if not success:
36
+ return {}, False
37
+ return data, True
@@ -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,23 +1,7 @@
1
- import requests
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
- return self._request("POST", "/api/orders/create", json=data)
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
- return self._request("GET", "/api/orders/list", params=params)
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
- return self._request("GET", f"/api/orders/{order_no}")
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
- return self._request("PUT", f"/api/orders/{order_no}", json=data)
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
- return self._request("DELETE", f"/api/orders/{order_no}")
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
- return self._request("GET", "/api/orders/stats/summary")
89
+ data, success = self._request("GET", "/api/orders/stats/summary")
90
+ if not success:
91
+ return {}, False
92
+ return data, True
@@ -10,7 +10,7 @@ class WeChatPayManager(Client):
10
10
  product_name: str,
11
11
  product_id: str,
12
12
  ):
13
- return self._request(
13
+ data, success = self._request(
14
14
  "POST",
15
15
  "/api/wx_pay/generate_qr_code",
16
16
  json={
@@ -21,15 +21,24 @@ class WeChatPayManager(Client):
21
21
  "product_id": product_id,
22
22
  },
23
23
  )
24
+ if not success:
25
+ return {}, False
26
+ return data, True
24
27
 
25
28
  def query_order(self, out_trade_no: str):
26
- return self._request(
29
+ data, success = self._request(
27
30
  "POST", "/api/wx_pay/query_order", json={"out_trade_no": out_trade_no}
28
31
  )
32
+ if not success:
33
+ return {}, False
34
+ return data, True
29
35
 
30
36
  def refund(self, out_trade_no: str, total_fee: int):
31
- return self._request(
37
+ data, success = self._request(
32
38
  "POST",
33
39
  "/api/wx_pay/refund",
34
40
  json={"out_trade_no": out_trade_no, "total_fee": total_fee},
35
41
  )
42
+ if not success:
43
+ return {}, False
44
+ return data, True
@@ -25,7 +25,10 @@ class ProductManager(Client):
25
25
  "features": features,
26
26
  "sort_order": sort_order,
27
27
  }
28
- return self._request("POST", "/api/products/create", json=data)
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
- return self._request("GET", "/api/products/list", params=params)
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
- return self._request("GET", f"/api/products/{product_id}")
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
- return self._request("PUT", f"/api/products/{product_id}", json=data)
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
- return self._request("DELETE", f"/api/products/{product_id}")
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
- return self._request("GET", "/api/products/categories/list")
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
- return self._request("GET", "/api/users/list", params=params)
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
- return self._request("POST", "/api/users/create", json=data)
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
- return self._request("PUT", f"/api/users/{user_id}", json=data)
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
- return self._request("DELETE", f"/api/users/{user_id}")
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
- return self._request("GET", f"/api/users/{user_id}")
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
- return self._request("POST", f"/api/users/{user_id}/reset-password", json=data)
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pixelarraythirdparty
3
- Version: 1.0.1
3
+ Version: 1.0.2
4
4
  Summary: PixelArray 第三方微服务客户端
5
5
  Author-email: Lu qi <qi.lu@pixelarrayai.com>
6
6
  License-Expression: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pixelarraythirdparty"
7
- version = "1.0.1"
7
+ version = "1.0.2"
8
8
  authors = [
9
9
  {name = "Lu qi", email = "qi.lu@pixelarrayai.com"},
10
10
  ]
@@ -1,22 +0,0 @@
1
- from pixelarraythirdparty.client import Client
2
-
3
-
4
- class CeleryManager(Client):
5
- def get_celery_status(self):
6
- return self._request("GET", "/api/celery/status")
7
-
8
- def get_celery_tasks(self):
9
- return self._request("GET", "/api/celery/tasks")
10
-
11
- def get_celery_tasks_scheduled(self):
12
- return self._request("GET", "/api/celery/tasks/scheduled")
13
-
14
- def get_celery_tasks_detail(self, task_name: str):
15
- return self._request("GET", f"/api/celery/tasks/{task_name}")
16
-
17
- def trigger_celery_task(self, task_name: str, args: list, kwargs: dict):
18
- return self._request(
19
- "POST",
20
- f"/api/celery/tasks/{task_name}/trigger",
21
- json={"args": args, "kwargs": kwargs},
22
- )