lingxingapi 1.0.0__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.

Potentially problematic release.


This version of lingxingapi might be problematic. Click here for more details.

Files changed (65) hide show
  1. lingxingapi/__init__.py +7 -0
  2. lingxingapi/ads/__init__.py +0 -0
  3. lingxingapi/ads/api.py +5946 -0
  4. lingxingapi/ads/param.py +192 -0
  5. lingxingapi/ads/route.py +134 -0
  6. lingxingapi/ads/schema.py +2615 -0
  7. lingxingapi/api.py +443 -0
  8. lingxingapi/base/__init__.py +0 -0
  9. lingxingapi/base/api.py +409 -0
  10. lingxingapi/base/param.py +59 -0
  11. lingxingapi/base/route.py +11 -0
  12. lingxingapi/base/schema.py +198 -0
  13. lingxingapi/basic/__init__.py +0 -0
  14. lingxingapi/basic/api.py +466 -0
  15. lingxingapi/basic/param.py +72 -0
  16. lingxingapi/basic/route.py +20 -0
  17. lingxingapi/basic/schema.py +212 -0
  18. lingxingapi/errors.py +143 -0
  19. lingxingapi/fba/__init__.py +0 -0
  20. lingxingapi/fba/api.py +1691 -0
  21. lingxingapi/fba/param.py +250 -0
  22. lingxingapi/fba/route.py +30 -0
  23. lingxingapi/fba/schema.py +987 -0
  24. lingxingapi/fields.py +50 -0
  25. lingxingapi/finance/__init__.py +0 -0
  26. lingxingapi/finance/api.py +3091 -0
  27. lingxingapi/finance/param.py +616 -0
  28. lingxingapi/finance/route.py +44 -0
  29. lingxingapi/finance/schema.py +1243 -0
  30. lingxingapi/product/__init__.py +0 -0
  31. lingxingapi/product/api.py +2643 -0
  32. lingxingapi/product/param.py +934 -0
  33. lingxingapi/product/route.py +49 -0
  34. lingxingapi/product/schema.py +1004 -0
  35. lingxingapi/purchase/__init__.py +0 -0
  36. lingxingapi/purchase/api.py +496 -0
  37. lingxingapi/purchase/param.py +126 -0
  38. lingxingapi/purchase/route.py +11 -0
  39. lingxingapi/purchase/schema.py +215 -0
  40. lingxingapi/sales/__init__.py +0 -0
  41. lingxingapi/sales/api.py +3200 -0
  42. lingxingapi/sales/param.py +723 -0
  43. lingxingapi/sales/route.py +70 -0
  44. lingxingapi/sales/schema.py +1718 -0
  45. lingxingapi/source/__init__.py +0 -0
  46. lingxingapi/source/api.py +1799 -0
  47. lingxingapi/source/param.py +176 -0
  48. lingxingapi/source/route.py +38 -0
  49. lingxingapi/source/schema.py +1011 -0
  50. lingxingapi/tools/__init__.py +0 -0
  51. lingxingapi/tools/api.py +291 -0
  52. lingxingapi/tools/param.py +73 -0
  53. lingxingapi/tools/route.py +8 -0
  54. lingxingapi/tools/schema.py +169 -0
  55. lingxingapi/utils.py +411 -0
  56. lingxingapi/warehourse/__init__.py +0 -0
  57. lingxingapi/warehourse/api.py +1778 -0
  58. lingxingapi/warehourse/param.py +506 -0
  59. lingxingapi/warehourse/route.py +28 -0
  60. lingxingapi/warehourse/schema.py +926 -0
  61. lingxingapi-1.0.0.dist-info/METADATA +67 -0
  62. lingxingapi-1.0.0.dist-info/RECORD +65 -0
  63. lingxingapi-1.0.0.dist-info/WHEEL +5 -0
  64. lingxingapi-1.0.0.dist-info/licenses/LICENSE +22 -0
  65. lingxingapi-1.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,212 @@
1
+ # -*- coding: utf-8 -*-
2
+ from pydantic import BaseModel, Field, field_validator
3
+ from lingxingapi.fields import IntOrNone2Zero
4
+ from lingxingapi.base.schema import ResponseV1, ResponseResult
5
+
6
+
7
+ # 基础数据 -----------------------------------------------------------------------------------------------------------------------
8
+ # . Marketplaces
9
+ class Marketplace(BaseModel):
10
+ """亚马逊站点."""
11
+
12
+ # 领星站点ID [唯一标识]
13
+ mid: int
14
+ # 站点区域
15
+ region: str
16
+ # 站点亚马逊仓库所属区域 [原字段 'aws_region']
17
+ amazon_region: str = Field(validation_alias="aws_region")
18
+ # 站点国家 (中文)
19
+ country: str
20
+ # 站点国家代码 [原字段 'code']
21
+ country_code: str = Field(validation_alias="code")
22
+ # 亚马逊市场ID
23
+ marketplace_id: str
24
+
25
+
26
+ class Marketplaces(ResponseV1):
27
+ """亚马逊站点查询结果."""
28
+
29
+ data: list[Marketplace]
30
+
31
+
32
+ # . States
33
+ class State(BaseModel):
34
+ """国家的省/州."""
35
+
36
+ # 国家代码
37
+ country_code: str
38
+ # 省/州名称 [原字段 'state_or_province_name']
39
+ state: str = Field(validation_alias="state_or_province_name")
40
+ # 省/州代码 [原字段 'code']
41
+ state_code: str = Field(validation_alias="code")
42
+
43
+
44
+ class States(ResponseV1):
45
+ """国家的省/州查询结果."""
46
+
47
+ data: list[State]
48
+
49
+
50
+ # . Sellers
51
+ class Seller(BaseModel):
52
+ """领星店铺."""
53
+
54
+ # 领星站点ID (Marketplace.mid)
55
+ mid: int
56
+ # 领星店铺ID [唯一标识]
57
+ sid: int
58
+ # 亚马逊卖家ID
59
+ seller_id: str
60
+ # 领星店铺名称 (含国家信息) [原字段 'name']
61
+ seller_name: str = Field(validation_alias="name")
62
+ # 领星店铺帐号ID [原字段 'seller_account_id']
63
+ account_id: int = Field(validation_alias="seller_account_id")
64
+ # 领星店铺帐号名称
65
+ account_name: str
66
+ # 亚马逊市场ID (Marketplace.marketplace_id)
67
+ marketplace_id: str
68
+ # 店铺区域
69
+ region: str
70
+ # 店铺国家 (中文)
71
+ country: str
72
+ # 店铺状态 (0: 停止同步, 1: 正常, 2: 授权异常, 3: 欠费停服)
73
+ status: int
74
+ # 店铺是否授权广告 (0: 否, 1: 是) [原字段 'has_ads_setting']
75
+ ads_authorized: int = Field(validation_alias="has_ads_setting")
76
+
77
+
78
+ class Sellers(ResponseV1):
79
+ """领星店铺查询结果."""
80
+
81
+ data: list[Seller]
82
+
83
+
84
+ # . Concept Sellers
85
+ class ConceptSeller(BaseModel):
86
+ """领星概念店铺."""
87
+
88
+ # 领星概念站点ID [原字段 'mid']
89
+ cmid: int = Field(validation_alias="mid")
90
+ # 领星概念店铺ID [唯一标识, 原字段 'id']
91
+ csid: int = Field(validation_alias="id")
92
+ # 亚马逊卖家ID
93
+ seller_id: str
94
+ # 领星概念店铺名称 (含区域信息) [原字段 'name']
95
+ seller_name: str = Field(validation_alias="name")
96
+ # 领星概念店铺账号ID [原字段 'seller_account_id']
97
+ account_id: int = Field(validation_alias="seller_account_id")
98
+ # 领星概念店铺帐号名称 [原字段 'seller_account_name']
99
+ account_name: str = Field(validation_alias="seller_account_name")
100
+ # 概念店铺区域
101
+ region: str
102
+ # 概念店铺国家, 如: "北美共享", "欧洲共享"
103
+ country: str
104
+ # 概念店铺状态 (1: 启用, 2: 停用)
105
+ status: int
106
+
107
+
108
+ class ConceptSellers(ResponseV1):
109
+ """领星概念店铺查询结果."""
110
+
111
+ data: list[ConceptSeller]
112
+
113
+
114
+ # . Rename Sellers
115
+ class RenameSellersFailureDetail(BaseModel):
116
+ """批量修改店铺名称失败的详情."""
117
+
118
+ # 领星店铺ID (Seller.sid)
119
+ sid: int
120
+ # 新店铺名称
121
+ name: str
122
+ # 失败信息 [原字段 'error']
123
+ message: str = Field(validation_alias="error")
124
+
125
+
126
+ class RenameSellers(BaseModel):
127
+ """批量修改店铺名称的结果."""
128
+
129
+ success: IntOrNone2Zero = Field(validation_alias="success_num")
130
+ # 修改失败数量 [原字段 'failure_num']
131
+ failure: IntOrNone2Zero = Field(validation_alias="failure_num")
132
+ # 修改失败详情
133
+ failure_detail: list[RenameSellersFailureDetail]
134
+
135
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
136
+ @field_validator("failure_detail", mode="before")
137
+ def _validate_failure_detail(cls, v):
138
+ if v is None:
139
+ return []
140
+ return [RenameSellersFailureDetail.model_validate(i) for i in v]
141
+
142
+
143
+ class RenameSellersResult(ResponseResult):
144
+ """批量修改店铺名称的响应结果."""
145
+
146
+ data: RenameSellers
147
+
148
+
149
+ # . Accounts
150
+ class Account(BaseModel):
151
+ """领星账号."""
152
+
153
+ # 领星账号所从属的ID (如主帐号ID) [原字段 'zid']
154
+ mid: int = Field(validation_alias="zid")
155
+ # 领星帐号ID [唯一标识] [原字段 'uid']
156
+ user_id: int = Field(validation_alias="uid")
157
+ # 是否为主账号 (0: 否, 1: 是)
158
+ is_master: int
159
+ # 帐号角色
160
+ role: str
161
+ # 领星帐号显示的姓名 [原字段 'realname']
162
+ display_name: str = Field(validation_alias="realname")
163
+ # 领星帐号登陆用户名
164
+ username: str
165
+ # 领星帐号电子邮箱
166
+ email: str
167
+ # 领星帐号电话号码 [原字段 'mobile']
168
+ phone: str = Field(validation_alias="mobile")
169
+ # 领星帐号创建时间 (北京时间)
170
+ create_time: str
171
+ # 领星帐号最后登录时间 (北京时间)
172
+ last_login_time: str
173
+ # 领星帐号最后登录IP
174
+ last_login_ip: str
175
+ # 领星帐号登录次数 [原字段 'login_num']
176
+ login_count: int = Field(validation_alias="login_num")
177
+ # 领星帐号状态 (0: 禁用, 1: 正常)
178
+ status: int
179
+ # 关联的领星店铺名称, 逗号分隔 [原字段 'seller']
180
+ sellers: str = Field(validation_alias="seller")
181
+
182
+
183
+ class Accounts(ResponseV1):
184
+ """领星账号查询结果."""
185
+
186
+ data: list[Account]
187
+
188
+
189
+ # . Exchange Rates
190
+ class ExchangeRate(BaseModel):
191
+ """货币汇率."""
192
+
193
+ # 汇率日期 (格式: YYYY-MM)
194
+ date: str
195
+ # 货币名称 (中文) [原字段 'name']
196
+ currency: str = Field(validation_alias="name")
197
+ # 货币代码 [原字段 'code']
198
+ currency_code: str = Field(validation_alias="code")
199
+ # 货币符号 [原字段 'icon']
200
+ currency_icon: str = Field(validation_alias="icon")
201
+ # 中国银行官方汇率 (对比人民币, 如: 7.1541) [原字段 'rate_org']
202
+ boc_rate: float = Field(validation_alias="rate_org")
203
+ # 用户汇率 (对比人民币, 如: 7.2008000000) [原字段 'my_rate']
204
+ user_rate: float = Field(validation_alias="my_rate")
205
+ # 用户汇率修改时间 (北京时间)
206
+ update_time: str
207
+
208
+
209
+ class ExchangeRates(ResponseV1):
210
+ """货币汇率查询结果."""
211
+
212
+ data: list[ExchangeRate]
lingxingapi/errors.py ADDED
@@ -0,0 +1,143 @@
1
+ # -*- coding: utf-8 -*-
2
+ from typing import Any
3
+
4
+
5
+ # Base errors -----------------------------------------------------------------------------------------------------------
6
+ class BaseApiError(Exception):
7
+ """The base class for all API errors."""
8
+
9
+ def __init__(
10
+ self,
11
+ msg: object,
12
+ url: str | None = None,
13
+ data: Any | None = None,
14
+ err_code: int | None = None,
15
+ ):
16
+ if not isinstance(msg, str):
17
+ msg = str(msg)
18
+ if url is not None:
19
+ msg += "\n请求路径: %s" % url
20
+ if data is not None:
21
+ if isinstance(data, dict):
22
+ data = {k: v for k, v in data.items() if v is not None}
23
+ msg += "\n数据信息: %r" % data
24
+ if err_code is not None:
25
+ msg += "\n错误代码: %r" % err_code
26
+ super().__init__(msg)
27
+
28
+
29
+ # API Settings errors ---------------------------------------------------------------------------------------------------
30
+ class ApiSettingsError(BaseApiError):
31
+ """Raised when there is an error with the API settings."""
32
+
33
+
34
+ # Request errors --------------------------------------------------------------------------------------------------------
35
+ class RequestError(BaseApiError):
36
+ """Raised when a request to the API fails."""
37
+
38
+
39
+ # Timeout
40
+ class ApiTimeoutError(RequestError, TimeoutError):
41
+ """Raise when the API request times out."""
42
+
43
+
44
+ # Server
45
+ class ServerError(RequestError):
46
+ """Raised when the API server deos not return proper response."""
47
+
48
+
49
+ # Authrization
50
+ class AuthorizationError(RequestError):
51
+ """Raised when the API server returns a 4xx error related to authorization."""
52
+
53
+
54
+ class UnauthorizedApiError(AuthorizationError):
55
+ """Raised when the API is not authorized for the app ID or secret."""
56
+
57
+
58
+ class UnauthorizedRequestIpError(AuthorizationError):
59
+ """Raised when the IP address is not whitelisted for API access."""
60
+
61
+
62
+ # Token
63
+ class TokenError(RequestError):
64
+ """Raised when the access token has expired."""
65
+
66
+
67
+ class TokenExpiredError(TokenError):
68
+ """Raised when the access token has expired."""
69
+
70
+
71
+ class AccessTokenExpiredError(TokenExpiredError):
72
+ """Raised when the access token has expired."""
73
+
74
+
75
+ class RefreshTokenExpiredError(TokenExpiredError):
76
+ """Raised when the refresh token has expired."""
77
+
78
+
79
+ class InvalidTokenError(TokenError):
80
+ """Raised when the token is invalid or malformed."""
81
+
82
+
83
+ class InvalidAccessTokenError(InvalidTokenError):
84
+ """Raised when the access token is invalid."""
85
+
86
+
87
+ class InvalidRefreshTokenError(InvalidTokenError):
88
+ """Raised when the refresh token is invalid."""
89
+
90
+
91
+ # App ID or Secret
92
+ class AppIdOrSecretError(RequestError):
93
+ """Raised when the app ID or secret is invalid or missing."""
94
+
95
+
96
+ # Signature errors
97
+ class SignatureError(RequestError):
98
+ """Raised when the signature is invalid or missing."""
99
+
100
+
101
+ class SignatureExpiredError(SignatureError):
102
+ """Raised when the signature has expired."""
103
+
104
+
105
+ class InvalidSignatureError(SignatureError):
106
+ """Raised when the signature is invalid."""
107
+
108
+
109
+ # Parameter
110
+ class ParametersError(RequestError):
111
+ """Raised when the request parameters are invalid or missing."""
112
+
113
+
114
+ class InvalidApiUrlError(ParametersError):
115
+ """Raised when the API server returns an error response."""
116
+
117
+
118
+ class InvalidParametersError(ParametersError):
119
+ """Raised when a required parameter is missing."""
120
+
121
+
122
+ # API Limit
123
+ class ApiLimitError(RequestError):
124
+ """Raised when the API limit has been reached."""
125
+
126
+
127
+ class TooManyRequestsError(ApiLimitError):
128
+ """Raised when too many requests have been made to the API."""
129
+
130
+
131
+ # Unknown
132
+ class UnknownRequestError(RequestError):
133
+ """Raised when an unknown error occurs during the request."""
134
+
135
+
136
+ # Response errors -------------------------------------------------------------------------------------------------------
137
+ class ReponseError(BaseApiError):
138
+ """Raised when the data returned by the API is invalid or malformed."""
139
+
140
+
141
+ # Response data
142
+ class ResponseDataError(ReponseError):
143
+ """Raised when the response data is not in the expected format."""
File without changes