lingxingapi 1.1.4__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.
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 +557 -0
  8. lingxingapi/base/__init__.py +0 -0
  9. lingxingapi/base/api.py +568 -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 +218 -0
  18. lingxingapi/errors.py +152 -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 +456 -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.1.4.dist-info/METADATA +73 -0
  62. lingxingapi-1.1.4.dist-info/RECORD +65 -0
  63. lingxingapi-1.1.4.dist-info/WHEEL +5 -0
  64. lingxingapi-1.1.4.dist-info/licenses/LICENSE +22 -0
  65. lingxingapi-1.1.4.dist-info/top_level.txt +1 -0
@@ -0,0 +1,176 @@
1
+ # -*- coding: utf-8 -*-
2
+ from typing import Optional
3
+ from pydantic import ValidationInfo, Field, field_validator
4
+ from lingxingapi import utils
5
+ from lingxingapi.fields import NonEmptyStr, NonNegativeInt
6
+ from lingxingapi.base.param import Parameter, PageOffestAndLength
7
+
8
+
9
+ # 店铺共享参数 --------------------------------------------------------------------------------------------------------------------
10
+ class Seller(PageOffestAndLength):
11
+ """店铺共享参数"""
12
+
13
+ # 领星店铺ID
14
+ sid: NonNegativeInt
15
+
16
+
17
+ # 订单数据 -----------------------------------------------------------------------------------------------------------------------
18
+ # . Orders
19
+ class Orders(Seller):
20
+ # 开始日期
21
+ start_date: str
22
+ # 结束日期
23
+ end_date: str
24
+ # 日期类型 (1: 下单日期, 2: 亚马逊订单更新时间 | 默认: 1)
25
+ date_type: Optional[NonNegativeInt] = None
26
+
27
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
28
+ @field_validator("start_date", "end_date", mode="before")
29
+ @classmethod
30
+ def _validate_date(cls, v: str, info: ValidationInfo) -> str:
31
+ dt = utils.validate_datetime(v, False, "订单数据日期 %s" % info.field_name)
32
+ return "%04d-%02d-%02d" % (dt.year, dt.month, dt.day)
33
+
34
+
35
+ # . FBA Shipments
36
+ class FbaShipments(Seller):
37
+ """查询 FBA 发货订单参数"""
38
+
39
+ # 发货开始时间 (本地时间), 时间间隔不超过7天
40
+ start_time: str = Field(alias="shipment_date_after")
41
+ # 发货结束时间 (本地时间), 时间间隔不超过7天
42
+ end_time: str = Field(alias="shipment_date_before")
43
+
44
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
45
+ @field_validator("start_time", "end_time", mode="before")
46
+ @classmethod
47
+ def _validate_time(cls, v: str, info: ValidationInfo) -> str:
48
+ dt = utils.validate_datetime(v, False, "FBA发货订单时间 %s" % info.field_name)
49
+ # fmt: off
50
+ return "%04d-%02d-%02d %02d:%02d:%02d" % (
51
+ dt.year, dt.month, dt.day,
52
+ dt.hour, dt.minute, dt.second,
53
+ )
54
+ # fmt: on
55
+
56
+
57
+ # FBA 库存数据 -------------------------------------------------------------------------------------------------------------------
58
+ # . FBA Removal Orders
59
+ class FbaRemovalOrders(Orders):
60
+ """查询 FBA 移除订单参数"""
61
+
62
+ # 日期类型 ('update_date', 'request_date' | 默认: 'update_date')
63
+ date_type: str = Field(alias="search_field_time")
64
+
65
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
66
+ @field_validator("date_type", mode="before")
67
+ @classmethod
68
+ def _validate_date_type(cls, v) -> str:
69
+ return "last_updated_date" if v == "update_date" else v
70
+
71
+
72
+ # . FBA Removal Shipments
73
+ class FbaRemovalShipments(Orders):
74
+ """查询 FBA 移除货件参数"""
75
+
76
+ # 领星店铺ID
77
+ sid: Optional[NonNegativeInt] = None
78
+ # 亚马逊卖家ID
79
+ seller_id: Optional[str] = None
80
+
81
+
82
+ # . FBA Inventory Adjustments
83
+ class FbaInventoryAdjustments(PageOffestAndLength):
84
+ """查询 FBA 库存调整参数"""
85
+
86
+ # 开始日期
87
+ start_date: str
88
+ # 结束日期
89
+ end_date: str
90
+ # 领星店铺IDs (多个用逗号分隔)
91
+ sids: Optional[str] = None
92
+ # 搜索字段 ('asin', 'msku', 'fnsku', 'title', 'transaction_item_id')
93
+ search_field: Optional[NonEmptyStr] = None
94
+ # 搜索值
95
+ search_value: Optional[NonEmptyStr] = None
96
+
97
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
98
+ @field_validator("start_date", "end_date", mode="before")
99
+ @classmethod
100
+ def _validate_date(cls, v: str, info: ValidationInfo) -> str:
101
+ dt = utils.validate_datetime(v, False, "FBA库存调整日期 %s" % info.field_name)
102
+ return "%04d-%02d-%02d" % (dt.year, dt.month, dt.day)
103
+
104
+ @field_validator("sids", mode="before")
105
+ @classmethod
106
+ def _validate_sids(cls, v) -> str | None:
107
+ if v is None:
108
+ return v
109
+ sids = utils.validate_array_of_unsigned_int(v, "领星店铺IDs")
110
+ return ",".join(map(str, sids))
111
+
112
+ @field_validator("search_field", mode="before")
113
+ @classmethod
114
+ def _validate_search_field(cls, v) -> str | None:
115
+ if v is None:
116
+ return v
117
+ if v == "title":
118
+ return "item_name"
119
+ return v
120
+
121
+
122
+ # 报告导出 -----------------------------------------------------------------------------------------------------------------------
123
+ # . Export Report Task
124
+ class ExportReportTask(Parameter):
125
+ """创建报告导出任务参数"""
126
+
127
+ # 亚马逊店铺ID (Seller.seller_id)
128
+ seller_id: NonEmptyStr
129
+ # 亚马逊市场ID列表 (Seller.marketplace_id)
130
+ marketplace_ids: list[NonEmptyStr]
131
+ # 店铺所在区域
132
+ region: NonEmptyStr
133
+ # 报告类型 具体参考亚马逊官方文档: https://developer-docs.amazon.com/sp-api/docs/report-type-values
134
+ report_type: NonEmptyStr
135
+ # 报告开始时间 (UTC时间, 例: '2023-01-01T00:00:00+00:00')
136
+ start_time: Optional[str] = None
137
+ # 报告结束时间 (UTC时间, 例: '2023-01-31T23:59:59+00:00')
138
+ end_time: Optional[str] = None
139
+
140
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
141
+ @field_validator("marketplace_ids", mode="before")
142
+ @classmethod
143
+ def _validate_marketplace_ids(cls, v: str) -> str:
144
+ return utils.validate_array_of_non_empty_str(v, "亚马逊市场IDs")
145
+
146
+ @field_validator("start_time", "end_time", mode="before")
147
+ @classmethod
148
+ def _validate_utc_time(cls, v: str, info: ValidationInfo) -> str | None:
149
+ if v is None:
150
+ return v
151
+ dt = utils.validate_datetime(v, True, "报告导出时间 %s" % info.field_name)
152
+ return dt.isoformat()
153
+
154
+
155
+ # . Export Report Result
156
+ class ExportReportResult(Parameter):
157
+ """查询报告导出结果参数"""
158
+
159
+ # 亚马逊卖家ID (Seller.seller_id)
160
+ seller_id: NonEmptyStr
161
+ # 报告导出任务ID (ExportReportTask.report_id)
162
+ task_id: NonEmptyStr
163
+ # 店铺所在区域
164
+ region: NonEmptyStr
165
+
166
+
167
+ # . Export Report Refresh
168
+ class ExportReportRefresh(Parameter):
169
+ """刷新报告导出结果参数"""
170
+
171
+ # 亚马逊卖家ID (Seller.seller_id)
172
+ seller_id: NonEmptyStr
173
+ # 报告文件ID (ExportReportResultData.report_document_id)
174
+ report_document_id: NonEmptyStr
175
+ # 店铺所在区域
176
+ region: NonEmptyStr
@@ -0,0 +1,38 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # fmt: off
4
+ # 订单数据 -----------------------------------------------------------------------------------------------------------------------
5
+ # https://apidoc.lingxing.com/#/docs/SourceData/AllOrders
6
+ ORDERS: str = "/erp/sc/data/mws_report/allOrders"
7
+ # https://apidoc.lingxing.com/#/docs/SourceData/FbaOrders
8
+ FBA_ORDERS: str = "/erp/sc/data/mws_report/fbaOrders"
9
+ # https://apidoc.lingxing.com/#/docs/SourceData/fbaExchangeOrderList
10
+ FBA_REPLACEMENT_ORDERS: str = "/erp/sc/routing/data/order/fbaExchangeOrderList"
11
+ # https://apidoc.lingxing.com/#/docs/SourceData/RefundOrders
12
+ FBA_RETURN_ORDERS: str = "/erp/sc/data/mws_report/refundOrders"
13
+ # https://apidoc.lingxing.com/#/docs/SourceData/v1getAmazonFulfilledShipmentsList
14
+ FBA_SHIPMENTS_V1: str = "/erp/sc/data/mws_report_v1/getAmazonFulfilledShipmentsList"
15
+ # https://apidoc.lingxing.com/#/docs/SourceData/fbmReturnOrderList
16
+ FBM_RETURN_ORDERS: str = "/erp/sc/routing/data/order/fbmReturnOrderList"
17
+
18
+ # FBA 库存数据 -------------------------------------------------------------------------------------------------------------------
19
+ # https://apidoc.lingxing.com/#/docs/SourceData/RemovalOrderListNew
20
+ FBA_REMOVAL_ORDERS: str = "/erp/sc/routing/data/order/removalOrderListNew"
21
+ # https://apidoc.lingxing.com/#/docs/SourceData/RemovalShipmentList
22
+ FBA_REMOVAL_SHIPMENTS: str = "/erp/sc/statistic/removalShipment/list"
23
+ # https://apidoc.lingxing.com/#/docs/SourceData/ManageInventory
24
+ FBA_INVENTORY: str = "/erp/sc/data/mws_report/manageInventory"
25
+ # https://apidoc.lingxing.com/#/docs/SourceData/AfnFulfillableQuantity
26
+ FBA_RESERVED_INVENTORY: str = "/erp/sc/data/mws_report/reservedInventory"
27
+ # https://apidoc.lingxing.com/#/docs/SourceData/getFbaAgeList
28
+ FBA_INVENTORY_HEALTH: str = "/erp/sc/routing/fba/fbaStock/getFbaAgeList"
29
+ # https://apidoc.lingxing.com/#/docs/SourceData/AdjustmentList
30
+ FBA_INVENTORY_ADJUSTMENTS: str = "/basicOpen/openapi/mwsReport/adjustmentList"
31
+
32
+ # 导出报告 -----------------------------------------------------------------------------------------------------------------------
33
+ # https://apidoc.lingxing.com/#/docs/Statistics/reportCreateReportExportTask
34
+ EXPORT_REPORT_TASK: str = "/basicOpen/report/create/reportExportTask"
35
+ # https://apidoc.lingxing.com/#/docs/Statistics/reportQueryReportExportTask
36
+ EXPORT_REPORT_RESULT: str = "/basicOpen/report/query/reportExportTask"
37
+ # https://apidoc.lingxing.com/#/docs/Statistics/AmazonReportExportTask
38
+ EXPORT_REPORT_REFRESH: str = "/basicOpen/report/amazonReportExportTask"