python-amazon-sp-api 1.7.5__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 (214) hide show
  1. {python_amazon_sp_api-1.7.5.data → python_amazon_sp_api-2.0.10.data}/scripts/make_endpoint +2 -2
  2. {python_amazon_sp_api-1.7.5.dist-info → python_amazon_sp_api-2.0.10.dist-info}/METADATA +58 -8
  3. python_amazon_sp_api-2.0.10.dist-info/RECORD +253 -0
  4. {python_amazon_sp_api-1.7.5.dist-info → python_amazon_sp_api-2.0.10.dist-info}/WHEEL +1 -1
  5. {python_amazon_sp_api-1.7.5.dist-info → python_amazon_sp_api-2.0.10.dist-info}/top_level.txt +0 -1
  6. sp_api/__version__.py +1 -1
  7. sp_api/api/__init__.py +48 -41
  8. sp_api/api/amazon_warehousing_and_distribu/amazon_warehousing_and_distribu.py +82 -76
  9. sp_api/api/aplus_content/aplus_content.py +76 -45
  10. sp_api/api/application_integrations/application_integrations.py +118 -0
  11. sp_api/api/application_management/application_management.py +6 -7
  12. sp_api/api/authorization/authorization.py +5 -5
  13. sp_api/api/catalog/catalog.py +9 -10
  14. sp_api/api/catalog_items/catalog_items.py +10 -13
  15. sp_api/api/customer_feedback/customer_feedback.py +110 -0
  16. sp_api/api/data_kiosk/data_kiosk.py +59 -39
  17. sp_api/api/easy_ship/easy_ship.py +190 -0
  18. sp_api/api/external_fulfillment/external_fulfillment.py +706 -0
  19. sp_api/api/fba_inbound_eligibility/fba_inbound_eligibility.py +23 -13
  20. sp_api/api/fba_small_and_light/fba_small_and_light.py +46 -20
  21. sp_api/api/feeds/feeds.py +60 -39
  22. sp_api/api/finances/finances.py +40 -9
  23. sp_api/api/fulfillment_inbound/fulfillment_inbound.py +844 -619
  24. sp_api/api/fulfillment_outbound/fulfillment_outbound.py +63 -57
  25. sp_api/api/inventories/inventories.py +13 -11
  26. sp_api/api/listings_items/listings_items.py +38 -25
  27. sp_api/api/listings_restrictions/listings_restrictions.py +6 -7
  28. sp_api/api/merchant_fulfillment/merchant_fulfillment.py +49 -36
  29. sp_api/api/messaging/messaging.py +129 -25
  30. sp_api/api/notifications/notifications.py +85 -45
  31. sp_api/api/orders/orders.py +123 -38
  32. sp_api/api/orders/orders_2026_01_01.py +54 -0
  33. sp_api/api/product_fees/product_fees.py +75 -67
  34. sp_api/api/product_type_definitions/product_type_definitions.py +9 -10
  35. sp_api/api/products/products.py +177 -53
  36. sp_api/api/products/products_definitions.py +11 -82
  37. sp_api/api/replenishment/replenishment.py +13 -11
  38. sp_api/api/reports/reports.py +113 -95
  39. sp_api/api/sales/sales.py +23 -13
  40. sp_api/api/sellers/sellers.py +3 -3
  41. sp_api/api/services/services.py +41 -30
  42. sp_api/api/shipping/shipping.py +39 -37
  43. sp_api/api/shipping/shippingV2.py +46 -30
  44. sp_api/api/solicitations/solicitations.py +20 -11
  45. sp_api/api/supply_sources/supply_sources.py +45 -37
  46. sp_api/api/tokens/tokens.py +4 -6
  47. sp_api/api/upload/upload.py +10 -8
  48. sp_api/api/vendor_direct_fulfillment_inventory/vendor_direct_fulfillment_inventory.py +10 -6
  49. sp_api/api/vendor_direct_fulfillment_orders/vendor_direct_fulfillment_orders.py +12 -14
  50. sp_api/api/vendor_direct_fulfillment_payments/vendor_direct_fulfillment_payments.py +4 -6
  51. sp_api/api/vendor_direct_fulfillment_shipping/vendor_direct_fulfillment_shipping.py +42 -37
  52. sp_api/api/vendor_direct_fulfillment_transactions/vendor_direct_fulfillment_transactions.py +8 -6
  53. sp_api/api/vendor_invoices/vendor_invoices.py +6 -4
  54. sp_api/api/vendor_orders/vendor_orders.py +16 -19
  55. sp_api/api/vendor_shipments/vendor_shipments.py +91 -262
  56. sp_api/api/vendor_transaction_status/vendor_transaction_status.py +6 -6
  57. sp_api/asyncio/api/__init__.py +167 -0
  58. sp_api/asyncio/api/amazon_warehousing_and_distribu/__init__.py +9 -0
  59. sp_api/asyncio/api/amazon_warehousing_and_distribu/amazon_warehousing_and_distribu.py +130 -0
  60. sp_api/asyncio/api/aplus_content/__init__.py +5 -0
  61. sp_api/asyncio/api/aplus_content/aplus_content.py +330 -0
  62. sp_api/asyncio/api/application_integrations/__init__.py +5 -0
  63. sp_api/asyncio/api/application_integrations/application_integrations.py +119 -0
  64. sp_api/asyncio/api/application_management/__init__.py +5 -0
  65. sp_api/asyncio/api/application_management/application_management.py +36 -0
  66. sp_api/asyncio/api/authorization/__init__.py +5 -0
  67. sp_api/asyncio/api/authorization/authorization.py +54 -0
  68. sp_api/asyncio/api/catalog/__init__.py +5 -0
  69. sp_api/asyncio/api/catalog/catalog.py +111 -0
  70. sp_api/asyncio/api/catalog_items/__init__.py +6 -0
  71. sp_api/asyncio/api/catalog_items/catalog_items.py +93 -0
  72. sp_api/asyncio/api/clients/__init__.py +1 -0
  73. sp_api/asyncio/api/customer_feedback/__init__.py +5 -0
  74. sp_api/asyncio/api/customer_feedback/customer_feedback.py +111 -0
  75. sp_api/asyncio/api/data_kiosk/__init__.py +5 -0
  76. sp_api/asyncio/api/data_kiosk/data_kiosk.py +236 -0
  77. sp_api/asyncio/api/easy_ship/__init__.py +5 -0
  78. sp_api/asyncio/api/easy_ship/easy_ship.py +191 -0
  79. sp_api/asyncio/api/external_fulfillment/__init__.py +5 -0
  80. sp_api/asyncio/api/external_fulfillment/external_fulfillment.py +706 -0
  81. sp_api/asyncio/api/fba_inbound_eligibility/__init__.py +5 -0
  82. sp_api/asyncio/api/fba_inbound_eligibility/fba_inbound_eligibility.py +96 -0
  83. sp_api/asyncio/api/fba_small_and_light/__init__.py +5 -0
  84. sp_api/asyncio/api/fba_small_and_light/fba_small_and_light.py +213 -0
  85. sp_api/asyncio/api/feeds/feeds.py +260 -0
  86. sp_api/asyncio/api/finances/finances.py +100 -0
  87. sp_api/asyncio/api/fulfillment_inbound/fulfillment_inbound.py +1798 -0
  88. sp_api/asyncio/api/fulfillment_outbound/fulfillment_outbound.py +736 -0
  89. sp_api/asyncio/api/inventories/inventories.py +74 -0
  90. sp_api/asyncio/api/listings_items/__init__.py +0 -0
  91. sp_api/asyncio/api/listings_items/listings_items.py +170 -0
  92. sp_api/asyncio/api/listings_restrictions/__init__.py +0 -0
  93. sp_api/asyncio/api/listings_restrictions/listings_restrictions.py +36 -0
  94. sp_api/asyncio/api/merchant_fulfillment/__init__.py +0 -0
  95. sp_api/asyncio/api/merchant_fulfillment/merchant_fulfillment.py +384 -0
  96. sp_api/asyncio/api/messaging/__init__.py +0 -0
  97. sp_api/asyncio/api/messaging/messaging.py +511 -0
  98. sp_api/asyncio/api/models/__init__.py +4 -0
  99. sp_api/asyncio/api/notifications/__init__.py +0 -0
  100. sp_api/asyncio/api/notifications/notifications.py +295 -0
  101. sp_api/asyncio/api/orders/__init__.py +0 -0
  102. sp_api/asyncio/api/orders/orders.py +412 -0
  103. sp_api/asyncio/api/orders/orders_2026_01_01.py +40 -0
  104. sp_api/asyncio/api/overrides/__init__.py +1 -0
  105. sp_api/asyncio/api/product_fees/__init__.py +0 -0
  106. sp_api/asyncio/api/product_fees/product_fees.py +194 -0
  107. sp_api/asyncio/api/product_type_definitions/__init__.py +0 -0
  108. sp_api/asyncio/api/product_type_definitions/product_type_definitions.py +75 -0
  109. sp_api/asyncio/api/products/__init__.py +0 -0
  110. sp_api/asyncio/api/products/products.py +405 -0
  111. sp_api/asyncio/api/products/products_definitions.py +11 -0
  112. sp_api/asyncio/api/replenishment/__init__.py +0 -0
  113. sp_api/asyncio/api/replenishment/replenishment.py +121 -0
  114. sp_api/asyncio/api/reports/__init__.py +0 -0
  115. sp_api/asyncio/api/reports/reports.py +439 -0
  116. sp_api/asyncio/api/sales/__init__.py +0 -0
  117. sp_api/asyncio/api/sales/sales.py +93 -0
  118. sp_api/asyncio/api/sellers/__init__.py +0 -0
  119. sp_api/asyncio/api/sellers/sellers.py +70 -0
  120. sp_api/asyncio/api/services/__init__.py +0 -0
  121. sp_api/asyncio/api/services/services.py +218 -0
  122. sp_api/asyncio/api/shipping/__init__.py +0 -0
  123. sp_api/asyncio/api/shipping/shipping.py +459 -0
  124. sp_api/asyncio/api/shipping/shippingV2.py +651 -0
  125. sp_api/asyncio/api/solicitations/__init__.py +0 -0
  126. sp_api/asyncio/api/solicitations/solicitations.py +78 -0
  127. sp_api/asyncio/api/supply_sources/__init__.py +0 -0
  128. sp_api/asyncio/api/supply_sources/supply_sources.py +138 -0
  129. sp_api/asyncio/api/tokens/__init__.py +0 -0
  130. sp_api/asyncio/api/tokens/tokens.py +65 -0
  131. sp_api/asyncio/api/upload/__init__.py +0 -0
  132. sp_api/asyncio/api/upload/upload.py +18 -0
  133. sp_api/asyncio/api/vendor_direct_fulfillment_inventory/__init__.py +0 -0
  134. sp_api/asyncio/api/vendor_direct_fulfillment_inventory/vendor_direct_fulfillment_inventory.py +64 -0
  135. sp_api/asyncio/api/vendor_direct_fulfillment_orders/__init__.py +0 -0
  136. sp_api/asyncio/api/vendor_direct_fulfillment_orders/vendor_direct_fulfillment_orders.py +196 -0
  137. sp_api/asyncio/api/vendor_direct_fulfillment_payments/__init__.py +0 -0
  138. sp_api/asyncio/api/vendor_direct_fulfillment_payments/vendor_direct_fulfillment_payments.py +254 -0
  139. sp_api/asyncio/api/vendor_direct_fulfillment_shipping/__init__.py +0 -0
  140. sp_api/asyncio/api/vendor_direct_fulfillment_shipping/vendor_direct_fulfillment_shipping.py +627 -0
  141. sp_api/asyncio/api/vendor_direct_fulfillment_transactions/__init__.py +0 -0
  142. sp_api/asyncio/api/vendor_direct_fulfillment_transactions/vendor_direct_fulfillment_transactions.py +43 -0
  143. sp_api/asyncio/api/vendor_invoices/__init__.py +0 -0
  144. sp_api/asyncio/api/vendor_invoices/vendor_invoices.py +295 -0
  145. sp_api/asyncio/api/vendor_orders/__init__.py +0 -0
  146. sp_api/asyncio/api/vendor_orders/vendor_orders.py +210 -0
  147. sp_api/asyncio/api/vendor_shipments/__init__.py +0 -0
  148. sp_api/asyncio/api/vendor_shipments/vendor_shipments.py +118 -0
  149. sp_api/asyncio/api/vendor_transaction_status/__init__.py +0 -0
  150. sp_api/asyncio/api/vendor_transaction_status/vendor_transaction_status.py +41 -0
  151. sp_api/asyncio/auth/__init__.py +12 -0
  152. sp_api/asyncio/auth/access_token_client.py +145 -0
  153. sp_api/asyncio/auth/exceptions.py +5 -0
  154. sp_api/asyncio/base/__init__.py +53 -0
  155. sp_api/asyncio/base/_transport_httpx.py +50 -0
  156. sp_api/asyncio/base/base_client.py +8 -0
  157. sp_api/asyncio/base/client.py +169 -0
  158. sp_api/asyncio/util/__init__.py +29 -0
  159. sp_api/asyncio/util/key_maker.py +5 -0
  160. sp_api/asyncio/util/load_all_pages.py +55 -0
  161. sp_api/asyncio/util/load_date_bound.py +53 -0
  162. sp_api/asyncio/util/retry.py +88 -0
  163. sp_api/auth/__init__.py +3 -3
  164. sp_api/auth/_core.py +39 -0
  165. sp_api/auth/access_token_client.py +20 -31
  166. sp_api/auth/access_token_response.py +4 -4
  167. sp_api/base/ApiResponse.py +5 -4
  168. sp_api/base/__init__.py +53 -42
  169. sp_api/base/_core.py +110 -0
  170. sp_api/base/_transport_httpx.py +39 -0
  171. sp_api/base/base_client.py +4 -4
  172. sp_api/base/client.py +131 -112
  173. sp_api/base/credential_provider.py +41 -34
  174. sp_api/base/exceptions.py +14 -3
  175. sp_api/base/feedTypes.py +44 -32
  176. sp_api/base/fulfillment_channel.py +2 -2
  177. sp_api/base/helpers.py +17 -16
  178. sp_api/base/identifiersType.py +8 -8
  179. sp_api/base/included_data.py +12 -12
  180. sp_api/base/marketplaces.py +5 -1
  181. sp_api/base/notifications.py +1 -1
  182. sp_api/base/processing_status.py +5 -5
  183. sp_api/base/reportTypes.py +198 -111
  184. sp_api/base/sales_enum.py +11 -13
  185. sp_api/util/__init__.py +42 -6
  186. sp_api/util/key_maker.py +4 -2
  187. sp_api/util/load_all_pages.py +16 -5
  188. sp_api/util/load_date_bound.py +28 -13
  189. sp_api/util/params.py +57 -0
  190. sp_api/util/product_fees.py +40 -0
  191. sp_api/util/products_definitions.py +169 -0
  192. sp_api/util/report_document.py +154 -0
  193. sp_api/util/retry.py +16 -15
  194. python_amazon_sp_api-1.7.5.dist-info/RECORD +0 -144
  195. tests/api/finances/test_finances.py +0 -19
  196. tests/api/notifications/test_notifications.py +0 -26
  197. tests/api/orders/test_orders.py +0 -122
  198. tests/api/product_fees/product_fees.py +0 -49
  199. tests/api/reports/test_reports.py +0 -127
  200. tests/client/test_auth.py +0 -59
  201. tests/client/test_base.py +0 -163
  202. tests/client/test_credential_provider.py +0 -45
  203. tests/client/test_helpers.py +0 -142
  204. {python_amazon_sp_api-1.7.5.dist-info → python_amazon_sp_api-2.0.10.dist-info/licenses}/LICENSE +0 -0
  205. {tests → sp_api/api/application_integrations}/__init__.py +0 -0
  206. {tests/api → sp_api/api/customer_feedback}/__init__.py +0 -0
  207. {tests/api/finances → sp_api/api/easy_ship}/__init__.py +0 -0
  208. {tests/api/notifications → sp_api/api/external_fulfillment}/__init__.py +0 -0
  209. {tests/api/orders → sp_api/asyncio}/__init__.py +0 -0
  210. {tests/api/product_fees → sp_api/asyncio/api/feeds}/__init__.py +0 -0
  211. {tests/api/reports → sp_api/asyncio/api/finances}/__init__.py +0 -0
  212. {tests/api/sellers → sp_api/asyncio/api/fulfillment_inbound}/__init__.py +0 -0
  213. {tests/client → sp_api/asyncio/api/fulfillment_outbound}/__init__.py +0 -0
  214. /tests/api/sellers/test_sellers.py → /sp_api/asyncio/api/inventories/__init__.py +0 -0
@@ -1,18 +1,23 @@
1
1
  import urllib.parse
2
2
 
3
- from sp_api.base import Client, sp_endpoint, fill_query_params, IneligibilityReasonList, ApiResponse
3
+ from sp_api.base import (
4
+ Client,
5
+ sp_endpoint,
6
+ fill_query_params,
7
+ IneligibilityReasonList,
8
+ ApiResponse,
9
+ )
4
10
 
5
11
 
6
12
  class FbaInboundEligibility(Client):
7
13
  """
8
14
  FbaInboundEligibility SP-API Client
9
- :link:
15
+ :link:
10
16
 
11
17
  With the FBA Inbound Eligibility API, you can build applications that let sellers get eligibility previews for items before shipping them to Amazon's fulfillment centers. With this API you can find out if an item is eligible for inbound shipment to Amazon's fulfillment centers in a specific marketplace. You can also find out if an item is eligible for using the manufacturer barcode for FBA inventory tracking. Sellers can use this information to inform their decisions about which items to ship Amazon's fulfillment centers.
12
18
  """
13
19
 
14
-
15
- @sp_endpoint('/fba/inbound/v1/eligibility/itemPreview', method='GET')
20
+ @sp_endpoint("/fba/inbound/v1/eligibility/itemPreview", method="GET")
16
21
  def get_item_eligibility_preview(self, **kwargs) -> ApiResponse:
17
22
  """
18
23
  get_item_eligibility_preview(self, **kwargs) -> ApiResponse
@@ -34,14 +39,14 @@ class FbaInboundEligibility(Client):
34
39
  key marketplaceIds:array | The identifier for the marketplace in which you want to determine eligibility. Required only when program=INBOUND.
35
40
  key asin:string | * REQUIRED The ASIN of the item for which you want an eligibility preview.
36
41
  key program:string | * REQUIRED The program that you want to check eligibility against.
37
-
42
+
38
43
 
39
44
  Returns:
40
45
  ApiResponse:
41
46
  """
42
- return self._request(kwargs.pop('path'), params=kwargs)
47
+ return self._request(kwargs.pop("path"), params=kwargs)
43
48
 
44
- @sp_endpoint('/fba/inbound/v1/eligibility/itemPreview', method='GET')
49
+ @sp_endpoint("/fba/inbound/v1/eligibility/itemPreview", method="GET")
45
50
  def get_item_eligibility_preview_extended(self, **kwargs) -> ApiResponse:
46
51
  """
47
52
  get_item_eligibility_preview_extended(self, **kwargs) -> ApiResponse
@@ -69,18 +74,23 @@ class FbaInboundEligibility(Client):
69
74
  ApiResponse:
70
75
  """
71
76
 
72
- api_response = self._request(kwargs.pop('path'), params=kwargs)
77
+ api_response = self._request(kwargs.pop("path"), params=kwargs)
73
78
 
74
- if api_response.payload.get("ineligibilityReasonList") and api_response.payload.get("isEligibleForProgram") is False:
79
+ if (
80
+ api_response.payload.get("ineligibilityReasonList")
81
+ and api_response.payload.get("isEligibleForProgram") is False
82
+ ):
75
83
  ineligibility_list = api_response.payload.get("ineligibilityReasonList")
76
84
  errors = []
77
85
  for ineligibility_option in ineligibility_list:
78
86
  try:
79
- errors.append(ineligibility_option + ": " + IneligibilityReasonList[ineligibility_option].value)
87
+ errors.append(
88
+ ineligibility_option
89
+ + ": "
90
+ + IneligibilityReasonList[ineligibility_option].value
91
+ )
80
92
  except KeyError as error:
81
93
  errors.append(error)
82
- api_response.payload.update({
83
- "ineligibilityReasonListMessage": errors
84
- })
94
+ api_response.payload.update({"ineligibilityReasonListMessage": errors})
85
95
 
86
96
  return api_response
@@ -6,17 +6,21 @@ from sp_api.base import Client, sp_endpoint, fill_query_params, ApiResponse, dep
6
6
  class FbaSmallAndLight(Client):
7
7
  """
8
8
  FbaSmallAndLight SP-API Client
9
- :link:
9
+ :link:
10
10
 
11
11
  The Selling Partner API for FBA Small and Light lets you help sellers manage their listings in the Small and Light program. The program reduces the cost of fulfilling orders for small and lightweight FBA inventory. You can enroll or remove items from the program and check item eligibility and enrollment status. You can also preview the estimated program fees charged to a seller for items sold while enrolled in the program.
12
12
  """
13
13
 
14
14
  @deprecated
15
- def get_small_and_light_enrollment_by_seller_s_k_u(self, sellerSKU, **kwargs) -> ApiResponse:
15
+ def get_small_and_light_enrollment_by_seller_s_k_u(
16
+ self, sellerSKU, **kwargs
17
+ ) -> ApiResponse:
16
18
  return self.get_small_and_light_enrollment_by_seller_sku(sellerSKU, **kwargs)
17
19
 
18
- @sp_endpoint('/fba/smallAndLight/v1/enrollments/{}', method='GET')
19
- def get_small_and_light_enrollment_by_seller_sku(self, seller_sku, **kwargs) -> ApiResponse:
20
+ @sp_endpoint("/fba/smallAndLight/v1/enrollments/{}", method="GET")
21
+ def get_small_and_light_enrollment_by_seller_sku(
22
+ self, seller_sku, **kwargs
23
+ ) -> ApiResponse:
20
24
  """
21
25
  get_small_and_light_enrollment_by_seller_s_k_u(self, sellerSKU, **kwargs) -> ApiResponse
22
26
 
@@ -40,14 +44,20 @@ class FbaSmallAndLight(Client):
40
44
  ApiResponse:
41
45
  """
42
46
 
43
- return self._request(fill_query_params(kwargs.pop('path'), seller_sku), params=kwargs)
47
+ return self._request(
48
+ fill_query_params(kwargs.pop("path"), seller_sku), params=kwargs
49
+ )
44
50
 
45
51
  @deprecated
46
- def put_small_and_light_enrollment_by_seller_s_k_u(self, sellerSKU, **kwargs) -> ApiResponse:
52
+ def put_small_and_light_enrollment_by_seller_s_k_u(
53
+ self, sellerSKU, **kwargs
54
+ ) -> ApiResponse:
47
55
  return self.put_small_and_light_enrollment_by_seller_sku(sellerSKU, **kwargs)
48
56
 
49
- @sp_endpoint('/fba/smallAndLight/v1/enrollments/{}', method='PUT')
50
- def put_small_and_light_enrollment_by_seller_sku(self, seller_sku, **kwargs) -> ApiResponse:
57
+ @sp_endpoint("/fba/smallAndLight/v1/enrollments/{}", method="PUT")
58
+ def put_small_and_light_enrollment_by_seller_sku(
59
+ self, seller_sku, **kwargs
60
+ ) -> ApiResponse:
51
61
  """
52
62
  put_small_and_light_enrollment_by_seller_s_k_u(self, sellerSKU, **kwargs) -> ApiResponse
53
63
 
@@ -72,15 +82,23 @@ class FbaSmallAndLight(Client):
72
82
  ApiResponse:
73
83
  """
74
84
 
75
- return self._request(fill_query_params(kwargs.pop('path'), seller_sku),
76
- params={'marketplaceIds': kwargs.get('marketplaceIds', self.marketplace_id)})
85
+ return self._request(
86
+ fill_query_params(kwargs.pop("path"), seller_sku),
87
+ params={
88
+ "marketplaceIds": kwargs.get("marketplaceIds", self.marketplace_id)
89
+ },
90
+ )
77
91
 
78
92
  @deprecated
79
- def delete_small_and_light_enrollment_by_seller_s_k_u(self, sellerSKU, **kwargs) -> ApiResponse:
93
+ def delete_small_and_light_enrollment_by_seller_s_k_u(
94
+ self, sellerSKU, **kwargs
95
+ ) -> ApiResponse:
80
96
  return self.delete_small_and_light_enrollment_by_seller_sku(sellerSKU, **kwargs)
81
97
 
82
- @sp_endpoint('/fba/smallAndLight/v1/enrollments/{}', method='DELETE')
83
- def delete_small_and_light_enrollment_by_seller_sku(self, seller_sku, **kwargs) -> ApiResponse:
98
+ @sp_endpoint("/fba/smallAndLight/v1/enrollments/{}", method="DELETE")
99
+ def delete_small_and_light_enrollment_by_seller_sku(
100
+ self, seller_sku, **kwargs
101
+ ) -> ApiResponse:
84
102
  """
85
103
  delete_small_and_light_enrollment_by_seller_s_k_u(self, sellerSKU, **kwargs) -> ApiResponse
86
104
 
@@ -104,14 +122,20 @@ class FbaSmallAndLight(Client):
104
122
  ApiResponse:
105
123
  """
106
124
 
107
- return self._request(fill_query_params(kwargs.pop('path'), seller_sku), data=kwargs)
125
+ return self._request(
126
+ fill_query_params(kwargs.pop("path"), seller_sku), data=kwargs
127
+ )
108
128
 
109
129
  @deprecated
110
- def get_small_and_light_eligibility_by_seller_s_k_u(self, sellerSKU, **kwargs) -> ApiResponse:
130
+ def get_small_and_light_eligibility_by_seller_s_k_u(
131
+ self, sellerSKU, **kwargs
132
+ ) -> ApiResponse:
111
133
  return self.get_small_and_light_eligibility_by_seller_sku(sellerSKU, **kwargs)
112
134
 
113
- @sp_endpoint('/fba/smallAndLight/v1/eligibilities/{}', method='GET')
114
- def get_small_and_light_eligibility_by_seller_sku(self, seller_sku, **kwargs) -> ApiResponse:
135
+ @sp_endpoint("/fba/smallAndLight/v1/eligibilities/{}", method="GET")
136
+ def get_small_and_light_eligibility_by_seller_sku(
137
+ self, seller_sku, **kwargs
138
+ ) -> ApiResponse:
115
139
  """
116
140
  get_small_and_light_eligibility_by_seller_s_k_u(self, sellerSKU, **kwargs) -> ApiResponse
117
141
 
@@ -136,9 +160,11 @@ class FbaSmallAndLight(Client):
136
160
  ApiResponse:
137
161
  """
138
162
 
139
- return self._request(fill_query_params(kwargs.pop('path'), seller_sku), params=kwargs)
163
+ return self._request(
164
+ fill_query_params(kwargs.pop("path"), seller_sku), params=kwargs
165
+ )
140
166
 
141
- @sp_endpoint('/fba/smallAndLight/v1/feePreviews', method='POST')
167
+ @sp_endpoint("/fba/smallAndLight/v1/feePreviews", method="POST")
142
168
  def get_small_and_light_fee_preview(self, **kwargs) -> ApiResponse:
143
169
  """
144
170
  get_small_and_light_fee_preview(self, **kwargs) -> ApiResponse
@@ -175,4 +201,4 @@ class FbaSmallAndLight(Client):
175
201
  ApiResponse:
176
202
  """
177
203
 
178
- return self._request(kwargs.pop('path'), data=kwargs)
204
+ return self._request(kwargs.pop("path"), data=kwargs)
sp_api/api/feeds/feeds.py CHANGED
@@ -1,8 +1,9 @@
1
1
  import zlib
2
2
 
3
- import requests
3
+ import httpx
4
4
 
5
5
  from sp_api.base import Client, sp_endpoint, fill_query_params, ApiResponse
6
+ from sp_api.util import should_add_marketplace
6
7
 
7
8
 
8
9
  class Feeds(Client):
@@ -13,7 +14,7 @@ class Feeds(Client):
13
14
  The Selling Partner API for Feeds lets you upload data to Amazon on behalf of a selling partner.
14
15
  """
15
16
 
16
- @sp_endpoint('/feeds/2021-06-30/feeds', method='GET')
17
+ @sp_endpoint("/feeds/2021-06-30/feeds", method="GET")
17
18
  def get_feeds(self, **kwargs) -> ApiResponse:
18
19
  """
19
20
  get_feeds(self, **kwargs) -> ApiResponse
@@ -34,10 +35,14 @@ class Feeds(Client):
34
35
  ApiResponse:
35
36
  """
36
37
 
37
- add_marketplace = not 'nextToken' in kwargs
38
- return self._request(kwargs.pop('path'), params=kwargs, add_marketplace=add_marketplace)
38
+ add_marketplace = should_add_marketplace(kwargs, "nextToken")
39
+ return self._request(
40
+ kwargs.pop("path"), params=kwargs, add_marketplace=add_marketplace
41
+ )
39
42
 
40
- def submit_feed(self, feed_type, file, content_type='text/tsv', **kwargs) -> [ApiResponse, ApiResponse]:
43
+ def submit_feed(
44
+ self, feed_type, file, content_type="text/tsv", **kwargs
45
+ ) -> [ApiResponse, ApiResponse]:
41
46
  """
42
47
  submit_feed(self, feed_type: str, file: File or File like, content_type='text/tsv', **kwargs) -> [ApiResponse, ApiResponse]
43
48
  Combines `create_feed_document` and `create_feed`, uploads the file and sends the feed to amazon.
@@ -69,9 +74,11 @@ class Feeds(Client):
69
74
  [ApiResponse:, ApiResponse:]
70
75
  """
71
76
  document_response = self.create_feed_document(file, content_type)
72
- return document_response, self.create_feed(feed_type, document_response.payload.get('feedDocumentId'), **kwargs)
77
+ return document_response, self.create_feed(
78
+ feed_type, document_response.payload.get("feedDocumentId"), **kwargs
79
+ )
73
80
 
74
- @sp_endpoint('/feeds/2021-06-30/feeds', method='POST')
81
+ @sp_endpoint("/feeds/2021-06-30/feeds", method="POST")
75
82
  def create_feed(self, feed_type, input_feed_document_id, **kwargs) -> ApiResponse:
76
83
  """
77
84
  create_feed(self, feed_type: str, input_feed_document_id: str, **kwargs) -> ApiResponse
@@ -104,13 +111,13 @@ class Feeds(Client):
104
111
  ApiResponse:
105
112
  """
106
113
  data = {
107
- 'feedType': feed_type,
108
- 'inputFeedDocumentId': input_feed_document_id,
109
- **kwargs
114
+ "feedType": feed_type,
115
+ "inputFeedDocumentId": input_feed_document_id,
116
+ **kwargs,
110
117
  }
111
- return self._request(kwargs.pop('path'), data=data)
118
+ return self._request(kwargs.pop("path"), data=data)
112
119
 
113
- @sp_endpoint('/feeds/2021-06-30/feeds/{}', method='DELETE')
120
+ @sp_endpoint("/feeds/2021-06-30/feeds/{}", method="DELETE")
114
121
  def cancel_feed(self, feedId, **kwargs) -> ApiResponse:
115
122
  """
116
123
  cancel_feed(self, feedId, **kwargs) -> ApiResponse
@@ -126,9 +133,9 @@ class Feeds(Client):
126
133
  ApiResponse:
127
134
  """
128
135
 
129
- return self._request(fill_query_params(kwargs.pop('path'), feedId), data=kwargs)
136
+ return self._request(fill_query_params(kwargs.pop("path"), feedId), data=kwargs)
130
137
 
131
- @sp_endpoint('/feeds/2021-06-30/feeds/{}', method='GET')
138
+ @sp_endpoint("/feeds/2021-06-30/feeds/{}", method="GET")
132
139
  def get_feed(self, feedId, **kwargs) -> ApiResponse:
133
140
  """
134
141
  get_feed(self, feedId, **kwargs) -> ApiResponse
@@ -144,9 +151,13 @@ class Feeds(Client):
144
151
  ApiResponse:
145
152
  """
146
153
 
147
- return self._request(fill_query_params(kwargs.pop('path'), feedId), params=kwargs, add_marketplace=False)
154
+ return self._request(
155
+ fill_query_params(kwargs.pop("path"), feedId),
156
+ params=kwargs,
157
+ add_marketplace=False,
158
+ )
148
159
 
149
- @sp_endpoint('/feeds/2021-06-30/documents', method='POST')
160
+ @sp_endpoint("/feeds/2021-06-30/documents", method="POST")
150
161
  def create_feed_document(self, file, content_type, **kwargs) -> ApiResponse:
151
162
  """
152
163
  create_feed_document(self, **kwargs) -> ApiResponse
@@ -164,30 +175,32 @@ class Feeds(Client):
164
175
  Returns:
165
176
  ApiResponse:
166
177
  """
167
- data = {
168
- 'contentType': kwargs.get('contentType', content_type)
169
- }
170
- response = self._request(kwargs.get('path'), data={**data, **kwargs})
178
+ data = {"contentType": kwargs.get("contentType", content_type)}
179
+ response = self._request(kwargs.get("path"), data={**data, **kwargs})
171
180
 
172
- if(file is None):
181
+ if file is None:
173
182
  return response
174
183
 
175
184
  upload_data = file.read()
176
185
  try:
177
- upload_data = upload_data.encode('iso-8859-1')
186
+ upload_data = upload_data.encode("iso-8859-1")
178
187
  except AttributeError:
179
188
  pass
180
- upload = requests.put(
181
- response.payload.get('url'),
182
- data=upload_data,
183
- headers={'Content-Type': content_type}
184
- )
189
+ with httpx.Client() as client:
190
+ upload = client.put(
191
+ response.payload.get("url"),
192
+ content=upload_data,
193
+ headers={"Content-Type": content_type},
194
+ )
185
195
  if 200 <= upload.status_code < 300:
186
196
  return response
187
197
  from sp_api.base.exceptions import SellingApiException
188
- raise SellingApiException(headers=upload.headers, error=upload.json().get('errors'))
189
198
 
190
- @sp_endpoint('/feeds/2021-06-30/documents/{}', method='GET')
199
+ raise SellingApiException(
200
+ headers=upload.headers, error=upload.json().get("errors")
201
+ )
202
+
203
+ @sp_endpoint("/feeds/2021-06-30/documents/{}", method="GET")
191
204
  def get_feed_document(self, feedDocumentId, **kwargs) -> str:
192
205
  """
193
206
  get_feed_document(self, feedDocumentId, **kwargs) -> ApiResponse
@@ -207,7 +220,7 @@ class Feeds(Client):
207
220
 
208
221
  return self.get_feed_result_document(feedDocumentId)
209
222
 
210
- @sp_endpoint('/feeds/2021-06-30/documents/{}', method='GET')
223
+ @sp_endpoint("/feeds/2021-06-30/documents/{}", method="GET")
211
224
  def get_feed_result_document(self, feedDocumentId, **kwargs) -> str:
212
225
  """
213
226
  get_feed_result_document(self, feedDocumentId, **kwargs) -> str
@@ -223,17 +236,25 @@ class Feeds(Client):
223
236
  Returns:
224
237
  str:
225
238
  """
226
- response = self._request(fill_query_params(kwargs.pop('path'), feedDocumentId), params=kwargs,
227
- add_marketplace=False)
228
- url = response.payload.get('url')
229
- doc_response = requests.get(url)
230
-
231
- encoding = doc_response.encoding if doc_response and doc_response.encoding else 'iso-8859-1'
232
- if encoding.lower() == 'windows-31j':
233
- encoding = 'cp932'
239
+ response = self._request(
240
+ fill_query_params(kwargs.pop("path"), feedDocumentId),
241
+ params=kwargs,
242
+ add_marketplace=False,
243
+ )
244
+ url = response.payload.get("url")
245
+ with httpx.Client() as client:
246
+ doc_response = client.get(url)
247
+
248
+ encoding = (
249
+ doc_response.encoding
250
+ if doc_response and doc_response.encoding
251
+ else "iso-8859-1"
252
+ )
253
+ if encoding.lower() == "windows-31j":
254
+ encoding = "cp932"
234
255
 
235
256
  content = doc_response.content
236
- if 'compressionAlgorithm' in response.payload:
257
+ if "compressionAlgorithm" in response.payload:
237
258
  try:
238
259
  return zlib.decompress(bytearray(content), 15 + 32).decode(encoding)
239
260
  except Exception:
@@ -1,10 +1,23 @@
1
+ import enum
2
+
1
3
  from sp_api.base import Client, Marketplaces, ApiResponse
2
4
  from sp_api.base import sp_endpoint, fill_query_params
3
5
 
6
+ class FinancesVersion(str, enum.Enum):
7
+ V_0 = "v0"
8
+ V_2024_06_19 = "2024-06-19"
9
+ LATEST = "2024-06-19"
10
+
4
11
 
5
12
  class Finances(Client):
13
+ version: FinancesVersion = FinancesVersion.V_0
14
+
15
+ def __init__(self, *args, **kwargs):
16
+ if "version" in kwargs:
17
+ self.version = kwargs.get("version", FinancesVersion.V_0)
18
+ super().__init__(*args, **{**kwargs, "version": self.version})
6
19
 
7
- @sp_endpoint('/finances/v0/orders/{}/financialEvents')
20
+ @sp_endpoint("/finances/<version>/orders/{}/financialEvents")
8
21
  def get_financial_events_for_order(self, order_id, **kwargs) -> ApiResponse:
9
22
  """
10
23
  get_financial_events_for_order(self, order_id, **kwargs) -> ApiResponse
@@ -21,9 +34,11 @@ class Finances(Client):
21
34
  Returns:
22
35
 
23
36
  """
24
- return self._request(fill_query_params(kwargs.pop('path'), order_id), params={**kwargs})
37
+ return self._request(
38
+ fill_query_params(kwargs.pop("path"), order_id), params={**kwargs}
39
+ )
25
40
 
26
- @sp_endpoint('/finances/v0/financialEvents')
41
+ @sp_endpoint("/finances/<version>/financialEvents")
27
42
  def list_financial_events(self, **kwargs) -> ApiResponse:
28
43
  """
29
44
  list_financial_events(self, **kwargs) -> ApiResponse:
@@ -35,10 +50,12 @@ class Finances(Client):
35
50
  Returns:
36
51
 
37
52
  """
38
- return self._request(fill_query_params(kwargs.pop('path')), params={**kwargs})
53
+ return self._request(fill_query_params(kwargs.pop("path")), params={**kwargs})
39
54
 
40
- @sp_endpoint('/finances/v0/financialEventGroups/{}/financialEvents')
41
- def list_financial_events_by_group_id(self, event_group_id, **kwargs) -> ApiResponse:
55
+ @sp_endpoint("/finances/<version>/financialEventGroups/{}/financialEvents")
56
+ def list_financial_events_by_group_id(
57
+ self, event_group_id, **kwargs
58
+ ) -> ApiResponse:
42
59
  """
43
60
  list_financial_events_by_groupid(self, event_group_id, **kwargs) -> ApiResponse:
44
61
 
@@ -50,9 +67,11 @@ class Finances(Client):
50
67
  Returns:
51
68
 
52
69
  """
53
- return self._request(fill_query_params(kwargs.pop('path'), event_group_id), params={**kwargs})
70
+ return self._request(
71
+ fill_query_params(kwargs.pop("path"), event_group_id), params={**kwargs}
72
+ )
54
73
 
55
- @sp_endpoint('/finances/v0/financialEventGroups')
74
+ @sp_endpoint("/finances/<version>/financialEventGroups")
56
75
  def list_financial_event_groups(self, **kwargs) -> ApiResponse:
57
76
  """
58
77
  list_financial_event_groups(self, **kwargs) -> ApiResponse:
@@ -64,5 +83,17 @@ class Finances(Client):
64
83
  Returns:
65
84
 
66
85
  """
67
- return self._request(kwargs.pop('path'), params={**kwargs})
86
+ return self._request(kwargs.pop("path"), params={**kwargs})
87
+
88
+ @sp_endpoint("/finances/<version>/transactions")
89
+ def list_transactions(self, **kwargs) -> ApiResponse:
90
+ """
91
+ list_transactions(self, **kwargs) -> ApiResponse:
92
+
93
+ Args:
94
+ **kwargs:
95
+
96
+ Returns: ApiResponse
97
+ """
68
98
 
99
+ return self._request(kwargs.pop("path"), params={**kwargs})