pixelarraythirdparty 1.0.0__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 PixelArray
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,7 @@
1
+ include README.md
2
+ include requirements.txt
3
+ include LICENSE
4
+ recursive-include pixelarraylib *.py
5
+ recursive-exclude * __pycache__
6
+ recursive-exclude * *.py[co]
7
+ recursive-exclude test_case *
@@ -0,0 +1,26 @@
1
+ Metadata-Version: 2.4
2
+ Name: pixelarraythirdparty
3
+ Version: 1.0.0
4
+ Summary: PixelArray 第三方微服务客户端
5
+ Author-email: Lu qi <qi.lu@pixelarrayai.com>
6
+ License-Expression: MIT
7
+ Keywords: python,utils,thirdparty,pixelarray
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.8
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
19
+ Classifier: Topic :: Utilities
20
+ Requires-Python: >=3.8
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: requests
24
+ Requires-Dist: aiohttp
25
+ Requires-Dist: asyncio
26
+ Dynamic: license-file
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+
4
+ """
5
+ PixelArray 第三方微服务客户端
6
+ 这个库包含了常用的开发工具和服务集成:
7
+ - order: 订单管理模块和支付模块
8
+ - product: 产品管理模块
9
+ - celery: 定时任务管理模块
10
+ - user: 用户管理模块
11
+ """
12
+
13
+ __version__ = "1.0.0"
14
+ __author__ = "Lu qi"
15
+ __email__ = "qi.lu@pixelarrayai.com"
16
+
17
+ # 导出主要模块
18
+ __all__ = [
19
+ "product",
20
+ "celery",
21
+ "user",
22
+ "order",
23
+ ]
@@ -0,0 +1,38 @@
1
+ import requests
2
+
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
+
21
+ def get_celery_status(self):
22
+ return self._request("GET", "/api/celery/status")
23
+
24
+ def get_celery_tasks(self):
25
+ return self._request("GET", "/api/celery/tasks")
26
+
27
+ def get_celery_tasks_scheduled(self):
28
+ return self._request("GET", "/api/celery/tasks/scheduled")
29
+
30
+ def get_celery_tasks_detail(self, task_name: str):
31
+ return self._request("GET", f"/api/celery/tasks/{task_name}")
32
+
33
+ def trigger_celery_task(self, task_name: str, args: list, kwargs: dict):
34
+ return self._request(
35
+ "POST",
36
+ f"/api/celery/tasks/{task_name}/trigger",
37
+ json={"args": args, "kwargs": kwargs},
38
+ )
@@ -0,0 +1,90 @@
1
+ import requests
2
+
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
+
21
+ def create_order(
22
+ self,
23
+ product_name: str,
24
+ product_id: str,
25
+ amount: float,
26
+ body: str,
27
+ remark: str,
28
+ payment_channel: str,
29
+ ):
30
+ data = {
31
+ "product_name": product_name,
32
+ "product_id": product_id,
33
+ "amount": amount,
34
+ "body": body,
35
+ "remark": remark,
36
+ "payment_channel": payment_channel,
37
+ }
38
+ return self._request("POST", "/api/orders/create", json=data)
39
+
40
+ def list_order(
41
+ self,
42
+ page: int = 1,
43
+ page_size: int = 10,
44
+ payment_status: str = None,
45
+ order_no: str = None,
46
+ ):
47
+ params = {
48
+ "page": page,
49
+ "page_size": page_size,
50
+ "payment_status": payment_status,
51
+ "order_no": order_no,
52
+ }
53
+ return self._request("GET", "/api/orders/list", params=params)
54
+
55
+ def get_order_detail(self, order_no: str):
56
+ return self._request("GET", f"/api/orders/{order_no}")
57
+
58
+ def update_order(
59
+ self,
60
+ order_no: str,
61
+ 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
+ ):
72
+ data = {
73
+ "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
+ }
84
+ return self._request("PUT", f"/api/orders/{order_no}", json=data)
85
+
86
+ def delete_order(self, order_no: str):
87
+ return self._request("DELETE", f"/api/orders/{order_no}")
88
+
89
+ def get_order_stats(self):
90
+ return self._request("GET", "/api/orders/stats/summary")
@@ -0,0 +1,51 @@
1
+ import requests
2
+
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
+
21
+ def generate_qr_code(
22
+ self,
23
+ out_trade_no: str,
24
+ total_fee: int,
25
+ body: str,
26
+ product_name: str,
27
+ product_id: str,
28
+ ):
29
+ return self._request(
30
+ "POST",
31
+ "/api/wx_pay/generate_qr_code",
32
+ json={
33
+ "out_trade_no": out_trade_no,
34
+ "total_fee": total_fee,
35
+ "body": body,
36
+ "product_name": product_name,
37
+ "product_id": product_id,
38
+ },
39
+ )
40
+
41
+ def query_order(self, out_trade_no: str):
42
+ return self._request(
43
+ "POST", "/api/wx_pay/query_order", json={"out_trade_no": out_trade_no}
44
+ )
45
+
46
+ def refund(self, out_trade_no: str, total_fee: int):
47
+ return self._request(
48
+ "POST",
49
+ "/api/wx_pay/refund",
50
+ json={"out_trade_no": out_trade_no, "total_fee": total_fee},
51
+ )
@@ -0,0 +1,102 @@
1
+ import requests
2
+
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
+
21
+ def create_product(
22
+ self,
23
+ name: str,
24
+ description: str,
25
+ price: float,
26
+ category: str,
27
+ status: str,
28
+ is_subscription: bool,
29
+ subscription_period: str,
30
+ features: str,
31
+ sort_order: int,
32
+ ):
33
+ data = {
34
+ "name": name,
35
+ "description": description,
36
+ "price": price,
37
+ "category": category,
38
+ "status": status,
39
+ "is_subscription": is_subscription,
40
+ "subscription_period": subscription_period,
41
+ "features": features,
42
+ "sort_order": sort_order,
43
+ }
44
+ return self._request("POST", "/api/products/create", json=data)
45
+
46
+ def list_product(
47
+ self,
48
+ page: int = 1,
49
+ page_size: int = 10,
50
+ status: str = None,
51
+ category: str = None,
52
+ name: str = None,
53
+ ):
54
+ params = {
55
+ "page": page,
56
+ "page_size": page_size,
57
+ "status": status,
58
+ "category": category,
59
+ "name": name,
60
+ }
61
+ if status is not None:
62
+ params["status"] = status
63
+ if category is not None:
64
+ params["category"] = category
65
+ if name is not None:
66
+ params["name"] = name
67
+ return self._request("GET", "/api/products/list", params=params)
68
+
69
+ def get_product_detail(self, product_id: str):
70
+ return self._request("GET", f"/api/products/{product_id}")
71
+
72
+ def update_product(
73
+ self,
74
+ product_id: str,
75
+ name: str,
76
+ description: str,
77
+ price: float,
78
+ category: str,
79
+ status: str,
80
+ is_subscription: bool,
81
+ subscription_period: str,
82
+ features: str,
83
+ sort_order: int,
84
+ ):
85
+ data = {
86
+ "name": name,
87
+ "description": description,
88
+ "price": price,
89
+ "category": category,
90
+ "status": status,
91
+ "is_subscription": is_subscription,
92
+ "subscription_period": subscription_period,
93
+ "features": features,
94
+ "sort_order": sort_order,
95
+ }
96
+ return self._request("PUT", f"/api/products/{product_id}", json=data)
97
+
98
+ def delete_product(self, product_id: str):
99
+ return self._request("DELETE", f"/api/products/{product_id}")
100
+
101
+ def get_product_categories(self):
102
+ return self._request("GET", "/api/products/categories/list")
@@ -0,0 +1,65 @@
1
+ import requests
2
+ import aiohttp
3
+ from typing import Optional
4
+
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
+
23
+ def list_user(
24
+ self,
25
+ page: int = 1,
26
+ page_size: int = 10,
27
+ role: Optional[str] = None,
28
+ is_active: Optional[bool] = None,
29
+ ):
30
+ params = {"page": page, "page_size": page_size}
31
+ if role is not None:
32
+ params["role"] = role
33
+ if is_active is not None:
34
+ params["is_active"] = is_active
35
+ return self._request("GET", "/api/users/list", params=params)
36
+
37
+ def create_user(self, username: str, password: str, email: str, role: str):
38
+ data = {
39
+ "username": username,
40
+ "password": password,
41
+ "email": email,
42
+ "role": role,
43
+ }
44
+ return self._request("POST", "/api/users/create", json=data)
45
+
46
+ def update_user(
47
+ self, user_id: int, username: str, email: str, role: str, is_active: bool
48
+ ):
49
+ data = {
50
+ "username": username,
51
+ "email": email,
52
+ "role": role,
53
+ "is_active": is_active,
54
+ }
55
+ return self._request("PUT", f"/api/users/{user_id}", json=data)
56
+
57
+ def delete_user(self, user_id: int):
58
+ return self._request("DELETE", f"/api/users/{user_id}")
59
+
60
+ def get_user_detail(self, user_id: int):
61
+ return self._request("GET", f"/api/users/{user_id}")
62
+
63
+ def reset_user_password(self, user_id: int, new_password: str):
64
+ data = {"new_password": new_password}
65
+ return self._request("POST", f"/api/users/{user_id}/reset-password", json=data)
@@ -0,0 +1,26 @@
1
+ Metadata-Version: 2.4
2
+ Name: pixelarraythirdparty
3
+ Version: 1.0.0
4
+ Summary: PixelArray 第三方微服务客户端
5
+ Author-email: Lu qi <qi.lu@pixelarrayai.com>
6
+ License-Expression: MIT
7
+ Keywords: python,utils,thirdparty,pixelarray
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.8
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
19
+ Classifier: Topic :: Utilities
20
+ Requires-Python: >=3.8
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: requests
24
+ Requires-Dist: aiohttp
25
+ Requires-Dist: asyncio
26
+ Dynamic: license-file
@@ -0,0 +1,19 @@
1
+ LICENSE
2
+ MANIFEST.in
3
+ pyproject.toml
4
+ pixelarraythirdparty/__init__.py
5
+ pixelarraythirdparty/auth.py
6
+ pixelarraythirdparty.egg-info/PKG-INFO
7
+ pixelarraythirdparty.egg-info/SOURCES.txt
8
+ pixelarraythirdparty.egg-info/dependency_links.txt
9
+ pixelarraythirdparty.egg-info/requires.txt
10
+ pixelarraythirdparty.egg-info/top_level.txt
11
+ pixelarraythirdparty/celery/__init__.py
12
+ pixelarraythirdparty/celery/celery.py
13
+ pixelarraythirdparty/order/__init__.py
14
+ pixelarraythirdparty/order/order.py
15
+ pixelarraythirdparty/order/pay.py
16
+ pixelarraythirdparty/product/__init__.py
17
+ pixelarraythirdparty/product/product.py
18
+ pixelarraythirdparty/user/__init__.py
19
+ pixelarraythirdparty/user/user.py
@@ -0,0 +1,3 @@
1
+ requests
2
+ aiohttp
3
+ asyncio
@@ -0,0 +1 @@
1
+ pixelarraythirdparty
@@ -0,0 +1,44 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel", "build"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "pixelarraythirdparty"
7
+ version = "1.0.0"
8
+ authors = [
9
+ {name = "Lu qi", email = "qi.lu@pixelarrayai.com"},
10
+ ]
11
+ description = "PixelArray 第三方微服务客户端"
12
+ readme = "README.md"
13
+ license = "MIT"
14
+ requires-python = ">=3.8"
15
+ classifiers = [
16
+ "Development Status :: 4 - Beta",
17
+ "Intended Audience :: Developers",
18
+ "Operating System :: OS Independent",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.8",
21
+ "Programming Language :: Python :: 3.9",
22
+ "Programming Language :: Python :: 3.10",
23
+ "Programming Language :: Python :: 3.11",
24
+ "Programming Language :: Python :: 3.12",
25
+ "Programming Language :: Python :: 3.13",
26
+ "Topic :: Software Development :: Libraries :: Python Modules",
27
+ "Topic :: Utilities",
28
+ ]
29
+ keywords = ["python", "utils", "thirdparty", "pixelarray"]
30
+ dependencies = [
31
+ "requests",
32
+ "aiohttp",
33
+ "asyncio"
34
+ ]
35
+
36
+ [tool.setuptools]
37
+ [tool.setuptools.packages.find]
38
+ include = ["pixelarraythirdparty", "pixelarraythirdparty.*"]
39
+
40
+ [tool.setuptools.package-data]
41
+ pixelarraythirdparty = ["*"]
42
+
43
+ [tool.setuptools.package-dir]
44
+ pixelarraythirdparty = "pixelarraythirdparty"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+