python-amazon-sp-api 1.9.39__py3-none-any.whl → 2.0.10__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 (163) hide show
  1. {python_amazon_sp_api-1.9.39.dist-info → python_amazon_sp_api-2.0.10.dist-info}/METADATA +44 -8
  2. python_amazon_sp_api-2.0.10.dist-info/RECORD +253 -0
  3. {python_amazon_sp_api-1.9.39.dist-info → python_amazon_sp_api-2.0.10.dist-info}/WHEEL +1 -1
  4. {python_amazon_sp_api-1.9.39.dist-info → python_amazon_sp_api-2.0.10.dist-info}/top_level.txt +0 -1
  5. sp_api/__version__.py +1 -1
  6. sp_api/api/__init__.py +9 -3
  7. sp_api/api/application_integrations/application_integrations.py +2 -2
  8. sp_api/api/catalog/catalog.py +3 -4
  9. sp_api/api/catalog_items/catalog_items.py +3 -6
  10. sp_api/api/customer_feedback/customer_feedback.py +110 -0
  11. sp_api/api/data_kiosk/data_kiosk.py +5 -6
  12. sp_api/api/easy_ship/easy_ship.py +5 -5
  13. sp_api/api/external_fulfillment/external_fulfillment.py +706 -0
  14. sp_api/api/feeds/feeds.py +11 -8
  15. sp_api/api/fulfillment_inbound/fulfillment_inbound.py +35 -2
  16. sp_api/api/inventories/inventories.py +2 -7
  17. sp_api/api/listings_items/listings_items.py +3 -24
  18. sp_api/api/messaging/messaging.py +42 -0
  19. sp_api/api/orders/orders.py +59 -3
  20. sp_api/api/orders/orders_2026_01_01.py +54 -0
  21. sp_api/api/product_fees/product_fees.py +31 -74
  22. sp_api/api/products/products.py +3 -1
  23. sp_api/api/products/products_definitions.py +11 -169
  24. sp_api/api/reports/reports.py +61 -96
  25. sp_api/api/sales/sales.py +2 -2
  26. sp_api/asyncio/api/__init__.py +167 -0
  27. sp_api/asyncio/api/amazon_warehousing_and_distribu/__init__.py +9 -0
  28. sp_api/asyncio/api/amazon_warehousing_and_distribu/amazon_warehousing_and_distribu.py +130 -0
  29. sp_api/asyncio/api/aplus_content/__init__.py +5 -0
  30. sp_api/asyncio/api/aplus_content/aplus_content.py +330 -0
  31. sp_api/asyncio/api/application_integrations/__init__.py +5 -0
  32. sp_api/asyncio/api/application_integrations/application_integrations.py +119 -0
  33. sp_api/asyncio/api/application_management/__init__.py +5 -0
  34. sp_api/asyncio/api/application_management/application_management.py +36 -0
  35. sp_api/asyncio/api/authorization/__init__.py +5 -0
  36. sp_api/asyncio/api/authorization/authorization.py +54 -0
  37. sp_api/asyncio/api/catalog/__init__.py +5 -0
  38. sp_api/asyncio/api/catalog/catalog.py +111 -0
  39. sp_api/asyncio/api/catalog_items/__init__.py +6 -0
  40. sp_api/asyncio/api/catalog_items/catalog_items.py +93 -0
  41. sp_api/asyncio/api/clients/__init__.py +1 -0
  42. sp_api/asyncio/api/customer_feedback/__init__.py +5 -0
  43. sp_api/asyncio/api/customer_feedback/customer_feedback.py +111 -0
  44. sp_api/asyncio/api/data_kiosk/__init__.py +5 -0
  45. sp_api/asyncio/api/data_kiosk/data_kiosk.py +236 -0
  46. sp_api/asyncio/api/easy_ship/__init__.py +5 -0
  47. sp_api/asyncio/api/easy_ship/easy_ship.py +191 -0
  48. sp_api/asyncio/api/external_fulfillment/__init__.py +5 -0
  49. sp_api/asyncio/api/external_fulfillment/external_fulfillment.py +706 -0
  50. sp_api/asyncio/api/fba_inbound_eligibility/__init__.py +5 -0
  51. sp_api/asyncio/api/fba_inbound_eligibility/fba_inbound_eligibility.py +96 -0
  52. sp_api/asyncio/api/fba_small_and_light/__init__.py +5 -0
  53. sp_api/asyncio/api/fba_small_and_light/fba_small_and_light.py +213 -0
  54. sp_api/asyncio/api/feeds/feeds.py +260 -0
  55. sp_api/asyncio/api/finances/finances.py +100 -0
  56. sp_api/asyncio/api/fulfillment_inbound/fulfillment_inbound.py +1798 -0
  57. sp_api/asyncio/api/fulfillment_outbound/fulfillment_outbound.py +736 -0
  58. sp_api/asyncio/api/inventories/inventories.py +74 -0
  59. sp_api/asyncio/api/listings_items/listings_items.py +170 -0
  60. sp_api/asyncio/api/listings_restrictions/listings_restrictions.py +36 -0
  61. sp_api/asyncio/api/merchant_fulfillment/__init__.py +0 -0
  62. sp_api/asyncio/api/merchant_fulfillment/merchant_fulfillment.py +384 -0
  63. sp_api/asyncio/api/messaging/__init__.py +0 -0
  64. sp_api/asyncio/api/messaging/messaging.py +511 -0
  65. sp_api/asyncio/api/models/__init__.py +4 -0
  66. sp_api/asyncio/api/notifications/__init__.py +0 -0
  67. sp_api/asyncio/api/notifications/notifications.py +295 -0
  68. sp_api/asyncio/api/orders/__init__.py +0 -0
  69. sp_api/asyncio/api/orders/orders.py +412 -0
  70. sp_api/asyncio/api/orders/orders_2026_01_01.py +40 -0
  71. sp_api/asyncio/api/overrides/__init__.py +1 -0
  72. sp_api/asyncio/api/product_fees/__init__.py +0 -0
  73. sp_api/asyncio/api/product_fees/product_fees.py +194 -0
  74. sp_api/asyncio/api/product_type_definitions/__init__.py +0 -0
  75. sp_api/asyncio/api/product_type_definitions/product_type_definitions.py +75 -0
  76. sp_api/asyncio/api/products/__init__.py +0 -0
  77. sp_api/asyncio/api/products/products.py +405 -0
  78. sp_api/asyncio/api/products/products_definitions.py +11 -0
  79. sp_api/asyncio/api/replenishment/__init__.py +0 -0
  80. sp_api/asyncio/api/replenishment/replenishment.py +121 -0
  81. sp_api/asyncio/api/reports/__init__.py +0 -0
  82. sp_api/asyncio/api/reports/reports.py +439 -0
  83. sp_api/asyncio/api/sales/__init__.py +0 -0
  84. sp_api/asyncio/api/sales/sales.py +93 -0
  85. sp_api/asyncio/api/sellers/__init__.py +0 -0
  86. sp_api/asyncio/api/sellers/sellers.py +70 -0
  87. sp_api/asyncio/api/services/__init__.py +0 -0
  88. sp_api/asyncio/api/services/services.py +218 -0
  89. sp_api/asyncio/api/shipping/__init__.py +0 -0
  90. sp_api/asyncio/api/shipping/shipping.py +459 -0
  91. sp_api/asyncio/api/shipping/shippingV2.py +651 -0
  92. sp_api/asyncio/api/solicitations/__init__.py +0 -0
  93. sp_api/asyncio/api/solicitations/solicitations.py +78 -0
  94. sp_api/asyncio/api/supply_sources/__init__.py +0 -0
  95. sp_api/asyncio/api/supply_sources/supply_sources.py +138 -0
  96. sp_api/asyncio/api/tokens/__init__.py +0 -0
  97. sp_api/asyncio/api/tokens/tokens.py +65 -0
  98. sp_api/asyncio/api/upload/__init__.py +0 -0
  99. sp_api/asyncio/api/upload/upload.py +18 -0
  100. sp_api/asyncio/api/vendor_direct_fulfillment_inventory/__init__.py +0 -0
  101. sp_api/asyncio/api/vendor_direct_fulfillment_inventory/vendor_direct_fulfillment_inventory.py +64 -0
  102. sp_api/asyncio/api/vendor_direct_fulfillment_orders/__init__.py +0 -0
  103. sp_api/asyncio/api/vendor_direct_fulfillment_orders/vendor_direct_fulfillment_orders.py +196 -0
  104. sp_api/asyncio/api/vendor_direct_fulfillment_payments/__init__.py +0 -0
  105. sp_api/asyncio/api/vendor_direct_fulfillment_payments/vendor_direct_fulfillment_payments.py +254 -0
  106. sp_api/asyncio/api/vendor_direct_fulfillment_shipping/__init__.py +0 -0
  107. sp_api/asyncio/api/vendor_direct_fulfillment_shipping/vendor_direct_fulfillment_shipping.py +627 -0
  108. sp_api/asyncio/api/vendor_direct_fulfillment_transactions/__init__.py +0 -0
  109. sp_api/asyncio/api/vendor_direct_fulfillment_transactions/vendor_direct_fulfillment_transactions.py +43 -0
  110. sp_api/asyncio/api/vendor_invoices/__init__.py +0 -0
  111. sp_api/asyncio/api/vendor_invoices/vendor_invoices.py +295 -0
  112. sp_api/asyncio/api/vendor_orders/__init__.py +0 -0
  113. sp_api/asyncio/api/vendor_orders/vendor_orders.py +210 -0
  114. sp_api/asyncio/api/vendor_shipments/__init__.py +0 -0
  115. sp_api/asyncio/api/vendor_shipments/vendor_shipments.py +118 -0
  116. sp_api/asyncio/api/vendor_transaction_status/__init__.py +0 -0
  117. sp_api/asyncio/api/vendor_transaction_status/vendor_transaction_status.py +41 -0
  118. sp_api/asyncio/auth/__init__.py +12 -0
  119. sp_api/asyncio/auth/access_token_client.py +145 -0
  120. sp_api/asyncio/auth/exceptions.py +5 -0
  121. sp_api/asyncio/base/__init__.py +53 -0
  122. sp_api/asyncio/base/_transport_httpx.py +50 -0
  123. sp_api/asyncio/base/base_client.py +8 -0
  124. sp_api/asyncio/base/client.py +169 -0
  125. sp_api/asyncio/util/__init__.py +29 -0
  126. sp_api/asyncio/util/key_maker.py +5 -0
  127. sp_api/asyncio/util/load_all_pages.py +55 -0
  128. sp_api/asyncio/util/load_date_bound.py +53 -0
  129. sp_api/asyncio/util/retry.py +88 -0
  130. sp_api/auth/_core.py +39 -0
  131. sp_api/auth/access_token_client.py +18 -29
  132. sp_api/base/ApiResponse.py +2 -2
  133. sp_api/base/_core.py +110 -0
  134. sp_api/base/_transport_httpx.py +39 -0
  135. sp_api/base/client.py +40 -63
  136. sp_api/base/helpers.py +1 -1
  137. sp_api/util/__init__.py +36 -0
  138. sp_api/util/params.py +57 -0
  139. sp_api/util/product_fees.py +40 -0
  140. sp_api/util/products_definitions.py +169 -0
  141. sp_api/util/report_document.py +154 -0
  142. python_amazon_sp_api-1.9.39.dist-info/RECORD +0 -148
  143. tests/api/finances/test_finances.py +0 -19
  144. tests/api/notifications/test_notifications.py +0 -26
  145. tests/api/orders/test_orders.py +0 -122
  146. tests/api/product_fees/product_fees.py +0 -49
  147. tests/api/reports/test_reports.py +0 -127
  148. tests/client/test_auth.py +0 -59
  149. tests/client/test_base.py +0 -163
  150. tests/client/test_credential_provider.py +0 -45
  151. tests/client/test_helpers.py +0 -142
  152. {python_amazon_sp_api-1.9.39.data → python_amazon_sp_api-2.0.10.data}/scripts/make_endpoint +0 -0
  153. {python_amazon_sp_api-1.9.39.dist-info → python_amazon_sp_api-2.0.10.dist-info}/licenses/LICENSE +0 -0
  154. {tests → sp_api/api/customer_feedback}/__init__.py +0 -0
  155. {tests/api → sp_api/api/external_fulfillment}/__init__.py +0 -0
  156. {tests/api/finances → sp_api/asyncio}/__init__.py +0 -0
  157. {tests/api/notifications → sp_api/asyncio/api/feeds}/__init__.py +0 -0
  158. {tests/api/orders → sp_api/asyncio/api/finances}/__init__.py +0 -0
  159. {tests/api/product_fees → sp_api/asyncio/api/fulfillment_inbound}/__init__.py +0 -0
  160. {tests/api/reports → sp_api/asyncio/api/fulfillment_outbound}/__init__.py +0 -0
  161. {tests/api/sellers → sp_api/asyncio/api/inventories}/__init__.py +0 -0
  162. {tests/client → sp_api/asyncio/api/listings_items}/__init__.py +0 -0
  163. /tests/api/sellers/test_sellers.py → /sp_api/asyncio/api/listings_restrictions/__init__.py +0 -0
@@ -0,0 +1,439 @@
1
+ from datetime import datetime
2
+ from typing import Optional, Union
3
+
4
+ from sp_api.base import (
5
+ Client,
6
+ sp_endpoint,
7
+ fill_query_params,
8
+ ApiResponse,
9
+ Marketplaces,
10
+ )
11
+ from sp_api.asyncio.base import AsyncBaseClient
12
+ from sp_api.util import (
13
+ normalize_csv_param,
14
+ normalize_datetime_kwargs,
15
+ normalize_marketplace_ids,
16
+ should_add_marketplace,
17
+ )
18
+ from sp_api.util.report_document import (
19
+ decode_document,
20
+ decompress_bytes,
21
+ handle_file,
22
+ resolve_character_code,
23
+ stream_to_file_async,
24
+ )
25
+
26
+
27
+ class Reports(AsyncBaseClient):
28
+ """
29
+ Reports SP-API Client
30
+ :link:
31
+
32
+ The Selling Partner API for Reports lets you retrieve and manage a variety of reports that can help selling partners manage their businesses.
33
+ """
34
+
35
+ @sp_endpoint("/reports/2021-06-30/reports", method="GET")
36
+ async def get_reports(self, **kwargs) -> ApiResponse:
37
+ """
38
+ get_reports(self, **kwargs) -> ApiResponse
39
+
40
+ Returns report details for the reports that match the filters that you specify.
41
+
42
+ **Usage Plan:**
43
+
44
+ ====================================== ==============
45
+ Rate (requests per second) Burst
46
+ ====================================== ==============
47
+ 0.0222 10
48
+ ====================================== ==============
49
+
50
+ For more information, see "Usage Plans and Rate Limits" in the Selling Partner API documentation.
51
+
52
+ Examples:
53
+ literal blocks::
54
+
55
+ report_types = ["FEE_DISCOUNTS_REPORT", "GET_AFN_INVENTORY_DATA"]
56
+ processing_status = ["IN_QUEUE", "IN_PROGRESS"]
57
+ res = Reports().get_reports(reportTypes=report_types, processingStatuses=processing_status)
58
+
59
+ Args:
60
+ key reportTypes: str[] or ReportType[] | optional A list of report types used to filter reports. When reportTypes is provided, the other filter parameters (processingStatuses, marketplaceIds, createdSince, createdUntil) and pageSize may also be provided. Either reportTypes or nextToken is required.
61
+ key processingStatuses: str[] or ProcessingStatus[] optional A list of processing statuses used to filter reports.
62
+ key marketplaceIds: str[] or Marketplaces[] optional A list of marketplace identifiers used to filter reports. The reports returned will match at least one of the marketplaces that you specify.
63
+ key pageSize: int optional The maximum number of reports to return in a single call.
64
+ key createdSince: str or datetime optional The earliest report creation date and time for reports to include in the response, in ISO 8601 date time format. The default is 90 days ago. Reports are retained for a maximum of 90 days. string (date-time) -
65
+ key createdUntil: str or datetime optional The latest report creation date and time for reports to include in the response, in ISO 8601 date time format. The default is now. string (date-time) -
66
+ key nextToken: str optional A stringget_report_document token returned in the response to your previous request. nextToken is returned when the number of results exceeds the specified pageSize value. To get the next page of results, call the getReports operation and include this token as the only parameter. Specifying nextToken with any other parameters will cause the request to fail. string -
67
+
68
+
69
+ Returns:
70
+ ApiResponse
71
+ """
72
+ normalize_csv_param(kwargs, "reportTypes")
73
+ normalize_csv_param(kwargs, "processingStatuses")
74
+ normalize_marketplace_ids(kwargs, marketplace_cls=Marketplaces)
75
+ normalize_datetime_kwargs(kwargs, ["createdSince", "createdUntil"])
76
+ add_marketplace = should_add_marketplace(kwargs, "nextToken")
77
+ return await self._request(
78
+ kwargs.pop("path"),
79
+ params=kwargs,
80
+ add_marketplace=add_marketplace,
81
+ )
82
+
83
+ @sp_endpoint("/reports/2021-06-30/reports", method="POST")
84
+ async def create_report(self, **kwargs) -> ApiResponse:
85
+ """
86
+ create_report(self, **kwargs) -> ApiResponse
87
+
88
+ See report types at
89
+ :link: https://github.com/amzn/selling-partner-api-docs/blob/main/references/reports-api/reporttype-values.md
90
+
91
+ **Usage Plan:**
92
+
93
+ ====================================== ==============
94
+ Rate (requests per second) Burst
95
+ ====================================== ==============
96
+ 0.0167 15
97
+ ====================================== ==============
98
+
99
+ Examples:
100
+ literal blocks::
101
+
102
+ res = Reports().create_report(
103
+ reportType=ReportType.GET_MERCHANT_LISTINGS_ALL_DATA,
104
+ dataStartTime='2019-12-10T20:11:24.000Z',
105
+ marketplaceIds=[
106
+ "A1PA6795UKMFR9",
107
+ "ATVPDKIKX0DER"
108
+ ])
109
+
110
+ Args:
111
+ key reportOptions: optional Additional information passed to reports. This varies by report type. ReportOptions
112
+ key reportType: required The report type. :link: https://github.com/amzn/selling-partner-api-docs/blob/main/references/reports-api/reporttype-values.md
113
+ key dataStartTime: optional The start of a date and time range, in ISO 8601 date time format, used for selecting the data to report. The default is now. The value must be prior to or equal to the current date and time. Not all report types make use of this. string (date-time)
114
+ key dataEndTime: optional The end of a date and time range, in ISO 8601 date time format, used for selecting the data to report. The default is now. The value must be prior to or equal to the current date and time. Not all report types make use of this. string (date-time)
115
+ key marketplaceIds: optional, defaults to the client's marketplace A list of marketplace identifiers. The report document's contents will contain data for all of the specified marketplaces, unless the report type indicates otherwise. < string > array
116
+
117
+ Returns:
118
+ ApiResponse
119
+ """
120
+ normalize_datetime_kwargs(kwargs, ["dataStartTime", "dataEndTime"])
121
+ return await self._request(kwargs.pop("path"), data=kwargs)
122
+
123
+ @sp_endpoint("/reports/2021-06-30/reports/{}", method="DELETE")
124
+ async def cancel_report(self, reportId, **kwargs) -> ApiResponse:
125
+ """
126
+ cancel_report(self, reportId, **kwargs) -> ApiResponse
127
+
128
+ Cancels the report that you specify. Only reports with processingStatus=IN_QUEUE can be cancelled. Cancelled reports are returned in subsequent calls to the getReport and getReports operations.
129
+
130
+ **Usage Plan:**
131
+
132
+ ====================================== ==============
133
+ Rate (requests per second) Burst
134
+ ====================================== ==============
135
+ 0.0022 10
136
+ ====================================== ==============
137
+
138
+ For more information, see "Usage Plans and Rate Limits" in the Selling Partner API documentation.
139
+
140
+ Args:
141
+ reportId:string | * REQUIRED The identifier for the report. This identifier is unique only in combination with a seller ID.
142
+
143
+ Returns:
144
+ ApiResponse:
145
+ """
146
+
147
+ return await self._request(
148
+ fill_query_params(kwargs.pop("path"), reportId), data=kwargs
149
+ )
150
+
151
+ @sp_endpoint("/reports/2021-06-30/reports/{}", method="GET")
152
+ async def get_report(self, reportId, **kwargs) -> ApiResponse:
153
+ """
154
+ get_report(self, report_id, **kwargs)
155
+ Returns report details (including the reportDocumentId, if available) for the report that you specify.
156
+
157
+ **Usage Plan:**
158
+
159
+ ====================================== ==============
160
+ Rate (requests per second) Burst
161
+ ====================================== ==============
162
+ 2 15
163
+ ====================================== ==============
164
+
165
+
166
+ For more information, see "Usage Plans and Rate Limits" in the Selling Partner API documentation.
167
+
168
+ Examples:
169
+ literal blocks::
170
+
171
+ Reports().get_report('ID323')
172
+
173
+ Args:
174
+ reportId: str
175
+
176
+ Returns:
177
+ ApiResponse
178
+
179
+ """
180
+
181
+ return await self._request(
182
+ fill_query_params(kwargs.pop("path"), reportId), params=kwargs
183
+ )
184
+
185
+ @sp_endpoint("/reports/2021-06-30/schedules", method="GET")
186
+ async def get_report_schedules(self, **kwargs) -> ApiResponse:
187
+ """
188
+ Returns report schedule details that match the filters that you specify.
189
+
190
+ **Usage Plan:**
191
+
192
+ ====================================== ==============
193
+ Rate (requests per second) Burst
194
+ ====================================== ==============
195
+ 0.0222 10
196
+ ====================================== ==============
197
+
198
+ For more information, see "Usage Plans and Rate Limits" in the Selling Partner API documentation.
199
+
200
+ Args:
201
+ key reportTypes: str[] or ReportType[] | required A list of report types used to filter report schedules. Min count : 1. Max count : 10.
202
+
203
+ Returns:
204
+ ApiResponse
205
+ """
206
+ normalize_csv_param(kwargs, "reportTypes")
207
+
208
+ return await self._request(kwargs.pop("path"), params=kwargs)
209
+
210
+ @sp_endpoint("/reports/2021-06-30/schedules", method="POST")
211
+ async def create_report_schedule(self, **kwargs) -> ApiResponse:
212
+ """
213
+ create_report_schedule(self, **kwargs) -> ApiResponse
214
+
215
+ Creates a report schedule. If a report schedule with the same report type and marketplace IDs already exists, it will be cancelled and replaced with this one.
216
+
217
+ **Usage Plan:**
218
+
219
+ ====================================== ==============
220
+ Rate (requests per second) Burst
221
+ ====================================== ==============
222
+ 0.0222 10
223
+ ====================================== ==============
224
+
225
+ Examples:
226
+ literal blocks::
227
+
228
+ Reports().create_report_schedule(reportType='FEE_DISCOUNTS_REPORT',
229
+ period=Schedules.MINUTES_5.value,
230
+ nextReportCreationTime="2019-12-10T20:11:24.000Z",
231
+ marketplaceIds=["A1PA6795UKMFR9", "ATVPDKIKX0DER"])
232
+
233
+ Args:
234
+ key reportType: str
235
+ key marketplaceIds: str
236
+ key reportOptions: dict
237
+ key period: Schedules
238
+ key nextReportCreationTime: str datetime isoformat
239
+
240
+ Returns:
241
+ ApiResponse:
242
+ """
243
+
244
+ return await self._request(kwargs.pop("path"), data=kwargs)
245
+
246
+ @sp_endpoint("/reports/2021-06-30/schedules/{}", method="DELETE")
247
+ async def cancel_report_schedule(self, reportScheduleId, **kwargs) -> ApiResponse:
248
+ """
249
+ cancel_report_schedule(self, reportScheduleId, **kwargs) -> ApiResponse
250
+
251
+ Cancels the report schedule that you specify.
252
+
253
+ **Usage Plan:**
254
+
255
+ ====================================== ==============
256
+ Rate (requests per second) Burst
257
+ ====================================== ==============
258
+ 0.0222 10
259
+ ====================================== ==============
260
+
261
+ For more information, see "Usage Plans and Rate Limits" in the Selling Partner API documentation.
262
+
263
+ Examples:
264
+ literal blocks::
265
+
266
+ Reports().cancel_report_schedule('ID')
267
+
268
+ Args:
269
+ reportScheduleId: str
270
+ kwargs:
271
+
272
+ Returns:
273
+ ApiResponse
274
+ """
275
+ return await self._request(
276
+ fill_query_params(kwargs.pop("path"), reportScheduleId), data=kwargs
277
+ )
278
+
279
+ def delete_report_schedule(self, reportScheduleId, **kwargs) -> ApiResponse:
280
+ """
281
+ cancel_report_schedule(self, reportScheduleId, **kwargs) -> ApiResponse
282
+
283
+ Cancels the report schedule that you specify.
284
+
285
+ **Usage Plan:**
286
+
287
+ ====================================== ==============
288
+ Rate (requests per second) Burst
289
+ ====================================== ==============
290
+ 0.0222 10
291
+ ====================================== ==============
292
+
293
+ For more information, see "Usage Plans and Rate Limits" in the Selling Partner API documentation.
294
+
295
+ Examples:
296
+ literal blocks::
297
+
298
+ Reports().cancel_report_schedule('ID')
299
+
300
+ Args:
301
+ reportScheduleId: str
302
+ kwargs:
303
+
304
+ Returns:
305
+ ApiResponse
306
+ """
307
+ return self.cancel_report_schedule(reportScheduleId)
308
+
309
+ @sp_endpoint("/reports/2021-06-30/schedules/{}", method="GET")
310
+ async def get_report_schedule(self, reportScheduleId, **kwargs) -> ApiResponse:
311
+ """
312
+ get_report_schedule(self, reportScheduleId, **kwargs) -> ApiResponse
313
+
314
+ Returns report schedule details for the report schedule that you specify.
315
+
316
+ **Usage Plan:**
317
+
318
+ ====================================== ==============
319
+ Rate (requests per second) Burst
320
+ ====================================== ==============
321
+ 0.0222 10
322
+ ====================================== ==============
323
+
324
+ For more information, see "Usage Plans and Rate Limits" in the Selling Partner API documentation.
325
+
326
+ Examples:
327
+ literal blocks::
328
+
329
+ Reports().get_report_schedule('ID323')
330
+
331
+ Args:
332
+ reportScheduleId: str | required The identifier for the report schedule. This identifier is unique only in combination with a seller ID.
333
+ kwargs:
334
+
335
+ Returns:
336
+ ApiResponse
337
+ """
338
+ return await self._request(
339
+ fill_query_params(kwargs.pop("path"), reportScheduleId), params=kwargs
340
+ )
341
+
342
+ @sp_endpoint("/reports/2021-06-30/documents/{}", method="GET")
343
+ async def get_report_document(
344
+ self,
345
+ reportDocumentId,
346
+ download: bool = False,
347
+ file=None,
348
+ character_code: Optional[str] = None,
349
+ stream: bool = False,
350
+ timeout: Optional[Union[float,int]] = None,
351
+ **kwargs
352
+ ) -> ApiResponse:
353
+ """
354
+ get_report_document(self, document_id, decrypt: bool = False, file=None, character_code: Optional[str] = None, **kwargs) -> ApiResponse
355
+ Returns the information required for retrieving a report document's contents. This includes a presigned URL for the report document as well as the information required to decrypt the document's contents.
356
+
357
+ If decrypt = True the report will automatically be loaded and decrypted/unpacked
358
+ If file is set to a file (or file like object), the report's contents are written to the file
359
+
360
+
361
+ **Usage Plan:**
362
+
363
+
364
+ ====================================== ==============
365
+ Rate (requests per second) Burst
366
+ ====================================== ==============
367
+ 0.0167 15
368
+ ====================================== ==============
369
+
370
+
371
+
372
+ For more information, see "Usage Plans and Rate Limits" in the Selling Partner API documentation.
373
+
374
+ Examples:
375
+ literal blocks::
376
+
377
+ Reports().get_report_document('0356cf79-b8b0-4226-b4b9-0ee058ea5760', download=True, file=file)
378
+
379
+ Args:
380
+ reportDocumentId: str | the document to load
381
+ download: bool | flag to automatically download a report
382
+ file: If passed, will save the document to the file specified.
383
+ Only valid if decrypt=True
384
+ character_code: If passed, will be a file with the specified character code.
385
+ The default is the Content-Encoding in the response while
386
+ obtaining the document from the document URL.
387
+ It fallbacks to 'iso-8859-1' if no encoding was found.
388
+ Only valid if decrypt=True.
389
+ stream: bool | if True and file is provided, stream the document to disk
390
+ timeout: int | optional, the timeout for the request to download the document
391
+
392
+ Returns:
393
+ ApiResponse
394
+ """ # noqa: E501
395
+ res = await self._request(
396
+ fill_query_params(kwargs.pop("path"), reportDocumentId),
397
+ add_marketplace=False,
398
+ )
399
+ if download or file or ("decrypt" in kwargs and kwargs["decrypt"]):
400
+ compression_algorithm = res.payload.get("compressionAlgorithm")
401
+ if stream and file:
402
+ async with self._transport.stream(
403
+ "GET",
404
+ res.payload.get("url"),
405
+ timeout=timeout,
406
+ ) as document_response:
407
+ if not character_code:
408
+ character_code = resolve_character_code(
409
+ document_response.encoding, fallback="iso-8859-1"
410
+ )
411
+ await stream_to_file_async(
412
+ document_response,
413
+ file,
414
+ character_code,
415
+ compression_algorithm,
416
+ )
417
+ else:
418
+ document_response = await self._transport.request(
419
+ "GET",
420
+ res.payload.get("url"),
421
+ timeout=timeout,
422
+ )
423
+ if not character_code:
424
+ character_code = resolve_character_code(
425
+ document_response.encoding, fallback="iso-8859-1"
426
+ )
427
+ document = decompress_bytes(
428
+ document_response.content, compression_algorithm
429
+ )
430
+ decoded_document = decode_document(document, character_code)
431
+ if download:
432
+ res.payload.update(
433
+ {
434
+ "document": decoded_document,
435
+ }
436
+ )
437
+ if file:
438
+ handle_file(file, decoded_document, character_code)
439
+ return res
File without changes
@@ -0,0 +1,93 @@
1
+ import urllib
2
+ from datetime import datetime
3
+
4
+ from sp_api.base import Client, Marketplaces, sp_endpoint, Granularity, ApiResponse
5
+ from sp_api.asyncio.base import AsyncBaseClient
6
+ import logging
7
+ from sp_api.util import encode_kwarg
8
+
9
+
10
+ class Sales(AsyncBaseClient):
11
+ """
12
+ :link: https://github.com/amzn/selling-partner-api-docs/blob/main/references/sales-api/sales.md#parameters
13
+ """
14
+
15
+ @sp_endpoint("/sales/v1/orderMetrics")
16
+ async def get_order_metrics(
17
+ self,
18
+ interval: tuple,
19
+ granularity: Granularity,
20
+ granularityTimeZone: str = None,
21
+ **kwargs
22
+ ) -> ApiResponse:
23
+ """
24
+ get_order_metrics(self, interval: tuple, granularity: Granularity, granularityTimeZone: str = None, **kwargs) -> ApiResponse
25
+
26
+ Returns aggregated order metrics for given interval, broken down by granularity, for given buyer type.
27
+
28
+ **Usage Plan:**
29
+
30
+
31
+ ====================================== ==============
32
+ Rate (requests per second) Burst
33
+ ====================================== ==============
34
+ 0.5 15
35
+ ====================================== ==============
36
+
37
+ For more information, see "Usage Plans and Rate Limits" in the Selling Partner API documentation.
38
+
39
+ Examples:
40
+ literal blocks::
41
+
42
+ from sp_api.api import Sales
43
+ from sp_api.base import Granularity
44
+
45
+ Sales().get_order_metrics(interval, Granularity.TOTAL, granularityTimeZone='US/Central')
46
+ Sales().get_order_metrics(interval, Granularity.DAY, granularityTimeZone='US/Central')
47
+ Sales().get_order_metrics(interval, Granularity.TOTAL, granularityTimeZone='US/Central', asin='B008OLKVEW')
48
+ Sales().get_order_metrics(interval, Granularity.DAY, granularityTimeZone='US/Central', asin='B008OLKVEW')
49
+
50
+
51
+ Args:
52
+ key marketplaceIds: [str]
53
+ interval: tuple | A time interval used for selecting order metrics. This takes the form of two dates separated by two hyphens (first date is inclusive; second date is exclusive). Dates are in ISO8601 format and must represent absolute time (either Z notation or offset notation). Example: 2018-09-01T00:00:00-07:00--2018-09-04T00:00:00-07:00 requests order metrics for Sept 1st, 2nd and 3rd in the -07:00 zone. string - Query granularityTimeZone
54
+ granularity: Granularity | The granularity of the grouping of order metrics, based on a unit of time. Specifying granularity=Hour results in a successful request only if the interval specified is less than or equal to 30 days from now. For all other granularities, the interval specified must be less or equal to 2 years from now. Specifying granularity=Total results in order metrics that are aggregated over the entire interval that you specify. If the interval start and end date don’t align with the specified granularity, the head and tail end of the response interval will contain partial data. Example: Day to get a daily breakdown of the request interval, where the day boundary is defined by the granularityTimeZone. enum (Granularity) -
55
+ key buyerType: BuyerType | Filters the results by the buyer type that you specify, B2B (business to business) or B2C (business to customer). Example: B2B, if you want the response to include order metrics for only B2B buyers. Default: enum (BuyerType) "All"
56
+ key fulfillmentNetwork: str | Filters the results by the fulfillment network that you specify, MFN (merchant fulfillment network) or AFN (Amazon fulfillment network). Do not include this filter if you want the response to include order metrics for all fulfillment networks. Example: AFN, if you want the response to include order metrics for only Amazon fulfillment network. string -
57
+ key firstDayOfWeek: str | Specifies the day that the week starts on when granularity=Week, either Monday or Sunday. Default: Monday. Example: Sunday, if you want the week to start on a Sunday. enum (FirstDayOfWeek) "Monday"
58
+ key asin: str | Filters the results by the ASIN that you specify. Specifying both ASIN and SKU returns an error. Do not include this filter if you want the response to include order metrics for all ASINs. Example: B0792R1RSN, if you want the response to include order metrics for only ASIN B0792R1RSN. string -
59
+ key sku: str | Filters the results by the SKU that you specify. Specifying both ASIN and SKU returns an error. Do not include this filter if you want the response to include order metrics for all SKUs. Example: TestSKU, if you want the response to include order metrics for only SKU TestSKU.
60
+ granularityTimeZone: str
61
+
62
+
63
+ Returns:
64
+ ApiResponse
65
+ """
66
+ kwargs.update(
67
+ {
68
+ "interval": "--".join(
69
+ [self._create_datetime_stamp(_interval) for _interval in interval]
70
+ ),
71
+ "granularity": granularity.value,
72
+ }
73
+ )
74
+ if granularityTimeZone:
75
+ kwargs.update({"granularityTimeZone": granularityTimeZone})
76
+ encode_kwarg(kwargs, "sku", lambda value: urllib.parse.quote(value, safe=""))
77
+ return await self._request(kwargs.pop("path"), params=kwargs)
78
+
79
+ @staticmethod
80
+ def _create_datetime_stamp(datetime_obj: datetime or str):
81
+ """
82
+ Create datetimestring
83
+
84
+ Args:
85
+ datetime_obj:
86
+
87
+ Returns:
88
+
89
+ """
90
+ if isinstance(datetime_obj, str):
91
+ return datetime_obj
92
+ fmt = "%Y-%m-%dT%H:%M:%S%z"
93
+ return datetime_obj.astimezone().isoformat(timespec="seconds")
File without changes
@@ -0,0 +1,70 @@
1
+ from sp_api.base.helpers import sp_endpoint
2
+ from sp_api.base import Client, Marketplaces, ApiResponse
3
+ from sp_api.asyncio.base import AsyncBaseClient
4
+
5
+
6
+ class Sellers(AsyncBaseClient):
7
+ """
8
+ :link: https://github.com/amzn/selling-partner-api-docs/blob/main/references/sellers-api/sellers.md
9
+
10
+ """
11
+
12
+ @sp_endpoint("/sellers/v1/marketplaceParticipations")
13
+ async def get_marketplace_participation(self, **kwargs) -> ApiResponse:
14
+ """
15
+ get_marketplace_participation(self, **kwargs) -> ApiResponse
16
+ Returns a list of marketplaces that the seller submitting the request can sell in and information about the seller's participation in those marketplaces.
17
+
18
+ **Usage Plan:**
19
+
20
+ ====================================== ==============
21
+ Rate (requests per second) Burst
22
+ ====================================== ==============
23
+ .016 15
24
+ ====================================== ==============
25
+
26
+ For more information, see "Usage Plans and Rate Limits" in the Selling Partner API documentation.
27
+
28
+ Examples:
29
+ literal blocks::
30
+
31
+ res = Sellers().get_marketplace_participation()
32
+
33
+ Args:
34
+ **kwargs:
35
+
36
+ Returns:
37
+ GetMarketplaceParticipationsResponse:
38
+
39
+ """
40
+ return await self._request(kwargs.pop("path"), add_marketplace=False)
41
+
42
+ @sp_endpoint("/sellers/v1/account")
43
+ async def get_account(self, **kwargs) -> ApiResponse:
44
+ """
45
+ get_account(self, **kwargs) -> ApiResponse
46
+ Returns information about a seller account and its marketplaces.
47
+
48
+ **Usage Plan:**
49
+
50
+ ====================================== ==============
51
+ Rate (requests per second) Burst
52
+ ====================================== ==============
53
+ .016 15
54
+ ====================================== ==============
55
+
56
+ For more information, see "Usage Plans and Rate Limits" in the Selling Partner API documentation.
57
+
58
+ Examples:
59
+ literal blocks::
60
+
61
+ res = Sellers().get_account()
62
+
63
+ Args:
64
+ **kwargs:
65
+
66
+ Returns:
67
+ GetAccountResponse:
68
+
69
+ """
70
+ return await self._request(kwargs.pop("path"), add_marketplace=False)
File without changes