From 2fa058f20b9e19978d50f2f08fedda766ef72f54 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 14 Dec 2024 18:07:56 +0000 Subject: [PATCH] code style #1608 --- sp_api/__version__.py | 2 +- sp_api/api/__init__.py | 65 +- .../amazon_warehousing_and_distribu.py | 158 +- sp_api/api/aplus_content/aplus_content.py | 121 +- .../application_management.py | 12 +- sp_api/api/authorization/authorization.py | 10 +- sp_api/api/catalog/catalog.py | 20 +- sp_api/api/catalog_items/catalog_items.py | 22 +- sp_api/api/data_kiosk/data_kiosk.py | 91 +- .../fba_inbound_eligibility.py | 36 +- .../fba_small_and_light.py | 66 +- sp_api/api/feeds/feeds.py | 84 +- sp_api/api/finances/finances.py | 25 +- .../fulfillment_inbound.py | 1459 +++++++++-------- .../fulfillment_outbound.py | 120 +- sp_api/api/inventories/inventories.py | 27 +- sp_api/api/listings_items/listings_items.py | 88 +- .../listings_restrictions.py | 13 +- .../merchant_fulfillment.py | 85 +- sp_api/api/messaging/messaging.py | 112 +- sp_api/api/notifications/notifications.py | 130 +- sp_api/api/orders/orders.py | 99 +- sp_api/api/product_fees/product_fees.py | 139 +- .../product_type_definitions.py | 19 +- sp_api/api/products/products.py | 150 +- sp_api/api/products/products_definitions.py | 23 +- sp_api/api/replenishment/replenishment.py | 24 +- sp_api/api/reports/reports.py | 148 +- sp_api/api/sales/sales.py | 36 +- sp_api/api/sellers/sellers.py | 6 +- sp_api/api/services/services.py | 71 +- sp_api/api/shipping/shipping.py | 76 +- sp_api/api/shipping/shippingV2.py | 76 +- sp_api/api/solicitations/solicitations.py | 31 +- sp_api/api/supply_sources/supply_sources.py | 82 +- sp_api/api/tokens/tokens.py | 10 +- sp_api/api/upload/upload.py | 18 +- .../vendor_direct_fulfillment_inventory.py | 16 +- .../vendor_direct_fulfillment_orders.py | 26 +- .../vendor_direct_fulfillment_payments.py | 10 +- .../vendor_direct_fulfillment_shipping.py | 79 +- .../vendor_direct_fulfillment_transactions.py | 14 +- sp_api/api/vendor_invoices/vendor_invoices.py | 10 +- sp_api/api/vendor_orders/vendor_orders.py | 35 +- .../api/vendor_shipments/vendor_shipments.py | 380 ++--- .../vendor_transaction_status.py | 12 +- sp_api/auth/__init__.py | 6 +- sp_api/auth/access_token_client.py | 77 +- sp_api/auth/access_token_response.py | 8 +- sp_api/base/ApiResponse.py | 4 +- sp_api/base/__init__.py | 95 +- sp_api/base/base_client.py | 8 +- sp_api/base/client.py | 175 +- sp_api/base/credential_provider.py | 75 +- sp_api/base/exceptions.py | 17 +- sp_api/base/feedTypes.py | 76 +- sp_api/base/fulfillment_channel.py | 4 +- sp_api/base/helpers.py | 31 +- sp_api/base/identifiersType.py | 16 +- sp_api/base/included_data.py | 24 +- sp_api/base/marketplaces.py | 2 +- sp_api/base/notifications.py | 2 +- sp_api/base/processing_status.py | 10 +- sp_api/base/reportTypes.py | 300 ++-- sp_api/base/sales_enum.py | 24 +- sp_api/util/__init__.py | 12 +- sp_api/util/key_maker.py | 6 +- sp_api/util/load_all_pages.py | 13 +- sp_api/util/load_date_bound.py | 41 +- sp_api/util/retry.py | 31 +- 70 files changed, 3040 insertions(+), 2353 deletions(-) diff --git a/sp_api/__version__.py b/sp_api/__version__.py index 8dfd9b599..608978d60 100644 --- a/sp_api/__version__.py +++ b/sp_api/__version__.py @@ -1 +1 @@ -__version__ = '1.8.19' +__version__ = "1.8.19" diff --git a/sp_api/api/__init__.py b/sp_api/api/__init__.py index 645b212b4..855661706 100644 --- a/sp_api/api/__init__.py +++ b/sp_api/api/__init__.py @@ -13,12 +13,16 @@ from .feeds.feeds import Feeds as FeedsV2 from .inventories.inventories import Inventories -from .fulfillment_inbound.fulfillment_inbound import FulfillmentInbound, FulfillmentInboundVersion +from .fulfillment_inbound.fulfillment_inbound import ( + FulfillmentInbound, + FulfillmentInboundVersion, +) from .upload.upload import Upload from .messaging.messaging import Messaging from .merchant_fulfillment.merchant_fulfillment import MerchantFulfillment ##### DO NOT DELETE ########## INSERT IMPORT HERE ####### + from .listings_restrictions.listings_restrictions import ListingsRestrictions from .messaging.messaging import Messaging @@ -37,16 +41,25 @@ from .vendor_invoices.vendor_invoices import VendorInvoices -from .vendor_direct_fulfillment_transactions.vendor_direct_fulfillment_transactions import \ - VendorDirectFulfillmentTransactions +from .vendor_direct_fulfillment_transactions.vendor_direct_fulfillment_transactions import ( + VendorDirectFulfillmentTransactions, +) -from .vendor_direct_fulfillment_shipping.vendor_direct_fulfillment_shipping import VendorDirectFulfillmentShipping +from .vendor_direct_fulfillment_shipping.vendor_direct_fulfillment_shipping import ( + VendorDirectFulfillmentShipping, +) -from .vendor_direct_fulfillment_payments.vendor_direct_fulfillment_payments import VendorDirectFulfillmentPayments +from .vendor_direct_fulfillment_payments.vendor_direct_fulfillment_payments import ( + VendorDirectFulfillmentPayments, +) -from .vendor_direct_fulfillment_orders.vendor_direct_fulfillment_orders import VendorDirectFulfillmentOrders +from .vendor_direct_fulfillment_orders.vendor_direct_fulfillment_orders import ( + VendorDirectFulfillmentOrders, +) -from .vendor_direct_fulfillment_inventory.vendor_direct_fulfillment_inventory import VendorDirectFulfillmentInventory +from .vendor_direct_fulfillment_inventory.vendor_direct_fulfillment_inventory import ( + VendorDirectFulfillmentInventory, +) from .tokens.tokens import Tokens @@ -74,8 +87,10 @@ from .application_management.application_management import ApplicationManagement -from .amazon_warehousing_and_distribu.amazon_warehousing_and_distribu import AmazonWarehousingAndDistribution, \ - AmazonWarehousingAndDistributionVersion +from .amazon_warehousing_and_distribu.amazon_warehousing_and_distribu import ( + AmazonWarehousingAndDistribution, + AmazonWarehousingAndDistributionVersion, +) __all__ = [ "Sales", @@ -90,7 +105,7 @@ "Feeds", "Inventories", "FulfillmentInbound", - 'Upload', + "Upload", "Messaging", "FulfillmentInbound", "MerchantFulfillment", @@ -102,59 +117,31 @@ "Feeds", "FeedsV2", "ReportsV2", - "Messaging", - "CatalogItems", - "ProductTypeDefinitions", - "ListingsItems", - "VendorTransactionStatus", - "VendorShipments", - "VendorOrders", - "VendorInvoices", - "VendorDirectFulfillmentTransactions", - "VendorDirectFulfillmentShipping", - "VendorDirectFulfillmentPayments", - "VendorDirectFulfillmentOrders", - "VendorDirectFulfillmentInventory", - "Tokens", - "Solicitations", - "Shipping", - "Services", - "FbaSmallAndLight", - "FbaInboundEligibility", - "Authorization", - "AplusContent", - "FulfillmentOutbound", - "Replenishment", - "SupplySources", - "DataKiosk", - "ApplicationManagement", - - "AmazonWarehousingAndDistribution" - + "AmazonWarehousingAndDistribution", ] diff --git a/sp_api/api/amazon_warehousing_and_distribu/amazon_warehousing_and_distribu.py b/sp_api/api/amazon_warehousing_and_distribu/amazon_warehousing_and_distribu.py index bb5df7b9e..bed0c23cf 100644 --- a/sp_api/api/amazon_warehousing_and_distribu/amazon_warehousing_and_distribu.py +++ b/sp_api/api/amazon_warehousing_and_distribu/amazon_warehousing_and_distribu.py @@ -12,112 +12,118 @@ class AmazonWarehousingAndDistributionVersion(str, enum.Enum): class AmazonWarehousingAndDistribution(Client): """ AmazonWarehousingAndDistribu SP-API Client - :link: + :link: The Selling Partner API for Amazon Warehousing and Distribution (AWD). """ - version: AmazonWarehousingAndDistributionVersion = AmazonWarehousingAndDistributionVersion.V_2024_05_09 + version: AmazonWarehousingAndDistributionVersion = ( + AmazonWarehousingAndDistributionVersion.V_2024_05_09 + ) def __init__(self, *args, **kwargs): - if 'version' in kwargs: - self.version = kwargs.get('version', AmazonWarehousingAndDistributionVersion.V_2024_05_09) - super().__init__(*args, **{**kwargs, 'version': self.version}) + if "version" in kwargs: + self.version = kwargs.get( + "version", AmazonWarehousingAndDistributionVersion.V_2024_05_09 + ) + super().__init__(*args, **{**kwargs, "version": self.version}) - @sp_endpoint('/awd//inboundShipments/{}', method='GET') + @sp_endpoint("/awd//inboundShipments/{}", method="GET") def get_inbound_shipment(self, shipmentId, **kwargs) -> ApiResponse: """ - get_inbound_shipment(self, shipmentId, **kwargs) -> ApiResponse + get_inbound_shipment(self, shipmentId, **kwargs) -> ApiResponse - Retrieves an AWD inbound shipment. + Retrieves an AWD inbound shipment. -**Usage Plan:** + **Usage Plan:** -| Rate (requests per second) | Burst | -| ---- | ---- | -| 2 | 2 | + | Rate (requests per second) | Burst | + | ---- | ---- | + | 2 | 2 | -The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api) + The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api) - Args: - - shipmentId:string | * REQUIRED ID for the shipment. A shipment contains the cases being inbounded. - + Args: - Returns: - ApiResponse: + shipmentId:string | * REQUIRED ID for the shipment. A shipment contains the cases being inbounded. + + + Returns: + ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), shipmentId), params=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), shipmentId), params=kwargs + ) - @sp_endpoint('/awd//inboundShipments', method='GET') + @sp_endpoint("/awd//inboundShipments", method="GET") def list_inbound_shipments(self, **kwargs) -> ApiResponse: """ - list_inbound_shipments(self, **kwargs) -> ApiResponse - - Retrieves a summary for all the inbound AWD shipments associated with a merchant, with the ability to apply optional filters. - -**Usage Plan:** - -| Rate (requests per second) | Burst | -| ---- | ---- | -| 1 | 1 | - -The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). - - Args: - - key sortBy:string | Field to sort results by. Required if `sortOrder` is provided. - - key sortOrder:string | Sort the response in `ASCENDING` or `DESCENDING` order. - - key shipmentStatus:string | Filter by inbound shipment status. - - key updatedAfter:string | List the inbound shipments that were updated after a certain time (inclusive). The date must be in ISO 8601 format. - - key updatedBefore:string | List the inbound shipments that were updated before a certain time (inclusive). The date must be in ISO 8601 format. - - key maxResults:integer | Maximum number of results to return. - - key nextToken:string | Token to retrieve the next set of paginated results. - - - Returns: - ApiResponse: + list_inbound_shipments(self, **kwargs) -> ApiResponse + + Retrieves a summary for all the inbound AWD shipments associated with a merchant, with the ability to apply optional filters. + + **Usage Plan:** + + | Rate (requests per second) | Burst | + | ---- | ---- | + | 1 | 1 | + + The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). + + Args: + + key sortBy:string | Field to sort results by. Required if `sortOrder` is provided. + + key sortOrder:string | Sort the response in `ASCENDING` or `DESCENDING` order. + + key shipmentStatus:string | Filter by inbound shipment status. + + key updatedAfter:string | List the inbound shipments that were updated after a certain time (inclusive). The date must be in ISO 8601 format. + + key updatedBefore:string | List the inbound shipments that were updated before a certain time (inclusive). The date must be in ISO 8601 format. + + key maxResults:integer | Maximum number of results to return. + + key nextToken:string | Token to retrieve the next set of paginated results. + + + Returns: + ApiResponse: """ - return self._request(kwargs.pop('path'), params=kwargs) + return self._request(kwargs.pop("path"), params=kwargs) - @sp_endpoint('/awd//inventory', method='GET') + @sp_endpoint("/awd//inventory", method="GET") def list_inventory(self, **kwargs) -> ApiResponse: """ - list_inventory(self, **kwargs) -> ApiResponse + list_inventory(self, **kwargs) -> ApiResponse + + Lists AWD inventory associated with a merchant with the ability to apply optional filters. + + **Usage Plan:** + + | Rate (requests per second) | Burst | + | ---- | ---- | + | 2 | 2 | + + The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). + + Args: + + key sku:string | Filter by seller or merchant SKU for the item. - Lists AWD inventory associated with a merchant with the ability to apply optional filters. + key sortOrder:string | Sort the response in `ASCENDING` or `DESCENDING` order. -**Usage Plan:** + key details:string | Set to `SHOW` to return summaries with additional inventory details. Defaults to `HIDE,` which returns only inventory summary totals. -| Rate (requests per second) | Burst | -| ---- | ---- | -| 2 | 2 | + key nextToken:string | Token to retrieve the next set of paginated results. -The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). + key maxResults:integer | Maximum number of results to return. - Args: - - key sku:string | Filter by seller or merchant SKU for the item. - - key sortOrder:string | Sort the response in `ASCENDING` or `DESCENDING` order. - - key details:string | Set to `SHOW` to return summaries with additional inventory details. Defaults to `HIDE,` which returns only inventory summary totals. - - key nextToken:string | Token to retrieve the next set of paginated results. - - key maxResults:integer | Maximum number of results to return. - - Returns: - ApiResponse: + Returns: + ApiResponse: """ - return self._request(kwargs.pop('path'), params=kwargs) + return self._request(kwargs.pop("path"), params=kwargs) diff --git a/sp_api/api/aplus_content/aplus_content.py b/sp_api/api/aplus_content/aplus_content.py index ec688e3fb..97d2babe5 100644 --- a/sp_api/api/aplus_content/aplus_content.py +++ b/sp_api/api/aplus_content/aplus_content.py @@ -5,13 +5,12 @@ class AplusContent(Client): """ AplusContent SP-API Client - :link: + :link: With the A+ Content API, you can build applications that help selling partners add rich marketing content to their Amazon product detail pages. A+ content helps selling partners share their brand and product story, which helps buyers make informed purchasing decisions. Selling partners assemble content by choosing from content modules and adding images and text. """ - - @sp_endpoint('/aplus/2020-11-01/contentDocuments', method='GET') + @sp_endpoint("/aplus/2020-11-01/contentDocuments", method="GET") def search_content_documents(self, **kwargs) -> ApiResponse: """ search_content_documents(self, **kwargs) -> ApiResponse @@ -36,11 +35,10 @@ def search_content_documents(self, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - - return self._request(kwargs.pop('path'), params=kwargs) - - @sp_endpoint('/aplus/2020-11-01/contentDocuments', method='POST') + return self._request(kwargs.pop("path"), params=kwargs) + + @sp_endpoint("/aplus/2020-11-01/contentDocuments", method="POST") def create_content_document(self, **kwargs) -> ApiResponse: """ create_content_document(self, **kwargs) -> ApiResponse @@ -61,16 +59,20 @@ def create_content_document(self, **kwargs) -> ApiResponse: Args: key marketplaceId:string | * REQUIRED The identifier for the marketplace where the A+ Content is published. postContentDocumentRequest: | * REQUIRED {'properties': {'contentDocument': {'$ref': '#/definitions/ContentDocument'}}, 'required': ['contentDocument'], 'type': 'object'} - + Returns: ApiResponse: """ - return self._request(kwargs.pop('path'), data=kwargs.pop('body'), params=kwargs, add_marketplace=False) - + return self._request( + kwargs.pop("path"), + data=kwargs.pop("body"), + params=kwargs, + add_marketplace=False, + ) - @sp_endpoint('/aplus/2020-11-01/contentDocuments/{}', method='GET') + @sp_endpoint("/aplus/2020-11-01/contentDocuments/{}", method="GET") def get_content_document(self, contentReferenceKey, **kwargs) -> ApiResponse: """ get_content_document(self, contentReferenceKey, **kwargs) -> ApiResponse @@ -92,15 +94,17 @@ def get_content_document(self, contentReferenceKey, **kwargs) -> ApiResponse: contentReferenceKey:string | * REQUIRED The unique reference key for the A+ Content document. A content reference key cannot form a permalink and may change in the future. A content reference key is not guaranteed to match any A+ Content identifier. key marketplaceId:string | * REQUIRED The identifier for the marketplace where the A+ Content is published. key includedDataSet:array | * REQUIRED The set of A+ Content data types to include in the response. - + Returns: ApiResponse: """ - - return self._request(fill_query_params(kwargs.pop('path'), contentReferenceKey), params=kwargs) - @sp_endpoint('/aplus/2020-11-01/contentDocuments/{}', method='POST') + return self._request( + fill_query_params(kwargs.pop("path"), contentReferenceKey), params=kwargs + ) + + @sp_endpoint("/aplus/2020-11-01/contentDocuments/{}", method="POST") def update_content_document(self, contentReferenceKey, **kwargs) -> ApiResponse: """ update_content_document(self, contentReferenceKey, **kwargs) -> ApiResponse @@ -124,12 +128,18 @@ def update_content_document(self, contentReferenceKey, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - - return self._request(fill_query_params(kwargs.pop('path'), contentReferenceKey), data=kwargs.pop("body"), params=kwargs, add_marketplace=False) - - @sp_endpoint('/aplus/2020-11-01/contentDocuments/{}/asins', method='GET') - def list_content_document_asin_relations(self, contentReferenceKey, **kwargs) -> ApiResponse: + return self._request( + fill_query_params(kwargs.pop("path"), contentReferenceKey), + data=kwargs.pop("body"), + params=kwargs, + add_marketplace=False, + ) + + @sp_endpoint("/aplus/2020-11-01/contentDocuments/{}/asins", method="GET") + def list_content_document_asin_relations( + self, contentReferenceKey, **kwargs + ) -> ApiResponse: """ list_content_document_asin_relations(self, contentReferenceKey, **kwargs) -> ApiResponse @@ -154,12 +164,15 @@ def list_content_document_asin_relations(self, contentReferenceKey, **kwargs) -> Returns: ApiResponse: """ - - return self._request(fill_query_params(kwargs.pop('path'), contentReferenceKey), params=kwargs) - - @sp_endpoint('/aplus/2020-11-01/contentDocuments/{}/asins', method='POST') - def post_content_document_asin_relations(self, contentReferenceKey, **kwargs) -> ApiResponse: + return self._request( + fill_query_params(kwargs.pop("path"), contentReferenceKey), params=kwargs + ) + + @sp_endpoint("/aplus/2020-11-01/contentDocuments/{}/asins", method="POST") + def post_content_document_asin_relations( + self, contentReferenceKey, **kwargs + ) -> ApiResponse: """ post_content_document_asin_relations(self, contentReferenceKey, **kwargs) -> ApiResponse @@ -182,11 +195,15 @@ def post_content_document_asin_relations(self, contentReferenceKey, **kwargs) -> Returns: ApiResponse: """ - - return self._request(fill_query_params(kwargs.pop('path'), contentReferenceKey), data=kwargs.pop("body"), params=kwargs, add_marketplace=False) - - @sp_endpoint('/aplus/2020-11-01/contentAsinValidations', method='POST') + return self._request( + fill_query_params(kwargs.pop("path"), contentReferenceKey), + data=kwargs.pop("body"), + params=kwargs, + add_marketplace=False, + ) + + @sp_endpoint("/aplus/2020-11-01/contentAsinValidations", method="POST") def validate_content_document_asin_relations(self, **kwargs) -> ApiResponse: """ validate_content_document_asin_relations(self, **kwargs) -> ApiResponse @@ -206,16 +223,20 @@ def validate_content_document_asin_relations(self, **kwargs) -> ApiResponse: key marketplaceId:string | * REQUIRED The identifier for the marketplace where the A+ Content is published. key asinSet:array | The set of ASINs. postContentDocumentRequest: | * REQUIRED {'properties': {'contentDocument': {'$ref': '#/definitions/ContentDocument'}}, 'required': ['contentDocument'], 'type': 'object'} - + Returns: ApiResponse: """ - return self._request(kwargs.pop('path'), data=kwargs.pop("body"), params=kwargs, add_marketplace=False) - + return self._request( + kwargs.pop("path"), + data=kwargs.pop("body"), + params=kwargs, + add_marketplace=False, + ) - @sp_endpoint('/aplus/2020-11-01/contentPublishRecords', method='GET') + @sp_endpoint("/aplus/2020-11-01/contentPublishRecords", method="GET") def search_content_publish_records(self, **kwargs) -> ApiResponse: """ search_content_publish_records(self, **kwargs) -> ApiResponse @@ -239,12 +260,15 @@ def search_content_publish_records(self, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - - return self._request(kwargs.pop('path'), params=kwargs) - - @sp_endpoint('/aplus/2020-11-01/contentDocuments/{}/approvalSubmissions', method='POST') - def post_content_document_approval_submission(self, contentReferenceKey, **kwargs) -> ApiResponse: + return self._request(kwargs.pop("path"), params=kwargs) + + @sp_endpoint( + "/aplus/2020-11-01/contentDocuments/{}/approvalSubmissions", method="POST" + ) + def post_content_document_approval_submission( + self, contentReferenceKey, **kwargs + ) -> ApiResponse: """ post_content_document_approval_submission(self, contentReferenceKey, **kwargs) -> ApiResponse @@ -266,12 +290,17 @@ def post_content_document_approval_submission(self, contentReferenceKey, **kwarg Returns: ApiResponse: """ - - return self._request(fill_query_params(kwargs.pop('path'), contentReferenceKey), params=kwargs) - - @sp_endpoint('/aplus/2020-11-01/contentDocuments/{}/suspendSubmissions', method='POST') - def post_content_document_suspend_submission(self, contentReferenceKey, **kwargs) -> ApiResponse: + return self._request( + fill_query_params(kwargs.pop("path"), contentReferenceKey), params=kwargs + ) + + @sp_endpoint( + "/aplus/2020-11-01/contentDocuments/{}/suspendSubmissions", method="POST" + ) + def post_content_document_suspend_submission( + self, contentReferenceKey, **kwargs + ) -> ApiResponse: """ post_content_document_suspend_submission(self, contentReferenceKey, **kwargs) -> ApiResponse @@ -293,5 +322,7 @@ def post_content_document_suspend_submission(self, contentReferenceKey, **kwargs Returns: ApiResponse: """ - - return self._request(fill_query_params(kwargs.pop('path'), contentReferenceKey), data=kwargs) + + return self._request( + fill_query_params(kwargs.pop("path"), contentReferenceKey), data=kwargs + ) diff --git a/sp_api/api/application_management/application_management.py b/sp_api/api/application_management/application_management.py index 9052fb50f..ead9e3092 100644 --- a/sp_api/api/application_management/application_management.py +++ b/sp_api/api/application_management/application_management.py @@ -4,13 +4,12 @@ class ApplicationManagement(Client): """ ApplicationManagement SP-API Client - :link: + :link: The Selling Partner API for Application Management lets you programmatically update the client secret on registered applications. """ - - @sp_endpoint('/applications/2023-11-30/clientSecret', method='POST') + @sp_endpoint("/applications/2023-11-30/clientSecret", method="POST") def rotate_application_client_secret(self, **kwargs) -> ApiResponse: """ rotate_application_client_secret(self, **kwargs) -> ApiResponse @@ -26,11 +25,10 @@ def rotate_application_client_secret(self, **kwargs) -> ApiResponse: The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). Args: - + Returns: ApiResponse: """ - - return self._request(kwargs.pop('path'), data=kwargs) - + + return self._request(kwargs.pop("path"), data=kwargs) diff --git a/sp_api/api/authorization/authorization.py b/sp_api/api/authorization/authorization.py index 4766da0f8..f67254814 100644 --- a/sp_api/api/authorization/authorization.py +++ b/sp_api/api/authorization/authorization.py @@ -6,13 +6,14 @@ class Authorization(Client): """ Authorization SP-API Client - :link: + :link: The Selling Partner API for Authorization helps developers manage authorizations and check the specific permissions associated with a given authorization. """ - grantless_scope = 'sellingpartnerapi::migration' - @sp_endpoint('/authorization/v1/authorizationCode', method='GET') + grantless_scope = "sellingpartnerapi::migration" + + @sp_endpoint("/authorization/v1/authorizationCode", method="GET") def get_authorization_code(self, **kwargs) -> ApiResponse: """ get_authorization_code(self, **kwargs) -> ApiResponse @@ -48,6 +49,5 @@ def get_authorization_code(self, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - - return self._request_grantless_operation(kwargs.pop('path'), params=kwargs) + return self._request_grantless_operation(kwargs.pop("path"), params=kwargs) diff --git a/sp_api/api/catalog/catalog.py b/sp_api/api/catalog/catalog.py index b49479a28..ab1f93849 100644 --- a/sp_api/api/catalog/catalog.py +++ b/sp_api/api/catalog/catalog.py @@ -9,7 +9,7 @@ class Catalog(Client): """ - @sp_endpoint('/catalog/v0/items/{}') + @sp_endpoint("/catalog/v0/items/{}") def get_item(self, asin: str, **kwargs) -> ApiResponse: """ get_item(self, asin: str, **kwargs) -> ApiResponse @@ -38,9 +38,9 @@ def get_item(self, asin: str, **kwargs) -> ApiResponse: Returns: GetCatalogItemResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), asin), params=kwargs) + return self._request(fill_query_params(kwargs.pop("path"), asin), params=kwargs) - @sp_endpoint('/catalog/v0/items') + @sp_endpoint("/catalog/v0/items") def list_items(self, **kwargs) -> ApiResponse: """ list_items(self, **kwargs) -> ApiResponse @@ -75,11 +75,11 @@ def list_items(self, **kwargs) -> ApiResponse: Returns: ListCatalogItemsResponse: """ - if 'Query' in kwargs: - kwargs.update({'Query': urllib.parse.quote_plus(kwargs.pop('Query'))}) - return self._request(kwargs.pop('path'), params=kwargs) + if "Query" in kwargs: + kwargs.update({"Query": urllib.parse.quote_plus(kwargs.pop("Query"))}) + return self._request(kwargs.pop("path"), params=kwargs) - @sp_endpoint('/catalog/v0/categories') + @sp_endpoint("/catalog/v0/categories") def list_categories(self, **kwargs) -> ApiResponse: """ list_categories(self, **kwargs) -> ApiResponse @@ -104,6 +104,6 @@ def list_categories(self, **kwargs) -> ApiResponse: Returns: ListCatalogCategoriesResponse: """ - if 'Query' in kwargs: - kwargs.update({'Query': urllib.parse.quote_plus(kwargs.pop('Query'))}) - return self._request(kwargs.pop('path'), params=kwargs) + if "Query" in kwargs: + kwargs.update({"Query": urllib.parse.quote_plus(kwargs.pop("Query"))}) + return self._request(kwargs.pop("path"), params=kwargs) diff --git a/sp_api/api/catalog_items/catalog_items.py b/sp_api/api/catalog_items/catalog_items.py index 25a05a71d..b741679a0 100644 --- a/sp_api/api/catalog_items/catalog_items.py +++ b/sp_api/api/catalog_items/catalog_items.py @@ -20,11 +20,11 @@ class CatalogItems(Client): version: CatalogItemsVersion = CatalogItemsVersion.V_2020_12_01 def __init__(self, *args, **kwargs): - if 'version' in kwargs: - self.version = kwargs.get('version', CatalogItemsVersion.V_2020_12_01) - super().__init__(*args, **{**kwargs, 'version': self.version}) + if "version" in kwargs: + self.version = kwargs.get("version", CatalogItemsVersion.V_2020_12_01) + super().__init__(*args, **{**kwargs, "version": self.version}) - @sp_endpoint('/catalog//items', method='GET') + @sp_endpoint("/catalog//items", method="GET") def search_catalog_items(self, **kwargs) -> ApiResponse: """ search_catalog_items(self, **kwargs) -> ApiResponse @@ -56,12 +56,12 @@ def search_catalog_items(self, **kwargs) -> ApiResponse: ApiResponse: """ - includedData = kwargs.get('includedData', []) + includedData = kwargs.get("includedData", []) if includedData and isinstance(includedData, list): - kwargs['includedData'] = ','.join(includedData) - return self._request(kwargs.pop('path'), params=kwargs) + kwargs["includedData"] = ",".join(includedData) + return self._request(kwargs.pop("path"), params=kwargs) - @sp_endpoint('/catalog//items/{}', method='GET') + @sp_endpoint("/catalog//items/{}", method="GET") def get_catalog_item(self, asin, **kwargs) -> ApiResponse: """ get_catalog_item(self, asin, **kwargs) -> ApiResponse @@ -87,7 +87,7 @@ def get_catalog_item(self, asin, **kwargs) -> ApiResponse: ApiResponse: """ - includedData = kwargs.get('includedData', []) + includedData = kwargs.get("includedData", []) if includedData and isinstance(includedData, list): - kwargs['includedData'] = ','.join(includedData) - return self._request(fill_query_params(kwargs.pop('path'), asin), params=kwargs) + kwargs["includedData"] = ",".join(includedData) + return self._request(fill_query_params(kwargs.pop("path"), asin), params=kwargs) diff --git a/sp_api/api/data_kiosk/data_kiosk.py b/sp_api/api/data_kiosk/data_kiosk.py index 1acdc4359..4a1a5a316 100644 --- a/sp_api/api/data_kiosk/data_kiosk.py +++ b/sp_api/api/data_kiosk/data_kiosk.py @@ -8,12 +8,12 @@ class DataKiosk(Client): """ DataKiosk SP-API Client - :link: + :link: The Selling Partner API for Data Kiosk lets you submit GraphQL queries from a variety of schemas to help selling partners manage their businesses. """ - @sp_endpoint('/dataKiosk/2023-11-15/queries', method='GET') + @sp_endpoint("/dataKiosk/2023-11-15/queries", method="GET") def get_queries(self, **kwargs) -> ApiResponse: """ get_queries(self, **kwargs) -> ApiResponse @@ -32,25 +32,25 @@ def get_queries(self, **kwargs) -> ApiResponse: The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). Args: - + key processingStatuses:array | A list of processing statuses used to filter queries. - + key pageSize:integer | The maximum number of queries to return in a single call. - + key createdSince:string | The earliest query creation date and time for queries to include in the response, in ISO 8601 date time format. The default is 90 days ago. - + key createdUntil:string | The latest query creation date and time for queries to include in the response, in ISO 8601 date time format. The default is the time of the `getQueries` request. - + key paginationToken:string | A token to fetch a certain page of results when there are multiple pages of results available. The value of this token is fetched from the `pagination.nextToken` field returned in the `GetQueriesResponse` object. All other parameters must be provided with the same values that were provided with the request that generated this token, with the exception of `pageSize` which can be modified between calls to `getQueries`. In the absence of this token value, `getQueries` returns the first page of results. - + Returns: ApiResponse: """ - return self._request(kwargs.pop('path'), params=kwargs, add_marketplace=False) + return self._request(kwargs.pop("path"), params=kwargs, add_marketplace=False) - @sp_endpoint('/dataKiosk/2023-11-15/queries', method='POST') + @sp_endpoint("/dataKiosk/2023-11-15/queries", method="POST") def create_query(self, query, pagination_token=None, **kwargs) -> ApiResponse: """ create_query(self, query, pagination_token=None, **kwargs) -> ApiResponse @@ -71,7 +71,7 @@ def create_query(self, query, pagination_token=None, **kwargs) -> ApiResponse: The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). Args: - + query:string | * REQUIRED The query to submit. The query must be a valid GraphQL query in the schema specified by the `schema` parameter. pagination_token:string | A token to fetch a certain page of results when there are multiple pages of results available. The value of this token is fetched from the `pagination.nextToken` field returned in the `GetQueriesResponse` object. All other parameters must be provided with the same values that were provided with the request that generated this token, with the exception of `pageSize` which can be modified between calls to `getQueries`. In the absence of this token value, `getQueries` returns the first page of results. @@ -79,12 +79,12 @@ def create_query(self, query, pagination_token=None, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - kwargs['query'] = query + kwargs["query"] = query if pagination_token: - kwargs['paginationToken'] = pagination_token - return self._request(kwargs.pop('path'), data=kwargs, add_marketplace=False) + kwargs["paginationToken"] = pagination_token + return self._request(kwargs.pop("path"), data=kwargs, add_marketplace=False) - @sp_endpoint('/dataKiosk/2023-11-15/queries/{}', method='DELETE') + @sp_endpoint("/dataKiosk/2023-11-15/queries/{}", method="DELETE") def cancel_query(self, query_id, **kwargs) -> ApiResponse: """ cancel_query(self, queryId, **kwargs) -> ApiResponse @@ -102,17 +102,21 @@ def cancel_query(self, query_id, **kwargs) -> ApiResponse: The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). Args: - + query_id:string | * REQUIRED The identifier for the query. This identifier is unique only in combination with a selling partner account ID. - + Returns: ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), query_id), data=kwargs, add_marketplace=False) + return self._request( + fill_query_params(kwargs.pop("path"), query_id), + data=kwargs, + add_marketplace=False, + ) - @sp_endpoint('/dataKiosk/2023-11-15/queries/{}', method='GET') + @sp_endpoint("/dataKiosk/2023-11-15/queries/{}", method="GET") def get_query(self, query_id, **kwargs) -> ApiResponse: """ get_query(self, queryId, **kwargs) -> ApiResponse @@ -130,19 +134,29 @@ def get_query(self, query_id, **kwargs) -> ApiResponse: The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). Args: - + query_id:string | * REQUIRED The query identifier. - + Returns: ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), query_id), params=kwargs, add_marketplace=False) - - @sp_endpoint('/dataKiosk/2023-11-15/documents/{}', method='GET') - def get_document(self, document_id, download: bool = False, file: Union[BytesIO, str, BinaryIO, TextIO] = None, - encoding='utf-8', **kwargs) -> ApiResponse: + return self._request( + fill_query_params(kwargs.pop("path"), query_id), + params=kwargs, + add_marketplace=False, + ) + + @sp_endpoint("/dataKiosk/2023-11-15/documents/{}", method="GET") + def get_document( + self, + document_id, + download: bool = False, + file: Union[BytesIO, str, BinaryIO, TextIO] = None, + encoding="utf-8", + **kwargs + ) -> ApiResponse: """ get_document(self, document_id, download: bool = False, file: Union[BytesIO, str, BinaryIO, TextIO] = None, encoding='utf-8', **kwargs) -> ApiResponse @@ -159,7 +173,7 @@ def get_document(self, document_id, download: bool = False, file: Union[BytesIO, The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). Args: - + document_id:string | * REQUIRED The identifier for the Data Kiosk document. file: | * OPTIONAL The file to write the response to. download: | * OPTIONAL If True, the file will be downloaded and returned in the payload. @@ -170,25 +184,32 @@ def get_document(self, document_id, download: bool = False, file: Union[BytesIO, ApiResponse: """ - res = self._request(fill_query_params(kwargs.pop('path'), document_id), params=kwargs, add_marketplace=False) - if download or file or ('decrypt' in kwargs and kwargs['decrypt']): + res = self._request( + fill_query_params(kwargs.pop("path"), document_id), + params=kwargs, + add_marketplace=False, + ) + if download or file or ("decrypt" in kwargs and kwargs["decrypt"]): import requests + document_response = requests.get( - res.payload.get('documentUrl'), + res.payload.get("documentUrl"), proxies=self.proxies, verify=self.verify, ) document = document_response.content if download: - res.payload.update({ - 'document': document, - }) + res.payload.update( + { + "document": document, + } + ) if file: self._handle_file(file, document, encoding=encoding) return res @staticmethod - def _handle_file(file, document, encoding='utf-8'): + def _handle_file(file, document, encoding="utf-8"): if isinstance(file, str): if isinstance(document, bytes): with open(file, "wb+") as f: @@ -203,7 +224,7 @@ def _handle_file(file, document, encoding='utf-8'): file.write(document.decode(encoding)) file.seek(0) else: - if 'b' in file.mode: + if "b" in file.mode: file.write(document) else: file.write(document.decode(encoding)) diff --git a/sp_api/api/fba_inbound_eligibility/fba_inbound_eligibility.py b/sp_api/api/fba_inbound_eligibility/fba_inbound_eligibility.py index 2df62c194..7cbdfdce5 100644 --- a/sp_api/api/fba_inbound_eligibility/fba_inbound_eligibility.py +++ b/sp_api/api/fba_inbound_eligibility/fba_inbound_eligibility.py @@ -1,18 +1,23 @@ import urllib.parse -from sp_api.base import Client, sp_endpoint, fill_query_params, IneligibilityReasonList, ApiResponse +from sp_api.base import ( + Client, + sp_endpoint, + fill_query_params, + IneligibilityReasonList, + ApiResponse, +) class FbaInboundEligibility(Client): """ FbaInboundEligibility SP-API Client - :link: + :link: 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. """ - - @sp_endpoint('/fba/inbound/v1/eligibility/itemPreview', method='GET') + @sp_endpoint("/fba/inbound/v1/eligibility/itemPreview", method="GET") def get_item_eligibility_preview(self, **kwargs) -> ApiResponse: """ get_item_eligibility_preview(self, **kwargs) -> ApiResponse @@ -34,14 +39,14 @@ def get_item_eligibility_preview(self, **kwargs) -> ApiResponse: key marketplaceIds:array | The identifier for the marketplace in which you want to determine eligibility. Required only when program=INBOUND. key asin:string | * REQUIRED The ASIN of the item for which you want an eligibility preview. key program:string | * REQUIRED The program that you want to check eligibility against. - + Returns: ApiResponse: """ - return self._request(kwargs.pop('path'), params=kwargs) + return self._request(kwargs.pop("path"), params=kwargs) - @sp_endpoint('/fba/inbound/v1/eligibility/itemPreview', method='GET') + @sp_endpoint("/fba/inbound/v1/eligibility/itemPreview", method="GET") def get_item_eligibility_preview_extended(self, **kwargs) -> ApiResponse: """ get_item_eligibility_preview_extended(self, **kwargs) -> ApiResponse @@ -69,18 +74,23 @@ def get_item_eligibility_preview_extended(self, **kwargs) -> ApiResponse: ApiResponse: """ - api_response = self._request(kwargs.pop('path'), params=kwargs) + api_response = self._request(kwargs.pop("path"), params=kwargs) - if api_response.payload.get("ineligibilityReasonList") and api_response.payload.get("isEligibleForProgram") is False: + if ( + api_response.payload.get("ineligibilityReasonList") + and api_response.payload.get("isEligibleForProgram") is False + ): ineligibility_list = api_response.payload.get("ineligibilityReasonList") errors = [] for ineligibility_option in ineligibility_list: try: - errors.append(ineligibility_option + ": " + IneligibilityReasonList[ineligibility_option].value) + errors.append( + ineligibility_option + + ": " + + IneligibilityReasonList[ineligibility_option].value + ) except KeyError as error: errors.append(error) - api_response.payload.update({ - "ineligibilityReasonListMessage": errors - }) + api_response.payload.update({"ineligibilityReasonListMessage": errors}) return api_response diff --git a/sp_api/api/fba_small_and_light/fba_small_and_light.py b/sp_api/api/fba_small_and_light/fba_small_and_light.py index 230ac0845..af7a14ac8 100644 --- a/sp_api/api/fba_small_and_light/fba_small_and_light.py +++ b/sp_api/api/fba_small_and_light/fba_small_and_light.py @@ -6,17 +6,21 @@ class FbaSmallAndLight(Client): """ FbaSmallAndLight SP-API Client - :link: + :link: 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. """ @deprecated - def get_small_and_light_enrollment_by_seller_s_k_u(self, sellerSKU, **kwargs) -> ApiResponse: + def get_small_and_light_enrollment_by_seller_s_k_u( + self, sellerSKU, **kwargs + ) -> ApiResponse: return self.get_small_and_light_enrollment_by_seller_sku(sellerSKU, **kwargs) - @sp_endpoint('/fba/smallAndLight/v1/enrollments/{}', method='GET') - def get_small_and_light_enrollment_by_seller_sku(self, seller_sku, **kwargs) -> ApiResponse: + @sp_endpoint("/fba/smallAndLight/v1/enrollments/{}", method="GET") + def get_small_and_light_enrollment_by_seller_sku( + self, seller_sku, **kwargs + ) -> ApiResponse: """ get_small_and_light_enrollment_by_seller_s_k_u(self, sellerSKU, **kwargs) -> ApiResponse @@ -40,14 +44,20 @@ def get_small_and_light_enrollment_by_seller_sku(self, seller_sku, **kwargs) -> ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), seller_sku), params=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), seller_sku), params=kwargs + ) @deprecated - def put_small_and_light_enrollment_by_seller_s_k_u(self, sellerSKU, **kwargs) -> ApiResponse: + def put_small_and_light_enrollment_by_seller_s_k_u( + self, sellerSKU, **kwargs + ) -> ApiResponse: return self.put_small_and_light_enrollment_by_seller_sku(sellerSKU, **kwargs) - @sp_endpoint('/fba/smallAndLight/v1/enrollments/{}', method='PUT') - def put_small_and_light_enrollment_by_seller_sku(self, seller_sku, **kwargs) -> ApiResponse: + @sp_endpoint("/fba/smallAndLight/v1/enrollments/{}", method="PUT") + def put_small_and_light_enrollment_by_seller_sku( + self, seller_sku, **kwargs + ) -> ApiResponse: """ put_small_and_light_enrollment_by_seller_s_k_u(self, sellerSKU, **kwargs) -> ApiResponse @@ -72,15 +82,23 @@ def put_small_and_light_enrollment_by_seller_sku(self, seller_sku, **kwargs) -> ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), seller_sku), - params={'marketplaceIds': kwargs.get('marketplaceIds', self.marketplace_id)}) + return self._request( + fill_query_params(kwargs.pop("path"), seller_sku), + params={ + "marketplaceIds": kwargs.get("marketplaceIds", self.marketplace_id) + }, + ) @deprecated - def delete_small_and_light_enrollment_by_seller_s_k_u(self, sellerSKU, **kwargs) -> ApiResponse: + def delete_small_and_light_enrollment_by_seller_s_k_u( + self, sellerSKU, **kwargs + ) -> ApiResponse: return self.delete_small_and_light_enrollment_by_seller_sku(sellerSKU, **kwargs) - @sp_endpoint('/fba/smallAndLight/v1/enrollments/{}', method='DELETE') - def delete_small_and_light_enrollment_by_seller_sku(self, seller_sku, **kwargs) -> ApiResponse: + @sp_endpoint("/fba/smallAndLight/v1/enrollments/{}", method="DELETE") + def delete_small_and_light_enrollment_by_seller_sku( + self, seller_sku, **kwargs + ) -> ApiResponse: """ delete_small_and_light_enrollment_by_seller_s_k_u(self, sellerSKU, **kwargs) -> ApiResponse @@ -104,14 +122,20 @@ def delete_small_and_light_enrollment_by_seller_sku(self, seller_sku, **kwargs) ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), seller_sku), data=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), seller_sku), data=kwargs + ) @deprecated - def get_small_and_light_eligibility_by_seller_s_k_u(self, sellerSKU, **kwargs) -> ApiResponse: + def get_small_and_light_eligibility_by_seller_s_k_u( + self, sellerSKU, **kwargs + ) -> ApiResponse: return self.get_small_and_light_eligibility_by_seller_sku(sellerSKU, **kwargs) - @sp_endpoint('/fba/smallAndLight/v1/eligibilities/{}', method='GET') - def get_small_and_light_eligibility_by_seller_sku(self, seller_sku, **kwargs) -> ApiResponse: + @sp_endpoint("/fba/smallAndLight/v1/eligibilities/{}", method="GET") + def get_small_and_light_eligibility_by_seller_sku( + self, seller_sku, **kwargs + ) -> ApiResponse: """ get_small_and_light_eligibility_by_seller_s_k_u(self, sellerSKU, **kwargs) -> ApiResponse @@ -136,9 +160,11 @@ def get_small_and_light_eligibility_by_seller_sku(self, seller_sku, **kwargs) -> ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), seller_sku), params=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), seller_sku), params=kwargs + ) - @sp_endpoint('/fba/smallAndLight/v1/feePreviews', method='POST') + @sp_endpoint("/fba/smallAndLight/v1/feePreviews", method="POST") def get_small_and_light_fee_preview(self, **kwargs) -> ApiResponse: """ get_small_and_light_fee_preview(self, **kwargs) -> ApiResponse @@ -175,4 +201,4 @@ def get_small_and_light_fee_preview(self, **kwargs) -> ApiResponse: ApiResponse: """ - return self._request(kwargs.pop('path'), data=kwargs) + return self._request(kwargs.pop("path"), data=kwargs) diff --git a/sp_api/api/feeds/feeds.py b/sp_api/api/feeds/feeds.py index 876bc415d..1a37ea7c8 100644 --- a/sp_api/api/feeds/feeds.py +++ b/sp_api/api/feeds/feeds.py @@ -13,7 +13,7 @@ class Feeds(Client): The Selling Partner API for Feeds lets you upload data to Amazon on behalf of a selling partner. """ - @sp_endpoint('/feeds/2021-06-30/feeds', method='GET') + @sp_endpoint("/feeds/2021-06-30/feeds", method="GET") def get_feeds(self, **kwargs) -> ApiResponse: """ get_feeds(self, **kwargs) -> ApiResponse @@ -34,10 +34,14 @@ def get_feeds(self, **kwargs) -> ApiResponse: ApiResponse: """ - add_marketplace = not 'nextToken' in kwargs - return self._request(kwargs.pop('path'), params=kwargs, add_marketplace=add_marketplace) + add_marketplace = not "nextToken" in kwargs + return self._request( + kwargs.pop("path"), params=kwargs, add_marketplace=add_marketplace + ) - def submit_feed(self, feed_type, file, content_type='text/tsv', **kwargs) -> [ApiResponse, ApiResponse]: + def submit_feed( + self, feed_type, file, content_type="text/tsv", **kwargs + ) -> [ApiResponse, ApiResponse]: """ submit_feed(self, feed_type: str, file: File or File like, content_type='text/tsv', **kwargs) -> [ApiResponse, ApiResponse] Combines `create_feed_document` and `create_feed`, uploads the file and sends the feed to amazon. @@ -69,9 +73,11 @@ def submit_feed(self, feed_type, file, content_type='text/tsv', **kwargs) -> [Ap [ApiResponse:, ApiResponse:] """ document_response = self.create_feed_document(file, content_type) - return document_response, self.create_feed(feed_type, document_response.payload.get('feedDocumentId'), **kwargs) + return document_response, self.create_feed( + feed_type, document_response.payload.get("feedDocumentId"), **kwargs + ) - @sp_endpoint('/feeds/2021-06-30/feeds', method='POST') + @sp_endpoint("/feeds/2021-06-30/feeds", method="POST") def create_feed(self, feed_type, input_feed_document_id, **kwargs) -> ApiResponse: """ create_feed(self, feed_type: str, input_feed_document_id: str, **kwargs) -> ApiResponse @@ -104,13 +110,13 @@ def create_feed(self, feed_type, input_feed_document_id, **kwargs) -> ApiRespons ApiResponse: """ data = { - 'feedType': feed_type, - 'inputFeedDocumentId': input_feed_document_id, - **kwargs + "feedType": feed_type, + "inputFeedDocumentId": input_feed_document_id, + **kwargs, } - return self._request(kwargs.pop('path'), data=data) + return self._request(kwargs.pop("path"), data=data) - @sp_endpoint('/feeds/2021-06-30/feeds/{}', method='DELETE') + @sp_endpoint("/feeds/2021-06-30/feeds/{}", method="DELETE") def cancel_feed(self, feedId, **kwargs) -> ApiResponse: """ cancel_feed(self, feedId, **kwargs) -> ApiResponse @@ -126,9 +132,9 @@ def cancel_feed(self, feedId, **kwargs) -> ApiResponse: ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), feedId), data=kwargs) + return self._request(fill_query_params(kwargs.pop("path"), feedId), data=kwargs) - @sp_endpoint('/feeds/2021-06-30/feeds/{}', method='GET') + @sp_endpoint("/feeds/2021-06-30/feeds/{}", method="GET") def get_feed(self, feedId, **kwargs) -> ApiResponse: """ get_feed(self, feedId, **kwargs) -> ApiResponse @@ -144,9 +150,13 @@ def get_feed(self, feedId, **kwargs) -> ApiResponse: ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), feedId), params=kwargs, add_marketplace=False) + return self._request( + fill_query_params(kwargs.pop("path"), feedId), + params=kwargs, + add_marketplace=False, + ) - @sp_endpoint('/feeds/2021-06-30/documents', method='POST') + @sp_endpoint("/feeds/2021-06-30/documents", method="POST") def create_feed_document(self, file, content_type, **kwargs) -> ApiResponse: """ create_feed_document(self, **kwargs) -> ApiResponse @@ -164,30 +174,31 @@ def create_feed_document(self, file, content_type, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - data = { - 'contentType': kwargs.get('contentType', content_type) - } - response = self._request(kwargs.get('path'), data={**data, **kwargs}) + data = {"contentType": kwargs.get("contentType", content_type)} + response = self._request(kwargs.get("path"), data={**data, **kwargs}) - if(file is None): + if file is None: return response upload_data = file.read() try: - upload_data = upload_data.encode('iso-8859-1') + upload_data = upload_data.encode("iso-8859-1") except AttributeError: pass upload = requests.put( - response.payload.get('url'), + response.payload.get("url"), data=upload_data, - headers={'Content-Type': content_type} + headers={"Content-Type": content_type}, ) if 200 <= upload.status_code < 300: return response from sp_api.base.exceptions import SellingApiException - raise SellingApiException(headers=upload.headers, error=upload.json().get('errors')) - @sp_endpoint('/feeds/2021-06-30/documents/{}', method='GET') + raise SellingApiException( + headers=upload.headers, error=upload.json().get("errors") + ) + + @sp_endpoint("/feeds/2021-06-30/documents/{}", method="GET") def get_feed_document(self, feedDocumentId, **kwargs) -> str: """ get_feed_document(self, feedDocumentId, **kwargs) -> ApiResponse @@ -207,7 +218,7 @@ def get_feed_document(self, feedDocumentId, **kwargs) -> str: return self.get_feed_result_document(feedDocumentId) - @sp_endpoint('/feeds/2021-06-30/documents/{}', method='GET') + @sp_endpoint("/feeds/2021-06-30/documents/{}", method="GET") def get_feed_result_document(self, feedDocumentId, **kwargs) -> str: """ get_feed_result_document(self, feedDocumentId, **kwargs) -> str @@ -223,17 +234,24 @@ def get_feed_result_document(self, feedDocumentId, **kwargs) -> str: Returns: str: """ - response = self._request(fill_query_params(kwargs.pop('path'), feedDocumentId), params=kwargs, - add_marketplace=False) - url = response.payload.get('url') + response = self._request( + fill_query_params(kwargs.pop("path"), feedDocumentId), + params=kwargs, + add_marketplace=False, + ) + url = response.payload.get("url") doc_response = requests.get(url) - encoding = doc_response.encoding if doc_response and doc_response.encoding else 'iso-8859-1' - if encoding.lower() == 'windows-31j': - encoding = 'cp932' + encoding = ( + doc_response.encoding + if doc_response and doc_response.encoding + else "iso-8859-1" + ) + if encoding.lower() == "windows-31j": + encoding = "cp932" content = doc_response.content - if 'compressionAlgorithm' in response.payload: + if "compressionAlgorithm" in response.payload: try: return zlib.decompress(bytearray(content), 15 + 32).decode(encoding) except Exception: diff --git a/sp_api/api/finances/finances.py b/sp_api/api/finances/finances.py index d40e6c0ab..f1631e0ae 100644 --- a/sp_api/api/finances/finances.py +++ b/sp_api/api/finances/finances.py @@ -4,7 +4,7 @@ class Finances(Client): - @sp_endpoint('/finances/v0/orders/{}/financialEvents') + @sp_endpoint("/finances/v0/orders/{}/financialEvents") def get_financial_events_for_order(self, order_id, **kwargs) -> ApiResponse: """ get_financial_events_for_order(self, order_id, **kwargs) -> ApiResponse @@ -21,9 +21,11 @@ def get_financial_events_for_order(self, order_id, **kwargs) -> ApiResponse: Returns: """ - return self._request(fill_query_params(kwargs.pop('path'), order_id), params={**kwargs}) + return self._request( + fill_query_params(kwargs.pop("path"), order_id), params={**kwargs} + ) - @sp_endpoint('/finances/v0/financialEvents') + @sp_endpoint("/finances/v0/financialEvents") def list_financial_events(self, **kwargs) -> ApiResponse: """ list_financial_events(self, **kwargs) -> ApiResponse: @@ -35,10 +37,12 @@ def list_financial_events(self, **kwargs) -> ApiResponse: Returns: """ - return self._request(fill_query_params(kwargs.pop('path')), params={**kwargs}) + return self._request(fill_query_params(kwargs.pop("path")), params={**kwargs}) - @sp_endpoint('/finances/v0/financialEventGroups/{}/financialEvents') - def list_financial_events_by_group_id(self, event_group_id, **kwargs) -> ApiResponse: + @sp_endpoint("/finances/v0/financialEventGroups/{}/financialEvents") + def list_financial_events_by_group_id( + self, event_group_id, **kwargs + ) -> ApiResponse: """ list_financial_events_by_groupid(self, event_group_id, **kwargs) -> ApiResponse: @@ -50,9 +54,11 @@ def list_financial_events_by_group_id(self, event_group_id, **kwargs) -> ApiRes Returns: """ - return self._request(fill_query_params(kwargs.pop('path'), event_group_id), params={**kwargs}) + return self._request( + fill_query_params(kwargs.pop("path"), event_group_id), params={**kwargs} + ) - @sp_endpoint('/finances/v0/financialEventGroups') + @sp_endpoint("/finances/v0/financialEventGroups") def list_financial_event_groups(self, **kwargs) -> ApiResponse: """ list_financial_event_groups(self, **kwargs) -> ApiResponse: @@ -64,5 +70,4 @@ def list_financial_event_groups(self, **kwargs) -> ApiResponse: Returns: """ - return self._request(kwargs.pop('path'), params={**kwargs}) - + return self._request(kwargs.pop("path"), params={**kwargs}) diff --git a/sp_api/api/fulfillment_inbound/fulfillment_inbound.py b/sp_api/api/fulfillment_inbound/fulfillment_inbound.py index b36452b9e..c048dc9ea 100644 --- a/sp_api/api/fulfillment_inbound/fulfillment_inbound.py +++ b/sp_api/api/fulfillment_inbound/fulfillment_inbound.py @@ -19,12 +19,13 @@ class FulfillmentInbound(Client): The Selling Partner API for Fulfillment By Amazon (FBA) Inbound. The FBA Inbound API enables building inbound workflows to create, manage, and send shipments into Amazon's fulfillment network. The API has interoperability with the Send-to-Amazon user interface. """ + version: FulfillmentInboundVersion = FulfillmentInboundVersion.V_v0 def __init__(self, *args, **kwargs): - if 'version' in kwargs: - self.version = kwargs.get('version', FulfillmentInboundVersion.V_v0) - super().__init__(*args, **{**kwargs, 'version': self.version}) + if "version" in kwargs: + self.version = kwargs.get("version", FulfillmentInboundVersion.V_v0) + super().__init__(*args, **{**kwargs, "version": self.version}) @sp_endpoint("/fba/inbound//itemsGuidance") def item_guidance(self, **kwargs): @@ -314,7 +315,9 @@ def void_transport(self, shipment_id, **kwargs): add_marketplace=False, ) - @sp_endpoint("/fba/inbound//shipments/{}/transport/estimate", method="POST") + @sp_endpoint( + "/fba/inbound//shipments/{}/transport/estimate", method="POST" + ) def estimate_transport(self, shipment_id, **kwargs): """ estimate_transport(self, shipment_id, **kwargs) -> ApiResponse @@ -454,1180 +457,1310 @@ def get_shipments_by_id(self, shipment_id_list, **kwargs) -> ApiResponse: ApiResponse """ if not isinstance(shipment_id_list, str): - shipment_id_list = ','.join(shipment_id_list) - return self.get_shipments(QueryType='SHIPMENT', ShipmentIdList=shipment_id_list, **kwargs) + shipment_id_list = ",".join(shipment_id_list) + return self.get_shipments( + QueryType="SHIPMENT", ShipmentIdList=shipment_id_list, **kwargs + ) # 2024-03-20 API - @sp_endpoint('/inbound/fba//inboundPlans', method='GET') + @sp_endpoint("/inbound/fba//inboundPlans", method="GET") def list_inbound_plans(self, **kwargs) -> ApiResponse: """ - list_inbound_plans(self, **kwargs) -> ApiResponse + list_inbound_plans(self, **kwargs) -> ApiResponse - Provides a list of inbound plans with minimal information. + Provides a list of inbound plans with minimal information. - **Usage Plan:** + **Usage Plan:** - | Rate (requests per second) | Burst | - | ---- | ---- | - | 1 | 1 | + | Rate (requests per second) | Burst | + | ---- | ---- | + | 1 | 1 | - The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). + The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). - Args: + Args: - key pageSize:integer | The number of inbound plans to return in the response matching the given query. + key pageSize:integer | The number of inbound plans to return in the response matching the given query. - key paginationToken:string | A token to fetch a certain page when there are multiple pages worth of results. The value of this token is fetched from the `pagination` returned in the API response. In the absence of the token value from the query parameter the API returns the first page of the result. + key paginationToken:string | A token to fetch a certain page when there are multiple pages worth of results. The value of this token is fetched from the `pagination` returned in the API response. In the absence of the token value from the query parameter the API returns the first page of the result. - key status:string | The status of an inbound plan. + key status:string | The status of an inbound plan. - key sortBy:string | Sort by field. + key sortBy:string | Sort by field. - key sortOrder:string | The sort order. + key sortOrder:string | The sort order. - Returns: - ApiResponse: - """ + Returns: + ApiResponse: + """ - return self._request(kwargs.pop('path'), params=kwargs) + return self._request(kwargs.pop("path"), params=kwargs) - @sp_endpoint('/inbound/fba//inboundPlans', method='POST') + @sp_endpoint("/inbound/fba//inboundPlans", method="POST") def create_inbound_plan(self, **kwargs) -> ApiResponse: """ - create_inbound_plan(self, **kwargs) -> ApiResponse + create_inbound_plan(self, **kwargs) -> ApiResponse - Creates an inbound plan. An inbound plan contains all the necessary information to send shipments into Amazon's fufillment network. + Creates an inbound plan. An inbound plan contains all the necessary information to send shipments into Amazon's fufillment network. -**Usage Plan:** + **Usage Plan:** -| Rate (requests per second) | Burst | -| ---- | ---- | -| 0.05 | 1 | + | Rate (requests per second) | Burst | + | ---- | ---- | + | 0.05 | 1 | -The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). + The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). - Args: + Args: - body: | * REQUIRED {'description': 'The `createInboundPlan` request.', - 'example': {'contactInformation': {'email': 'email@email.com', 'phoneNumber': '1234567890'}, - 'destinationMarketplaces': ['ATVPDKIKX0DER'], - 'items': [{'expiration': '2024-01-01', 'labelOwner': 'AMAZON', 'manufacturingLotCode': 'manufacturingLotCode', 'msku': 'Sunglasses', 'prepOwner': 'AMAZON', 'quantity': 10}], - 'name': 'My inbound plan', - 'sourceAddress': {'addressLine1': '123 example street', 'addressLine2': 'Floor 19', 'city': 'Toronto', 'companyName': 'Acme', 'countryCode': 'CA', 'name': 'name', 'postalCode': 'M1M1M1', 'stateOrProvinceCode': 'ON'}}, - 'properties': {'contactInformation': {'$ref': '#/definitions/ContactInformation'}, - 'destinationMarketplaces': {'description': 'Marketplaces where the items need to be shipped to. Currently only one marketplace can be selected in this request.', - 'items': {'description': 'The Marketplace ID. Refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids) for a list of possible values.', - 'maxLength': 256, - 'minLength': 1, - 'type': 'string'}, - 'maxItems': 1, - 'minItems': 1, - 'type': 'array'}, - 'items': {'description': 'Items included in this plan.', 'items': {'$ref': '#/definitions/ItemInput'}, 'maxItems': 2000, 'minItems': 1, 'type': 'array'}, - 'name': {'description': "Name for the Inbound Plan. If one isn't provided, a default name will be provided.", 'maxLength': 40, 'minLength': 1, 'type': 'string'}, - 'sourceAddress': {'$ref': '#/definitions/Address'}}, - 'required': ['contactInformation', 'destinationMarketplaces', 'items', 'sourceAddress'], - 'type': 'object'} + body: | * REQUIRED {'description': 'The `createInboundPlan` request.', + 'example': {'contactInformation': {'email': 'email@email.com', 'phoneNumber': '1234567890'}, + 'destinationMarketplaces': ['ATVPDKIKX0DER'], + 'items': [{'expiration': '2024-01-01', 'labelOwner': 'AMAZON', 'manufacturingLotCode': 'manufacturingLotCode', 'msku': 'Sunglasses', 'prepOwner': 'AMAZON', 'quantity': 10}], + 'name': 'My inbound plan', + 'sourceAddress': {'addressLine1': '123 example street', 'addressLine2': 'Floor 19', 'city': 'Toronto', 'companyName': 'Acme', 'countryCode': 'CA', 'name': 'name', 'postalCode': 'M1M1M1', 'stateOrProvinceCode': 'ON'}}, + 'properties': {'contactInformation': {'$ref': '#/definitions/ContactInformation'}, + 'destinationMarketplaces': {'description': 'Marketplaces where the items need to be shipped to. Currently only one marketplace can be selected in this request.', + 'items': {'description': 'The Marketplace ID. Refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids) for a list of possible values.', + 'maxLength': 256, + 'minLength': 1, + 'type': 'string'}, + 'maxItems': 1, + 'minItems': 1, + 'type': 'array'}, + 'items': {'description': 'Items included in this plan.', 'items': {'$ref': '#/definitions/ItemInput'}, 'maxItems': 2000, 'minItems': 1, 'type': 'array'}, + 'name': {'description': "Name for the Inbound Plan. If one isn't provided, a default name will be provided.", 'maxLength': 40, 'minLength': 1, 'type': 'string'}, + 'sourceAddress': {'$ref': '#/definitions/Address'}}, + 'required': ['contactInformation', 'destinationMarketplaces', 'items', 'sourceAddress'], + 'type': 'object'} - Returns: - ApiResponse: + Returns: + ApiResponse: """ - return self._request(kwargs.pop('path'), data=kwargs) + return self._request(kwargs.pop("path"), data=kwargs) - @sp_endpoint('/inbound/fba//inboundPlans/{}', method='GET') + @sp_endpoint("/inbound/fba//inboundPlans/{}", method="GET") def get_inbound_plan(self, inboundPlanId, **kwargs) -> ApiResponse: """ - get_inbound_plan(self, inboundPlanId, **kwargs) -> ApiResponse + get_inbound_plan(self, inboundPlanId, **kwargs) -> ApiResponse - Fetches the top level information about an inbound plan. + Fetches the top level information about an inbound plan. -**Usage Plan:** + **Usage Plan:** -| Rate (requests per second) | Burst | -| ---- | ---- | -| 1 | 1 | + | Rate (requests per second) | Burst | + | ---- | ---- | + | 1 | 1 | -The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). + The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). - Args: + Args: - inboundPlanId:string | * REQUIRED Identifier to an inbound plan. + inboundPlanId:string | * REQUIRED Identifier to an inbound plan. - Returns: - ApiResponse: + Returns: + ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), inboundPlanId), params=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), inboundPlanId), params=kwargs + ) - @sp_endpoint('/inbound/fba//inboundPlans/{}/boxes', method='GET') + @sp_endpoint("/inbound/fba//inboundPlans/{}/boxes", method="GET") def list_inbound_plan_boxes(self, inboundPlanId, **kwargs) -> ApiResponse: """ - list_inbound_plan_boxes(self, inboundPlanId, **kwargs) -> ApiResponse + list_inbound_plan_boxes(self, inboundPlanId, **kwargs) -> ApiResponse - Provides a paginated list of box packages in an inbound plan. + Provides a paginated list of box packages in an inbound plan. -**Usage Plan:** + **Usage Plan:** -| Rate (requests per second) | Burst | -| ---- | ---- | -| 1 | 1 | + | Rate (requests per second) | Burst | + | ---- | ---- | + | 1 | 1 | -The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). + The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). - Args: + Args: - inboundPlanId:string | * REQUIRED Identifier to an inbound plan. + inboundPlanId:string | * REQUIRED Identifier to an inbound plan. - key pageSize:integer | The number of boxes to return in the response matching the given query. + key pageSize:integer | The number of boxes to return in the response matching the given query. - key paginationToken:string | A token to fetch a certain page when there are multiple pages worth of results. The value of this token is fetched from the `pagination` returned in the API response. In the absence of the token value from the query parameter the API returns the first page of the result. + key paginationToken:string | A token to fetch a certain page when there are multiple pages worth of results. The value of this token is fetched from the `pagination` returned in the API response. In the absence of the token value from the query parameter the API returns the first page of the result. - Returns: - ApiResponse: + Returns: + ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), inboundPlanId), params=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), inboundPlanId), params=kwargs + ) - @sp_endpoint('/inbound/fba//inboundPlans/{}/cancellation', method='PUT') + @sp_endpoint("/inbound/fba//inboundPlans/{}/cancellation", method="PUT") def cancel_inbound_plan(self, inboundPlanId, **kwargs) -> ApiResponse: """ - cancel_inbound_plan(self, inboundPlanId, **kwargs) -> ApiResponse + cancel_inbound_plan(self, inboundPlanId, **kwargs) -> ApiResponse - Cancels an Inbound Plan. Charges may apply if the cancellation is performed outside of a void window. The window - for Amazon Partnered Carriers is 24 hours for Small Parcel Delivery (SPD) and one hour for Less-Than-Truckload (LTL) carrier shipments. + Cancels an Inbound Plan. Charges may apply if the cancellation is performed outside of a void window. The window + for Amazon Partnered Carriers is 24 hours for Small Parcel Delivery (SPD) and one hour for Less-Than-Truckload (LTL) carrier shipments. -**Usage Plan:** + **Usage Plan:** -| Rate (requests per second) | Burst | -| ---- | ---- | -| 0.05 | 1 | + | Rate (requests per second) | Burst | + | ---- | ---- | + | 0.05 | 1 | -The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). + The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). - Args: + Args: - inboundPlanId:string | * REQUIRED Identifier to an inbound plan. + inboundPlanId:string | * REQUIRED Identifier to an inbound plan. - Returns: - ApiResponse: + Returns: + ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), inboundPlanId), data=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), inboundPlanId), data=kwargs + ) - @sp_endpoint('/inbound/fba//inboundPlans/{}/items', method='GET') + @sp_endpoint("/inbound/fba//inboundPlans/{}/items", method="GET") def list_inbound_plan_items(self, inboundPlanId, **kwargs) -> ApiResponse: """ - list_inbound_plan_items(self, inboundPlanId, **kwargs) -> ApiResponse + list_inbound_plan_items(self, inboundPlanId, **kwargs) -> ApiResponse - Provides a paginated list of item packages in an inbound plan. + Provides a paginated list of item packages in an inbound plan. -**Usage Plan:** + **Usage Plan:** -| Rate (requests per second) | Burst | -| ---- | ---- | -| 1 | 1 | + | Rate (requests per second) | Burst | + | ---- | ---- | + | 1 | 1 | -The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). + The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). - Args: + Args: - inboundPlanId:string | * REQUIRED Identifier to an inbound plan. + inboundPlanId:string | * REQUIRED Identifier to an inbound plan. - key pageSize:integer | The number of items to return in the response matching the given query. + key pageSize:integer | The number of items to return in the response matching the given query. - key paginationToken:string | A token to fetch a certain page when there are multiple pages worth of results. The value of this token is fetched from the `pagination` returned in the API response. In the absence of the token value from the query parameter the API returns the first page of the result. + key paginationToken:string | A token to fetch a certain page when there are multiple pages worth of results. The value of this token is fetched from the `pagination` returned in the API response. In the absence of the token value from the query parameter the API returns the first page of the result. - Returns: - ApiResponse: + Returns: + ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), inboundPlanId), params=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), inboundPlanId), params=kwargs + ) - @sp_endpoint('/inbound/fba//inboundPlans/{}/packingInformation', method='POST') + @sp_endpoint( + "/inbound/fba//inboundPlans/{}/packingInformation", method="POST" + ) def set_packing_information(self, inboundPlanId, **kwargs) -> ApiResponse: """ - set_packing_information(self, inboundPlanId, **kwargs) -> ApiResponse + set_packing_information(self, inboundPlanId, **kwargs) -> ApiResponse - Sets packing information for an inbound plan. This should be called after an inbound plan is created to populate - the box level information required for planning and transportation estimates. + Sets packing information for an inbound plan. This should be called after an inbound plan is created to populate + the box level information required for planning and transportation estimates. -**Usage Plan:** + **Usage Plan:** -| Rate (requests per second) | Burst | -| ---- | ---- | -| 0.05 | 1 | + | Rate (requests per second) | Burst | + | ---- | ---- | + | 0.05 | 1 | -The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). + The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). - Args: + Args: - inboundPlanId:string | * REQUIRED Identifier to an inbound plan. + inboundPlanId:string | * REQUIRED Identifier to an inbound plan. - body: | * REQUIRED {'description': '`setPackingInformation` request.', - 'example': {'packageGroupings': [{'boxes': [{'boxId': 'boxId', - 'contentInformationSource': 'BOX_CONTENT_PROVIDED', - 'contents': [{'expiration': '2024-01-01', 'labelOwner': 'AMAZON', 'manufacturingLotCode': 'manufacturingLotCode', 'msku': 'Sunglasses', 'prepOwner': 'AMAZON', 'quantityInBox': 10}], - 'dimensions': {'height': 5, 'length': 3, 'unitOfMeasurement': 'CM', 'width': 4}, - 'quantity': 2, - 'templateName': 'templateName', - 'weight': {'unit': 'KG', 'value': 5.5}}], - 'packingGroupId': 'pg1234abcd-1234-abcd-5678-1234abcd5678', - 'shipmentId': 'sh1234abcd-1234-abcd-5678-1234abcd5678'}]}, - 'properties': {'packageGroupings': {'description': 'List of packing information for the inbound plan.', 'items': {'$ref': '#/definitions/PackageGroupingInput'}, 'type': 'array'}}, - 'type': 'object'} + body: | * REQUIRED {'description': '`setPackingInformation` request.', + 'example': {'packageGroupings': [{'boxes': [{'boxId': 'boxId', + 'contentInformationSource': 'BOX_CONTENT_PROVIDED', + 'contents': [{'expiration': '2024-01-01', 'labelOwner': 'AMAZON', 'manufacturingLotCode': 'manufacturingLotCode', 'msku': 'Sunglasses', 'prepOwner': 'AMAZON', 'quantityInBox': 10}], + 'dimensions': {'height': 5, 'length': 3, 'unitOfMeasurement': 'CM', 'width': 4}, + 'quantity': 2, + 'templateName': 'templateName', + 'weight': {'unit': 'KG', 'value': 5.5}}], + 'packingGroupId': 'pg1234abcd-1234-abcd-5678-1234abcd5678', + 'shipmentId': 'sh1234abcd-1234-abcd-5678-1234abcd5678'}]}, + 'properties': {'packageGroupings': {'description': 'List of packing information for the inbound plan.', 'items': {'$ref': '#/definitions/PackageGroupingInput'}, 'type': 'array'}}, + 'type': 'object'} - Returns: - ApiResponse: + Returns: + ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), inboundPlanId), data=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), inboundPlanId), data=kwargs + ) - @sp_endpoint('/inbound/fba//inboundPlans/{}/packingOptions', method='GET') + @sp_endpoint("/inbound/fba//inboundPlans/{}/packingOptions", method="GET") def list_packing_options(self, inboundPlanId, **kwargs) -> ApiResponse: """ - list_packing_options(self, inboundPlanId, **kwargs) -> ApiResponse + list_packing_options(self, inboundPlanId, **kwargs) -> ApiResponse - Retrieves a list of all packing options for an inbound plan. Packing options must first be generated by the corresponding endpoint before becoming available. + Retrieves a list of all packing options for an inbound plan. Packing options must first be generated by the corresponding endpoint before becoming available. -**Usage Plan:** + **Usage Plan:** -| Rate (requests per second) | Burst | -| ---- | ---- | -| 1 | 1 | + | Rate (requests per second) | Burst | + | ---- | ---- | + | 1 | 1 | -The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). + The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). - Args: + Args: - inboundPlanId:string | * REQUIRED Identifier to an inbound plan. + inboundPlanId:string | * REQUIRED Identifier to an inbound plan. - key pageSize:integer | The number of packing options to return in the response matching the given query. + key pageSize:integer | The number of packing options to return in the response matching the given query. - key paginationToken:string | A token to fetch a certain page when there are multiple pages worth of results. The value of this token is fetched from the `pagination` returned in the API response. In the absence of the token value from the query parameter the API returns the first page of the result. + key paginationToken:string | A token to fetch a certain page when there are multiple pages worth of results. The value of this token is fetched from the `pagination` returned in the API response. In the absence of the token value from the query parameter the API returns the first page of the result. - Returns: - ApiResponse: + Returns: + ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), inboundPlanId), params=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), inboundPlanId), params=kwargs + ) - @sp_endpoint('/inbound/fba//inboundPlans/{}/packingOptions', method='POST') + @sp_endpoint("/inbound/fba//inboundPlans/{}/packingOptions", method="POST") def generate_packing_options(self, inboundPlanId, **kwargs) -> ApiResponse: """ - generate_packing_options(self, inboundPlanId, **kwargs) -> ApiResponse + generate_packing_options(self, inboundPlanId, **kwargs) -> ApiResponse - Generates available packing options for the inbound plan. + Generates available packing options for the inbound plan. -**Usage Plan:** + **Usage Plan:** -| Rate (requests per second) | Burst | -| ---- | ---- | -| 0.05 | 1 | + | Rate (requests per second) | Burst | + | ---- | ---- | + | 0.05 | 1 | -The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). + The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). - Args: + Args: - inboundPlanId:string | * REQUIRED Identifier to an inbound plan. + inboundPlanId:string | * REQUIRED Identifier to an inbound plan. - Returns: - ApiResponse: + Returns: + ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), inboundPlanId), data=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), inboundPlanId), data=kwargs + ) - @sp_endpoint('/inbound/fba//inboundPlans/{}/packingOptions/{}/confirmation', method='POST') - def confirm_packing_option(self, inboundPlanId, packingOptionId, **kwargs) -> ApiResponse: + @sp_endpoint( + "/inbound/fba//inboundPlans/{}/packingOptions/{}/confirmation", + method="POST", + ) + def confirm_packing_option( + self, inboundPlanId, packingOptionId, **kwargs + ) -> ApiResponse: """ - confirm_packing_option(self, inboundPlanId, **kwargs) -> ApiResponse + confirm_packing_option(self, inboundPlanId, **kwargs) -> ApiResponse - Confirms the packing option for an inbound plan. + Confirms the packing option for an inbound plan. -**Usage Plan:** + **Usage Plan:** -| Rate (requests per second) | Burst | -| ---- | ---- | -| 0.05 | 1 | + | Rate (requests per second) | Burst | + | ---- | ---- | + | 0.05 | 1 | -The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). + The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). - Args: + Args: - inboundPlanId:string | * REQUIRED Identifier to an inbound plan. + inboundPlanId:string | * REQUIRED Identifier to an inbound plan. - packingOptionId:string | * REQUIRED Identifier to a packing option. + packingOptionId:string | * REQUIRED Identifier to a packing option. - Returns: - ApiResponse: + Returns: + ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), inboundPlanId, packingOptionId), data=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), inboundPlanId, packingOptionId), + data=kwargs, + ) - @sp_endpoint('/inbound/fba//inboundPlans/{}/items', method='GET') + @sp_endpoint("/inbound/fba//inboundPlans/{}/items", method="GET") def list_packing_group_items(self, inboundPlanId, **kwargs) -> ApiResponse: """ - list_packing_group_items(self, inboundPlanId, **kwargs) -> ApiResponse + list_packing_group_items(self, inboundPlanId, **kwargs) -> ApiResponse - Retrieves a list of all items in a packing options's packing group. Packing options must first be generated by the corresponding endpoint before packing group items can be listed. + Retrieves a list of all items in a packing options's packing group. Packing options must first be generated by the corresponding endpoint before packing group items can be listed. -**Usage Plan:** + **Usage Plan:** -| Rate (requests per second) | Burst | -| ---- | ---- | -| 1 | 1 | + | Rate (requests per second) | Burst | + | ---- | ---- | + | 1 | 1 | -The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). + The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). - Args: + Args: - inboundPlanId:string | * REQUIRED Identifier to an inbound plan. + inboundPlanId:string | * REQUIRED Identifier to an inbound plan. - packingOptionId:string | * REQUIRED Identifier to a packing option. + packingOptionId:string | * REQUIRED Identifier to a packing option. - packingGroupId:string | * REQUIRED Identifier to a packing group. + packingGroupId:string | * REQUIRED Identifier to a packing group. - key pageSize:integer | The number of packing group items to return in the response matching the given query. + key pageSize:integer | The number of packing group items to return in the response matching the given query. - key paginationToken:string | A token to fetch a certain page when there are multiple pages worth of results. The value of this token is fetched from the `pagination` returned in the API response. In the absence of the token value from the query parameter the API returns the first page of the result. + key paginationToken:string | A token to fetch a certain page when there are multiple pages worth of results. The value of this token is fetched from the `pagination` returned in the API response. In the absence of the token value from the query parameter the API returns the first page of the result. - Returns: - ApiResponse: + Returns: + ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), inboundPlanId), params=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), inboundPlanId), params=kwargs + ) - @sp_endpoint('/inbound/fba//inboundPlans/{}/pallets', method='GET') + @sp_endpoint("/inbound/fba//inboundPlans/{}/pallets", method="GET") def list_inbound_plan_pallets(self, inboundPlanId, **kwargs) -> ApiResponse: """ - list_inbound_plan_pallets(self, inboundPlanId, **kwargs) -> ApiResponse + list_inbound_plan_pallets(self, inboundPlanId, **kwargs) -> ApiResponse - Provides a paginated list of pallet packages in an inbound plan. An inbound plan will have pallets when the related details are provided after generating Less-Than-Truckload (LTL) carrier shipments. + Provides a paginated list of pallet packages in an inbound plan. An inbound plan will have pallets when the related details are provided after generating Less-Than-Truckload (LTL) carrier shipments. -**Usage Plan:** + **Usage Plan:** -| Rate (requests per second) | Burst | -| ---- | ---- | -| 1 | 1 | + | Rate (requests per second) | Burst | + | ---- | ---- | + | 1 | 1 | -The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). + The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). - Args: + Args: - inboundPlanId:string | * REQUIRED Identifier to an inbound plan. + inboundPlanId:string | * REQUIRED Identifier to an inbound plan. - key pageSize:integer | The number of pallets to return in the response matching the given query. + key pageSize:integer | The number of pallets to return in the response matching the given query. - key paginationToken:string | A token to fetch a certain page when there are multiple pages worth of results. The value of this token is fetched from the `pagination` returned in the API response. In the absence of the token value from the query parameter the API returns the first page of the result. + key paginationToken:string | A token to fetch a certain page when there are multiple pages worth of results. The value of this token is fetched from the `pagination` returned in the API response. In the absence of the token value from the query parameter the API returns the first page of the result. - Returns: - ApiResponse: + Returns: + ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), inboundPlanId), params=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), inboundPlanId), params=kwargs + ) - @sp_endpoint('/inbound/fba//inboundPlans/{}/placementOptions', method='GET') + @sp_endpoint( + "/inbound/fba//inboundPlans/{}/placementOptions", method="GET" + ) def list_placement_options(self, inboundPlanId, **kwargs) -> ApiResponse: """ - list_placement_options(self, inboundPlanId, **kwargs) -> ApiResponse + list_placement_options(self, inboundPlanId, **kwargs) -> ApiResponse - Provides a list of all placement options for an inbound plan. Placement options must first be generated by the corresponding endpoint before becoming available. + Provides a list of all placement options for an inbound plan. Placement options must first be generated by the corresponding endpoint before becoming available. -**Usage Plan:** + **Usage Plan:** -| Rate (requests per second) | Burst | -| ---- | ---- | -| 1 | 1 | + | Rate (requests per second) | Burst | + | ---- | ---- | + | 1 | 1 | -The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). + The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). - Args: + Args: - inboundPlanId:string | * REQUIRED Identifier to an inbound plan. + inboundPlanId:string | * REQUIRED Identifier to an inbound plan. - key pageSize:integer | The number of placement options to return in the response matching the given query. + key pageSize:integer | The number of placement options to return in the response matching the given query. - key paginationToken:string | A token to fetch a certain page when there are multiple pages worth of results. The value of this token is fetched from the `pagination` returned in the API response. In the absence of the token value from the query parameter the API returns the first page of the result. + key paginationToken:string | A token to fetch a certain page when there are multiple pages worth of results. The value of this token is fetched from the `pagination` returned in the API response. In the absence of the token value from the query parameter the API returns the first page of the result. - Returns: - ApiResponse: + Returns: + ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), inboundPlanId), params=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), inboundPlanId), params=kwargs + ) - @sp_endpoint('/inbound/fba//inboundPlans/{}/placementOptions', method='POST') + @sp_endpoint( + "/inbound/fba//inboundPlans/{}/placementOptions", method="POST" + ) def generate_placement_options(self, inboundPlanId, **kwargs) -> ApiResponse: """ - generate_placement_options(self, inboundPlanId, **kwargs) -> ApiResponse + generate_placement_options(self, inboundPlanId, **kwargs) -> ApiResponse - Generates placement options for the inbound plan. + Generates placement options for the inbound plan. -**Usage Plan:** + **Usage Plan:** -| Rate (requests per second) | Burst | -| ---- | ---- | -| 0.05 | 1 | + | Rate (requests per second) | Burst | + | ---- | ---- | + | 0.05 | 1 | -The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). + The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). - Args: + Args: - inboundPlanId:string | * REQUIRED Identifier to an inbound plan. + inboundPlanId:string | * REQUIRED Identifier to an inbound plan. - body: | * REQUIRED {'description': 'The `generatePlacementOptions` request.', - 'example': {'customPlacement': [{'items': [{'expiration': '2024-01-01', 'labelOwner': 'AMAZON', 'manufacturingLotCode': 'manufacturingLotCode', 'msku': 'Sunglasses', 'prepOwner': 'AMAZON', 'quantity': 10}], 'warehouseId': 'YYZ14'}]}, - 'properties': {'customPlacement': {'description': 'Custom placements options to be added to the plan.', 'items': {'$ref': '#/definitions/CustomPlacementInput'}, 'type': 'array'}}, - 'type': 'object'} + body: | * REQUIRED {'description': 'The `generatePlacementOptions` request.', + 'example': {'customPlacement': [{'items': [{'expiration': '2024-01-01', 'labelOwner': 'AMAZON', 'manufacturingLotCode': 'manufacturingLotCode', 'msku': 'Sunglasses', 'prepOwner': 'AMAZON', 'quantity': 10}], 'warehouseId': 'YYZ14'}]}, + 'properties': {'customPlacement': {'description': 'Custom placements options to be added to the plan.', 'items': {'$ref': '#/definitions/CustomPlacementInput'}, 'type': 'array'}}, + 'type': 'object'} - Returns: - ApiResponse: + Returns: + ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), inboundPlanId), data=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), inboundPlanId), data=kwargs + ) - @sp_endpoint('/inbound/fba//inboundPlans/{}/placementOptions/{}/confirmation', method='POST') - def confirm_placement_option(self, inboundPlanId, placementOptionId, **kwargs) -> ApiResponse: + @sp_endpoint( + "/inbound/fba//inboundPlans/{}/placementOptions/{}/confirmation", + method="POST", + ) + def confirm_placement_option( + self, inboundPlanId, placementOptionId, **kwargs + ) -> ApiResponse: """ - confirm_placement_option(self, inboundPlanId, **kwargs) -> ApiResponse + confirm_placement_option(self, inboundPlanId, **kwargs) -> ApiResponse - Confirms the placement option for an inbound plan. Once confirmed, it cannot be changed for the Inbound Plan. + Confirms the placement option for an inbound plan. Once confirmed, it cannot be changed for the Inbound Plan. -**Usage Plan:** + **Usage Plan:** -| Rate (requests per second) | Burst | -| ---- | ---- | -| 0.05 | 1 | + | Rate (requests per second) | Burst | + | ---- | ---- | + | 0.05 | 1 | -The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). + The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). - Args: + Args: - inboundPlanId:string | * REQUIRED Identifier to an inbound plan. + inboundPlanId:string | * REQUIRED Identifier to an inbound plan. - placementOptionId:string | * REQUIRED Identifier to a placement option. A placement option represents the shipment splits and destinations of SKUs. + placementOptionId:string | * REQUIRED Identifier to a placement option. A placement option represents the shipment splits and destinations of SKUs. - Returns: - ApiResponse: + Returns: + ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), inboundPlanId, placementOptionId), data=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), inboundPlanId, placementOptionId), + data=kwargs, + ) - @sp_endpoint('/inbound/fba//inboundPlans/{}/shipments/{}', method='GET') + @sp_endpoint("/inbound/fba//inboundPlans/{}/shipments/{}", method="GET") def get_shipment(self, inboundPlanId, shipmentId, **kwargs) -> ApiResponse: """ - get_shipment(self, inboundPlanId, shipmentId, **kwargs) -> ApiResponse + get_shipment(self, inboundPlanId, shipmentId, **kwargs) -> ApiResponse - Provides the full details for a specific shipment within an inbound plan. The `transportationOptionId` inside `acceptedTransportationSelection` can be used to retrieve the transportation details for the shipment. + Provides the full details for a specific shipment within an inbound plan. The `transportationOptionId` inside `acceptedTransportationSelection` can be used to retrieve the transportation details for the shipment. -**Usage Plan:** + **Usage Plan:** -| Rate (requests per second) | Burst | -| ---- | ---- | -| 1 | 1 | + | Rate (requests per second) | Burst | + | ---- | ---- | + | 1 | 1 | -The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). + The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). - Args: + Args: - inboundPlanId:string | * REQUIRED Identifier to an inbound plan. + inboundPlanId:string | * REQUIRED Identifier to an inbound plan. - shipmentId:string | * REQUIRED Identifier to a shipment. A shipment contains the boxes and units being inbounded. + shipmentId:string | * REQUIRED Identifier to a shipment. A shipment contains the boxes and units being inbounded. - Returns: - ApiResponse: + Returns: + ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), inboundPlanId, shipmentId), params=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), inboundPlanId, shipmentId), + params=kwargs, + ) - @sp_endpoint('/inbound/fba//inboundPlans/{}/deliveryChallanDocument', method='GET') + @sp_endpoint( + "/inbound/fba//inboundPlans/{}/deliveryChallanDocument", method="GET" + ) def get_delivery_challan_document(self, inboundPlanId, **kwargs) -> ApiResponse: """ - get_delivery_challan_document(self, inboundPlanId, **kwargs) -> ApiResponse + get_delivery_challan_document(self, inboundPlanId, **kwargs) -> ApiResponse - Provide delivery challan document for PCP transportation in IN marketplace. + Provide delivery challan document for PCP transportation in IN marketplace. -**Usage Plan:** + **Usage Plan:** -| Rate (requests per second) | Burst | -| ---- | ---- | -| 1 | 1 | + | Rate (requests per second) | Burst | + | ---- | ---- | + | 1 | 1 | -The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). + The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). - Args: + Args: - inboundPlanId:string | * REQUIRED Identifier to an inbound plan. + inboundPlanId:string | * REQUIRED Identifier to an inbound plan. - shipmentId:string | * REQUIRED Identifier to a shipment. A shipment contains the boxes and units being inbounded. + shipmentId:string | * REQUIRED Identifier to a shipment. A shipment contains the boxes and units being inbounded. - Returns: - ApiResponse: + Returns: + ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), inboundPlanId), params=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), inboundPlanId), params=kwargs + ) - @sp_endpoint('/inbound/fba//inboundPlans/{}/deliveryWindow', method='POST') + @sp_endpoint("/inbound/fba//inboundPlans/{}/deliveryWindow", method="POST") def update_shipment_delivery_window(self, inboundPlanId, **kwargs) -> ApiResponse: """ - update_shipment_delivery_window(self, inboundPlanId, **kwargs) -> ApiResponse + update_shipment_delivery_window(self, inboundPlanId, **kwargs) -> ApiResponse - Update the time window that a shipment will be delivered to the warehouse. The window is used to provide the expected time that a non-Amazon partnered carrier will arrive at the warehouse. + Update the time window that a shipment will be delivered to the warehouse. The window is used to provide the expected time that a non-Amazon partnered carrier will arrive at the warehouse. -**Usage Plan:** + **Usage Plan:** -| Rate (requests per second) | Burst | -| ---- | ---- | -| 1 | 1 | + | Rate (requests per second) | Burst | + | ---- | ---- | + | 1 | 1 | -The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). + The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). - Args: + Args: - inboundPlanId:string | * REQUIRED Identifier to an inbound plan. + inboundPlanId:string | * REQUIRED Identifier to an inbound plan. - shipmentId:string | * REQUIRED Identifier to a shipment. A shipment contains the boxes and units being inbounded. + shipmentId:string | * REQUIRED Identifier to a shipment. A shipment contains the boxes and units being inbounded. - body: | * REQUIRED {'description': 'The `updateShipmentDeliveryWindow` request.', - 'example': {'deliveryWindow': {'start': '2024-01-01T00:00Z'}}, - 'properties': {'deliveryWindow': {'$ref': '#/definitions/WindowInput', 'description': 'The range of dates within which the seller expects that their shipment will be delivered to Amazon.\n'}}, - 'required': ['deliveryWindow'], - 'type': 'object'} + body: | * REQUIRED {'description': 'The `updateShipmentDeliveryWindow` request.', + 'example': {'deliveryWindow': {'start': '2024-01-01T00:00Z'}}, + 'properties': {'deliveryWindow': {'$ref': '#/definitions/WindowInput', 'description': 'The range of dates within which the seller expects that their shipment will be delivered to Amazon.\n'}}, + 'required': ['deliveryWindow'], + 'type': 'object'} - Returns: - ApiResponse: + Returns: + ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), inboundPlanId), data=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), inboundPlanId), data=kwargs + ) - @sp_endpoint('/inbound/fba//inboundPlans/{}/selfShipAppointmentSlots', method='GET') + @sp_endpoint( + "/inbound/fba//inboundPlans/{}/selfShipAppointmentSlots", method="GET" + ) def get_self_ship_appointment_slots(self, inboundPlanId, **kwargs) -> ApiResponse: """ - get_self_ship_appointment_slots(self, inboundPlanId, **kwargs) -> ApiResponse + get_self_ship_appointment_slots(self, inboundPlanId, **kwargs) -> ApiResponse - Retrieves a list of available self-ship appointment slots used to drop off a shipment at a warehouse. + Retrieves a list of available self-ship appointment slots used to drop off a shipment at a warehouse. -**Usage Plan:** + **Usage Plan:** -| Rate (requests per second) | Burst | -| ---- | ---- | -| 1 | 1 | + | Rate (requests per second) | Burst | + | ---- | ---- | + | 1 | 1 | -The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). + The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). - Args: + Args: - inboundPlanId:string | * REQUIRED Identifier to an inbound plan. + inboundPlanId:string | * REQUIRED Identifier to an inbound plan. - shipmentId:string | * REQUIRED Identifier to a shipment. A shipment contains the boxes and units being inbounded. + shipmentId:string | * REQUIRED Identifier to a shipment. A shipment contains the boxes and units being inbounded. - key pageSize:integer | The number of self ship appointment slots to return in the response matching the given query. + key pageSize:integer | The number of self ship appointment slots to return in the response matching the given query. - key paginationToken:string | A token to fetch a certain page when there are multiple pages worth of results. The value of this token is fetched from the `pagination` returned in the API response. In the absence of the token value from the query parameter the API returns the first page of the result. + key paginationToken:string | A token to fetch a certain page when there are multiple pages worth of results. The value of this token is fetched from the `pagination` returned in the API response. In the absence of the token value from the query parameter the API returns the first page of the result. - Returns: - ApiResponse: + Returns: + ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), inboundPlanId), params=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), inboundPlanId), params=kwargs + ) - @sp_endpoint('/inbound/fba//inboundPlans/{}/selfShipAppointmentSlots', method='POST') - def generate_self_ship_appointment_slots(self, inboundPlanId, **kwargs) -> ApiResponse: + @sp_endpoint( + "/inbound/fba//inboundPlans/{}/selfShipAppointmentSlots", method="POST" + ) + def generate_self_ship_appointment_slots( + self, inboundPlanId, **kwargs + ) -> ApiResponse: """ - generate_self_ship_appointment_slots(self, inboundPlanId, **kwargs) -> ApiResponse + generate_self_ship_appointment_slots(self, inboundPlanId, **kwargs) -> ApiResponse - Initiates the process of generating the appointment slots list. + Initiates the process of generating the appointment slots list. -**Usage Plan:** + **Usage Plan:** -| Rate (requests per second) | Burst | -| ---- | ---- | -| 1 | 1 | + | Rate (requests per second) | Burst | + | ---- | ---- | + | 1 | 1 | -The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). + The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). - Args: + Args: - inboundPlanId:string | * REQUIRED Identifier to an inbound plan. + inboundPlanId:string | * REQUIRED Identifier to an inbound plan. - shipmentId:string | * REQUIRED Identifier to a shipment. A shipment contains the boxes and units being inbounded. + shipmentId:string | * REQUIRED Identifier to a shipment. A shipment contains the boxes and units being inbounded. - body: | * REQUIRED {'description': 'The `generateSelfShipAppointmentSlots` request.', - 'example': {'desiredEndDate': '2024-01-06T14:48:00.000Z', 'desiredStartDate': '2024-01-05T14:48:00.000Z'}, - 'properties': {'desiredEndDate': {'description': 'The ISO 8601 datetime with pattern `yyyy-MM-ddTHH:mm:ss.sssZ`.', 'format': 'date-time', 'type': 'string'}, - 'desiredStartDate': {'description': 'The ISO 8601 datetime with pattern `yyyy-MM-ddTHH:mm:ss.sssZ`.', 'format': 'date-time', 'type': 'string'}}, - 'type': 'object'} + body: | * REQUIRED {'description': 'The `generateSelfShipAppointmentSlots` request.', + 'example': {'desiredEndDate': '2024-01-06T14:48:00.000Z', 'desiredStartDate': '2024-01-05T14:48:00.000Z'}, + 'properties': {'desiredEndDate': {'description': 'The ISO 8601 datetime with pattern `yyyy-MM-ddTHH:mm:ss.sssZ`.', 'format': 'date-time', 'type': 'string'}, + 'desiredStartDate': {'description': 'The ISO 8601 datetime with pattern `yyyy-MM-ddTHH:mm:ss.sssZ`.', 'format': 'date-time', 'type': 'string'}}, + 'type': 'object'} - Returns: - ApiResponse: + Returns: + ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), inboundPlanId), data=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), inboundPlanId), data=kwargs + ) - @sp_endpoint('/inbound/fba//inboundPlans/{}/cancellation', method='PUT') + @sp_endpoint("/inbound/fba//inboundPlans/{}/cancellation", method="PUT") def cancel_self_ship_appointment(self, inboundPlanId, **kwargs) -> ApiResponse: """ - cancel_self_ship_appointment(self, inboundPlanId, **kwargs) -> ApiResponse + cancel_self_ship_appointment(self, inboundPlanId, **kwargs) -> ApiResponse - Cancels a self-ship appointment slot against a shipment. + Cancels a self-ship appointment slot against a shipment. -**Usage Plan:** + **Usage Plan:** -| Rate (requests per second) | Burst | -| ---- | ---- | -| 1 | 1 | + | Rate (requests per second) | Burst | + | ---- | ---- | + | 1 | 1 | -The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). + The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). - Args: + Args: - inboundPlanId:string | * REQUIRED Identifier to an inbound plan. + inboundPlanId:string | * REQUIRED Identifier to an inbound plan. - shipmentId:string | * REQUIRED Identifier to a shipment. A shipment contains the boxes and units being inbounded. + shipmentId:string | * REQUIRED Identifier to a shipment. A shipment contains the boxes and units being inbounded. - slotId:string | * REQUIRED Identifier to a self-ship appointment slot. + slotId:string | * REQUIRED Identifier to a self-ship appointment slot. - body: | * REQUIRED {'description': 'The `cancelSelfShipAppointment` request.', 'example': {'reasonComment': 'OTHER'}, 'properties': {'reasonComment': {'$ref': '#/definitions/ReasonComment'}}, 'type': 'object'} + body: | * REQUIRED {'description': 'The `cancelSelfShipAppointment` request.', 'example': {'reasonComment': 'OTHER'}, 'properties': {'reasonComment': {'$ref': '#/definitions/ReasonComment'}}, 'type': 'object'} - Returns: - ApiResponse: + Returns: + ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), inboundPlanId), data=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), inboundPlanId), data=kwargs + ) - @sp_endpoint('/inbound/fba//inboundPlans/{}/schedule', method='POST') + @sp_endpoint("/inbound/fba//inboundPlans/{}/schedule", method="POST") def schedule_self_ship_appointment(self, inboundPlanId, **kwargs) -> ApiResponse: """ - schedule_self_ship_appointment(self, inboundPlanId, **kwargs) -> ApiResponse + schedule_self_ship_appointment(self, inboundPlanId, **kwargs) -> ApiResponse - Confirms or reschedules a self-ship appointment slot against a shipment. + Confirms or reschedules a self-ship appointment slot against a shipment. -**Usage Plan:** + **Usage Plan:** -| Rate (requests per second) | Burst | -| ---- | ---- | -| 1 | 1 | + | Rate (requests per second) | Burst | + | ---- | ---- | + | 1 | 1 | -The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). + The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). - Args: + Args: - inboundPlanId:string | * REQUIRED Identifier to an inbound plan. + inboundPlanId:string | * REQUIRED Identifier to an inbound plan. - shipmentId:string | * REQUIRED Identifier to a shipment. A shipment contains the boxes and units being inbounded. + shipmentId:string | * REQUIRED Identifier to a shipment. A shipment contains the boxes and units being inbounded. - slotId:string | * REQUIRED Identifier to a self-ship appointment slot. + slotId:string | * REQUIRED Identifier to a self-ship appointment slot. - body: | * REQUIRED {'description': '`scheduleSelfShipAppointment` request.', 'example': {'reasonComment': 'OTHER'}, 'properties': {'reasonComment': {'$ref': '#/definitions/ReasonComment'}}, 'type': 'object'} + body: | * REQUIRED {'description': '`scheduleSelfShipAppointment` request.', 'example': {'reasonComment': 'OTHER'}, 'properties': {'reasonComment': {'$ref': '#/definitions/ReasonComment'}}, 'type': 'object'} - Returns: - ApiResponse: + Returns: + ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), inboundPlanId), data=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), inboundPlanId), data=kwargs + ) - @sp_endpoint('/inbound/fba//inboundPlans/{}/trackingDetails', method='PUT') + @sp_endpoint("/inbound/fba//inboundPlans/{}/trackingDetails", method="PUT") def update_shipment_tracking_details(self, inboundPlanId, **kwargs) -> ApiResponse: """ - update_shipment_tracking_details(self, inboundPlanId, **kwargs) -> ApiResponse + update_shipment_tracking_details(self, inboundPlanId, **kwargs) -> ApiResponse - Updates a shipment's tracking details. + Updates a shipment's tracking details. -**Usage Plan:** + **Usage Plan:** -| Rate (requests per second) | Burst | -| ---- | ---- | -| 1 | 1 | + | Rate (requests per second) | Burst | + | ---- | ---- | + | 1 | 1 | -The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). + The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). - Args: + Args: - inboundPlanId:string | * REQUIRED Identifier to an inbound plan. + inboundPlanId:string | * REQUIRED Identifier to an inbound plan. - shipmentId:string | * REQUIRED Identifier to a shipment. A shipment contains the boxes and units being inbounded. + shipmentId:string | * REQUIRED Identifier to a shipment. A shipment contains the boxes and units being inbounded. - body: | * REQUIRED {'description': 'The `updateShipmentTrackingDetails` request.', - 'example': {'trackingDetails': {'spdTrackingDetail': {'spdTrackingItems': [{'boxId': 'FBA10ABC0YY100001', 'trackingId': 'FBA10002000'}]}}}, - 'properties': {'trackingDetails': {'$ref': '#/definitions/TrackingDetailsInput'}}, - 'required': ['trackingDetails'], - 'type': 'object'} + body: | * REQUIRED {'description': 'The `updateShipmentTrackingDetails` request.', + 'example': {'trackingDetails': {'spdTrackingDetail': {'spdTrackingItems': [{'boxId': 'FBA10ABC0YY100001', 'trackingId': 'FBA10002000'}]}}}, + 'properties': {'trackingDetails': {'$ref': '#/definitions/TrackingDetailsInput'}}, + 'required': ['trackingDetails'], + 'type': 'object'} - Returns: - ApiResponse: + Returns: + ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), inboundPlanId), data=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), inboundPlanId), data=kwargs + ) - @sp_endpoint('/inbound/fba//inboundPlans/{}/transportationOptions', method='GET') + @sp_endpoint( + "/inbound/fba//inboundPlans/{}/transportationOptions", method="GET" + ) def list_transportation_options(self, inboundPlanId, **kwargs) -> ApiResponse: """ - list_transportation_options(self, inboundPlanId, **kwargs) -> ApiResponse + list_transportation_options(self, inboundPlanId, **kwargs) -> ApiResponse - Retrieves all transportation options for a shipment. Transportation options must first be generated by the corresponding endpoint before becoming available. + Retrieves all transportation options for a shipment. Transportation options must first be generated by the corresponding endpoint before becoming available. -**Usage Plan:** + **Usage Plan:** -| Rate (requests per second) | Burst | -| ---- | ---- | -| 1 | 1 | + | Rate (requests per second) | Burst | + | ---- | ---- | + | 1 | 1 | -The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). + The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). - Args: + Args: - inboundPlanId:string | * REQUIRED Identifier to an inbound plan. + inboundPlanId:string | * REQUIRED Identifier to an inbound plan. - key pageSize:integer | The number of transportation options to return in the response matching the given query. + key pageSize:integer | The number of transportation options to return in the response matching the given query. - key paginationToken:string | A token to fetch a certain page when there are multiple pages worth of results. The value of this token is fetched from the `pagination` returned in the API response. In the absence of the token value from the query parameter the API returns the first page of the result. + key paginationToken:string | A token to fetch a certain page when there are multiple pages worth of results. The value of this token is fetched from the `pagination` returned in the API response. In the absence of the token value from the query parameter the API returns the first page of the result. - key placementOptionId:string | The placement option to get transportation options for. Either placementOptionId or shipmentId must be specified. + key placementOptionId:string | The placement option to get transportation options for. Either placementOptionId or shipmentId must be specified. - key shipmentId:string | The shipment to get transportation options for. Either placementOptionId or shipmentId must be specified. + key shipmentId:string | The shipment to get transportation options for. Either placementOptionId or shipmentId must be specified. - Returns: - ApiResponse: + Returns: + ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), inboundPlanId), params=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), inboundPlanId), params=kwargs + ) - @sp_endpoint('/inbound/fba//inboundPlans/{}/transportationOptions', method='POST') + @sp_endpoint( + "/inbound/fba//inboundPlans/{}/transportationOptions", method="POST" + ) def generate_transportation_options(self, inboundPlanId, **kwargs) -> ApiResponse: """ - generate_transportation_options(self, inboundPlanId, **kwargs) -> ApiResponse + generate_transportation_options(self, inboundPlanId, **kwargs) -> ApiResponse - Generates available transportation options for a given placement option. + Generates available transportation options for a given placement option. -**Usage Plan:** + **Usage Plan:** -| Rate (requests per second) | Burst | -| ---- | ---- | -| 0.05 | 1 | + | Rate (requests per second) | Burst | + | ---- | ---- | + | 0.05 | 1 | -The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). + The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). - Args: + Args: - inboundPlanId:string | * REQUIRED Identifier to an inbound plan. - - body: | * REQUIRED {'description': 'The `generateTransportationOptions` request.', - 'example': {'placementOptionId': 'pl1234abcd-1234-abcd-5678-1234abcd5678', - 'shipmentTransportationConfigurations': [{'contactInformation': {'email': 'email@email.com', 'name': 'John Smithy', 'phoneNumber': '1234567890'}, - 'palletInformation': {'declaredValue': {'amount': 500, 'code': 'USD'}, - 'freightClass': 'FC_50', - 'pallets': [{'dimensions': {'height': 5, 'length': 3, 'unitOfMeasurement': 'CM', 'width': 4}, - 'quantity': 2, - 'stackability': 'STACKABLE', - 'weight': {'unit': 'KG', 'value': 5.5}}]}, - 'readyToShipWindow': {'start': '2024-01-01T00:00Z'}, - 'shipmentId': 'sh1234abcd-1234-abcd-5678-1234abcd5678'}]}, - 'properties': {'placementOptionId': {'description': 'The placement option to generate transportation options for.', 'maxLength': 38, 'minLength': 38, 'pattern': '^[a-zA-Z0-9-]*$', 'type': 'string'}, - 'shipmentTransportationConfigurations': {'description': 'List of shipment transportation configurations.', 'items': {'$ref': '#/definitions/ShipmentTransportationConfiguration'}, 'type': 'array'}}, - 'required': ['placementOptionId', 'shipmentTransportationConfigurations'], - 'type': 'object'} + inboundPlanId:string | * REQUIRED Identifier to an inbound plan. + body: | * REQUIRED {'description': 'The `generateTransportationOptions` request.', + 'example': {'placementOptionId': 'pl1234abcd-1234-abcd-5678-1234abcd5678', + 'shipmentTransportationConfigurations': [{'contactInformation': {'email': 'email@email.com', 'name': 'John Smithy', 'phoneNumber': '1234567890'}, + 'palletInformation': {'declaredValue': {'amount': 500, 'code': 'USD'}, + 'freightClass': 'FC_50', + 'pallets': [{'dimensions': {'height': 5, 'length': 3, 'unitOfMeasurement': 'CM', 'width': 4}, + 'quantity': 2, + 'stackability': 'STACKABLE', + 'weight': {'unit': 'KG', 'value': 5.5}}]}, + 'readyToShipWindow': {'start': '2024-01-01T00:00Z'}, + 'shipmentId': 'sh1234abcd-1234-abcd-5678-1234abcd5678'}]}, + 'properties': {'placementOptionId': {'description': 'The placement option to generate transportation options for.', 'maxLength': 38, 'minLength': 38, 'pattern': '^[a-zA-Z0-9-]*$', 'type': 'string'}, + 'shipmentTransportationConfigurations': {'description': 'List of shipment transportation configurations.', 'items': {'$ref': '#/definitions/ShipmentTransportationConfiguration'}, 'type': 'array'}}, + 'required': ['placementOptionId', 'shipmentTransportationConfigurations'], + 'type': 'object'} - Returns: - ApiResponse: + + Returns: + ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), inboundPlanId), data=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), inboundPlanId), data=kwargs + ) - @sp_endpoint('/inbound/fba//inboundPlans/{}/transportationOptions/confirmation', method='POST') + @sp_endpoint( + "/inbound/fba//inboundPlans/{}/transportationOptions/confirmation", + method="POST", + ) def confirm_transportation_options(self, inboundPlanId, **kwargs) -> ApiResponse: """ - confirm_transportation_options(self, inboundPlanId, **kwargs) -> ApiResponse + confirm_transportation_options(self, inboundPlanId, **kwargs) -> ApiResponse - Confirms all the transportation options for an inbound plan. A placement option must be confirmed prior to use of this API. Once confirmed, new transportation options can not be generated or confirmed for the Inbound Plan. + Confirms all the transportation options for an inbound plan. A placement option must be confirmed prior to use of this API. Once confirmed, new transportation options can not be generated or confirmed for the Inbound Plan. -**Usage Plan:** + **Usage Plan:** -| Rate (requests per second) | Burst | -| ---- | ---- | -| 0.05 | 1 | + | Rate (requests per second) | Burst | + | ---- | ---- | + | 0.05 | 1 | -The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). + The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). - Args: + Args: - inboundPlanId:string | * REQUIRED Identifier to an inbound plan. + inboundPlanId:string | * REQUIRED Identifier to an inbound plan. - body: | * REQUIRED {'description': 'The `confirmTransportationOptions` request.', - 'example': {'transportationSelections': [{'contactInformation': {'email': 'email@email.com', 'name': 'John Smithy', 'phoneNumber': '1234567890'}, - 'deliveryWindow': {'start': '2024-01-01T00:00Z'}, - 'shipmentId': 'sh1234abcd-1234-abcd-5678-1234abcd5678', - 'transportationOptionId': 'to1234abcd-1234-abcd-5678-1234abcd5678'}]}, - 'properties': {'transportationSelections': {'description': 'Information needed to confirm one of the available transportation options.', 'items': {'$ref': '#/definitions/TransportationSelection'}, 'minItems': 1, 'type': 'array'}}, - 'required': ['transportationSelections'], - 'type': 'object'} + body: | * REQUIRED {'description': 'The `confirmTransportationOptions` request.', + 'example': {'transportationSelections': [{'contactInformation': {'email': 'email@email.com', 'name': 'John Smithy', 'phoneNumber': '1234567890'}, + 'deliveryWindow': {'start': '2024-01-01T00:00Z'}, + 'shipmentId': 'sh1234abcd-1234-abcd-5678-1234abcd5678', + 'transportationOptionId': 'to1234abcd-1234-abcd-5678-1234abcd5678'}]}, + 'properties': {'transportationSelections': {'description': 'Information needed to confirm one of the available transportation options.', 'items': {'$ref': '#/definitions/TransportationSelection'}, 'minItems': 1, 'type': 'array'}}, + 'required': ['transportationSelections'], + 'type': 'object'} - Returns: - ApiResponse: + Returns: + ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), inboundPlanId), data=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), inboundPlanId), data=kwargs + ) - @sp_endpoint('/inbound/fba//items/compliance', method='GET') + @sp_endpoint("/inbound/fba//items/compliance", method="GET") def list_item_compliance_details(self, **kwargs) -> ApiResponse: """ - list_item_compliance_details(self, **kwargs) -> ApiResponse + list_item_compliance_details(self, **kwargs) -> ApiResponse - List the inbound compliance details for MSKUs in a given marketplace. + List the inbound compliance details for MSKUs in a given marketplace. -**Usage Plan:** + **Usage Plan:** -| Rate (requests per second) | Burst | -| ---- | ---- | -| 1 | 1 | + | Rate (requests per second) | Burst | + | ---- | ---- | + | 1 | 1 | -The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). + The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). - Args: + Args: - key mskus:array | * REQUIRED List of merchant SKUs, a merchant-supplied identifier for a specific SKU. + key mskus:array | * REQUIRED List of merchant SKUs, a merchant-supplied identifier for a specific SKU. - key marketplaceId:string | * REQUIRED The Marketplace ID. Refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids) for a list of possible values. + key marketplaceId:string | * REQUIRED The Marketplace ID. Refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids) for a list of possible values. - Returns: - ApiResponse: + Returns: + ApiResponse: """ - return self._request(kwargs.pop('path'), params=kwargs) + return self._request(kwargs.pop("path"), params=kwargs) - @sp_endpoint('/inbound/fba//items/compliance', method='PUT') + @sp_endpoint("/inbound/fba//items/compliance", method="PUT") def update_item_compliance_details(self, **kwargs) -> ApiResponse: """ - update_item_compliance_details(self, **kwargs) -> ApiResponse + update_item_compliance_details(self, **kwargs) -> ApiResponse - Update compliance details for list of MSKUs. The details provided here are only used for the IN marketplace compliance validation. + Update compliance details for list of MSKUs. The details provided here are only used for the IN marketplace compliance validation. -**Usage Plan:** + **Usage Plan:** -| Rate (requests per second) | Burst | -| ---- | ---- | -| 1 | 1 | + | Rate (requests per second) | Burst | + | ---- | ---- | + | 1 | 1 | -The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). + The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). - Args: + Args: - key marketplaceId:string | * REQUIRED The Marketplace ID. Refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids) for a list of possible values. + key marketplaceId:string | * REQUIRED The Marketplace ID. Refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids) for a list of possible values. - body: | * REQUIRED {'description': 'The `updateItemComplianceDetails` request.', - 'example': {'msku': 'Sunglasses', 'taxDetails': {'declaredValue': {'amount': 5.5, 'code': 'CAD'}, 'hsnCode': 'hsnCode'}}, - 'properties': {'msku': {'description': 'The merchant SKU, a merchant-supplied identifier for a specific SKU.', 'maxLength': 40, 'minLength': 1, 'type': 'string'}, 'taxDetails': {'$ref': '#/definitions/TaxDetails'}}, - 'required': ['msku', 'taxDetails'], - 'type': 'object'} + body: | * REQUIRED {'description': 'The `updateItemComplianceDetails` request.', + 'example': {'msku': 'Sunglasses', 'taxDetails': {'declaredValue': {'amount': 5.5, 'code': 'CAD'}, 'hsnCode': 'hsnCode'}}, + 'properties': {'msku': {'description': 'The merchant SKU, a merchant-supplied identifier for a specific SKU.', 'maxLength': 40, 'minLength': 1, 'type': 'string'}, 'taxDetails': {'$ref': '#/definitions/TaxDetails'}}, + 'required': ['msku', 'taxDetails'], + 'type': 'object'} - Returns: - ApiResponse: + Returns: + ApiResponse: """ - return self._request(kwargs.pop('path'), data=kwargs) + return self._request(kwargs.pop("path"), data=kwargs) - @sp_endpoint('/inbound/fba//operations/{}', method='GET') + @sp_endpoint("/inbound/fba//operations/{}", method="GET") def get_inbound_operation_status(self, operationId, **kwargs) -> ApiResponse: """ - get_inbound_operation_status(self, operationId, **kwargs) -> ApiResponse + get_inbound_operation_status(self, operationId, **kwargs) -> ApiResponse - Gets the status of the processing of an asynchronous API call. + Gets the status of the processing of an asynchronous API call. -**Usage Plan:** + **Usage Plan:** -| Rate (requests per second) | Burst | -| ---- | ---- | -| 1 | 1 | + | Rate (requests per second) | Burst | + | ---- | ---- | + | 1 | 1 | -The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). + The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). - Args: + Args: - operationId:string | * REQUIRED Identifier to an asynchronous operation. + operationId:string | * REQUIRED Identifier to an asynchronous operation. - Returns: - ApiResponse: + Returns: + ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), operationId), params=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), operationId), params=kwargs + ) - @sp_endpoint('/inbound/fba//inboundPlans/{}/shipments/{}/deliveryWindowOptions', method='POST') - def generate_delivery_window_options(self, inboundPlanId, shipmentId, **kwargs) -> ApiResponse: + @sp_endpoint( + "/inbound/fba//inboundPlans/{}/shipments/{}/deliveryWindowOptions", + method="POST", + ) + def generate_delivery_window_options( + self, inboundPlanId, shipmentId, **kwargs + ) -> ApiResponse: """ - def generate_delivery_window_options(self, inboundPlanId, shipmentId, **kwargs) -> ApiResponse: + def generate_delivery_window_options(self, inboundPlanId, shipmentId, **kwargs) -> ApiResponse: - Generates available delivery window options for a given shipment. + Generates available delivery window options for a given shipment. -**Usage Plan:** + **Usage Plan:** -| Rate (requests per second) | Burst | -| ---- | ---- | -| 2 | 30 | + | Rate (requests per second) | Burst | + | ---- | ---- | + | 2 | 30 | -The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). + The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). - Args: + Args: - inboundPlanId:string | * REQUIRED Identifier of an inbound plan. - shipmentId:string | * REQUIRED The shipment to generate delivery window options for. + inboundPlanId:string | * REQUIRED Identifier of an inbound plan. + shipmentId:string | * REQUIRED The shipment to generate delivery window options for. - Returns: - ApiResponse: + Returns: + ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), inboundPlanId, shipmentId), params=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), inboundPlanId, shipmentId), + params=kwargs, + ) - @sp_endpoint('/inbound/fba//inboundPlans/{}/shipments/{}/deliveryWindowOptions', method='GET') - def list_delivery_window_options(self, inboundPlanId, shipmentId, **kwargs) -> ApiResponse: + @sp_endpoint( + "/inbound/fba//inboundPlans/{}/shipments/{}/deliveryWindowOptions", + method="GET", + ) + def list_delivery_window_options( + self, inboundPlanId, shipmentId, **kwargs + ) -> ApiResponse: """ - def generate_delivery_window_options(self, inboundPlanId, shipmentId, **kwargs) -> ApiResponse: + def generate_delivery_window_options(self, inboundPlanId, shipmentId, **kwargs) -> ApiResponse: - Retrieves all delivery window options for a shipment. Delivery window options must first be generated by the generateDeliveryWindowOptions operation before becoming available. + Retrieves all delivery window options for a shipment. Delivery window options must first be generated by the generateDeliveryWindowOptions operation before becoming available. -**Usage Plan:** + **Usage Plan:** -| Rate (requests per second) | Burst | -| ---- | ---- | -| 2 | 30 | + | Rate (requests per second) | Burst | + | ---- | ---- | + | 2 | 30 | -The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). + The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). - Args: + Args: - inboundPlanId:string | * REQUIRED Identifier of an inbound plan. - shipmentId:string | * REQUIRED The shipment to generate delivery window options for. + inboundPlanId:string | * REQUIRED Identifier of an inbound plan. + shipmentId:string | * REQUIRED The shipment to generate delivery window options for. - Returns: - ApiResponse: + Returns: + ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), inboundPlanId, shipmentId), params=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), inboundPlanId, shipmentId), + params=kwargs, + ) - @sp_endpoint('/inbound/fba//inboundPlans/{}/shipments/{}/deliveryWindowOptions/{}/confirmation', method='POST') - def confirm_delivery_window_options(self, inboundPlanId, shipmentId, deliveryWindowOptionId, **kwargs) -> ApiResponse: + @sp_endpoint( + "/inbound/fba//inboundPlans/{}/shipments/{}/deliveryWindowOptions/{}/confirmation", + method="POST", + ) + def confirm_delivery_window_options( + self, inboundPlanId, shipmentId, deliveryWindowOptionId, **kwargs + ) -> ApiResponse: """ - def confirm_delivery_window_options(self, inboundPlanId, shipmentId, deliveryWindowOptionId, **kwargs) -> ApiResponse: + def confirm_delivery_window_options(self, inboundPlanId, shipmentId, deliveryWindowOptionId, **kwargs) -> ApiResponse: - Confirms the delivery window option for chosen shipment within an inbound plan. A placement option must be confirmed prior to use of this API. Once confirmed, new delivery window options cannot be generated, but the chosen delivery window option can be updated before shipment closure. The window is used to provide the expected time when a shipment will arrive at the warehouse. All transportation options which have the program CONFIRMED_DELIVERY_WINDOW require a delivery window to be confirmed prior to transportation option confirmation. + Confirms the delivery window option for chosen shipment within an inbound plan. A placement option must be confirmed prior to use of this API. Once confirmed, new delivery window options cannot be generated, but the chosen delivery window option can be updated before shipment closure. The window is used to provide the expected time when a shipment will arrive at the warehouse. All transportation options which have the program CONFIRMED_DELIVERY_WINDOW require a delivery window to be confirmed prior to transportation option confirmation. -**Usage Plan:** + **Usage Plan:** -| Rate (requests per second) | Burst | -| ---- | ---- | -| 2 | 30 | + | Rate (requests per second) | Burst | + | ---- | ---- | + | 2 | 30 | -The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). + The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). - Args: + Args: - inboundPlanId:string | * REQUIRED Identifier of an inbound plan. - shipmentId:string | * REQUIRED The shipment to generate delivery window options for. - deliveryWindowOptionId:string | REQUIRED The id of the delivery window option to be confirmed. + inboundPlanId:string | * REQUIRED Identifier of an inbound plan. + shipmentId:string | * REQUIRED The shipment to generate delivery window options for. + deliveryWindowOptionId:string | REQUIRED The id of the delivery window option to be confirmed. - Returns: - ApiResponse: + Returns: + ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), inboundPlanId, shipmentId, deliveryWindowOptionId), params=kwargs) + return self._request( + fill_query_params( + kwargs.pop("path"), inboundPlanId, shipmentId, deliveryWindowOptionId + ), + params=kwargs, + ) - @sp_endpoint('/inbound/fba//inboundPlans/{}/shipments/{}/items', method='GET') + @sp_endpoint( + "/inbound/fba//inboundPlans/{}/shipments/{}/items", method="GET" + ) def list_shipment_items(self, inboundPlanId, shipmentId, **kwargs) -> ApiResponse: """ - list_shipment_items(self, inboundPlanId, shipmentId, **kwargs) -> ApiResponse + list_shipment_items(self, inboundPlanId, shipmentId, **kwargs) -> ApiResponse - Provides a paginated list of item packages in a shipment. + Provides a paginated list of item packages in a shipment. -**Usage Plan:** + **Usage Plan:** -| Rate (requests per second) | Burst | -| ---- | ---- | -| 2 | 30 | + | Rate (requests per second) | Burst | + | ---- | ---- | + | 2 | 30 | -The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The preceding table contains the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may have higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). + The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The preceding table contains the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may have higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). - Args: + Args: - inboundPlanId:string | * REQUIRED Identifier to an inbound plan. + inboundPlanId:string | * REQUIRED Identifier to an inbound plan. - shipmentId:string | * REQUIRED Identifier of a shipment. A shipment contains the boxes and units being inbounded. + shipmentId:string | * REQUIRED Identifier of a shipment. A shipment contains the boxes and units being inbounded. - key pageSize:integer | The number of items to return in the response matching the given query. + key pageSize:integer | The number of items to return in the response matching the given query. - key paginationToken:string | A token to fetch a certain page when there are multiple pages worth of results. The value of this token is fetched from the `pagination` returned in the API response. In the absence of the token value from the query parameter the API returns the first page of the result. + key paginationToken:string | A token to fetch a certain page when there are multiple pages worth of results. The value of this token is fetched from the `pagination` returned in the API response. In the absence of the token value from the query parameter the API returns the first page of the result. - Returns: - ApiResponse: + Returns: + ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), inboundPlanId, shipmentId), params=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), inboundPlanId, shipmentId), + params=kwargs, + ) - @sp_endpoint('/inbound/fba//items/labels', method='POST') + @sp_endpoint("/inbound/fba//items/labels", method="POST") def create_marketplace_item_labels(self, **kwargs) -> ApiResponse: """ - create_marketplace_item_labels(self, **kwargs) -> ApiResponse + create_marketplace_item_labels(self, **kwargs) -> ApiResponse - For a given marketplace - creates labels for a list of MSKUs. + For a given marketplace - creates labels for a list of MSKUs. -**Usage Plan:** + **Usage Plan:** -| Rate (requests per second) | Burst | -| ---- | ---- | -| 2 | 30 | + | Rate (requests per second) | Burst | + | ---- | ---- | + | 2 | 30 | -The x-amzn-RateLimit-Limit response header returns the usage plan rate limits that were applied to the requested operation, when available. The preceding table contains the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may have higher rate and burst values than those shown here. For more information, refer to Usage Plans and Rate Limits in the Selling Partner API. - Args: + The x-amzn-RateLimit-Limit response header returns the usage plan rate limits that were applied to the requested operation, when available. The preceding table contains the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may have higher rate and burst values than those shown here. For more information, refer to Usage Plans and Rate Limits in the Selling Partner API. + Args: - height:number | *OPTIONAL The height of the item label. - labelType: | *RERQUIRED ndicates the type of print type for a given label. - localeCode:string | *OPTIONAL The locale code constructed from ISO 639 language code and ISO 3166-1 alpha-2 standard of country codes separated by an underscore character. - marketplaceId:string | *REQUIRED The marketplace ID. - mskuQuantities:array | *REQUIRED Represents the quantity of an MSKU to print item labels for. - pageType: | *OPTIONAL The page type to use to print the labels. - width:number | *OPTIONAL The width of the item label. + height:number | *OPTIONAL The height of the item label. + labelType: | *RERQUIRED ndicates the type of print type for a given label. + localeCode:string | *OPTIONAL The locale code constructed from ISO 639 language code and ISO 3166-1 alpha-2 standard of country codes separated by an underscore character. + marketplaceId:string | *REQUIRED The marketplace ID. + mskuQuantities:array | *REQUIRED Represents the quantity of an MSKU to print item labels for. + pageType: | *OPTIONAL The page type to use to print the labels. + width:number | *OPTIONAL The width of the item label. - Returns: - ApiResponse: + Returns: + ApiResponse: """ - return self._request(kwargs.pop('path'), data=kwargs) + return self._request(kwargs.pop("path"), data=kwargs) - @sp_endpoint('/inbound/fba//items/prepDetails', method='GET') + @sp_endpoint("/inbound/fba//items/prepDetails", method="GET") def list_prep_details(self, **kwargs) -> ApiResponse: """ - list_prep_details(self, **kwargs) -> ApiResponse: + list_prep_details(self, **kwargs) -> ApiResponse: - Get preparation details for a list of MSKUs in a specified marketplace. + Get preparation details for a list of MSKUs in a specified marketplace. -**Usage Plan:** + **Usage Plan:** -| Rate (requests per second) | Burst | -| ---- | ---- | -| 2 | 30 | + | Rate (requests per second) | Burst | + | ---- | ---- | + | 2 | 30 | -The x-amzn-RateLimit-Limit response header returns the usage plan rate limits that were applied to the requested operation, when available. The preceding table contains the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may have higher rate and burst values than those shown here. For more information, refer to Usage Plans and Rate Limits in the Selling Partner API. - Args: - marketplaceId:string | *REQUIRED The marketplace ID. - mskus:array | *REQUIRED A list of merchant SKUs, a merchant-supplied identifier of a specific SKU. + The x-amzn-RateLimit-Limit response header returns the usage plan rate limits that were applied to the requested operation, when available. The preceding table contains the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may have higher rate and burst values than those shown here. For more information, refer to Usage Plans and Rate Limits in the Selling Partner API. + Args: + marketplaceId:string | *REQUIRED The marketplace ID. + mskus:array | *REQUIRED A list of merchant SKUs, a merchant-supplied identifier of a specific SKU. - Returns: - ApiResponse: + Returns: + ApiResponse: """ - return self._request(kwargs.pop('path'), params=kwargs) + return self._request(kwargs.pop("path"), params=kwargs) - @sp_endpoint('/inbound/fba//items/prepDetails', method='POST') + @sp_endpoint("/inbound/fba//items/prepDetails", method="POST") def set_prep_details(self, **kwargs) -> ApiResponse: """ - set_prep_details(self, **kwargs) -> ApiResponse: + set_prep_details(self, **kwargs) -> ApiResponse: - Set the preparation details for a list of MSKUs in a specified marketplace. + Set the preparation details for a list of MSKUs in a specified marketplace. -**Usage Plan:** + **Usage Plan:** -| Rate (requests per second) | Burst | -| ---- | ---- | -| 2 | 30 | + | Rate (requests per second) | Burst | + | ---- | ---- | + | 2 | 30 | -The x-amzn-RateLimit-Limit response header returns the usage plan rate limits that were applied to the requested operation, when available. The preceding table contains the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may have higher rate and burst values than those shown here. For more information, refer to Usage Plans and Rate Limits in the Selling Partner API. - Args: + The x-amzn-RateLimit-Limit response header returns the usage plan rate limits that were applied to the requested operation, when available. The preceding table contains the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may have higher rate and burst values than those shown here. For more information, refer to Usage Plans and Rate Limits in the Selling Partner API. + Args: - marketplaceId:string | *REQUIRED The marketplace ID. - mskuPrepDetails:array | *REQUIRED A list of MSKUs and related prep details. + marketplaceId:string | *REQUIRED The marketplace ID. + mskuPrepDetails:array | *REQUIRED A list of MSKUs and related prep details. - Returns: - ApiResponse: + Returns: + ApiResponse: """ - return self._request(kwargs.pop('path'), data=kwargs) + return self._request(kwargs.pop("path"), data=kwargs) - @sp_endpoint('/inbound/fba//inboundPlans/{}/shipments/{}/boxes', method='GET') + @sp_endpoint( + "/inbound/fba//inboundPlans/{}/shipments/{}/boxes", method="GET" + ) def list_shipment_boxes(self, inboundPlanId, shipmentId, **kwargs) -> ApiResponse: """ - list_shipment_boxes(self, **kwargs) -> ApiResponse: - - Provides a paginated list of box packages in a shipment. + list_shipment_boxes(self, **kwargs) -> ApiResponse: -**Usage Plan:** + Provides a paginated list of box packages in a shipment. -| Rate (requests per second) | Burst | -| ---- | ---- | -| 2 | 30 | + **Usage Plan:** -The x-amzn-RateLimit-Limit response header returns the usage plan rate limits that were applied to the requested operation, when available. The preceding table contains the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may have higher rate and burst values than those shown here. For more information, refer to Usage Plans and Rate Limits in the Selling Partner API. - Args: + | Rate (requests per second) | Burst | + | ---- | ---- | + | 2 | 30 | - pageSize:string | *OPTIONAL Identifier of a shipment. A shipment contains the boxes and units being inbounded. - paginationToken: | *OPTIONAL A token to fetch a certain page when there are multiple pages worth of results. The value of this token is fetched from the pagination returned in the API response. In the absence of the token value from the query parameter the API returns the first page of the result. - - Returns: - ApiResponse: - """ + The x-amzn-RateLimit-Limit response header returns the usage plan rate limits that were applied to the requested operation, when available. The preceding table contains the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may have higher rate and burst values than those shown here. For more information, refer to Usage Plans and Rate Limits in the Selling Partner API. + Args: - return self._request(fill_query_params(kwargs.pop('path'), inboundPlanId, shipmentId), params=kwargs) + pageSize:string | *OPTIONAL Identifier of a shipment. A shipment contains the boxes and units being inbounded. + paginationToken: | *OPTIONAL A token to fetch a certain page when there are multiple pages worth of results. The value of this token is fetched from the pagination returned in the API response. In the absence of the token value from the query parameter the API returns the first page of the result. - @sp_endpoint('/inbound/fba//inboundPlans/{}/shipments/{}/trackingDetails', method='PUT') - def update_shipment_tracking_details(self, inboundPlanId, shipmentId, **kwargs) -> ApiResponse: + Returns: + ApiResponse: """ - update_shipment_tracking_details(self, **kwargs) -> ApiResponse: - - Updates a shipment's tracking details. - -**Usage Plan:** -| Rate (requests per second) | Burst | -| ---- | ---- | -| 2 | 2 | - -The x-amzn-RateLimit-Limit response header returns the usage plan rate limits that were applied to the requested operation, when available. The preceding table contains the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may have higher rate and burst values than those shown here. For more information, refer to Usage Plans and Rate Limits in the Selling Partner API. - Args: + return self._request( + fill_query_params(kwargs.pop("path"), inboundPlanId, shipmentId), + params=kwargs, + ) - body: | * REQUIRED { - 'trackingDetails': [ - ltlTrackingDetail: [ - billOfLadingNumber: string, - freightBillNumber: string - ], - spdTrackingDetail: [ - spdTrackingItems:[ - boxId: string, - trackingId: string, - ] - ], - ], - } + @sp_endpoint( + "/inbound/fba//inboundPlans/{}/shipments/{}/trackingDetails", + method="PUT", + ) + def update_shipment_tracking_details( + self, inboundPlanId, shipmentId, **kwargs + ) -> ApiResponse: + """ + update_shipment_tracking_details(self, **kwargs) -> ApiResponse: + + Updates a shipment's tracking details. + + **Usage Plan:** + + | Rate (requests per second) | Burst | + | ---- | ---- | + | 2 | 2 | + + The x-amzn-RateLimit-Limit response header returns the usage plan rate limits that were applied to the requested operation, when available. The preceding table contains the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may have higher rate and burst values than those shown here. For more information, refer to Usage Plans and Rate Limits in the Selling Partner API. + Args: + + body: | * REQUIRED { + 'trackingDetails': [ + ltlTrackingDetail: [ + billOfLadingNumber: string, + freightBillNumber: string + ], + spdTrackingDetail: [ + spdTrackingItems:[ + boxId: string, + trackingId: string, + ] + ], + ], + } - Returns: - ApiResponse: + Returns: + ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), inboundPlanId, shipmentId), data=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), inboundPlanId, shipmentId), + data=kwargs, + ) diff --git a/sp_api/api/fulfillment_outbound/fulfillment_outbound.py b/sp_api/api/fulfillment_outbound/fulfillment_outbound.py index 4e2e92422..20fc1e92f 100644 --- a/sp_api/api/fulfillment_outbound/fulfillment_outbound.py +++ b/sp_api/api/fulfillment_outbound/fulfillment_outbound.py @@ -6,13 +6,12 @@ class FulfillmentOutbound(Client): """ FulfillmentOutbound SP-API Client - :link: + :link: The Selling Partner API for Fulfillment Outbound lets you create applications that help a seller fulfill Multi-Channel Fulfillment orders using their inventory in Amazon's fulfillment network. You can get information on both potential and existing fulfillment orders. """ - - @sp_endpoint('/fba/outbound/2020-07-01/fulfillmentOrders/preview', method='POST') + @sp_endpoint("/fba/outbound/2020-07-01/fulfillmentOrders/preview", method="POST") def get_fulfillment_preview(self, **kwargs) -> ApiResponse: """ get_fulfillment_preview(self, **kwargs) -> ApiResponse @@ -108,16 +107,15 @@ def get_fulfillment_preview(self, **kwargs) -> ApiResponse: } ] } - + Returns: ApiResponse: """ - - return self._request(kwargs.pop('path'), data=kwargs) - - @sp_endpoint('/fba/outbound/2020-07-01/fulfillmentOrders', method='GET') + return self._request(kwargs.pop("path"), data=kwargs) + + @sp_endpoint("/fba/outbound/2020-07-01/fulfillmentOrders", method="GET") def list_all_fulfillment_orders(self, **kwargs) -> ApiResponse: """ list_all_fulfillment_orders(self, **kwargs) -> ApiResponse @@ -141,11 +139,10 @@ def list_all_fulfillment_orders(self, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - - return self._request(kwargs.pop('path'), params=kwargs) - - @sp_endpoint('/fba/outbound/2020-07-01/fulfillmentOrders', method='POST') + return self._request(kwargs.pop("path"), params=kwargs) + + @sp_endpoint("/fba/outbound/2020-07-01/fulfillmentOrders", method="POST") def create_fulfillment_order(self, **kwargs) -> ApiResponse: """ create_fulfillment_order(self, **kwargs) -> ApiResponse @@ -322,16 +319,15 @@ def create_fulfillment_order(self, **kwargs) -> ApiResponse: } ] } - + Returns: ApiResponse: """ - - return self._request(kwargs.pop('path'), data=kwargs) - - @sp_endpoint('/fba/outbound/2020-07-01/tracking', method='GET') + return self._request(kwargs.pop("path"), data=kwargs) + + @sp_endpoint("/fba/outbound/2020-07-01/tracking", method="GET") def get_package_tracking_details(self, **kwargs) -> ApiResponse: """ get_package_tracking_details(self, **kwargs) -> ApiResponse @@ -354,11 +350,10 @@ def get_package_tracking_details(self, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - - return self._request(kwargs.pop('path'), params=kwargs) - - @sp_endpoint('/fba/outbound/2020-07-01/returnReasonCodes', method='GET') + return self._request(kwargs.pop("path"), params=kwargs) + + @sp_endpoint("/fba/outbound/2020-07-01/returnReasonCodes", method="GET") def list_return_reason_codes(self, **kwargs) -> ApiResponse: """ list_return_reason_codes(self, **kwargs) -> ApiResponse @@ -385,16 +380,17 @@ def list_return_reason_codes(self, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - - return self._request(kwargs.pop('path'), params=kwargs) - - @sp_endpoint('/fba/outbound/2020-07-01/fulfillmentOrders/{}/return', method='PUT') - def create_fulfillment_return(self, sellerFulfillmentOrderId, **kwargs) -> ApiResponse: + return self._request(kwargs.pop("path"), params=kwargs) + + @sp_endpoint("/fba/outbound/2020-07-01/fulfillmentOrders/{}/return", method="PUT") + def create_fulfillment_return( + self, sellerFulfillmentOrderId, **kwargs + ) -> ApiResponse: """ create_fulfillment_return(self, sellerFulfillmentOrderId, **kwargs) -> ApiResponse - Creates a fulfillment return. + Creates a fulfillment return. **Usage Plan:** @@ -440,11 +436,12 @@ def create_fulfillment_return(self, sellerFulfillmentOrderId, **kwargs) -> ApiRe Returns: ApiResponse: """ - - return self._request(fill_query_params(kwargs.pop('path'), sellerFulfillmentOrderId), data=kwargs) - - @sp_endpoint('/fba/outbound/2020-07-01/fulfillmentOrders/{}', method='GET') + return self._request( + fill_query_params(kwargs.pop("path"), sellerFulfillmentOrderId), data=kwargs + ) + + @sp_endpoint("/fba/outbound/2020-07-01/fulfillmentOrders/{}", method="GET") def get_fulfillment_order(self, sellerFulfillmentOrderId, **kwargs) -> ApiResponse: """ get_fulfillment_order(self, sellerFulfillmentOrderId, **kwargs) -> ApiResponse @@ -467,12 +464,16 @@ def get_fulfillment_order(self, sellerFulfillmentOrderId, **kwargs) -> ApiRespon Returns: ApiResponse: """ - - return self._request(fill_query_params(kwargs.pop('path'), sellerFulfillmentOrderId), params=kwargs) - - @sp_endpoint('/fba/outbound/2020-07-01/fulfillmentOrders/{}', method='PUT') - def update_fulfillment_order(self, sellerFulfillmentOrderId, **kwargs) -> ApiResponse: + return self._request( + fill_query_params(kwargs.pop("path"), sellerFulfillmentOrderId), + params=kwargs, + ) + + @sp_endpoint("/fba/outbound/2020-07-01/fulfillmentOrders/{}", method="PUT") + def update_fulfillment_order( + self, sellerFulfillmentOrderId, **kwargs + ) -> ApiResponse: """ update_fulfillment_order(self, sellerFulfillmentOrderId, **kwargs) -> ApiResponse @@ -609,12 +610,15 @@ def update_fulfillment_order(self, sellerFulfillmentOrderId, **kwargs) -> ApiRes Returns: ApiResponse: """ - - return self._request(fill_query_params(kwargs.pop('path'), sellerFulfillmentOrderId), data=kwargs) - - @sp_endpoint('/fba/outbound/2020-07-01/fulfillmentOrders/{}/cancel', method='PUT') - def cancel_fulfillment_order(self, sellerFulfillmentOrderId, **kwargs) -> ApiResponse: + return self._request( + fill_query_params(kwargs.pop("path"), sellerFulfillmentOrderId), data=kwargs + ) + + @sp_endpoint("/fba/outbound/2020-07-01/fulfillmentOrders/{}/cancel", method="PUT") + def cancel_fulfillment_order( + self, sellerFulfillmentOrderId, **kwargs + ) -> ApiResponse: """ cancel_fulfillment_order(self, sellerFulfillmentOrderId, **kwargs) -> ApiResponse @@ -632,16 +636,17 @@ def cancel_fulfillment_order(self, sellerFulfillmentOrderId, **kwargs) -> ApiRes Args: sellerFulfillmentOrderId:string | * REQUIRED The identifier assigned to the item by the seller when the fulfillment order was created. - + Returns: ApiResponse: """ - - return self._request(fill_query_params(kwargs.pop('path'), sellerFulfillmentOrderId), data=kwargs) - - @sp_endpoint('/fba/outbound/2020-07-01/features', method='GET') + return self._request( + fill_query_params(kwargs.pop("path"), sellerFulfillmentOrderId), data=kwargs + ) + + @sp_endpoint("/fba/outbound/2020-07-01/features", method="GET") def get_features(self, **kwargs) -> ApiResponse: """ get_features(self, **kwargs) -> ApiResponse @@ -665,11 +670,10 @@ def get_features(self, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - - return self._request(kwargs.pop('path'), params=kwargs) - - @sp_endpoint('/fba/outbound/2020-07-01/features/inventory/{}', method='GET') + return self._request(kwargs.pop("path"), params=kwargs) + + @sp_endpoint("/fba/outbound/2020-07-01/features/inventory/{}", method="GET") def get_feature_inventory(self, featureName, **kwargs) -> ApiResponse: """ get_feature_inventory(self, featureName, **kwargs) -> ApiResponse @@ -694,11 +698,12 @@ def get_feature_inventory(self, featureName, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - - return self._request(fill_query_params(kwargs.pop('path'), featureName), params=kwargs) - - @sp_endpoint('/fba/outbound/2020-07-01/features/inventory/{}', method='GET') + return self._request( + fill_query_params(kwargs.pop("path"), featureName), params=kwargs + ) + + @sp_endpoint("/fba/outbound/2020-07-01/features/inventory/{}", method="GET") def get_feature_s_k_u(self, featureName, **kwargs) -> ApiResponse: """ get_feature_s_k_u(self, featureName, **kwargs) -> ApiResponse @@ -724,6 +729,7 @@ def get_feature_s_k_u(self, featureName, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - - return self._request(fill_query_params(kwargs.pop('path'), featureName), params=kwargs) - + + return self._request( + fill_query_params(kwargs.pop("path"), featureName), params=kwargs + ) diff --git a/sp_api/api/inventories/inventories.py b/sp_api/api/inventories/inventories.py index a81d23efa..988d8051d 100644 --- a/sp_api/api/inventories/inventories.py +++ b/sp_api/api/inventories/inventories.py @@ -10,7 +10,7 @@ class Inventories(Client): :link: https://github.com/amzn/selling-partner-api-docs/blob/main/references/fba-inventory-api/fbaInventory.md#getinventorysummaries """ - @sp_endpoint('/fba/inventory/v1/summaries') + @sp_endpoint("/fba/inventory/v1/summaries") def get_inventory_summary_marketplace(self, **kwargs) -> ApiResponse: """ get_inventory_summary_marketplace(self, **kwargs) -> GetInventorySummariesResponse @@ -60,12 +60,19 @@ def get_inventory_summary_marketplace(self, **kwargs) -> ApiResponse: """ - kwargs.update({ - 'granularityType': kwargs.get('granularityType', InventoryGranularity.MARKETPLACE.value), - "granularityId": kwargs.get('granularityId', self.marketplace_id) - }) - if 'sellerSkus' in kwargs and isinstance(kwargs.get('sellerSkus'), abc.Iterable) and not isinstance(kwargs.get('sellerSkus'), str): - kwargs.update({'sellerSkus': ','.join(kwargs.get('sellerSkus'))}) - - return self._request(kwargs.pop('path'), params=kwargs) - + kwargs.update( + { + "granularityType": kwargs.get( + "granularityType", InventoryGranularity.MARKETPLACE.value + ), + "granularityId": kwargs.get("granularityId", self.marketplace_id), + } + ) + if ( + "sellerSkus" in kwargs + and isinstance(kwargs.get("sellerSkus"), abc.Iterable) + and not isinstance(kwargs.get("sellerSkus"), str) + ): + kwargs.update({"sellerSkus": ",".join(kwargs.get("sellerSkus"))}) + + return self._request(kwargs.pop("path"), params=kwargs) diff --git a/sp_api/api/listings_items/listings_items.py b/sp_api/api/listings_items/listings_items.py index 92f4561d2..26f99ce02 100644 --- a/sp_api/api/listings_items/listings_items.py +++ b/sp_api/api/listings_items/listings_items.py @@ -1,19 +1,25 @@ from collections import abc -from sp_api.base import Client, sp_endpoint, fill_query_params, ApiResponse, IncludedData +from sp_api.base import ( + Client, + sp_endpoint, + fill_query_params, + ApiResponse, + IncludedData, +) class ListingsItems(Client): """ - ListingsItems SP-API Client - :link: + ListingsItems SP-API Client + :link: - The Selling Partner API for Listings Items (Listings Items API) provides programmatic access to selling partner listings on Amazon. Use this API in collaboration with the Selling Partner API for Product Type Definitions, which you use to retrieve the information about Amazon product types needed to use the Listings Items API. + The Selling Partner API for Listings Items (Listings Items API) provides programmatic access to selling partner listings on Amazon. Use this API in collaboration with the Selling Partner API for Product Type Definitions, which you use to retrieve the information about Amazon product types needed to use the Listings Items API. -For more information, see the [Listings Items API Use Case Guide](https://github.com/amzn/selling-partner-api-docs/blob/main/guides/en-US/use-case-guides/listings-items-api-use-case-guide/listings-items-api-use-case-guide_2021-08-01.md). + For more information, see the [Listings Items API Use Case Guide](https://github.com/amzn/selling-partner-api-docs/blob/main/guides/en-US/use-case-guides/listings-items-api-use-case-guide/listings-items-api-use-case-guide_2021-08-01.md). """ - @sp_endpoint('/listings/2021-08-01/items/{}/{}', method='DELETE') + @sp_endpoint("/listings/2021-08-01/items/{}/{}", method="DELETE") def delete_listings_item(self, sellerId, sku, **kwargs) -> ApiResponse: """ delete_listings_item(self, sellerId, sku, **kwargs) -> ApiResponse @@ -34,9 +40,11 @@ def delete_listings_item(self, sellerId, sku, **kwargs) -> ApiResponse: ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), sellerId, sku), data=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), sellerId, sku), data=kwargs + ) - @sp_endpoint('/listings/2021-08-01/items/{}/{}', method='GET') + @sp_endpoint("/listings/2021-08-01/items/{}/{}", method="GET") def get_listings_item(self, sellerId, sku, **kwargs) -> ApiResponse: """ get_listings_item(self, sellerId, **kwargs) -> ApiResponse @@ -57,13 +65,23 @@ def get_listings_item(self, sellerId, sku, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - if kwargs.get('includedData') and isinstance(kwargs.get('includedData'), abc.Iterable) and not isinstance(kwargs.get('includedData'), str): - kwargs['includedData'] = ','.join( - [x.value if isinstance(x, IncludedData) else x for x in kwargs['includedData']]) - - return self._request(fill_query_params(kwargs.pop('path'), sellerId, sku), params=kwargs) - - @sp_endpoint('/listings/2021-08-01/items/{}', method='GET') + if ( + kwargs.get("includedData") + and isinstance(kwargs.get("includedData"), abc.Iterable) + and not isinstance(kwargs.get("includedData"), str) + ): + kwargs["includedData"] = ",".join( + [ + x.value if isinstance(x, IncludedData) else x + for x in kwargs["includedData"] + ] + ) + + return self._request( + fill_query_params(kwargs.pop("path"), sellerId, sku), params=kwargs + ) + + @sp_endpoint("/listings/2021-08-01/items/{}", method="GET") def search_listings_items(self, sellerId, **kwargs) -> ApiResponse: """ search_listings_items(self, sellerId, **kwargs) -> ApiResponse @@ -83,13 +101,23 @@ def search_listings_items(self, sellerId, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - if kwargs.get('includedData') and isinstance(kwargs.get('includedData'), abc.Iterable) and not isinstance(kwargs.get('includedData'), str): - kwargs['includedData'] = ','.join( - [x.value if isinstance(x, IncludedData) else x for x in kwargs['includedData']]) - - return self._request(fill_query_params(kwargs.pop('path'), sellerId), params=kwargs) - - @sp_endpoint('/listings/2021-08-01/items/{}/{}', method='PATCH') + if ( + kwargs.get("includedData") + and isinstance(kwargs.get("includedData"), abc.Iterable) + and not isinstance(kwargs.get("includedData"), str) + ): + kwargs["includedData"] = ",".join( + [ + x.value if isinstance(x, IncludedData) else x + for x in kwargs["includedData"] + ] + ) + + return self._request( + fill_query_params(kwargs.pop("path"), sellerId), params=kwargs + ) + + @sp_endpoint("/listings/2021-08-01/items/{}/{}", method="PATCH") def patch_listings_item(self, sellerId, sku, **kwargs) -> ApiResponse: """ patch_listings_item(self, sellerId, sku, **kwargs) -> ApiResponse @@ -122,10 +150,13 @@ def patch_listings_item(self, sellerId, sku, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), sellerId, sku), data=kwargs.pop('body'), - params=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), sellerId, sku), + data=kwargs.pop("body"), + params=kwargs, + ) - @sp_endpoint('/listings/2021-08-01/items/{}/{}', method='PUT') + @sp_endpoint("/listings/2021-08-01/items/{}/{}", method="PUT") def put_listings_item(self, sellerId, sku, **kwargs) -> ApiResponse: """ put_listings_item(self, sellerId, sku, **kwargs) -> ApiResponse @@ -152,5 +183,8 @@ def put_listings_item(self, sellerId, sku, **kwargs) -> ApiResponse: ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), sellerId, sku), data=kwargs.pop('body'), - params=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), sellerId, sku), + data=kwargs.pop("body"), + params=kwargs, + ) diff --git a/sp_api/api/listings_restrictions/listings_restrictions.py b/sp_api/api/listings_restrictions/listings_restrictions.py index 043d336d1..aa4d50431 100644 --- a/sp_api/api/listings_restrictions/listings_restrictions.py +++ b/sp_api/api/listings_restrictions/listings_restrictions.py @@ -12,25 +12,24 @@ class ListingsRestrictions(Client): For more information, see the [Listings Restrictions API Use Case Guide](https://github.com/amzn/selling-partner-api-docs/blob/main/guides/en-US/use-case-guides/listings-restrictions-api-use-case-guide/listings-restrictions-api-use-case-guide_2021-08-01.md). """ - @sp_endpoint('/listings/2021-08-01/restrictions', method='GET') + @sp_endpoint("/listings/2021-08-01/restrictions", method="GET") def get_listings_restrictions(self, **kwargs) -> ApiResponse: """ get_listings_restrictions(self, **kwargs) -> ApiResponse - Returns listing restrictions for an item in the Amazon Catalog. + Returns listing restrictions for an item in the Amazon Catalog. Args: - + key asin:string | * REQUIRED The Amazon Standard Identification Number (ASIN) of the item. key conditionType:string | The condition used to filter restrictions. key sellerId:string | * REQUIRED A selling partner identifier, such as a merchant account. key marketplaceIds:array | * REQUIRED A comma-delimited list of Amazon marketplace identifiers for the request. key reasonLocale:string | A locale for reason text localization. When not provided, the default language code of the first marketplace is used. Examples: "en_US", "fr_CA", "fr_FR". Localized messages default to "en_US" when a localization is not available in the specified locale. - + Returns: ApiResponse """ - - return self._request(kwargs.pop('path'), params=kwargs) - + + return self._request(kwargs.pop("path"), params=kwargs) diff --git a/sp_api/api/merchant_fulfillment/merchant_fulfillment.py b/sp_api/api/merchant_fulfillment/merchant_fulfillment.py index 886ad0a76..33ec22e55 100644 --- a/sp_api/api/merchant_fulfillment/merchant_fulfillment.py +++ b/sp_api/api/merchant_fulfillment/merchant_fulfillment.py @@ -1,15 +1,16 @@ - from sp_api.base import Client, sp_endpoint, fill_query_params, ApiResponse class MerchantFulfillment(Client): """ - :link: https://github.com/amzn/selling-partner-api-docs/blob/main/references/merchant-fulfillment-api/merchantFulfillmentV0.md + :link: https://github.com/amzn/selling-partner-api-docs/blob/main/references/merchant-fulfillment-api/merchantFulfillmentV0.md """ - @sp_endpoint("/mfn/v0/eligibleServices", method='POST') - def get_eligible_shipment_services_old(self, shipment_request_details: dict, **kwargs) -> ApiResponse: + @sp_endpoint("/mfn/v0/eligibleServices", method="POST") + def get_eligible_shipment_services_old( + self, shipment_request_details: dict, **kwargs + ) -> ApiResponse: """ get_eligible_shipment_services_old(self, shipment_request_details: dict, **kwargs) -> ApiResponse Returns a list of shipping service offers that satisfy the specified shipment request details. @@ -69,15 +70,14 @@ def get_eligible_shipment_services_old(self, shipment_request_details: dict, **k GetEligibleShipmentServicesResponse: """ # GetEligibleShipmentServicesRequest - data = { - "ShipmentRequestDetails": shipment_request_details, - **kwargs - } + data = {"ShipmentRequestDetails": shipment_request_details, **kwargs} - return self._request(kwargs.pop('path'), data=data) + return self._request(kwargs.pop("path"), data=data) - @sp_endpoint("/mfn/v0/eligibleShippingServices", method='POST') - def get_eligible_shipment_services(self, shipment_request_details: dict, **kwargs) -> ApiResponse: + @sp_endpoint("/mfn/v0/eligibleShippingServices", method="POST") + def get_eligible_shipment_services( + self, shipment_request_details: dict, **kwargs + ) -> ApiResponse: """ get_eligible_shipment_services(self, shipment_request_details: dict, **kwargs) -> ApiResponse Returns a list of shipping service offers that satisfy the specified shipment request details. @@ -138,12 +138,9 @@ def get_eligible_shipment_services(self, shipment_request_details: dict, **kwarg """ # GetEligibleShipmentServicesRequest - data = { - "ShipmentRequestDetails": shipment_request_details, - **kwargs - } + data = {"ShipmentRequestDetails": shipment_request_details, **kwargs} - return self._request(kwargs.pop('path'), data=data) + return self._request(kwargs.pop("path"), data=data) @sp_endpoint("/mfn/v0/shipments/{}") def get_shipment(self, shipment_id: str, **kwargs) -> ApiResponse: @@ -172,9 +169,13 @@ def get_shipment(self, shipment_id: str, **kwargs) -> ApiResponse: Returns: GetShipmentResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), shipment_id), params=kwargs, add_marketplace=False) + return self._request( + fill_query_params(kwargs.pop("path"), shipment_id), + params=kwargs, + add_marketplace=False, + ) - @sp_endpoint("/mfn/v0/shipments/{}", method='DELETE') + @sp_endpoint("/mfn/v0/shipments/{}", method="DELETE") def cancel_shipment(self, shipment_id: str, **kwargs) -> ApiResponse: """ cancel_shipment(self, shipment_id: str, **kwargs) -> ApiResponse @@ -196,9 +197,13 @@ def cancel_shipment(self, shipment_id: str, **kwargs) -> ApiResponse: Returns: CancelShipmentResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), shipment_id), params=kwargs, add_marketplace=False) + return self._request( + fill_query_params(kwargs.pop("path"), shipment_id), + params=kwargs, + add_marketplace=False, + ) - @sp_endpoint("/mfn/v0/shipments/{}/cancel", method='PUT') + @sp_endpoint("/mfn/v0/shipments/{}/cancel", method="PUT") def cancel_shipment_old(self, shipment_id: str, **kwargs) -> ApiResponse: """ cancel_shipment_old(self, shipment_id: str, **kwargs) -> ApiResponse @@ -220,10 +225,16 @@ def cancel_shipment_old(self, shipment_id: str, **kwargs) -> ApiResponse: Returns: CancelShipmentResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), shipment_id), params=kwargs, add_marketplace=False) - - @sp_endpoint("/mfn/v0/shipments", method='POST') - def create_shipment(self, shipment_request_details: dict, shipping_service_id: str, **kwargs) -> ApiResponse: + return self._request( + fill_query_params(kwargs.pop("path"), shipment_id), + params=kwargs, + add_marketplace=False, + ) + + @sp_endpoint("/mfn/v0/shipments", method="POST") + def create_shipment( + self, shipment_request_details: dict, shipping_service_id: str, **kwargs + ) -> ApiResponse: """ create_shipment(self, shipment_request_details: dict, shipping_service_id: str, **kwargs) -> ApiResponse Create a shipment with the information provided. @@ -295,13 +306,14 @@ def create_shipment(self, shipment_request_details: dict, shipping_service_id: s data = { "ShipmentRequestDetails": shipment_request_details, "ShippingServiceId": shipping_service_id, - **kwargs + **kwargs, } - return self._request(kwargs.pop('path'), data=data, add_marketplace=False) + return self._request(kwargs.pop("path"), data=data, add_marketplace=False) - @sp_endpoint("/mfn/v0/sellerInputs", method='POST') - def get_additional_seller_inputs_old(self, shipping_service_id: str, ship_from_address: dict, - order_id: str, **kwargs) -> ApiResponse: + @sp_endpoint("/mfn/v0/sellerInputs", method="POST") + def get_additional_seller_inputs_old( + self, shipping_service_id: str, ship_from_address: dict, order_id: str, **kwargs + ) -> ApiResponse: """ get_additional_seller_inputs_old(self, shipping_service_id: str, ship_from_address: dict, order_id: str, **kwargs) -> ApiResponse @@ -330,13 +342,14 @@ def get_additional_seller_inputs_old(self, shipping_service_id: str, ship_from_ data = { "ShippingServiceId": shipping_service_id, "ShipFromAddress": ship_from_address, - "OrderId": order_id + "OrderId": order_id, } - return self._request(kwargs.pop('path'), data=data, add_marketplace=False) + return self._request(kwargs.pop("path"), data=data, add_marketplace=False) - @sp_endpoint("/mfn/v0/additionalSellerInputs", method='POST') - def get_additional_seller_inputs(self, shipping_service_id: str, ship_from_address: dict, - order_id: str, **kwargs) -> ApiResponse: + @sp_endpoint("/mfn/v0/additionalSellerInputs", method="POST") + def get_additional_seller_inputs( + self, shipping_service_id: str, ship_from_address: dict, order_id: str, **kwargs + ) -> ApiResponse: """ get_additional_seller_inputs(self, shipping_service_id: str, ship_from_address: dict, order_id: str, **kwargs) -> ApiResponse @@ -365,6 +378,6 @@ def get_additional_seller_inputs(self, shipping_service_id: str, ship_from_addre data = { "ShippingServiceId": shipping_service_id, "ShipFromAddress": ship_from_address, - "OrderId": order_id + "OrderId": order_id, } - return self._request(kwargs.pop('path'), data=data, add_marketplace=False) + return self._request(kwargs.pop("path"), data=data, add_marketplace=False) diff --git a/sp_api/api/messaging/messaging.py b/sp_api/api/messaging/messaging.py index 7fc6d23fb..5e8ea6446 100644 --- a/sp_api/api/messaging/messaging.py +++ b/sp_api/api/messaging/messaging.py @@ -6,12 +6,12 @@ class Messaging(Client): """ Messaging SP-API Client - :link: + :link: With the Messaging API you can build applications that send messages to buyers. You can get a list of message types that are available for an order that you specify, then call an operation that sends a message to the buyer for that order. The Messaging API returns responses that are formed according to the JSON Hypertext Application Language (HAL) standard. """ - @sp_endpoint('/messaging/v1/orders/{}', method='GET') + @sp_endpoint("/messaging/v1/orders/{}", method="GET") def get_messaging_actions_for_order(self, order_id, **kwargs) -> ApiResponse: """ get_messaging_actions_for_order(self, order_id, **kwargs) -> ApiResponse @@ -36,9 +36,13 @@ def get_messaging_actions_for_order(self, order_id, **kwargs) -> ApiResponse: ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), order_id), params=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), order_id), params=kwargs + ) - @sp_endpoint('/messaging/v1/orders/{}/messages/confirmCustomizationDetails', method='POST') + @sp_endpoint( + "/messaging/v1/orders/{}/messages/confirmCustomizationDetails", method="POST" + ) def confirm_customization_details(self, order_id, **kwargs) -> ApiResponse: """ confirm_customization_details(self, order_id, **kwargs) -> ApiResponse @@ -72,10 +76,17 @@ def confirm_customization_details(self, order_id, **kwargs) -> ApiResponse: """ return self._request( - fill_query_params(kwargs.pop('path'), order_id), data=kwargs.pop("body"), params={"marketplaceIds": self.marketplace_id, "method": kwargs.pop('method')} + fill_query_params(kwargs.pop("path"), order_id), + data=kwargs.pop("body"), + params={ + "marketplaceIds": self.marketplace_id, + "method": kwargs.pop("method"), + }, ) - @sp_endpoint('/messaging/v1/orders/{}/messages/confirmDeliveryDetails', method='POST') + @sp_endpoint( + "/messaging/v1/orders/{}/messages/confirmDeliveryDetails", method="POST" + ) def create_confirm_delivery_details(self, order_id, **kwargs) -> ApiResponse: """ create_confirm_delivery_details(self, order_id, **kwargs) -> ApiResponse @@ -104,10 +115,15 @@ def create_confirm_delivery_details(self, order_id, **kwargs) -> ApiResponse: """ return self._request( - fill_query_params(kwargs.pop('path'), order_id), data=kwargs.pop("body"), params={"marketplaceIds": self.marketplace_id, "method": kwargs.pop('method')} + fill_query_params(kwargs.pop("path"), order_id), + data=kwargs.pop("body"), + params={ + "marketplaceIds": self.marketplace_id, + "method": kwargs.pop("method"), + }, ) - @sp_endpoint('/messaging/v1/orders/{}/messages/legalDisclosure', method='POST') + @sp_endpoint("/messaging/v1/orders/{}/messages/legalDisclosure", method="POST") def create_legal_disclosure(self, order_id, **kwargs) -> ApiResponse: """ create_legal_disclosure(self, order_id, **kwargs) -> ApiResponse @@ -141,10 +157,17 @@ def create_legal_disclosure(self, order_id, **kwargs) -> ApiResponse: """ return self._request( - fill_query_params(kwargs.pop('path'), order_id), data=kwargs.pop("body"), params={"marketplaceIds": self.marketplace_id, "method": kwargs.pop('method')} + fill_query_params(kwargs.pop("path"), order_id), + data=kwargs.pop("body"), + params={ + "marketplaceIds": self.marketplace_id, + "method": kwargs.pop("method"), + }, ) - @sp_endpoint('/messaging/v1/orders/{}/messages/negativeFeedbackRemoval', method='POST') + @sp_endpoint( + "/messaging/v1/orders/{}/messages/negativeFeedbackRemoval", method="POST" + ) def create_negative_feedback_removal(self, order_id, **kwargs) -> ApiResponse: """ create_negative_feedback_removal(self, order_id, **kwargs) -> ApiResponse @@ -169,10 +192,15 @@ def create_negative_feedback_removal(self, order_id, **kwargs) -> ApiResponse: """ return self._request( - fill_query_params(kwargs.pop('path'), order_id), data=kwargs.pop("body"), params={"marketplaceIds": self.marketplace_id, "method": kwargs.pop('method')} + fill_query_params(kwargs.pop("path"), order_id), + data=kwargs.pop("body"), + params={ + "marketplaceIds": self.marketplace_id, + "method": kwargs.pop("method"), + }, ) - @sp_endpoint('/messaging/v1/orders/{}/messages/confirmOrderDetails', method='POST') + @sp_endpoint("/messaging/v1/orders/{}/messages/confirmOrderDetails", method="POST") def create_confirm_order_details(self, order_id, **kwargs) -> ApiResponse: """ create_confirm_order_details(self, order_id, **kwargs) -> ApiResponse @@ -200,10 +228,17 @@ def create_confirm_order_details(self, order_id, **kwargs) -> ApiResponse: """ return self._request( - fill_query_params(kwargs.pop('path'), order_id), data=kwargs.pop("body"), params={"marketplaceIds": self.marketplace_id, "method": kwargs.pop('method')} + fill_query_params(kwargs.pop("path"), order_id), + data=kwargs.pop("body"), + params={ + "marketplaceIds": self.marketplace_id, + "method": kwargs.pop("method"), + }, ) - @sp_endpoint('/messaging/v1/orders/{}/messages/confirmServiceDetails', method='POST') + @sp_endpoint( + "/messaging/v1/orders/{}/messages/confirmServiceDetails", method="POST" + ) def create_confirm_service_details(self, order_id, **kwargs) -> ApiResponse: """ create_confirm_service_details(self, order_id, **kwargs) -> ApiResponse @@ -232,10 +267,15 @@ def create_confirm_service_details(self, order_id, **kwargs) -> ApiResponse: """ return self._request( - fill_query_params(kwargs.pop('path'), order_id), data=kwargs.pop("body"), params={"marketplaceIds": self.marketplace_id, "method": kwargs.pop('method')} + fill_query_params(kwargs.pop("path"), order_id), + data=kwargs.pop("body"), + params={ + "marketplaceIds": self.marketplace_id, + "method": kwargs.pop("method"), + }, ) - @sp_endpoint('/messaging/v1/orders/{}/messages/amazonMotors', method='POST') + @sp_endpoint("/messaging/v1/orders/{}/messages/amazonMotors", method="POST") def create_amazon_motors(self, order_id, **kwargs) -> ApiResponse: """ create_amazon_motors(self, order_id, **kwargs) -> ApiResponse @@ -269,10 +309,15 @@ def create_amazon_motors(self, order_id, **kwargs) -> ApiResponse: """ return self._request( - fill_query_params(kwargs.pop('path'), order_id), data=kwargs.pop("body"), params={"marketplaceIds": self.marketplace_id, "method": kwargs.pop('method')} + fill_query_params(kwargs.pop("path"), order_id), + data=kwargs.pop("body"), + params={ + "marketplaceIds": self.marketplace_id, + "method": kwargs.pop("method"), + }, ) - @sp_endpoint('/messaging/v1/orders/{}/messages/warranty', method='POST') + @sp_endpoint("/messaging/v1/orders/{}/messages/warranty", method="POST") def create_warranty(self, order_id, **kwargs) -> ApiResponse: """ create_warranty(self, order_id, **kwargs) -> ApiResponse @@ -309,10 +354,15 @@ def create_warranty(self, order_id, **kwargs) -> ApiResponse: """ return self._request( - fill_query_params(kwargs.pop('path'), order_id), data=kwargs.pop("body"), params={"marketplaceIds": self.marketplace_id, "method": kwargs.pop('method')} + fill_query_params(kwargs.pop("path"), order_id), + data=kwargs.pop("body"), + params={ + "marketplaceIds": self.marketplace_id, + "method": kwargs.pop("method"), + }, ) - @sp_endpoint('/messaging/v1/orders/{}/attributes', method='GET') + @sp_endpoint("/messaging/v1/orders/{}/attributes", method="GET") def get_attributes(self, order_id, **kwargs) -> ApiResponse: """ get_attributes(self, order_id, **kwargs) -> ApiResponse @@ -334,9 +384,11 @@ def get_attributes(self, order_id, **kwargs) -> ApiResponse: ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), order_id), params=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), order_id), params=kwargs + ) - @sp_endpoint('/messaging/v1/orders/{}/messages/digitalAccessKey', method='POST') + @sp_endpoint("/messaging/v1/orders/{}/messages/digitalAccessKey", method="POST") def create_digital_access_key(self, order_id, **kwargs) -> ApiResponse: """ create_digital_access_key(self, order_id, **kwargs) -> ApiResponse @@ -371,10 +423,15 @@ def create_digital_access_key(self, order_id, **kwargs) -> ApiResponse: """ return self._request( - fill_query_params(kwargs.pop('path'), order_id), data=kwargs.pop("body"), params={"marketplaceIds": self.marketplace_id, "method": kwargs.pop('method')} + fill_query_params(kwargs.pop("path"), order_id), + data=kwargs.pop("body"), + params={ + "marketplaceIds": self.marketplace_id, + "method": kwargs.pop("method"), + }, ) - @sp_endpoint('/messaging/v1/orders/{}/messages/unexpectedProblem', method='POST') + @sp_endpoint("/messaging/v1/orders/{}/messages/unexpectedProblem", method="POST") def create_unexpected_problem(self, order_id, **kwargs) -> ApiResponse: """ create_unexpected_problem(self, order_id, **kwargs) -> ApiResponse @@ -402,5 +459,10 @@ def create_unexpected_problem(self, order_id, **kwargs) -> ApiResponse: """ return self._request( - fill_query_params(kwargs.pop('path'), order_id), data=kwargs.pop("body"), params={"marketplaceIds": self.marketplace_id, "method": kwargs.pop('method')} + fill_query_params(kwargs.pop("path"), order_id), + data=kwargs.pop("body"), + params={ + "marketplaceIds": self.marketplace_id, + "method": kwargs.pop("method"), + }, ) diff --git a/sp_api/api/notifications/notifications.py b/sp_api/api/notifications/notifications.py index 18573d146..4b78b3b9d 100644 --- a/sp_api/api/notifications/notifications.py +++ b/sp_api/api/notifications/notifications.py @@ -6,16 +6,21 @@ class Notifications(Client): """ :link: https://github.com/amzn/selling-partner-api-docs/blob/main/references/notifications-api/notifications.md """ - grantless_scope = 'sellingpartnerapi::notifications' + + grantless_scope = "sellingpartnerapi::notifications" @deprecated def add_subscription(self, notification_type: NotificationType or str, **kwargs): """deprecated, use create_subscription""" return self.create_subscription(notification_type, **kwargs) - @sp_endpoint('/notifications/v1/subscriptions/{}', method='POST') - def create_subscription(self, notification_type: NotificationType or str, destination_id: str = None, - **kwargs) -> ApiResponse: + @sp_endpoint("/notifications/v1/subscriptions/{}", method="POST") + def create_subscription( + self, + notification_type: NotificationType or str, + destination_id: str = None, + **kwargs + ) -> ApiResponse: """ create_subscription(self, notification_type: NotificationType or str, destination_id: str = None, **kwargs) -> ApiResponse Creates a subscription for the specified notification type to be delivered to the specified destination. @@ -47,16 +52,25 @@ def create_subscription(self, notification_type: NotificationType or str, destin """ data = { - 'destinationId': kwargs.pop('destinationId', destination_id), - 'payloadVersion': kwargs.pop('payload_version', '1.0') + "destinationId": kwargs.pop("destinationId", destination_id), + "payloadVersion": kwargs.pop("payload_version", "1.0"), } - return self._request(fill_query_params(kwargs.pop('path'), - notification_type if isinstance(notification_type, - str) else notification_type.value), - data={**kwargs, **data}) - - @sp_endpoint('/notifications/v1/subscriptions/{}') - def get_subscription(self, notification_type: NotificationType or str, **kwargs) -> ApiResponse: + return self._request( + fill_query_params( + kwargs.pop("path"), + ( + notification_type + if isinstance(notification_type, str) + else notification_type.value + ), + ), + data={**kwargs, **data}, + ) + + @sp_endpoint("/notifications/v1/subscriptions/{}") + def get_subscription( + self, notification_type: NotificationType or str, **kwargs + ) -> ApiResponse: """ get_subscription(self, notification_type: NotificationType or str, **kwargs) -> ApiResponse Returns information about subscriptions of the specified notification type. You can use this API to get subscription information when you do not have a subscription identifier. @@ -84,13 +98,22 @@ def get_subscription(self, notification_type: NotificationType or str, **kwargs) ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), notification_type if isinstance(notification_type, - str) else notification_type.value), - params={**kwargs}) - - @sp_endpoint('/notifications/v1/subscriptions/{}/{}', method='DELETE') - def delete_notification_subscription(self, notification_type: NotificationType or str, subscription_id: str, - **kwargs) -> ApiResponse: + return self._request( + fill_query_params( + kwargs.pop("path"), + ( + notification_type + if isinstance(notification_type, str) + else notification_type.value + ), + ), + params={**kwargs}, + ) + + @sp_endpoint("/notifications/v1/subscriptions/{}/{}", method="DELETE") + def delete_notification_subscription( + self, notification_type: NotificationType or str, subscription_id: str, **kwargs + ) -> ApiResponse: """ delete_notification_subscription(self, notification_type: NotificationType or str, subscription_id: str, **kwargs) -> ApiResponse Deletes the subscription indicated by the subscription identifier and notification type that you specify. @@ -119,13 +142,27 @@ def delete_notification_subscription(self, notification_type: NotificationType o """ return self._request( - fill_query_params(kwargs.pop('path'), - notification_type if isinstance(notification_type, str) else notification_type.value, - subscription_id), - params={**kwargs}) - - @sp_endpoint(path='/notifications/v1/destinations', method='POST') - def create_destination(self, name: str, arn: str = None, account_id: str = None, region: str = None, **kwargs) -> ApiResponse: + fill_query_params( + kwargs.pop("path"), + ( + notification_type + if isinstance(notification_type, str) + else notification_type.value + ), + subscription_id, + ), + params={**kwargs}, + ) + + @sp_endpoint(path="/notifications/v1/destinations", method="POST") + def create_destination( + self, + name: str, + arn: str = None, + account_id: str = None, + region: str = None, + **kwargs + ) -> ApiResponse: """ create_destination(self, name: str, arn: str, **kwargs) -> ApiResponse Creates a destination resource to receive notifications. The createDestination API is grantless. For more information, see "Grantless operations" in the Selling Partner API Developer Guide. @@ -154,24 +191,25 @@ def create_destination(self, name: str, arn: str = None, account_id: str = None, ApiResponse: """ - resource_name = 'sqs' if not account_id else 'eventBridge' + resource_name = "sqs" if not account_id else "eventBridge" region = region if region else self.region data = { - 'resourceSpecification': { - resource_name: { - 'arn': arn - } if not account_id else { - 'region': region, - 'accountId': account_id - } + "resourceSpecification": { + resource_name: ( + {"arn": arn} + if not account_id + else {"region": region, "accountId": account_id} + ) }, - 'name': name, + "name": name, } - return self._request_grantless_operation(kwargs.pop('path'), data={**kwargs, **data}) + return self._request_grantless_operation( + kwargs.pop("path"), data={**kwargs, **data} + ) - @sp_endpoint('/notifications/v1/destinations', method='GET') + @sp_endpoint("/notifications/v1/destinations", method="GET") def get_destinations(self, **kwargs) -> ApiResponse: """ get_destinations(self, **kwargs) -> ApiResponse @@ -195,9 +233,9 @@ def get_destinations(self, **kwargs) -> ApiResponse: ApiResponse: """ - return self._request_grantless_operation(kwargs.pop('path'), params={**kwargs}) + return self._request_grantless_operation(kwargs.pop("path"), params={**kwargs}) - @sp_endpoint('/notifications/v1/destinations/{}', method='GET') + @sp_endpoint("/notifications/v1/destinations/{}", method="GET") def get_destination(self, destination_id: str, **kwargs) -> ApiResponse: """ get_destination(self, destination_id: str, **kwargs) -> ApiResponse @@ -223,10 +261,11 @@ def get_destination(self, destination_id: str, **kwargs) -> ApiResponse: """ - return self._request_grantless_operation(fill_query_params(kwargs.pop('path'), destination_id), - params={**kwargs}) + return self._request_grantless_operation( + fill_query_params(kwargs.pop("path"), destination_id), params={**kwargs} + ) - @sp_endpoint('/notifications/v1/destinations/{}', method='DELETE') + @sp_endpoint("/notifications/v1/destinations/{}", method="DELETE") def delete_destination(self, destination_id: str, **kwargs) -> ApiResponse: """ delete_destination(self, destination_id: str, **kwargs) -> ApiResponse @@ -250,5 +289,6 @@ def delete_destination(self, destination_id: str, **kwargs) -> ApiResponse: ApiResponse: """ - return self._request_grantless_operation(fill_query_params(kwargs.pop('path'), destination_id), - params={**kwargs}) + return self._request_grantless_operation( + fill_query_params(kwargs.pop("path"), destination_id), params={**kwargs} + ) diff --git a/sp_api/api/orders/orders.py b/sp_api/api/orders/orders.py index c920abe6e..681155e7e 100644 --- a/sp_api/api/orders/orders.py +++ b/sp_api/api/orders/orders.py @@ -7,7 +7,7 @@ class Orders(Client): :link: https://github.com/amzn/selling-partner-api-docs/tree/main/references/orders-api """ - @sp_endpoint('/orders/v0/orders') + @sp_endpoint("/orders/v0/orders") def get_orders(self, **kwargs) -> ApiResponse: """ get_orders(self, **kwargs) -> ApiResponse @@ -53,11 +53,11 @@ def get_orders(self, **kwargs) -> ApiResponse: """ - if 'RestrictedResources' in kwargs: + if "RestrictedResources" in kwargs: return self._access_restricted(kwargs) - return self._request(kwargs.pop('path'), params={**kwargs}) + return self._request(kwargs.pop("path"), params={**kwargs}) - @sp_endpoint('/orders/v0/orders/{}') + @sp_endpoint("/orders/v0/orders/{}") def get_order(self, order_id: str, **kwargs) -> ApiResponse: """ get_order(self, order_id: str, **kwargs) -> ApiResponse @@ -89,12 +89,18 @@ def get_order(self, order_id: str, **kwargs) -> ApiResponse: """ - if 'RestrictedResources' in kwargs: - kwargs.update({'original_path': fill_query_params(kwargs.get('path'), order_id)}) + if "RestrictedResources" in kwargs: + kwargs.update( + {"original_path": fill_query_params(kwargs.get("path"), order_id)} + ) return self._access_restricted(kwargs) - return self._request(fill_query_params(kwargs.pop('path'), order_id), params={**kwargs}, add_marketplace=False) + return self._request( + fill_query_params(kwargs.pop("path"), order_id), + params={**kwargs}, + add_marketplace=False, + ) - @sp_endpoint('/orders/v0/orders/{}/orderItems') + @sp_endpoint("/orders/v0/orders/{}/orderItems") def get_order_items(self, order_id: str, **kwargs) -> ApiResponse: """ get_order_items(self, order_id: str, **kwargs) -> ApiResponse @@ -136,12 +142,16 @@ def get_order_items(self, order_id: str, **kwargs) -> ApiResponse: ApiResponse: """ - if 'RestrictedResources' in kwargs: - kwargs.update({'original_path': fill_query_params(kwargs.get('path'), order_id)}) + if "RestrictedResources" in kwargs: + kwargs.update( + {"original_path": fill_query_params(kwargs.get("path"), order_id)} + ) return self._access_restricted(kwargs) - return self._request(fill_query_params(kwargs.pop('path'), order_id), params={**kwargs}) + return self._request( + fill_query_params(kwargs.pop("path"), order_id), params={**kwargs} + ) - @sp_endpoint('/orders/v0/orders/{}/address') + @sp_endpoint("/orders/v0/orders/{}/address") def get_order_address(self, order_id, **kwargs) -> ApiResponse: """ get_order_address(self, order_id, **kwargs) -> ApiResponse @@ -168,9 +178,11 @@ def get_order_address(self, order_id, **kwargs) -> ApiResponse: Returns: ApiResponse """ - return self._request(fill_query_params(kwargs.pop('path'), order_id), params={**kwargs}) + return self._request( + fill_query_params(kwargs.pop("path"), order_id), params={**kwargs} + ) - @sp_endpoint('/orders/v0/orders/{}/buyerInfo') + @sp_endpoint("/orders/v0/orders/{}/buyerInfo") def get_order_buyer_info(self, order_id: str, **kwargs) -> ApiResponse: """ get_order_buyer_info(self, order_id: str, **kwargs) -> ApiResponse @@ -201,9 +213,11 @@ def get_order_buyer_info(self, order_id: str, **kwargs) -> ApiResponse: GetOrderBuyerInfoResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), order_id), params={**kwargs}) + return self._request( + fill_query_params(kwargs.pop("path"), order_id), params={**kwargs} + ) - @sp_endpoint('/orders/v0/orders/{}/orderItems/buyerInfo') + @sp_endpoint("/orders/v0/orders/{}/orderItems/buyerInfo") def get_order_items_buyer_info(self, order_id: str, **kwargs) -> ApiResponse: """ get_order_items_buyer_info(self, order_id: str, **kwargs) -> ApiResponse @@ -232,9 +246,11 @@ def get_order_items_buyer_info(self, order_id: str, **kwargs) -> ApiResponse: Returns: ApiResponse """ - return self._request(fill_query_params(kwargs.pop('path'), order_id), params=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), order_id), params=kwargs + ) - @sp_endpoint('/orders/v0/orders/{}/shipment', method='POST') + @sp_endpoint("/orders/v0/orders/{}/shipment", method="POST") def update_shipment_status(self, order_id: str, **kwargs) -> ApiResponse: """ update_shipment_status(self, order_id: str, **kwargs) -> ApiResponse @@ -258,9 +274,13 @@ def update_shipment_status(self, order_id: str, **kwargs) -> ApiResponse: Returns: ApiResponse """ - return self._request(fill_query_params(kwargs.pop('path'), order_id), res_no_data=True, data=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), order_id), + res_no_data=True, + data=kwargs, + ) - @sp_endpoint('/orders/v0/orders/{}/shipmentConfirmation', method='POST') + @sp_endpoint("/orders/v0/orders/{}/shipmentConfirmation", method="POST") def confirm_shipment(self, order_id: str, **kwargs) -> ApiResponse: """ confirm_shipment(self, order_id: str, **kwargs) -> ApiResponse @@ -300,27 +320,36 @@ def confirm_shipment(self, order_id: str, **kwargs) -> ApiResponse: Returns: ApiResponse """ - return self._request(fill_query_params(kwargs.pop('path'), order_id), add_marketplace=False, res_no_data=True, - data=kwargs) - - @sp_endpoint('/tokens/2021-03-01/restrictedDataToken', method='POST') + return self._request( + fill_query_params(kwargs.pop("path"), order_id), + add_marketplace=False, + res_no_data=True, + data=kwargs, + ) + + @sp_endpoint("/tokens/2021-03-01/restrictedDataToken", method="POST") def _get_token(self, **kwargs): - data_elements = kwargs.pop('RestrictedResources') + data_elements = kwargs.pop("RestrictedResources") - restricted_resources = [{ - "method": "GET", - "path": kwargs.get('original_path'), - "dataElements": data_elements - }] + restricted_resources = [ + { + "method": "GET", + "path": kwargs.get("original_path"), + "dataElements": data_elements, + } + ] - return self._request(kwargs.pop('path'), data={'restrictedResources': restricted_resources, **kwargs}) + return self._request( + kwargs.pop("path"), + data={"restrictedResources": restricted_resources, **kwargs}, + ) def _access_restricted(self, kwargs): - if 'original_path' not in kwargs: - kwargs.update({'original_path': kwargs['path']}) + if "original_path" not in kwargs: + kwargs.update({"original_path": kwargs["path"]}) token = self._get_token(**kwargs).payload - self.restricted_data_token = token['restrictedDataToken'] - r = self._request(kwargs.pop('original_path'), params={**kwargs}) + self.restricted_data_token = token["restrictedDataToken"] + r = self._request(kwargs.pop("original_path"), params={**kwargs}) if not self.keep_restricted_data_token: self.restricted_data_token = None return r diff --git a/sp_api/api/product_fees/product_fees.py b/sp_api/api/product_fees/product_fees.py index 9b61ed3db..d53fb6ca6 100644 --- a/sp_api/api/product_fees/product_fees.py +++ b/sp_api/api/product_fees/product_fees.py @@ -10,11 +10,20 @@ class ProductFees(Client): :link: https://github.com/amzn/selling-partner-api-docs/tree/main/references/product-fees-api """ - @sp_endpoint('/products/fees/v0/listings/{}/feesEstimate', method='POST') - def get_product_fees_estimate_for_sku(self, seller_sku, price: float, shipping_price=None, currency='USD', - is_fba=False, points: dict = None, marketplace_id: str = None, - optional_fulfillment_program: str = None, force_safe_sku: bool = True, - **kwargs) -> ApiResponse: + @sp_endpoint("/products/fees/v0/listings/{}/feesEstimate", method="POST") + def get_product_fees_estimate_for_sku( + self, + seller_sku, + price: float, + shipping_price=None, + currency="USD", + is_fba=False, + points: dict = None, + marketplace_id: str = None, + optional_fulfillment_program: str = None, + force_safe_sku: bool = True, + **kwargs + ) -> ApiResponse: """ get_product_fees_estimate_for_sku(self, seller_sku, price: float, shipping_price=None, currency='USD', is_fba=False, points: dict = dict, **kwargs) -> ApiResponse @@ -50,17 +59,38 @@ def get_product_fees_estimate_for_sku(self, seller_sku, price: float, shipping_p """ if force_safe_sku: - #handle `forward slash` issue in SKU + # handle `forward slash` issue in SKU seller_sku = quote_plus(seller_sku) - kwargs.update(self._create_body(price, shipping_price, currency, is_fba, seller_sku, points, marketplace_id, optional_fulfillment_program)) - return self._request(fill_query_params(kwargs.pop('path'), seller_sku), data=kwargs) - - @sp_endpoint('/products/fees/v0/items/{}/feesEstimate', method='POST') - def get_product_fees_estimate_for_asin(self, asin, price: float, currency='USD', shipping_price=None, is_fba=False, - points: dict = None, marketplace_id: str = None, - optional_fulfillment_program: str = None, - **kwargs) -> ApiResponse: + kwargs.update( + self._create_body( + price, + shipping_price, + currency, + is_fba, + seller_sku, + points, + marketplace_id, + optional_fulfillment_program, + ) + ) + return self._request( + fill_query_params(kwargs.pop("path"), seller_sku), data=kwargs + ) + + @sp_endpoint("/products/fees/v0/items/{}/feesEstimate", method="POST") + def get_product_fees_estimate_for_asin( + self, + asin, + price: float, + currency="USD", + shipping_price=None, + is_fba=False, + points: dict = None, + marketplace_id: str = None, + optional_fulfillment_program: str = None, + **kwargs + ) -> ApiResponse: """ get_product_fees_estimate_for_asin(self, asin, price: float, currency='USD', shipping_price=None, is_fba=False, points: dict = dict, **kwargs) -> ApiResponse @@ -93,9 +123,19 @@ def get_product_fees_estimate_for_asin(self, asin, price: float, currency='USD', ApiResponse: """ - kwargs.update(self._create_body(price, shipping_price, currency, is_fba, asin, points, marketplace_id, optional_fulfillment_program)) - return self._request(fill_query_params(kwargs.pop('path'), asin), data=kwargs) - + kwargs.update( + self._create_body( + price, + shipping_price, + currency, + is_fba, + asin, + points, + marketplace_id, + optional_fulfillment_program, + ) + ) + return self._request(fill_query_params(kwargs.pop("path"), asin), data=kwargs) def get_product_fees_estimate(self, estimate_requests: List[dict]) -> ApiResponse: """ @@ -126,17 +166,27 @@ def get_product_fees_estimate(self, estimate_requests: List[dict]) -> ApiRespons marketplace_id: str | Defaults to self.marketplace_id optional_fulfillment_program: """ - data = [ - dict( - **self._create_body(**er) - ) - for er in estimate_requests - ] - return self._request('/products/fees/v0/feesEstimate', data=data, params=dict(method='POST'), wrap_list=True) - - - def _create_body(self, price, shipping_price=None, currency='USD', is_fba=False, identifier=None, points: dict = None, - marketplace_id: str = None, optional_fulfillment_program: str=None, id_type=None, id_value=None): + data = [dict(**self._create_body(**er)) for er in estimate_requests] + return self._request( + "/products/fees/v0/feesEstimate", + data=data, + params=dict(method="POST"), + wrap_list=True, + ) + + def _create_body( + self, + price, + shipping_price=None, + currency="USD", + is_fba=False, + identifier=None, + points: dict = None, + marketplace_id: str = None, + optional_fulfillment_program: str = None, + id_type=None, + id_value=None, + ): """ Create request body @@ -152,22 +202,24 @@ def _create_body(self, price, shipping_price=None, currency='USD', is_fba=False, """ body = { - 'FeesEstimateRequest': { - 'Identifier': identifier or str(price), - 'PriceToEstimateFees': { - 'ListingPrice': { - 'Amount': price, - 'CurrencyCode': currency - }, - 'Shipping': { - 'Amount': shipping_price, - 'CurrencyCode': currency - } if shipping_price else None, - 'Points': points or None + "FeesEstimateRequest": { + "Identifier": identifier or str(price), + "PriceToEstimateFees": { + "ListingPrice": {"Amount": price, "CurrencyCode": currency}, + "Shipping": ( + {"Amount": shipping_price, "CurrencyCode": currency} + if shipping_price + else None + ), + "Points": points or None, }, - 'IsAmazonFulfilled': is_fba, - 'OptionalFulfillmentProgram': optional_fulfillment_program if is_fba is True and optional_fulfillment_program else None, - 'MarketplaceId': marketplace_id or self.marketplace_id + "IsAmazonFulfilled": is_fba, + "OptionalFulfillmentProgram": ( + optional_fulfillment_program + if is_fba is True and optional_fulfillment_program + else None + ), + "MarketplaceId": marketplace_id or self.marketplace_id, } } @@ -177,7 +229,6 @@ def _create_body(self, price, shipping_price=None, currency='USD', is_fba=False, return body - def _add_marketplaces(self, data): # MarketplaceID is a property of the body's FeesEstimateRequest for this section, and does # not need to be added. Additionally, Client._add_marketplaces will fail as it assumes diff --git a/sp_api/api/product_type_definitions/product_type_definitions.py b/sp_api/api/product_type_definitions/product_type_definitions.py index b1dd6c2c0..2dfcee8ac 100644 --- a/sp_api/api/product_type_definitions/product_type_definitions.py +++ b/sp_api/api/product_type_definitions/product_type_definitions.py @@ -6,13 +6,12 @@ class ProductTypeDefinitions(Client): """ ProductTypeDefinitions SP-API Client - :link: + :link: The Selling Partner API for Product Type Definitions provides programmatic access to attribute and data requirements for product types in the Amazon catalog. Use this API to return the JSON Schema for a product type that you can then use with other Selling Partner APIs, such as the Selling Partner API for Listings Items, the Selling Partner API for Catalog Items, and the Selling Partner API for Feeds (for JSON-based listing feeds). """ - - @sp_endpoint('/definitions/2020-09-01/productTypes', method='GET') + @sp_endpoint("/definitions/2020-09-01/productTypes", method="GET") def search_definitions_product_types(self, **kwargs) -> ApiResponse: """ search_definitions_product_types(self, **kwargs) -> ApiResponse @@ -36,11 +35,10 @@ def search_definitions_product_types(self, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - - return self._request(kwargs.pop('path'), params=kwargs) - - @sp_endpoint('/definitions/2020-09-01/productTypes/{}', method='GET') + return self._request(kwargs.pop("path"), params=kwargs) + + @sp_endpoint("/definitions/2020-09-01/productTypes/{}", method="GET") def get_definitions_product_type(self, productType, **kwargs) -> ApiResponse: """ get_definitions_product_type(self, productType, **kwargs) -> ApiResponse @@ -70,6 +68,7 @@ def get_definitions_product_type(self, productType, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - - return self._request(fill_query_params(kwargs.pop('path'), productType), params=kwargs) - + + return self._request( + fill_query_params(kwargs.pop("path"), productType), params=kwargs + ) diff --git a/sp_api/api/products/products.py b/sp_api/api/products/products.py index d0711a813..959dff480 100644 --- a/sp_api/api/products/products.py +++ b/sp_api/api/products/products.py @@ -1,7 +1,10 @@ from typing import Optional, List, Dict, Union from sp_api.base import ApiResponse, Client, fill_query_params, sp_endpoint -from sp_api.api.products.products_definitions import GetItemOffersBatchRequest, GetListingOffersBatchRequest +from sp_api.api.products.products_definitions import ( + GetItemOffersBatchRequest, + GetListingOffersBatchRequest, +) class Products(Client): @@ -9,8 +12,10 @@ class Products(Client): :link: https://github.com/amzn/selling-partner-api-docs/blob/main/references/product-pricing-api/productPricingV0.md """ - @sp_endpoint('/products/pricing/v0/price', method='GET') - def get_product_pricing_for_skus(self, seller_sku_list: [str], item_condition=None, offer_type=None, **kwargs) -> ApiResponse: + @sp_endpoint("/products/pricing/v0/price", method="GET") + def get_product_pricing_for_skus( + self, seller_sku_list: [str], item_condition=None, offer_type=None, **kwargs + ) -> ApiResponse: """ get_product_pricing_for_skus(self, seller_sku_list: [str], item_condition: str = None, **kwargs) -> ApiResponse Returns pricing information for a seller's offer listings based on SKU. @@ -38,14 +43,16 @@ def get_product_pricing_for_skus(self, seller_sku_list: [str], item_condition=No ApiResponse: """ if item_condition is not None: - kwargs['ItemCondition'] = item_condition + kwargs["ItemCondition"] = item_condition if offer_type is not None: - kwargs['OfferType'] = offer_type + kwargs["OfferType"] = offer_type - return self._create_get_pricing_request(seller_sku_list, 'Sku', **kwargs) + return self._create_get_pricing_request(seller_sku_list, "Sku", **kwargs) - @sp_endpoint('/products/pricing/v0/price', method='GET') - def get_product_pricing_for_asins(self, asin_list: [str], item_condition=None, offer_type=None, **kwargs) -> ApiResponse: + @sp_endpoint("/products/pricing/v0/price", method="GET") + def get_product_pricing_for_asins( + self, asin_list: [str], item_condition=None, offer_type=None, **kwargs + ) -> ApiResponse: """ get_product_pricing_for_asins(self, asin_list: [str], item_condition=None, **kwargs) -> ApiResponse Returns pricing information for a seller's offer listings based on ASIN. @@ -71,14 +78,16 @@ def get_product_pricing_for_asins(self, asin_list: [str], item_condition=None, o ApiResponse """ if item_condition is not None: - kwargs['ItemCondition'] = item_condition + kwargs["ItemCondition"] = item_condition if offer_type is not None: - kwargs['OfferType'] = offer_type + kwargs["OfferType"] = offer_type - return self._create_get_pricing_request(asin_list, 'Asin', **kwargs) + return self._create_get_pricing_request(asin_list, "Asin", **kwargs) - @sp_endpoint('/products/pricing/v0/competitivePrice', method='GET') - def get_competitive_pricing_for_skus(self, seller_sku_list: [str], customer_type=None, **kwargs) -> ApiResponse: + @sp_endpoint("/products/pricing/v0/competitivePrice", method="GET") + def get_competitive_pricing_for_skus( + self, seller_sku_list: [str], customer_type=None, **kwargs + ) -> ApiResponse: """ get_competitive_pricing_for_skus(self, seller_sku_list, **kwargs) -> ApiResponse Returns competitive pricing information for a seller's offer listings based on Seller Sku @@ -105,12 +114,14 @@ def get_competitive_pricing_for_skus(self, seller_sku_list: [str], customer_type """ if customer_type is not None: - kwargs['CustomerType'] = customer_type + kwargs["CustomerType"] = customer_type - return self._create_get_pricing_request(seller_sku_list, 'Sku', **kwargs) + return self._create_get_pricing_request(seller_sku_list, "Sku", **kwargs) - @sp_endpoint('/products/pricing/v0/competitivePrice', method='GET') - def get_competitive_pricing_for_asins(self, asin_list: [str], customer_type=None, **kwargs) -> ApiResponse: + @sp_endpoint("/products/pricing/v0/competitivePrice", method="GET") + def get_competitive_pricing_for_asins( + self, asin_list: [str], customer_type=None, **kwargs + ) -> ApiResponse: """ get_competitive_pricing_for_asins(self, asin_list, **kwargs) -> ApiResponse Returns competitive pricing information for a seller's offer listings based on ASIN @@ -137,12 +148,14 @@ def get_competitive_pricing_for_asins(self, asin_list: [str], customer_type=None """ if customer_type is not None: - kwargs['CustomerType'] = customer_type + kwargs["CustomerType"] = customer_type - return self._create_get_pricing_request(asin_list, 'Asin', **kwargs) + return self._create_get_pricing_request(asin_list, "Asin", **kwargs) - @sp_endpoint('/products/pricing/v0/listings/{}/offers', method='GET') - def get_listings_offer(self, seller_sku: str, item_condition: str, customer_type: str = None, **kwargs) -> ApiResponse: + @sp_endpoint("/products/pricing/v0/listings/{}/offers", method="GET") + def get_listings_offer( + self, seller_sku: str, item_condition: str, customer_type: str = None, **kwargs + ) -> ApiResponse: """ get_listings_offer(self, seller_sku: str, **kwargs) -> ApiResponse Returns the lowest priced offers for a single SKU listing @@ -166,15 +179,19 @@ def get_listings_offer(self, seller_sku: str, item_condition: str, customer_type ApiResponse """ - kwargs['ItemCondition'] = item_condition + kwargs["ItemCondition"] = item_condition if customer_type is not None: - kwargs['CustomerType'] = customer_type + kwargs["CustomerType"] = customer_type - return self._request(fill_query_params(kwargs.pop('path'), seller_sku), params={**kwargs}) + return self._request( + fill_query_params(kwargs.pop("path"), seller_sku), params={**kwargs} + ) - @sp_endpoint('/products/pricing/v0/items/{}/offers', method='GET') - def get_item_offers(self, asin: str, item_condition: str, customer_type: str = None, **kwargs) -> ApiResponse: + @sp_endpoint("/products/pricing/v0/items/{}/offers", method="GET") + def get_item_offers( + self, asin: str, item_condition: str, customer_type: str = None, **kwargs + ) -> ApiResponse: """ get_item_offers(self, asin: str, **kwargs) -> ApiResponse Returns the lowest priced offers for a single item based on ASIN @@ -198,16 +215,21 @@ def get_item_offers(self, asin: str, item_condition: str, customer_type: str = N ApiResponse """ - kwargs['ItemCondition'] = item_condition + kwargs["ItemCondition"] = item_condition if customer_type is not None: - kwargs['CustomerType'] = customer_type - - return self._request(fill_query_params(kwargs.pop('path'), asin), params={**kwargs}) - - @sp_endpoint('/batches/products/pricing/v0/itemOffers', method='POST') - def get_item_offers_batch(self, requests_: Optional[Union[List[Dict], GetItemOffersBatchRequest]] = None, - **kwargs) -> ApiResponse: + kwargs["CustomerType"] = customer_type + + return self._request( + fill_query_params(kwargs.pop("path"), asin), params={**kwargs} + ) + + @sp_endpoint("/batches/products/pricing/v0/itemOffers", method="POST") + def get_item_offers_batch( + self, + requests_: Optional[Union[List[Dict], GetItemOffersBatchRequest]] = None, + **kwargs, + ) -> ApiResponse: """ get_item_offers_batch(self, requests_: Optional[List[Union[Dict, ItemOffersRequest]]], **kwargs) -> ApiResponse Returns the lowest priced offers for a batch of items based on ASIN. @@ -233,11 +255,19 @@ def get_item_offers_batch(self, requests_: Optional[Union[List[Dict], GetItemOff else: get_item_offers_batch_request = {"requests": requests_} - return self._request(kwargs.pop('path'), data=get_item_offers_batch_request, params={**kwargs}, - add_marketplace=False) - - @sp_endpoint('/batches/products/pricing/v0/listingOffers', method='POST') - def get_listing_offers_batch(self, requests_: Optional[Union[List[Dict], GetListingOffersBatchRequest]] = None, **kwargs) -> ApiResponse: + return self._request( + kwargs.pop("path"), + data=get_item_offers_batch_request, + params={**kwargs}, + add_marketplace=False, + ) + + @sp_endpoint("/batches/products/pricing/v0/listingOffers", method="POST") + def get_listing_offers_batch( + self, + requests_: Optional[Union[List[Dict], GetListingOffersBatchRequest]] = None, + **kwargs, + ) -> ApiResponse: """ get_listing_offers_batch(self, requests_: Optional[Union[List[Dict], GetListingOffersBatchRequest]], **kwargs) -> ApiResponse Returns the lowest priced offers for a batch of listings based on ASIN. @@ -263,18 +293,34 @@ def get_listing_offers_batch(self, requests_: Optional[Union[List[Dict], GetList else: get_listing_offers_batch_request = {"requests": requests_} - return self._request(kwargs.pop('path'), data=get_listing_offers_batch_request, params={**kwargs}, - add_marketplace=False) + return self._request( + kwargs.pop("path"), + data=get_listing_offers_batch_request, + params={**kwargs}, + add_marketplace=False, + ) def _create_get_pricing_request(self, item_list, item_type, **kwargs): - return self._request(kwargs.pop('path'), - params={**{f"{item_type}s": ','.join(item_list)}, - 'ItemType': item_type, - **({'ItemCondition': kwargs.pop( - 'ItemCondition')} if 'ItemCondition' in kwargs else {}), - **({'CustomerType': kwargs.pop( - 'CustomerType')} if 'CustomerType' in kwargs else {}), - **({'OfferType': kwargs.pop( - 'OfferType')} if 'OfferType' in kwargs else {}), - 'MarketplaceId': kwargs.get('MarketplaceId', self.marketplace_id)}) - + return self._request( + kwargs.pop("path"), + params={ + **{f"{item_type}s": ",".join(item_list)}, + "ItemType": item_type, + **( + {"ItemCondition": kwargs.pop("ItemCondition")} + if "ItemCondition" in kwargs + else {} + ), + **( + {"CustomerType": kwargs.pop("CustomerType")} + if "CustomerType" in kwargs + else {} + ), + **( + {"OfferType": kwargs.pop("OfferType")} + if "OfferType" in kwargs + else {} + ), + "MarketplaceId": kwargs.get("MarketplaceId", self.marketplace_id), + }, + ) diff --git a/sp_api/api/products/products_definitions.py b/sp_api/api/products/products_definitions.py index c7a9e5dfa..6abcd9fc1 100644 --- a/sp_api/api/products/products_definitions.py +++ b/sp_api/api/products/products_definitions.py @@ -4,8 +4,9 @@ @dataclass class ItemOffersRequest: - """ Implements definition: https://developer-docs.amazon.com/sp-api/docs/product-pricing-api-v0-reference - #itemoffersrequest """ + """Implements definition: https://developer-docs.amazon.com/sp-api/docs/product-pricing-api-v0-reference + #itemoffersrequest""" + uri: str method: str MarketplaceId: str @@ -16,8 +17,9 @@ class ItemOffersRequest: @dataclass class GetItemOffersBatchRequest: - """ Implements definition: https://developer-docs.amazon.com/sp-api/docs/product-pricing-api-v0-reference - #getitemoffersbatchrequest """ + """Implements definition: https://developer-docs.amazon.com/sp-api/docs/product-pricing-api-v0-reference + #getitemoffersbatchrequest""" + requests: Optional[List[Union[ItemOffersRequest, Dict]]] = None def __post_init__(self): @@ -40,12 +42,13 @@ def parse_requests(requests) -> List[ItemOffersRequest]: parsed_requestes.append(request) return parsed_requestes - + @dataclass class ListingOffersRequest: - """ Implements definition: https://developer-docs.amazon.com/sp-api/docs/product-pricing-api-v0-reference - #listingoffersrequest """ + """Implements definition: https://developer-docs.amazon.com/sp-api/docs/product-pricing-api-v0-reference + #listingoffersrequest""" + uri: str MarketplaceId: str ItemCondition: str @@ -55,8 +58,9 @@ class ListingOffersRequest: @dataclass class GetListingOffersBatchRequest: - """ Implements definition: https://developer-docs.amazon.com/sp-api/docs/product-pricing-api-v0-reference - #getlistingoffersbatchrequest """ + """Implements definition: https://developer-docs.amazon.com/sp-api/docs/product-pricing-api-v0-reference + #getlistingoffersbatchrequest""" + requests: Optional[List[Union[ListingOffersRequest, Dict]]] = None def __post_init__(self): @@ -79,4 +83,3 @@ def parse_requests(requests) -> List[ListingOffersRequest]: parsed_requestes.append(request) return parsed_requestes - diff --git a/sp_api/api/replenishment/replenishment.py b/sp_api/api/replenishment/replenishment.py index a0d517fad..d0b67dc5f 100644 --- a/sp_api/api/replenishment/replenishment.py +++ b/sp_api/api/replenishment/replenishment.py @@ -6,19 +6,21 @@ class Replenishment(Client): """ Replenishment SP-API Client - :link: + :link: The Selling Partner API for Replenishment (Replenishment API) provides programmatic access to replenishment program metrics and offers. These programs provide recurring delivery of any replenishable item at a frequency chosen by the customer. The Replenishment API is available worldwide wherever Amazon Subscribe & Save is available or is supported. The API is available to vendors and FBA selling partners. """ - @sp_endpoint('/replenishment/2022-11-07/sellingPartners/metrics/search', method='POST') + @sp_endpoint( + "/replenishment/2022-11-07/sellingPartners/metrics/search", method="POST" + ) def get_selling_partner_metrics(self, **kwargs) -> ApiResponse: """ get_selling_partner_metrics(self, **kwargs) -> ApiResponse - Returns aggregated replenishment program metrics for a selling partner. + Returns aggregated replenishment program metrics for a selling partner. **Usage Plan:** @@ -29,7 +31,7 @@ def get_selling_partner_metrics(self, **kwargs) -> ApiResponse: The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, see [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). Args: - + body: | {'description': 'The request body for the `getSellingPartnerMetrics` operation.', 'properties': {'aggregationFrequency': {'$ref': '#/definitions/AggregationFrequency'}, 'marketplaceId': {'$ref': '#/definitions/MarketplaceId', @@ -51,9 +53,9 @@ def get_selling_partner_metrics(self, **kwargs) -> ApiResponse: ApiResponse: """ - return self._request(kwargs.pop('path'), data=kwargs) + return self._request(kwargs.pop("path"), data=kwargs) - @sp_endpoint('/replenishment/2022-11-07/offers/metrics/search', method='POST') + @sp_endpoint("/replenishment/2022-11-07/offers/metrics/search", method="POST") def list_offer_metrics(self, **kwargs) -> ApiResponse: """ list_offer_metrics(self, **kwargs) -> ApiResponse @@ -69,7 +71,7 @@ def list_offer_metrics(self, **kwargs) -> ApiResponse: The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, see [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). Args: - + body: | {'description': 'The request body for the `listOfferMetrics` operation.', 'properties': {'filters': {'$ref': '#/definitions/ListOfferMetricsRequestFilters', 'description': 'Use these parameters to filter results. Any result must match all provided parameters. For any parameter that is an array, the result must match at least one element in the provided array.'}, @@ -83,9 +85,9 @@ def list_offer_metrics(self, **kwargs) -> ApiResponse: ApiResponse: """ - return self._request(kwargs.pop('path'), data=kwargs) + return self._request(kwargs.pop("path"), data=kwargs) - @sp_endpoint('/replenishment/2022-11-07/offers/search', method='POST') + @sp_endpoint("/replenishment/2022-11-07/offers/search", method="POST") def list_offers(self, **kwargs) -> ApiResponse: """ list_offers(self, **kwargs) -> ApiResponse @@ -101,7 +103,7 @@ def list_offers(self, **kwargs) -> ApiResponse: The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, see [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). Args: - + body: | {'description': 'The request body for the `listOffers` operation.', 'properties': {'filters': {'$ref': '#/definitions/ListOffersRequestFilters', 'description': 'Use these parameters to filter results. Any result must match all provided parameters. For any parameter that is an array, the result must match at least one element in the provided array.'}, @@ -115,4 +117,4 @@ def list_offers(self, **kwargs) -> ApiResponse: ApiResponse: """ - return self._request(kwargs.pop('path'), data=kwargs) + return self._request(kwargs.pop("path"), data=kwargs) diff --git a/sp_api/api/reports/reports.py b/sp_api/api/reports/reports.py index 6f1eeb575..21d399361 100644 --- a/sp_api/api/reports/reports.py +++ b/sp_api/api/reports/reports.py @@ -6,7 +6,13 @@ import requests -from sp_api.base import Client, sp_endpoint, fill_query_params, ApiResponse, Marketplaces +from sp_api.base import ( + Client, + sp_endpoint, + fill_query_params, + ApiResponse, + Marketplaces, +) class Reports(Client): @@ -17,7 +23,7 @@ class Reports(Client): The Selling Partner API for Reports lets you retrieve and manage a variety of reports that can help selling partners manage their businesses. """ - @sp_endpoint('/reports/2021-06-30/reports', method='GET') + @sp_endpoint("/reports/2021-06-30/reports", method="GET") def get_reports(self, **kwargs) -> ApiResponse: """ get_reports(self, **kwargs) -> ApiResponse @@ -54,22 +60,44 @@ def get_reports(self, **kwargs) -> ApiResponse: Returns: ApiResponse """ - if kwargs.get('reportTypes', None) and isinstance(kwargs.get('reportTypes'), abc.Iterable) and not isinstance(kwargs.get('reportTypes'), str): - kwargs.update({'reportTypes': ','.join(kwargs.get('reportTypes'))}) - if kwargs.get('processingStatuses', None) and isinstance(kwargs.get('processingStatuses'), abc.Iterable) and not isinstance(kwargs.get('processingStatuses'), str): - kwargs.update({'processingStatuses': ','.join(kwargs.get('processingStatuses'))}) - if kwargs.get('marketplaceIds', None) and isinstance(kwargs.get('marketplaceIds'), abc.Iterable) and not isinstance(kwargs.get('marketplaceIds'), str): - marketplaces = kwargs.get('marketplaceIds') - kwargs.update({'marketplaceIds': ','.join( - [m.marketplace_id if isinstance(m, Marketplaces) else m for m in marketplaces])}) - for k in ['createdSince', 'createdUntil']: + if ( + kwargs.get("reportTypes", None) + and isinstance(kwargs.get("reportTypes"), abc.Iterable) + and not isinstance(kwargs.get("reportTypes"), str) + ): + kwargs.update({"reportTypes": ",".join(kwargs.get("reportTypes"))}) + if ( + kwargs.get("processingStatuses", None) + and isinstance(kwargs.get("processingStatuses"), abc.Iterable) + and not isinstance(kwargs.get("processingStatuses"), str) + ): + kwargs.update( + {"processingStatuses": ",".join(kwargs.get("processingStatuses"))} + ) + if ( + kwargs.get("marketplaceIds", None) + and isinstance(kwargs.get("marketplaceIds"), abc.Iterable) + and not isinstance(kwargs.get("marketplaceIds"), str) + ): + marketplaces = kwargs.get("marketplaceIds") + kwargs.update( + { + "marketplaceIds": ",".join( + [ + m.marketplace_id if isinstance(m, Marketplaces) else m + for m in marketplaces + ] + ) + } + ) + for k in ["createdSince", "createdUntil"]: if kwargs.get(k, None) and isinstance(kwargs.get(k), datetime): kwargs.update({k: kwargs.get(k).isoformat()}) - if not kwargs.get('nextToken'): - return self._request(kwargs.pop('path'), params=kwargs) - return self._request(kwargs.pop('path'), params=kwargs, add_marketplace=False) + if not kwargs.get("nextToken"): + return self._request(kwargs.pop("path"), params=kwargs) + return self._request(kwargs.pop("path"), params=kwargs, add_marketplace=False) - @sp_endpoint('/reports/2021-06-30/reports', method='POST') + @sp_endpoint("/reports/2021-06-30/reports", method="POST") def create_report(self, **kwargs) -> ApiResponse: """ create_report(self, **kwargs) -> ApiResponse @@ -106,13 +134,13 @@ def create_report(self, **kwargs) -> ApiResponse: Returns: ApiResponse """ - if isinstance(kwargs.get('dataStartTime', None), datetime): - kwargs.update({'dataStartTime': kwargs.get('dataStartTime').isoformat()}) - if isinstance(kwargs.get('dataEndTime', None), datetime): - kwargs.update({'dataEndTime': kwargs.get('dataEndTime').isoformat()}) - return self._request(kwargs.pop('path'), data=kwargs) + if isinstance(kwargs.get("dataStartTime", None), datetime): + kwargs.update({"dataStartTime": kwargs.get("dataStartTime").isoformat()}) + if isinstance(kwargs.get("dataEndTime", None), datetime): + kwargs.update({"dataEndTime": kwargs.get("dataEndTime").isoformat()}) + return self._request(kwargs.pop("path"), data=kwargs) - @sp_endpoint('/reports/2021-06-30/reports/{}', method='DELETE') + @sp_endpoint("/reports/2021-06-30/reports/{}", method="DELETE") def cancel_report(self, reportId, **kwargs) -> ApiResponse: """ cancel_report(self, reportId, **kwargs) -> ApiResponse @@ -136,9 +164,11 @@ def cancel_report(self, reportId, **kwargs) -> ApiResponse: ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), reportId), data=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), reportId), data=kwargs + ) - @sp_endpoint('/reports/2021-06-30/reports/{}', method='GET') + @sp_endpoint("/reports/2021-06-30/reports/{}", method="GET") def get_report(self, reportId, **kwargs) -> ApiResponse: """ get_report(self, report_id, **kwargs) @@ -168,9 +198,11 @@ def get_report(self, reportId, **kwargs) -> ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), reportId), params=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), reportId), params=kwargs + ) - @sp_endpoint('/reports/2021-06-30/schedules', method='GET') + @sp_endpoint("/reports/2021-06-30/schedules", method="GET") def get_report_schedules(self, **kwargs) -> ApiResponse: """ Returns report schedule details that match the filters that you specify. @@ -191,12 +223,16 @@ def get_report_schedules(self, **kwargs) -> ApiResponse: Returns: ApiResponse """ - if kwargs.get('reportTypes', None) and isinstance(kwargs.get('reportTypes'), abc.Iterable) and not isinstance(kwargs.get('reportTypes'), str): - kwargs.update({'reportTypes': ','.join(kwargs.get('reportTypes'))}) + if ( + kwargs.get("reportTypes", None) + and isinstance(kwargs.get("reportTypes"), abc.Iterable) + and not isinstance(kwargs.get("reportTypes"), str) + ): + kwargs.update({"reportTypes": ",".join(kwargs.get("reportTypes"))}) - return self._request(kwargs.pop('path'), params=kwargs) + return self._request(kwargs.pop("path"), params=kwargs) - @sp_endpoint('/reports/2021-06-30/schedules', method='POST') + @sp_endpoint("/reports/2021-06-30/schedules", method="POST") def create_report_schedule(self, **kwargs) -> ApiResponse: """ create_report_schedule(self, **kwargs) -> ApiResponse @@ -230,9 +266,9 @@ def create_report_schedule(self, **kwargs) -> ApiResponse: ApiResponse: """ - return self._request(kwargs.pop('path'), data=kwargs) + return self._request(kwargs.pop("path"), data=kwargs) - @sp_endpoint('/reports/2021-06-30/schedules/{}', method='DELETE') + @sp_endpoint("/reports/2021-06-30/schedules/{}", method="DELETE") def cancel_report_schedule(self, reportScheduleId, **kwargs) -> ApiResponse: """ cancel_report_schedule(self, reportScheduleId, **kwargs) -> ApiResponse @@ -261,7 +297,9 @@ def cancel_report_schedule(self, reportScheduleId, **kwargs) -> ApiResponse: Returns: ApiResponse """ - return self._request(fill_query_params(kwargs.pop('path'), reportScheduleId), data=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), reportScheduleId), data=kwargs + ) def delete_report_schedule(self, reportScheduleId, **kwargs) -> ApiResponse: """ @@ -293,7 +331,7 @@ def delete_report_schedule(self, reportScheduleId, **kwargs) -> ApiResponse: """ return self.cancel_report_schedule(reportScheduleId) - @sp_endpoint('/reports/2021-06-30/schedules/{}', method='GET') + @sp_endpoint("/reports/2021-06-30/schedules/{}", method="GET") def get_report_schedule(self, reportScheduleId, **kwargs) -> ApiResponse: """ get_report_schedule(self, reportScheduleId, **kwargs) -> ApiResponse @@ -322,11 +360,19 @@ def get_report_schedule(self, reportScheduleId, **kwargs) -> ApiResponse: Returns: ApiResponse """ - return self._request(fill_query_params(kwargs.pop('path'), reportScheduleId), params=kwargs) - - @sp_endpoint('/reports/2021-06-30/documents/{}', method='GET') - def get_report_document(self, reportDocumentId, download: bool = False, file=None, - character_code: Optional[str] = None, **kwargs) -> ApiResponse: + return self._request( + fill_query_params(kwargs.pop("path"), reportScheduleId), params=kwargs + ) + + @sp_endpoint("/reports/2021-06-30/documents/{}", method="GET") + def get_report_document( + self, + reportDocumentId, + download: bool = False, + file=None, + character_code: Optional[str] = None, + **kwargs + ) -> ApiResponse: """ get_report_document(self, document_id, decrypt: bool = False, file=None, character_code: Optional[str] = None, **kwargs) -> ApiResponse 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. @@ -367,11 +413,13 @@ def get_report_document(self, reportDocumentId, download: bool = False, file=Non Returns: ApiResponse """ # noqa: E501 - res = self._request(fill_query_params(kwargs.pop( - 'path'), reportDocumentId), add_marketplace=False) - if download or file or ('decrypt' in kwargs and kwargs['decrypt']): + res = self._request( + fill_query_params(kwargs.pop("path"), reportDocumentId), + add_marketplace=False, + ) + if download or file or ("decrypt" in kwargs and kwargs["decrypt"]): document_response = requests.get( - res.payload.get('url'), + res.payload.get("url"), proxies=self.proxies, verify=self.verify, ) @@ -380,11 +428,11 @@ def get_report_document(self, reportDocumentId, download: bool = False, file=Non character_code = ( document_response.encoding if document_response and document_response.encoding - else 'iso-8859-1' + else "iso-8859-1" ) - if character_code.lower() == 'windows-31j': - character_code = 'cp932' - if 'compressionAlgorithm' in res.payload: + if character_code.lower() == "windows-31j": + character_code = "cp932" + if "compressionAlgorithm" in res.payload: try: document = zlib.decompress(bytearray(document), 15 + 32) except Exception as e: @@ -397,9 +445,11 @@ def get_report_document(self, reportDocumentId, download: bool = False, file=Non decoded_document = document if download: - res.payload.update({ - 'document': decoded_document, - }) + res.payload.update( + { + "document": decoded_document, + } + ) if file: self._handle_file(file, decoded_document, character_code) return res diff --git a/sp_api/api/sales/sales.py b/sp_api/api/sales/sales.py index 89c5b2ec3..ed31f2d81 100644 --- a/sp_api/api/sales/sales.py +++ b/sp_api/api/sales/sales.py @@ -10,8 +10,14 @@ class Sales(Client): :link: https://github.com/amzn/selling-partner-api-docs/blob/main/references/sales-api/sales.md#parameters """ - @sp_endpoint('/sales/v1/orderMetrics') - def get_order_metrics(self, interval: tuple, granularity: Granularity, granularityTimeZone: str = None, **kwargs) -> ApiResponse: + @sp_endpoint("/sales/v1/orderMetrics") + def get_order_metrics( + self, + interval: tuple, + granularity: Granularity, + granularityTimeZone: str = None, + **kwargs + ) -> ApiResponse: """ get_order_metrics(self, interval: tuple, granularity: Granularity, granularityTimeZone: str = None, **kwargs) -> ApiResponse @@ -46,8 +52,8 @@ def get_order_metrics(self, interval: tuple, granularity: Granularity, granulari 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) - 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" 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 - - 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" - 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 - + 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" + 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 - 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. granularityTimeZone: str @@ -55,15 +61,19 @@ def get_order_metrics(self, interval: tuple, granularity: Granularity, granulari Returns: ApiResponse """ - kwargs.update({ - 'interval': '--'.join([self._create_datetime_stamp(_interval) for _interval in interval]), - 'granularity': granularity.value, - }) + kwargs.update( + { + "interval": "--".join( + [self._create_datetime_stamp(_interval) for _interval in interval] + ), + "granularity": granularity.value, + } + ) if granularityTimeZone: - kwargs.update({'granularityTimeZone': granularityTimeZone}) - if 'sku' in kwargs: - kwargs.update({'sku': urllib.parse.quote(kwargs.pop('sku'), safe='')}) - return self._request(kwargs.pop('path'), params=kwargs) + kwargs.update({"granularityTimeZone": granularityTimeZone}) + if "sku" in kwargs: + kwargs.update({"sku": urllib.parse.quote(kwargs.pop("sku"), safe="")}) + return self._request(kwargs.pop("path"), params=kwargs) @staticmethod def _create_datetime_stamp(datetime_obj: datetime or str): @@ -78,5 +88,5 @@ def _create_datetime_stamp(datetime_obj: datetime or str): """ if isinstance(datetime_obj, str): return datetime_obj - fmt = '%Y-%m-%dT%H:%M:%S%z' + fmt = "%Y-%m-%dT%H:%M:%S%z" return datetime_obj.astimezone().isoformat(timespec="seconds") diff --git a/sp_api/api/sellers/sellers.py b/sp_api/api/sellers/sellers.py index 3ffeef7ad..5b7587691 100644 --- a/sp_api/api/sellers/sellers.py +++ b/sp_api/api/sellers/sellers.py @@ -8,7 +8,7 @@ class Sellers(Client): """ - @sp_endpoint('/sellers/v1/marketplaceParticipations') + @sp_endpoint("/sellers/v1/marketplaceParticipations") def get_marketplace_participation(self, **kwargs) -> ApiResponse: """ get_marketplace_participation(self, **kwargs) -> ApiResponse @@ -36,7 +36,7 @@ def get_marketplace_participation(self, **kwargs) -> ApiResponse: GetMarketplaceParticipationsResponse: """ - return self._request(kwargs.pop('path'), add_marketplace=False) + return self._request(kwargs.pop("path"), add_marketplace=False) @sp_endpoint("/sellers/v1/account") def get_account(self, **kwargs) -> ApiResponse: @@ -66,4 +66,4 @@ def get_account(self, **kwargs) -> ApiResponse: GetAccountResponse: """ - return self._request(kwargs.pop('path'), add_marketplace=False) + return self._request(kwargs.pop("path"), add_marketplace=False) diff --git a/sp_api/api/services/services.py b/sp_api/api/services/services.py index ecadcb39f..4a6b4f6bc 100644 --- a/sp_api/api/services/services.py +++ b/sp_api/api/services/services.py @@ -6,13 +6,12 @@ class Services(Client): """ Services SP-API Client - :link: + :link: With the Services API, you can build applications that help service providers get and modify their service orders. """ - - @sp_endpoint('/service/v1/serviceJobs/{}', method='GET') + @sp_endpoint("/service/v1/serviceJobs/{}", method="GET") def get_service_job_by_service_job_id(self, serviceJobId, **kwargs) -> ApiResponse: """ get_service_job_by_service_job_id(self, serviceJobId, **kwargs) -> ApiResponse @@ -35,12 +34,15 @@ def get_service_job_by_service_job_id(self, serviceJobId, **kwargs) -> ApiRespon Returns: ApiResponse: """ - - return self._request(fill_query_params(kwargs.pop('path'), serviceJobId), params=kwargs) - - @sp_endpoint('/service/v1/serviceJobs/{}/cancellations', method='PUT') - def cancel_service_job_by_service_job_id(self, serviceJobId, **kwargs) -> ApiResponse: + return self._request( + fill_query_params(kwargs.pop("path"), serviceJobId), params=kwargs + ) + + @sp_endpoint("/service/v1/serviceJobs/{}/cancellations", method="PUT") + def cancel_service_job_by_service_job_id( + self, serviceJobId, **kwargs + ) -> ApiResponse: """ cancel_service_job_by_service_job_id(self, serviceJobId, **kwargs) -> ApiResponse @@ -64,12 +66,15 @@ def cancel_service_job_by_service_job_id(self, serviceJobId, **kwargs) -> ApiRes Returns: ApiResponse: """ - - return self._request(fill_query_params(kwargs.pop('path'), serviceJobId), data=kwargs) - - @sp_endpoint('/service/v1/serviceJobs/{}/completions', method='PUT') - def complete_service_job_by_service_job_id(self, serviceJobId, **kwargs) -> ApiResponse: + return self._request( + fill_query_params(kwargs.pop("path"), serviceJobId), data=kwargs + ) + + @sp_endpoint("/service/v1/serviceJobs/{}/completions", method="PUT") + def complete_service_job_by_service_job_id( + self, serviceJobId, **kwargs + ) -> ApiResponse: """ complete_service_job_by_service_job_id(self, serviceJobId, **kwargs) -> ApiResponse @@ -92,11 +97,12 @@ def complete_service_job_by_service_job_id(self, serviceJobId, **kwargs) -> ApiR Returns: ApiResponse: """ - - return self._request(fill_query_params(kwargs.pop('path'), serviceJobId), data=kwargs) - - @sp_endpoint('/service/v1/serviceJobs', method='GET') + return self._request( + fill_query_params(kwargs.pop("path"), serviceJobId), data=kwargs + ) + + @sp_endpoint("/service/v1/serviceJobs", method="GET") def get_service_jobs(self, **kwargs) -> ApiResponse: """ get_service_jobs(self, **kwargs) -> ApiResponse @@ -131,12 +137,13 @@ def get_service_jobs(self, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - - return self._request(kwargs.pop('path'), params=kwargs) - - @sp_endpoint('/service/v1/serviceJobs/{}/appointments', method='POST') - def add_appointment_for_service_job_by_service_job_id(self, serviceJobId, **kwargs) -> ApiResponse: + return self._request(kwargs.pop("path"), params=kwargs) + + @sp_endpoint("/service/v1/serviceJobs/{}/appointments", method="POST") + def add_appointment_for_service_job_by_service_job_id( + self, serviceJobId, **kwargs + ) -> ApiResponse: """ add_appointment_for_service_job_by_service_job_id(self, serviceJobId, **kwargs) -> ApiResponse @@ -165,12 +172,15 @@ def add_appointment_for_service_job_by_service_job_id(self, serviceJobId, **kwar Returns: ApiResponse: """ - - return self._request(fill_query_params(kwargs.pop('path'), serviceJobId), data=kwargs) - - @sp_endpoint('/service/v1/serviceJobs/{}', method='POST') - def reschedule_appointment_for_service_job_by_service_job_id(self, serviceJobId, **kwargs) -> ApiResponse: + return self._request( + fill_query_params(kwargs.pop("path"), serviceJobId), data=kwargs + ) + + @sp_endpoint("/service/v1/serviceJobs/{}", method="POST") + def reschedule_appointment_for_service_job_by_service_job_id( + self, serviceJobId, **kwargs + ) -> ApiResponse: """ reschedule_appointment_for_service_job_by_service_job_id(self, serviceJobId, **kwargs) -> ApiResponse @@ -201,6 +211,7 @@ def reschedule_appointment_for_service_job_by_service_job_id(self, serviceJobId, Returns: ApiResponse: """ - - return self._request(fill_query_params(kwargs.pop('path'), serviceJobId), data=kwargs) - + + return self._request( + fill_query_params(kwargs.pop("path"), serviceJobId), data=kwargs + ) diff --git a/sp_api/api/shipping/shipping.py b/sp_api/api/shipping/shipping.py index 833d4d2af..c8c9293d4 100644 --- a/sp_api/api/shipping/shipping.py +++ b/sp_api/api/shipping/shipping.py @@ -6,13 +6,12 @@ class Shipping(Client): """ Shipping SP-API Client - :link: + :link: Provides programmatic access to Amazon Shipping APIs. """ - - @sp_endpoint('/shipping/v1/shipments', method='POST') + @sp_endpoint("/shipping/v1/shipments", method="POST") def create_shipment(self, **kwargs) -> ApiResponse: """ create_shipment(self, **kwargs) -> ApiResponse @@ -101,10 +100,10 @@ def create_shipment(self, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - - return self._request(kwargs.pop('path'), data=kwargs) - @sp_endpoint('/shipping/v1/shipments/{}', method='GET') + return self._request(kwargs.pop("path"), data=kwargs) + + @sp_endpoint("/shipping/v1/shipments/{}", method="GET") def get_shipment(self, shipmentId, **kwargs) -> ApiResponse: """ get_shipment(self, shipmentId, **kwargs) -> ApiResponse @@ -127,10 +126,12 @@ def get_shipment(self, shipmentId, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - - return self._request(fill_query_params(kwargs.pop('path'), shipmentId), params=kwargs) - @sp_endpoint('/shipping/v1/shipments/{}/cancel', method='POST') + return self._request( + fill_query_params(kwargs.pop("path"), shipmentId), params=kwargs + ) + + @sp_endpoint("/shipping/v1/shipments/{}/cancel", method="POST") def cancel_shipment(self, shipmentId, **kwargs) -> ApiResponse: """ cancel_shipment(self, shipmentId, **kwargs) -> ApiResponse @@ -154,11 +155,12 @@ def cancel_shipment(self, shipmentId, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - - return self._request(fill_query_params(kwargs.pop('path'), shipmentId), data=kwargs) - - @sp_endpoint('/shipping/v1/shipments/{}/purchaseLabels', method='POST') + return self._request( + fill_query_params(kwargs.pop("path"), shipmentId), data=kwargs + ) + + @sp_endpoint("/shipping/v1/shipments/{}/purchaseLabels", method="POST") def purchase_labels(self, shipmentId, **kwargs) -> ApiResponse: """ purchase_labels(self, shipmentId, **kwargs) -> ApiResponse @@ -185,16 +187,17 @@ def purchase_labels(self, shipmentId, **kwargs) -> ApiResponse: "labelStockSize": "4x6" } } - + Returns: ApiResponse: """ - - return self._request(fill_query_params(kwargs.pop('path'), shipmentId), data=kwargs) - - @sp_endpoint('/shipping/v1/shipments/{}/label', method='POST') + return self._request( + fill_query_params(kwargs.pop("path"), shipmentId), data=kwargs + ) + + @sp_endpoint("/shipping/v1/shipments/{}/label", method="POST") def retrieve_shipping_label(self, shipmentId, **kwargs) -> ApiResponse: """ retrieve_shipping_label(self, shipmentId, **kwargs) -> ApiResponse @@ -224,11 +227,12 @@ def retrieve_shipping_label(self, shipmentId, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - - return self._request(fill_query_params(kwargs.pop('path'), shipmentId), data=kwargs) - - @sp_endpoint('/shipping/v1/purchaseShipment', method='POST') + return self._request( + fill_query_params(kwargs.pop("path"), shipmentId), data=kwargs + ) + + @sp_endpoint("/shipping/v1/purchaseShipment", method="POST") def purchase_shipment(self, **kwargs) -> ApiResponse: """ purchase_shipment(self, **kwargs) -> ApiResponse @@ -323,11 +327,10 @@ def purchase_shipment(self, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - - return self._request(kwargs.pop('path'), data=kwargs) - - @sp_endpoint('/shipping/v1/rates', method='POST') + return self._request(kwargs.pop("path"), data=kwargs) + + @sp_endpoint("/shipping/v1/rates", method="POST") def get_rates(self, **kwargs) -> ApiResponse: """ get_rates(self, **kwargs) -> ApiResponse @@ -399,11 +402,10 @@ def get_rates(self, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - - return self._request(kwargs.pop('path'), data=kwargs) - - @sp_endpoint('/shipping/v1/account', method='GET') + return self._request(kwargs.pop("path"), data=kwargs) + + @sp_endpoint("/shipping/v1/account", method="GET") def get_account(self, **kwargs) -> ApiResponse: """ get_account(self, **kwargs) -> ApiResponse @@ -423,11 +425,10 @@ def get_account(self, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - - return self._request(kwargs.pop('path'), params=kwargs) - - @sp_endpoint('/shipping/v1/tracking/{}', method='GET') + return self._request(kwargs.pop("path"), params=kwargs) + + @sp_endpoint("/shipping/v1/tracking/{}", method="GET") def get_tracking_information(self, trackingId, **kwargs) -> ApiResponse: """ get_tracking_information(self, trackingId, **kwargs) -> ApiResponse @@ -451,6 +452,7 @@ def get_tracking_information(self, trackingId, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - - return self._request(fill_query_params(kwargs.pop('path'), trackingId), params=kwargs) - + + return self._request( + fill_query_params(kwargs.pop("path"), trackingId), params=kwargs + ) diff --git a/sp_api/api/shipping/shippingV2.py b/sp_api/api/shipping/shippingV2.py index 1fc101a31..e53cf082a 100644 --- a/sp_api/api/shipping/shippingV2.py +++ b/sp_api/api/shipping/shippingV2.py @@ -3,7 +3,13 @@ import urllib.parse from datetime import datetime -from sp_api.base import Client, sp_endpoint, fill_query_params, ApiResponse, Marketplaces +from sp_api.base import ( + Client, + sp_endpoint, + fill_query_params, + ApiResponse, + Marketplaces, +) class AmznShippingBusiness(str, enum.Enum): @@ -26,7 +32,7 @@ def has_key(cls, name): class Shipping(Client): """ Shipping V2 SP-API Client - :link: + :link: Provides programmatic access to Amazon Shipping APIs. """ @@ -34,12 +40,14 @@ class Shipping(Client): amzn_shipping_business: AmznShippingBusiness = AmznShippingBusiness.US def __init__(self, *args, **kwargs): - if 'amzn_shipping_business' in kwargs: - self.amzn_shipping_business = kwargs.pop('amzn_shipping_business', AmznShippingBusiness.US) + if "amzn_shipping_business" in kwargs: + self.amzn_shipping_business = kwargs.pop( + "amzn_shipping_business", AmznShippingBusiness.US + ) else: marketplace = args[0] if len(args) > 0 else Marketplaces.US - if os.environ.get('SP_API_DEFAULT_MARKETPLACE', None): - marketplace = Marketplaces[os.environ.get('SP_API_DEFAULT_MARKETPLACE')] + if os.environ.get("SP_API_DEFAULT_MARKETPLACE", None): + marketplace = Marketplaces[os.environ.get("SP_API_DEFAULT_MARKETPLACE")] if AmznShippingBusiness.has_key(marketplace.name): self.amzn_shipping_business = AmznShippingBusiness[marketplace.name] @@ -49,15 +57,15 @@ def __init__(self, *args, **kwargs): @property def headers(self): return { - 'host': self.endpoint[8:], - 'user-agent': self.user_agent, - 'x-amz-access-token': self.restricted_data_token or self.auth.access_token, - 'x-amz-date': datetime.utcnow().strftime('%Y%m%dT%H%M%SZ'), - 'content-type': 'application/json', - 'x-amzn-shipping-business-id': self.amzn_shipping_business.value, + "host": self.endpoint[8:], + "user-agent": self.user_agent, + "x-amz-access-token": self.restricted_data_token or self.auth.access_token, + "x-amz-date": datetime.utcnow().strftime("%Y%m%dT%H%M%SZ"), + "content-type": "application/json", + "x-amzn-shipping-business-id": self.amzn_shipping_business.value, } - @sp_endpoint('/shipping/v2/shipments/rates', method='POST') + @sp_endpoint("/shipping/v2/shipments/rates", method="POST") def get_rates(self, **kwargs) -> ApiResponse: """ get_rates(self, **kwargs) -> ApiResponse @@ -236,9 +244,9 @@ def get_rates(self, **kwargs) -> ApiResponse: ApiResponse: """ - return self._request(kwargs.pop('path'), data=kwargs, add_marketplace=False) + return self._request(kwargs.pop("path"), data=kwargs, add_marketplace=False) - @sp_endpoint('/shipping/v2/shipments', method='POST') + @sp_endpoint("/shipping/v2/shipments", method="POST") def purchase_shipment(self, **kwargs) -> ApiResponse: """ purchase_shipment(self, **kwargs) -> ApiResponse @@ -284,9 +292,9 @@ def purchase_shipment(self, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - return self._request(kwargs.pop('path'), data=kwargs, add_marketplace=False) + return self._request(kwargs.pop("path"), data=kwargs, add_marketplace=False) - @sp_endpoint('/shipping/v2/oneClickShipment', method='POST') + @sp_endpoint("/shipping/v2/oneClickShipment", method="POST") def one_click_shipment(self, **kwargs) -> ApiResponse: """ one_click_shipment(self, **kwargs) -> ApiResponse @@ -472,9 +480,9 @@ def one_click_shipment(self, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - return self._request(kwargs.pop('path'), data=kwargs, add_marketplace=False) + return self._request(kwargs.pop("path"), data=kwargs, add_marketplace=False) - @sp_endpoint('/shipping/v2/tracking', method='GET') + @sp_endpoint("/shipping/v2/tracking", method="GET") def get_tracking(self, **kwargs) -> ApiResponse: """ get_tracking(self, **kwargs) -> ApiResponse @@ -498,9 +506,9 @@ def get_tracking(self, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - return self._request(kwargs.pop('path'), params=kwargs, add_marketplace=False) + return self._request(kwargs.pop("path"), params=kwargs, add_marketplace=False) - @sp_endpoint('/shipping/v2/shipments/{}/documents', method='GET') + @sp_endpoint("/shipping/v2/shipments/{}/documents", method="GET") def get_shipment_documents(self, shipmentId, **kwargs) -> ApiResponse: """ get_shipment_documents(self, shipmentId, **kwargs) -> ApiResponse @@ -527,9 +535,13 @@ def get_shipment_documents(self, shipmentId, **kwargs) -> ApiResponse: ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), shipmentId), params=kwargs, add_marketplace=False) + return self._request( + fill_query_params(kwargs.pop("path"), shipmentId), + params=kwargs, + add_marketplace=False, + ) - @sp_endpoint('/shipping/v2/shipments/{}/cancel', method='PUT') + @sp_endpoint("/shipping/v2/shipments/{}/cancel", method="PUT") def cancel_shipment(self, shipmentId, **kwargs) -> ApiResponse: """ cancel_shipment(self, shipmentId, **kwargs) -> ApiResponse @@ -552,9 +564,13 @@ def cancel_shipment(self, shipmentId, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), shipmentId), data=kwargs, add_marketplace=False) + return self._request( + fill_query_params(kwargs.pop("path"), shipmentId), + data=kwargs, + add_marketplace=False, + ) - @sp_endpoint('/shipping/v2/accessPoints', method='GET') + @sp_endpoint("/shipping/v2/accessPoints", method="GET") def get_access_points(self, **kwargs) -> ApiResponse: """ get_access_points(self, **kwargs) -> ApiResponse @@ -579,9 +595,9 @@ def get_access_points(self, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - return self._request(kwargs.pop('path'), params=kwargs, add_marketplace=False) + return self._request(kwargs.pop("path"), params=kwargs, add_marketplace=False) - @sp_endpoint('/shipping/v2/ndrFeedback', method='POST') + @sp_endpoint("/shipping/v2/ndrFeedback", method="POST") def submit_ndr_feedback(self, **kwargs) -> ApiResponse: """ submit_ndr_feedback(self, **kwargs) -> ApiResponse @@ -611,9 +627,9 @@ def submit_ndr_feedback(self, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - return self._request(kwargs.pop('path'), data=kwargs, add_marketplace=False) + return self._request(kwargs.pop("path"), data=kwargs, add_marketplace=False) - @sp_endpoint('/shipping/v2/shipments/additionalInputs/schema', method='GET') + @sp_endpoint("/shipping/v2/shipments/additionalInputs/schema", method="GET") def get_additional_inputs(self, **kwargs) -> ApiResponse: """ get_additional_inputs(self, **kwargs) -> ApiResponse @@ -637,4 +653,4 @@ def get_additional_inputs(self, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - return self._request(kwargs.pop('path'), params=kwargs, add_marketplace=False) + return self._request(kwargs.pop("path"), params=kwargs, add_marketplace=False) diff --git a/sp_api/api/solicitations/solicitations.py b/sp_api/api/solicitations/solicitations.py index c1f90d6b0..fc9d06d0b 100644 --- a/sp_api/api/solicitations/solicitations.py +++ b/sp_api/api/solicitations/solicitations.py @@ -6,14 +6,15 @@ class Solicitations(Client): """ Solicitations SP-API Client - :link: + :link: With the Solicitations API you can build applications that send non-critical solicitations to buyers. You can get a list of solicitation types that are available for an order that you specify, then call an operation that sends a solicitation to the buyer for that order. Buyers cannot respond to solicitations sent by this API, and these solicitations do not appear in the Messaging section of Seller Central or in the recipient's Message Center. The Solicitations API returns responses that are formed according to the JSON Hypertext Application Language (HAL) standard. """ - - @sp_endpoint('/solicitations/v1/orders/{}', method='GET') - def get_solicitation_actions_for_order(self, amazonOrderId, **kwargs) -> ApiResponse: + @sp_endpoint("/solicitations/v1/orders/{}", method="GET") + def get_solicitation_actions_for_order( + self, amazonOrderId, **kwargs + ) -> ApiResponse: """ get_solicitation_actions_for_order(self, amazonOrderId, **kwargs) -> ApiResponse @@ -36,11 +37,18 @@ def get_solicitation_actions_for_order(self, amazonOrderId, **kwargs) -> ApiResp Returns: ApiResponse: """ - - return self._request(fill_query_params(kwargs.pop('path'), amazonOrderId), params=kwargs) - @sp_endpoint('/solicitations/v1/orders/{}/solicitations/productReviewAndSellerFeedback', method='POST') - def create_product_review_and_seller_feedback_solicitation(self, amazonOrderId, **kwargs) -> ApiResponse: + return self._request( + fill_query_params(kwargs.pop("path"), amazonOrderId), params=kwargs + ) + + @sp_endpoint( + "/solicitations/v1/orders/{}/solicitations/productReviewAndSellerFeedback", + method="POST", + ) + def create_product_review_and_seller_feedback_solicitation( + self, amazonOrderId, **kwargs + ) -> ApiResponse: """ create_product_review_and_seller_feedback_solicitation(self, amazonOrderId, **kwargs) -> ApiResponse @@ -63,6 +71,7 @@ def create_product_review_and_seller_feedback_solicitation(self, amazonOrderId, Returns: ApiResponse: """ - - return self._request(fill_query_params(kwargs.pop('path'), amazonOrderId), params=kwargs) - + + return self._request( + fill_query_params(kwargs.pop("path"), amazonOrderId), params=kwargs + ) diff --git a/sp_api/api/supply_sources/supply_sources.py b/sp_api/api/supply_sources/supply_sources.py index 01a31bfa3..7a6dcc6b2 100644 --- a/sp_api/api/supply_sources/supply_sources.py +++ b/sp_api/api/supply_sources/supply_sources.py @@ -4,12 +4,12 @@ class SupplySources(Client): """ SupplySources SP-API Client - :link: + :link: Manage configurations and capabilities of seller supply sources. """ - @sp_endpoint('/supplySources/2020-07-01/supplySources', method='GET') + @sp_endpoint("/supplySources/2020-07-01/supplySources", method="GET") def get_supply_sources(self, **kwargs) -> ApiResponse: """ get_supply_sources(self, **kwargs) -> ApiResponse @@ -17,40 +17,40 @@ def get_supply_sources(self, **kwargs) -> ApiResponse: The path to retrieve paginated supply sources. Args: - + key nextPageToken:string | The pagination token to retrieve a specific page of results. - + key pageSize:number | The number of supply sources to return per paginated request. - + Returns: ApiResponse: """ - return self._request(kwargs.pop('path'), params=kwargs) + return self._request(kwargs.pop("path"), params=kwargs) - @sp_endpoint('/supplySources/2020-07-01/supplySources', method='POST') + @sp_endpoint("/supplySources/2020-07-01/supplySources", method="POST") def create_supply_source(self, **kwargs) -> ApiResponse: """ - create_supply_source(self, **kwargs) -> ApiResponse + create_supply_source(self, **kwargs) -> ApiResponse - Create a new supply source. + Create a new supply source. - Args: - - payload: | * REQUIRED {'description': 'A request to create a supply source.', - 'properties': {'address': {'$ref': '#/definitions/Address'}, 'alias': {'$ref': '#/definitions/SupplySourceAlias'}, 'supplySourceCode': {'$ref': '#/definitions/SupplySourceCode'}}, - 'required': ['address', 'supplySourceCode', 'alias'], - 'type': 'object'} - + Args: - Returns: - ApiResponse: + payload: | * REQUIRED {'description': 'A request to create a supply source.', + 'properties': {'address': {'$ref': '#/definitions/Address'}, 'alias': {'$ref': '#/definitions/SupplySourceAlias'}, 'supplySourceCode': {'$ref': '#/definitions/SupplySourceCode'}}, + 'required': ['address', 'supplySourceCode', 'alias'], + 'type': 'object'} + + + Returns: + ApiResponse: """ - return self._request(kwargs.pop('path'), data=kwargs) + return self._request(kwargs.pop("path"), data=kwargs) - @sp_endpoint('/supplySources/2020-07-01/supplySources/{}', method='GET') + @sp_endpoint("/supplySources/2020-07-01/supplySources/{}", method="GET") def get_supply_source(self, supplySourceId, **kwargs) -> ApiResponse: """ get_supply_source(self, supplySourceId, **kwargs) -> ApiResponse @@ -58,17 +58,19 @@ def get_supply_source(self, supplySourceId, **kwargs) -> ApiResponse: Retrieve a supply source. Args: - + supplySourceId:string | * REQUIRED The unique identifier of a supply source. - + Returns: ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), supplySourceId), params=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), supplySourceId), params=kwargs + ) - @sp_endpoint('/supplySources/2020-07-01/supplySources/{}', method='PUT') + @sp_endpoint("/supplySources/2020-07-01/supplySources/{}", method="PUT") def update_supply_source(self, supplySourceId, **kwargs) -> ApiResponse: """ update_supply_source(self, supplySourceId, **kwargs) -> ApiResponse @@ -76,21 +78,23 @@ def update_supply_source(self, supplySourceId, **kwargs) -> ApiResponse: Update the configuration and capabilities of a supply source. Args: - + supplySourceId:string | * REQUIRED The unique identitier of a supply source. - + payload: | {'description': 'A request to update the configuration and capabilities of a supply source.', 'properties': {'alias': {'$ref': '#/definitions/SupplySourceAlias'}, 'capabilities': {'$ref': '#/definitions/SupplySourceCapabilities'}, 'configuration': {'$ref': '#/definitions/SupplySourceConfiguration'}}, 'type': 'object'} - + Returns: ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), supplySourceId), data=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), supplySourceId), data=kwargs + ) - @sp_endpoint('/supplySources/2020-07-01/supplySources/{}', method='DELETE') + @sp_endpoint("/supplySources/2020-07-01/supplySources/{}", method="DELETE") def archive_supply_source(self, supplySourceId, **kwargs) -> ApiResponse: """ archive_supply_source(self, supplySourceId, **kwargs) -> ApiResponse @@ -98,17 +102,19 @@ def archive_supply_source(self, supplySourceId, **kwargs) -> ApiResponse: Archive a supply source, making it inactive. Cannot be undone. Args: - + supplySourceId:string | * REQUIRED The unique identifier of a supply source. - + Returns: ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), supplySourceId), data=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), supplySourceId), data=kwargs + ) - @sp_endpoint('/supplySources/2020-07-01/supplySources/{}/status', method='PUT') + @sp_endpoint("/supplySources/2020-07-01/supplySources/{}/status", method="PUT") def update_supply_source_status(self, supplySourceId, **kwargs) -> ApiResponse: """ update_supply_source_status(self, supplySourceId, **kwargs) -> ApiResponse @@ -116,14 +122,16 @@ def update_supply_source_status(self, supplySourceId, **kwargs) -> ApiResponse: Update the status of a supply source. Args: - + supplySourceId:string | * REQUIRED The unique identifier of a supply source. - + payload: | {'description': 'A request to update the status of a supply source.', 'properties': {'status': {'$ref': '#/definitions/SupplySourceStatus'}}, 'type': 'object'} - + Returns: ApiResponse: """ - return self._request(fill_query_params(kwargs.pop('path'), supplySourceId), data=kwargs) + return self._request( + fill_query_params(kwargs.pop("path"), supplySourceId), data=kwargs + ) diff --git a/sp_api/api/tokens/tokens.py b/sp_api/api/tokens/tokens.py index 20abce4ad..f165fa605 100644 --- a/sp_api/api/tokens/tokens.py +++ b/sp_api/api/tokens/tokens.py @@ -6,13 +6,12 @@ class Tokens(Client): """ Tokens SP-API Client - :link: + :link: The Selling Partner API for Tokens provides a secure way to access a customers's PII (Personally Identifiable Information). You can call the Tokens API to get a Restricted Data Token (RDT) for one or more restricted resources that you specify. The RDT authorizes you to make subsequent requests to access these restricted resources. """ - - @sp_endpoint('/tokens/2021-03-01/restrictedDataToken', method='POST') + @sp_endpoint("/tokens/2021-03-01/restrictedDataToken", method="POST") def create_restricted_data_token(self, **kwargs) -> ApiResponse: """ create_restricted_data_token(self, **kwargs) -> ApiResponse @@ -61,6 +60,5 @@ def create_restricted_data_token(self, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - - return self._request(kwargs.pop('path'), data=kwargs) - + + return self._request(kwargs.pop("path"), data=kwargs) diff --git a/sp_api/api/upload/upload.py b/sp_api/api/upload/upload.py index d10bd342d..62bcc7b74 100644 --- a/sp_api/api/upload/upload.py +++ b/sp_api/api/upload/upload.py @@ -4,12 +4,14 @@ class Upload(Client): - @sp_endpoint('/uploads/2020-11-01/uploadDestinations/{}', method='POST') - def upload_document(self, resource, file, content_type='application/pdf', **kwargs): + @sp_endpoint("/uploads/2020-11-01/uploadDestinations/{}", method="POST") + def upload_document(self, resource, file, content_type="application/pdf", **kwargs): md5 = urllib.parse.quote(create_md5(file)) - kwargs.update({ - 'contentMD5': md5, - 'contentType': kwargs.pop('contentType', content_type), - 'marketplaceIds': self.marketplace_id - }) - return self._request(kwargs.pop('path').format(resource), params=kwargs) + kwargs.update( + { + "contentMD5": md5, + "contentType": kwargs.pop("contentType", content_type), + "marketplaceIds": self.marketplace_id, + } + ) + return self._request(kwargs.pop("path").format(resource), params=kwargs) diff --git a/sp_api/api/vendor_direct_fulfillment_inventory/vendor_direct_fulfillment_inventory.py b/sp_api/api/vendor_direct_fulfillment_inventory/vendor_direct_fulfillment_inventory.py index 731ae2f98..b35c818d9 100644 --- a/sp_api/api/vendor_direct_fulfillment_inventory/vendor_direct_fulfillment_inventory.py +++ b/sp_api/api/vendor_direct_fulfillment_inventory/vendor_direct_fulfillment_inventory.py @@ -6,13 +6,14 @@ class VendorDirectFulfillmentInventory(Client): """ VendorDirectFulfillmentInventory SP-API Client - :link: + :link: The Selling Partner API for Direct Fulfillment Inventory Updates provides programmatic access to a direct fulfillment vendor's inventory updates. """ - - @sp_endpoint('/vendor/directFulfillment/inventory/v1/warehouses/{}/items', method='POST') + @sp_endpoint( + "/vendor/directFulfillment/inventory/v1/warehouses/{}/items", method="POST" + ) def submit_inventory_update(self, warehouseId, **kwargs) -> ApiResponse: """ submit_inventory_update(self, warehouseId, **kwargs) -> ApiResponse @@ -54,6 +55,9 @@ def submit_inventory_update(self, warehouseId, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - - return self._request(fill_query_params(kwargs.pop('path'), warehouseId), data=kwargs, add_marketplace=False) - + + return self._request( + fill_query_params(kwargs.pop("path"), warehouseId), + data=kwargs, + add_marketplace=False, + ) diff --git a/sp_api/api/vendor_direct_fulfillment_orders/vendor_direct_fulfillment_orders.py b/sp_api/api/vendor_direct_fulfillment_orders/vendor_direct_fulfillment_orders.py index a2135e14f..2e347448e 100644 --- a/sp_api/api/vendor_direct_fulfillment_orders/vendor_direct_fulfillment_orders.py +++ b/sp_api/api/vendor_direct_fulfillment_orders/vendor_direct_fulfillment_orders.py @@ -6,13 +6,12 @@ class VendorDirectFulfillmentOrders(Client): """ VendorDirectFulfillmentOrders SP-API Client - :link: + :link: The Selling Partner API for Direct Fulfillment Orders provides programmatic access to a direct fulfillment vendor's order data. """ - - @sp_endpoint('/vendor/directFulfillment/orders/v1/purchaseOrders', method='GET') + @sp_endpoint("/vendor/directFulfillment/orders/v1/purchaseOrders", method="GET") def get_orders(self, **kwargs) -> ApiResponse: """ get_orders(self, **kwargs) -> ApiResponse @@ -42,11 +41,10 @@ def get_orders(self, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - - return self._request(kwargs.pop('path'), params=kwargs) - - @sp_endpoint('/vendor/directFulfillment/orders/v1/purchaseOrders/{}', method='GET') + return self._request(kwargs.pop("path"), params=kwargs) + + @sp_endpoint("/vendor/directFulfillment/orders/v1/purchaseOrders/{}", method="GET") def get_order(self, purchaseOrderNumber, **kwargs) -> ApiResponse: """ get_order(self, purchaseOrderNumber, **kwargs) -> ApiResponse @@ -69,11 +67,12 @@ def get_order(self, purchaseOrderNumber, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - - return self._request(fill_query_params(kwargs.pop('path'), purchaseOrderNumber), params=kwargs) - - @sp_endpoint('/vendor/directFulfillment/orders/v1/acknowledgements', method='POST') + return self._request( + fill_query_params(kwargs.pop("path"), purchaseOrderNumber), params=kwargs + ) + + @sp_endpoint("/vendor/directFulfillment/orders/v1/acknowledgements", method="POST") def submit_acknowledgement(self, **kwargs) -> ApiResponse: """ submit_acknowledgement(self, **kwargs) -> ApiResponse @@ -192,6 +191,5 @@ def submit_acknowledgement(self, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - - return self._request(kwargs.pop('path'), data=kwargs, add_marketplace=False) - + + return self._request(kwargs.pop("path"), data=kwargs, add_marketplace=False) diff --git a/sp_api/api/vendor_direct_fulfillment_payments/vendor_direct_fulfillment_payments.py b/sp_api/api/vendor_direct_fulfillment_payments/vendor_direct_fulfillment_payments.py index 309bf46cf..b2dde16f5 100644 --- a/sp_api/api/vendor_direct_fulfillment_payments/vendor_direct_fulfillment_payments.py +++ b/sp_api/api/vendor_direct_fulfillment_payments/vendor_direct_fulfillment_payments.py @@ -6,13 +6,12 @@ class VendorDirectFulfillmentPayments(Client): """ VendorDirectFulfillmentPayments SP-API Client - :link: + :link: The Selling Partner API for Direct Fulfillment Payments provides programmatic access to a direct fulfillment vendor's invoice data. """ - - @sp_endpoint('/vendor/directFulfillment/payments/v1/invoices', method='POST') + @sp_endpoint("/vendor/directFulfillment/payments/v1/invoices", method="POST") def submit_invoice(self, **kwargs) -> ApiResponse: """ submit_invoice(self, **kwargs) -> ApiResponse @@ -250,6 +249,5 @@ def submit_invoice(self, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - - return self._request(kwargs.pop('path'), data=kwargs, add_marketplace=False) - + + return self._request(kwargs.pop("path"), data=kwargs, add_marketplace=False) diff --git a/sp_api/api/vendor_direct_fulfillment_shipping/vendor_direct_fulfillment_shipping.py b/sp_api/api/vendor_direct_fulfillment_shipping/vendor_direct_fulfillment_shipping.py index 6533d0191..a70994c02 100644 --- a/sp_api/api/vendor_direct_fulfillment_shipping/vendor_direct_fulfillment_shipping.py +++ b/sp_api/api/vendor_direct_fulfillment_shipping/vendor_direct_fulfillment_shipping.py @@ -6,13 +6,12 @@ class VendorDirectFulfillmentShipping(Client): """ VendorDirectFulfillmentShipping SP-API Client - :link: + :link: The Selling Partner API for Direct Fulfillment Shipping provides programmatic access to a direct fulfillment vendor's shipping data. """ - - @sp_endpoint('/vendor/directFulfillment/shipping/v1/shippingLabels', method='GET') + @sp_endpoint("/vendor/directFulfillment/shipping/v1/shippingLabels", method="GET") def get_shipping_labels(self, **kwargs) -> ApiResponse: """ get_shipping_labels(self, **kwargs) -> ApiResponse @@ -40,11 +39,10 @@ def get_shipping_labels(self, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - - return self._request(kwargs.pop('path'), params=kwargs) - - @sp_endpoint('/vendor/directFulfillment/shipping/v1/shippingLabels', method='POST') + return self._request(kwargs.pop("path"), params=kwargs) + + @sp_endpoint("/vendor/directFulfillment/shipping/v1/shippingLabels", method="POST") def submit_shipping_label_request(self, **kwargs) -> ApiResponse: """ submit_shipping_label_request(self, **kwargs) -> ApiResponse @@ -180,11 +178,12 @@ def submit_shipping_label_request(self, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - - return self._request(kwargs.pop('path'), data=kwargs, add_marketplace=False) - - @sp_endpoint('/vendor/directFulfillment/shipping/v1/shippingLabels/{}', method='GET') + return self._request(kwargs.pop("path"), data=kwargs, add_marketplace=False) + + @sp_endpoint( + "/vendor/directFulfillment/shipping/v1/shippingLabels/{}", method="GET" + ) def get_shipping_label(self, purchaseOrderNumber, **kwargs) -> ApiResponse: """ get_shipping_label(self, purchaseOrderNumber, **kwargs) -> ApiResponse @@ -208,11 +207,14 @@ def get_shipping_label(self, purchaseOrderNumber, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - - return self._request(fill_query_params(kwargs.pop('path'), purchaseOrderNumber), params=kwargs) - - @sp_endpoint('/vendor/directFulfillment/shipping/v1/shipmentConfirmations', method='POST') + return self._request( + fill_query_params(kwargs.pop("path"), purchaseOrderNumber), params=kwargs + ) + + @sp_endpoint( + "/vendor/directFulfillment/shipping/v1/shipmentConfirmations", method="POST" + ) def submit_shipment_confirmations(self, **kwargs) -> ApiResponse: """ submit_shipment_confirmations(self, **kwargs) -> ApiResponse @@ -366,11 +368,12 @@ def submit_shipment_confirmations(self, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - - return self._request(kwargs.pop('path'), data=kwargs, add_marketplace=False) - - @sp_endpoint('/vendor/directFulfillment/shipping/v1/shipmentStatusUpdates', method='POST') + return self._request(kwargs.pop("path"), data=kwargs, add_marketplace=False) + + @sp_endpoint( + "/vendor/directFulfillment/shipping/v1/shipmentStatusUpdates", method="POST" + ) def submit_shipment_status_updates(self, **kwargs) -> ApiResponse: """ submit_shipment_status_updates(self, **kwargs) -> ApiResponse @@ -495,11 +498,10 @@ def submit_shipment_status_updates(self, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - - return self._request(kwargs.pop('path'), data=kwargs) - - @sp_endpoint('/vendor/directFulfillment/shipping/v1/customerInvoices', method='GET') + return self._request(kwargs.pop("path"), data=kwargs) + + @sp_endpoint("/vendor/directFulfillment/shipping/v1/customerInvoices", method="GET") def get_customer_invoices(self, **kwargs) -> ApiResponse: """ get_customer_invoices(self, **kwargs) -> ApiResponse @@ -528,10 +530,12 @@ def get_customer_invoices(self, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - - return self._request(kwargs.pop('path'), params=kwargs) - @sp_endpoint('/vendor/directFulfillment/shipping/v1/customerInvoices/{}', method='GET') + return self._request(kwargs.pop("path"), params=kwargs) + + @sp_endpoint( + "/vendor/directFulfillment/shipping/v1/customerInvoices/{}", method="GET" + ) def get_customer_invoice(self, purchaseOrderNumber, **kwargs) -> ApiResponse: """ get_customer_invoice(self, purchaseOrderNumber, **kwargs) -> ApiResponse @@ -555,11 +559,12 @@ def get_customer_invoice(self, purchaseOrderNumber, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - - return self._request(fill_query_params(kwargs.pop('path'), purchaseOrderNumber), params=kwargs) - - @sp_endpoint('/vendor/directFulfillment/shipping/v1/packingSlips', method='GET') + return self._request( + fill_query_params(kwargs.pop("path"), purchaseOrderNumber), params=kwargs + ) + + @sp_endpoint("/vendor/directFulfillment/shipping/v1/packingSlips", method="GET") def get_packing_slips(self, **kwargs) -> ApiResponse: """ get_packing_slips(self, **kwargs) -> ApiResponse @@ -588,11 +593,10 @@ def get_packing_slips(self, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - - return self._request(kwargs.pop('path'), params=kwargs) - - @sp_endpoint('/vendor/directFulfillment/shipping/v1/packingSlips/{}', method='GET') + return self._request(kwargs.pop("path"), params=kwargs) + + @sp_endpoint("/vendor/directFulfillment/shipping/v1/packingSlips/{}", method="GET") def get_packing_slip(self, purchaseOrderNumber, **kwargs) -> ApiResponse: """ get_packing_slip(self, purchaseOrderNumber, **kwargs) -> ApiResponse @@ -616,6 +620,7 @@ def get_packing_slip(self, purchaseOrderNumber, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - - return self._request(fill_query_params(kwargs.pop('path'), purchaseOrderNumber), params=kwargs) - + + return self._request( + fill_query_params(kwargs.pop("path"), purchaseOrderNumber), params=kwargs + ) diff --git a/sp_api/api/vendor_direct_fulfillment_transactions/vendor_direct_fulfillment_transactions.py b/sp_api/api/vendor_direct_fulfillment_transactions/vendor_direct_fulfillment_transactions.py index 1d777e151..fb21276cd 100644 --- a/sp_api/api/vendor_direct_fulfillment_transactions/vendor_direct_fulfillment_transactions.py +++ b/sp_api/api/vendor_direct_fulfillment_transactions/vendor_direct_fulfillment_transactions.py @@ -6,13 +6,14 @@ class VendorDirectFulfillmentTransactions(Client): """ VendorDirectFulfillmentTransactions SP-API Client - :link: + :link: The Selling Partner API for Direct Fulfillment Transaction Status provides programmatic access to a direct fulfillment vendor's transaction status. """ - - @sp_endpoint('/vendor/directFulfillment/transactions/v1/transactions/{}', method='GET') + @sp_endpoint( + "/vendor/directFulfillment/transactions/v1/transactions/{}", method="GET" + ) def get_transaction_status(self, transactionId, **kwargs) -> ApiResponse: """ get_transaction_status(self, transactionId, **kwargs) -> ApiResponse @@ -35,6 +36,7 @@ def get_transaction_status(self, transactionId, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - - return self._request(fill_query_params(kwargs.pop('path'), transactionId), params=kwargs) - + + return self._request( + fill_query_params(kwargs.pop("path"), transactionId), params=kwargs + ) diff --git a/sp_api/api/vendor_invoices/vendor_invoices.py b/sp_api/api/vendor_invoices/vendor_invoices.py index 139aba067..413c3aba8 100644 --- a/sp_api/api/vendor_invoices/vendor_invoices.py +++ b/sp_api/api/vendor_invoices/vendor_invoices.py @@ -6,12 +6,12 @@ class VendorInvoices(Client): """ VendorInvoices SP-API Client - :link: + :link: The Selling Partner API for Retail Procurement Payments provides programmatic access to vendors payments data. """ - @sp_endpoint('/vendor/payments/v1/invoices', method='POST') + @sp_endpoint("/vendor/payments/v1/invoices", method="POST") def submit_invoices(self, data, **kwargs) -> ApiResponse: """ submit_invoices(self, data, **kwargs) -> ApiResponse @@ -288,5 +288,7 @@ def submit_invoices(self, data, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - - return self._request(kwargs.pop('path'), data={**data, **kwargs}, add_marketplace=False) + + return self._request( + kwargs.pop("path"), data={**data, **kwargs}, add_marketplace=False + ) diff --git a/sp_api/api/vendor_orders/vendor_orders.py b/sp_api/api/vendor_orders/vendor_orders.py index 34acbbd9e..a2e1af583 100644 --- a/sp_api/api/vendor_orders/vendor_orders.py +++ b/sp_api/api/vendor_orders/vendor_orders.py @@ -6,13 +6,12 @@ class VendorOrders(Client): """ VendorOrders SP-API Client - :link: + :link: The Selling Partner API for Retail Procurement Orders provides programmatic access to vendor orders data. """ - - @sp_endpoint('/vendor/orders/v1/purchaseOrders', method='GET') + @sp_endpoint("/vendor/orders/v1/purchaseOrders", method="GET") def get_purchase_orders(self, **kwargs) -> ApiResponse: """ get_purchase_orders(self, **kwargs) -> ApiResponse @@ -46,11 +45,10 @@ def get_purchase_orders(self, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - - return self._request(kwargs.pop('path'), params=kwargs) - - @sp_endpoint('/vendor/orders/v1/purchaseOrders/{}', method='GET') + return self._request(kwargs.pop("path"), params=kwargs) + + @sp_endpoint("/vendor/orders/v1/purchaseOrders/{}", method="GET") def get_purchase_order(self, purchaseOrderNumber, **kwargs) -> ApiResponse: """ get_purchase_order(self, purchaseOrderNumber, **kwargs) -> ApiResponse @@ -74,11 +72,12 @@ def get_purchase_order(self, purchaseOrderNumber, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - - return self._request(fill_query_params(kwargs.pop('path'), purchaseOrderNumber), params=kwargs) - - @sp_endpoint('/vendor/orders/v1/acknowledgements', method='POST') + return self._request( + fill_query_params(kwargs.pop("path"), purchaseOrderNumber), params=kwargs + ) + + @sp_endpoint("/vendor/orders/v1/acknowledgements", method="POST") def submit_acknowledgement(self, **kwargs) -> ApiResponse: """ submit_acknowledgement(self, **kwargs) -> ApiResponse @@ -168,11 +167,10 @@ def submit_acknowledgement(self, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - - return self._request(kwargs.pop('path'), data=kwargs, add_marketplace=False) - - @sp_endpoint('/vendor/orders/v1/purchaseOrdersStatus', method='GET') + return self._request(kwargs.pop("path"), data=kwargs, add_marketplace=False) + + @sp_endpoint("/vendor/orders/v1/purchaseOrdersStatus", method="GET") def get_purchase_orders_status(self, **kwargs) -> ApiResponse: """ get_purchase_orders_status(self, **kwargs) -> ApiResponse @@ -202,11 +200,10 @@ def get_purchase_orders_status(self, **kwargs) -> ApiResponse: key itemConfirmationStatus:string | Filters purchase orders based on the specified purchase order item status. If not included in filter, purchase orders for all statuses are included. key orderingVendorCode:string | Filters purchase orders based on the specified ordering vendor code. This value should be same as 'sellingParty.partyId' in the purchase order. If not included in filter, all purchase orders for all the vendor codes that exist in the vendor group used to authorize API client application are returned. key shipToPartyId:string | Filters purchase orders for a specific buyer's Fulfillment Center/warehouse by providing ship to location id here. This value should be same as 'shipToParty.partyId' in the purchase order. If not included in filter, this will return purchase orders for all the buyer's warehouses used for vendor group purchase orders. - + Returns: ApiResponse: """ - - return self._request(kwargs.pop('path'), params=kwargs) - + + return self._request(kwargs.pop("path"), params=kwargs) diff --git a/sp_api/api/vendor_shipments/vendor_shipments.py b/sp_api/api/vendor_shipments/vendor_shipments.py index 89f810577..799581bbb 100644 --- a/sp_api/api/vendor_shipments/vendor_shipments.py +++ b/sp_api/api/vendor_shipments/vendor_shipments.py @@ -6,283 +6,135 @@ class VendorShipments(Client): """ VendorShipments SP-API Client - :link: + :link: The Selling Partner API for Retail Procurement Shipments provides programmatic access to retail shipping data for vendors. """ - - @sp_endpoint('/vendor/shipping/v1/shipmentConfirmations', method='POST') + @sp_endpoint("/vendor/shipping/v1/shipmentConfirmations", method="POST") def submit_shipment_confirmations(self, **kwargs) -> ApiResponse: """ - submit_shipment_confirmations(self, **kwargs) -> ApiResponse + submit_shipment_confirmations(self, **kwargs) -> ApiResponse + + Submits one or more shipment confirmations for vendor orders. + + **Usage Plan:** + + | Rate (requests per second) | Burst | + | ---- | ---- | + | 10 | 10 | + + The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, see [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). + + Args: + + body: | * REQUIRED {'description': 'The request schema for the SubmitShipmentConfirmations operation.', + 'properties': {'shipmentConfirmations': {'description': 'A list of one or more shipment confirmations.', 'items': {'$ref': '#/definitions/ShipmentConfirmation'}, 'type': 'array'}}, + 'type': 'object'} + + + Returns: + ApiResponse: + """ + + return self._request(kwargs.pop("path"), data=kwargs) + + @sp_endpoint("/vendor/shipping/v1/shipments", method="POST") + def submit_shipments(self, **kwargs) -> ApiResponse: + """ + submit_shipments(self, **kwargs) -> ApiResponse - Submits one or more shipment confirmations for vendor orders. + Submits one or more shipment request for vendor Orders. - **Usage Plans:** + **Usage Plan:** - ====================================== ============== - Rate (requests per second) Burst - ====================================== ============== - 10 10 - ====================================== ============== + | Rate (requests per second) | Burst | + | ---- | ---- | + | 10 | 10 | - The x-amzn-RateLimit-Limit response header returns the usage plan rate limits that were applied to the requested operation. Rate limits for some selling partners will vary from the default rate and burst shown in the table above. For more information, see "Usage Plans and Rate Limits" in the Selling Partner API documentation. + The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, see [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). + + Args: + + body: | * REQUIRED {'description': 'The request schema for the SubmitShipments operation.', + 'properties': {'shipments': {'description': 'A list of one or more shipments with underlying details.', 'items': {'$ref': '#/definitions/Shipment'}, 'type': 'array'}}, + 'type': 'object'} + + + Returns: + ApiResponse: + """ + + return self._request(kwargs.pop("path"), data=kwargs) + + @sp_endpoint("/vendor/shipping/v1/shipments", method="GET") + def get_shipment_details(self, **kwargs) -> ApiResponse: + """ + get_shipment_details(self, **kwargs) -> ApiResponse + + Returns the Details about Shipment, Carrier Details, status of the shipment, container details and other details related to shipment based on the filter parameters value that you specify. + + **Usage Plan:** + + | Rate (requests per second) | Burst | + | ---- | ---- | + | 10 | 10 | + + The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, see [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). Args: - body: { - "shipmentConfirmations": [ - { - "shipmentIdentifier": "string", - "shipmentConfirmationType": "Original", - "shipmentType": "TruckLoad", - "shipmentStructure": "PalletizedAssortmentCase", - "transportationDetails": { - "carrierScac": "string", - "carrierShipmentReferenceNumber": "string", - "transportationMode": "Road", - "billOfLadingNumber": "string" - }, - "amazonReferenceNumber": "string", - "shipmentConfirmationDate": "2019-08-24T14:15:22Z", - "shippedDate": "2019-08-24T14:15:22Z", - "estimatedDeliveryDate": "2019-08-24T14:15:22Z", - "sellingParty": { - "address": { - "name": "string", - "addressLine1": "string", - "addressLine2": "string", - "addressLine3": "string", - "city": "string", - "county": "string", - "district": "string", - "stateOrRegion": "string", - "postalCode": "string", - "countryCode": "string", - "phone": "string" - }, - "partyId": "string", - "taxRegistrationDetails": [ - { - "taxRegistrationType": "VAT", - "taxRegistrationNumber": "string" - } - ] - }, - "shipFromParty": { - "address": { - "name": "string", - "addressLine1": "string", - "addressLine2": "string", - "addressLine3": "string", - "city": "string", - "county": "string", - "district": "string", - "stateOrRegion": "string", - "postalCode": "string", - "countryCode": "string", - "phone": "string" - }, - "partyId": "string", - "taxRegistrationDetails": [ - { - "taxRegistrationType": "VAT", - "taxRegistrationNumber": "string" - } - ] - }, - "shipToParty": { - "address": { - "name": "string", - "addressLine1": "string", - "addressLine2": "string", - "addressLine3": "string", - "city": "string", - "county": "string", - "district": "string", - "stateOrRegion": "string", - "postalCode": "string", - "countryCode": "string", - "phone": "string" - }, - "partyId": "string", - "taxRegistrationDetails": [ - { - "taxRegistrationType": "VAT", - "taxRegistrationNumber": "string" - } - ] - }, - "shipmentMeasurements": { - "grossShipmentWeight": { - "unitOfMeasure": "G", - "value": "string" - }, - "shipmentVolume": { - "unitOfMeasure": "CuFt", - "value": "string" - }, - "cartonCount": 0, - "palletCount": 0 - }, - "importDetails": { - "methodOfPayment": "PaidByBuyer", - "sealNumber": "string", - "route": { - "stops": [ - { - "functionCode": "PortOfDischarge", - "locationIdentification": { - "type": "string", - "locationCode": "string", - "countryCode": "string" - }, - "arrivalTime": "2019-08-24T14:15:22Z", - "departureTime": "2019-08-24T14:15:22Z" - } - ] - }, - "importContainers": "string", - "billableWeight": { - "unitOfMeasure": "G", - "value": "string" - }, - "estimatedShipByDate": "2019-08-24T14:15:22Z" - }, - "shippedItems": [ - { - "itemSequenceNumber": "string", - "amazonProductIdentifier": "string", - "vendorProductIdentifier": "string", - "shippedQuantity": { - "amount": 0, - "unitOfMeasure": "Cases", - "unitSize": 0 - }, - "itemDetails": { - "purchaseOrderNumber": "string", - "lotNumber": "string", - "expiry": { - "manufacturerDate": "2019-08-24T14:15:22Z", - "expiryDate": "2019-08-24T14:15:22Z", - "expiryAfterDuration": { - "durationUnit": "Days", - "durationValue": 0 - } - }, - "maximumRetailPrice": { - "currencyCode": "string", - "amount": "string" - }, - "handlingCode": "Oversized" - } - } - ], - "cartons": [ - { - "cartonIdentifiers": [ - { - "containerIdentificationType": "SSCC", - "containerIdentificationNumber": "string" - } - ], - "cartonSequenceNumber": "string", - "dimensions": { - "length": "string", - "width": "string", - "height": "string", - "unitOfMeasure": "In" - }, - "weight": { - "unitOfMeasure": "G", - "value": "string" - }, - "trackingNumber": "string", - "items": [ - { - "itemReference": "string", - "shippedQuantity": { - "amount": 0, - "unitOfMeasure": "Cases", - "unitSize": 0 - }, - "itemDetails": { - "purchaseOrderNumber": "string", - "lotNumber": "string", - "expiry": { - "manufacturerDate": "2019-08-24T14:15:22Z", - "expiryDate": "2019-08-24T14:15:22Z", - "expiryAfterDuration": {} - }, - "maximumRetailPrice": { - "currencyCode": "string", - "amount": "string" - }, - "handlingCode": "Oversized" - } - } - ] - } - ], - "pallets": [ - { - "palletIdentifiers": [ - { - "containerIdentificationType": "SSCC", - "containerIdentificationNumber": "string" - } - ], - "tier": 0, - "block": 0, - "dimensions": { - "length": "string", - "width": "string", - "height": "string", - "unitOfMeasure": "In" - }, - "weight": { - "unitOfMeasure": "G", - "value": "string" - }, - "cartonReferenceDetails": { - "cartonCount": 0, - "cartonReferenceNumbers": [ - "string" - ] - }, - "items": [ - { - "itemReference": "string", - "shippedQuantity": { - "amount": 0, - "unitOfMeasure": "Cases", - "unitSize": 0 - }, - "itemDetails": { - "purchaseOrderNumber": "string", - "lotNumber": "string", - "expiry": { - "manufacturerDate": "2019-08-24T14:15:22Z", - "expiryDate": "2019-08-24T14:15:22Z", - "expiryAfterDuration": {} - }, - "maximumRetailPrice": { - "currencyCode": "string", - "amount": "string" - }, - "handlingCode": "Oversized" - } - } - ] - } - ] - } - ] - } + + key limit:integer | The limit to the number of records returned. Default value is 50 records. + + key sortOrder:string | Sort in ascending or descending order by purchase order creation date. + + key nextToken:string | Used for pagination when there are more shipments than the specified result size limit. + + key createdAfter:string | Get Shipment Details that became available after this timestamp will be included in the result. Must be in ISO 8601 format. + + key createdBefore:string | Get Shipment Details that became available before this timestamp will be included in the result. Must be in ISO 8601 format. + + key shipmentConfirmedBefore:string | Get Shipment Details by passing Shipment confirmed create Date Before. Must be in ISO 8601 format. + + key shipmentConfirmedAfter:string | Get Shipment Details by passing Shipment confirmed create Date After. Must be in ISO 8601 format. + + key packageLabelCreatedBefore:string | Get Shipment Details by passing Package label create Date by buyer. Must be in ISO 8601 format. + + key packageLabelCreatedAfter:string | Get Shipment Details by passing Package label create Date After by buyer. Must be in ISO 8601 format. + + key shippedBefore:string | Get Shipment Details by passing Shipped Date Before. Must be in ISO 8601 format. + + key shippedAfter:string | Get Shipment Details by passing Shipped Date After. Must be in ISO 8601 format. + + key estimatedDeliveryBefore:string | Get Shipment Details by passing Estimated Delivery Date Before. Must be in ISO 8601 format. + + key estimatedDeliveryAfter:string | Get Shipment Details by passing Estimated Delivery Date Before. Must be in ISO 8601 format. + + key shipmentDeliveryBefore:string | Get Shipment Details by passing Shipment Delivery Date Before. Must be in ISO 8601 format. + + key shipmentDeliveryAfter:string | Get Shipment Details by passing Shipment Delivery Date After. Must be in ISO 8601 format. + + key requestedPickUpBefore:string | Get Shipment Details by passing Before Requested pickup date. Must be in ISO 8601 format. + + key requestedPickUpAfter:string | Get Shipment Details by passing After Requested pickup date. Must be in ISO 8601 format. + + key scheduledPickUpBefore:string | Get Shipment Details by passing Before scheduled pickup date. Must be in ISO 8601 format. + + key scheduledPickUpAfter:string | Get Shipment Details by passing After Scheduled pickup date. Must be in ISO 8601 format. + + key currentShipmentStatus:string | Get Shipment Details by passing Current shipment status. + + key vendorShipmentIdentifier:string | Get Shipment Details by passing Vendor Shipment ID + + key buyerReferenceNumber:string | Get Shipment Details by passing buyer Reference ID + + key buyerWarehouseCode:string | Get Shipping Details based on buyer warehouse code. This value should be same as 'shipToParty.partyId' in the Shipment. + + key sellerWarehouseCode:string | Get Shipping Details based on vendor warehouse code. This value should be same as 'sellingParty.partyId' in the Shipment. + Returns: ApiResponse: """ - - return self._request(kwargs.pop('path'), data=kwargs) - + + return self._request(kwargs.pop("path"), params=kwargs) diff --git a/sp_api/api/vendor_transaction_status/vendor_transaction_status.py b/sp_api/api/vendor_transaction_status/vendor_transaction_status.py index 6a7777ce9..b986a2ad1 100644 --- a/sp_api/api/vendor_transaction_status/vendor_transaction_status.py +++ b/sp_api/api/vendor_transaction_status/vendor_transaction_status.py @@ -6,13 +6,12 @@ class VendorTransactionStatus(Client): """ VendorTransactionStatus SP-API Client - :link: + :link: The Selling Partner API for Retail Procurement Transaction Status provides programmatic access to status information on specific asynchronous POST transactions for vendors. """ - - @sp_endpoint('/vendor/transactions/v1/transactions/{}', method='GET') + @sp_endpoint("/vendor/transactions/v1/transactions/{}", method="GET") def get_transaction(self, transactionId, **kwargs) -> ApiResponse: """ get_transaction(self, transactionId, **kwargs) -> ApiResponse @@ -35,6 +34,7 @@ def get_transaction(self, transactionId, **kwargs) -> ApiResponse: Returns: ApiResponse: """ - - return self._request(fill_query_params(kwargs.pop('path'), transactionId), params=kwargs) - + + return self._request( + fill_query_params(kwargs.pop("path"), transactionId), params=kwargs + ) diff --git a/sp_api/auth/__init__.py b/sp_api/auth/__init__.py index 27a13a456..ab395418c 100644 --- a/sp_api/auth/__init__.py +++ b/sp_api/auth/__init__.py @@ -3,7 +3,7 @@ from .credentials import Credentials __all__ = [ - 'AccessTokenResponse', - 'AccessTokenClient', - 'Credentials', + "AccessTokenResponse", + "AccessTokenClient", + "Credentials", ] diff --git a/sp_api/auth/access_token_client.py b/sp_api/auth/access_token_client.py index f071392d4..0ff1d1e96 100644 --- a/sp_api/auth/access_token_client.py +++ b/sp_api/auth/access_token_client.py @@ -10,16 +10,18 @@ from .access_token_response import AccessTokenResponse from .exceptions import AuthorizationError -cache = TTLCache(maxsize=int(os.environ.get('SP_API_AUTH_CACHE_SIZE', 10)), ttl=3200) -grantless_cache = TTLCache(maxsize=int(os.environ.get('SP_API_AUTH_CACHE_SIZE', 10)), ttl=3200) +cache = TTLCache(maxsize=int(os.environ.get("SP_API_AUTH_CACHE_SIZE", 10)), ttl=3200) +grantless_cache = TTLCache( + maxsize=int(os.environ.get("SP_API_AUTH_CACHE_SIZE", 10)), ttl=3200 +) logger = logging.getLogger(__name__) class AccessTokenClient(BaseClient): - host = 'api.amazon.com' - grant_type = 'refresh_token' - path = '/auth/o2/token' + host = "api.amazon.com" + grant_type = "refresh_token" + path = "/auth/o2/token" def __init__(self, refresh_token=None, credentials=None, proxies=None, verify=True): self.cred = Credentials(refresh_token, credentials) @@ -27,11 +29,13 @@ def __init__(self, refresh_token=None, credentials=None, proxies=None, verify=Tr self.verify = verify def _request(self, url, data, headers): - response = requests.post(url, data=data, headers=headers, proxies=self.proxies, verify=self.verify) + response = requests.post( + url, data=data, headers=headers, proxies=self.proxies, verify=self.verify + ) response_data = response.json() if response.status_code != 200: - error_message = response_data.get('error_description') - error_code = response_data.get('error') + error_message = response_data.get("error_description") + error_code = response_data.get("error") raise AuthorizationError(error_code, error_message, response.status_code) return response_data @@ -50,7 +54,7 @@ def get_auth(self) -> AccessTokenResponse: cache[cache_key] = access_token return AccessTokenResponse(**access_token) - def get_grantless_auth(self, scope='sellingpartnerapi::notifications'): + def get_grantless_auth(self, scope="sellingpartnerapi::notifications"): """ :param scope: One of allowed scope for grantless operations: sellingpartnerapi::notifications or sellingpartnerapi::migration @@ -69,15 +73,13 @@ def get_grantless_auth(self, scope='sellingpartnerapi::notifications'): cache_key = self._get_cache_key(scope) try: access_token = grantless_cache[cache_key] - logger.debug('from_cache. scope: %s', scope) + logger.debug("from_cache. scope: %s", scope) except KeyError: request_url = self.scheme + self.host + self.path access_token = self._request( - request_url, - data=self.grantless_data(scope), - headers=self.headers + request_url, data=self.grantless_data(scope), headers=self.headers ) - logger.debug('token_refreshed') + logger.debug("token_refreshed") grantless_cache.clear() grantless_cache[cache_key] = access_token @@ -88,44 +90,45 @@ def authorize_auth_code(self, auth_code): res = self._request( request_url, data=self._auth_code_request_body(auth_code), - headers=self.headers + headers=self.headers, ) return res def _auth_code_request_body(self, auth_code): return { - 'grant_type': 'authorization_code', - 'code': auth_code, - 'client_id': self.cred.client_id, - 'client_secret': self.cred.client_secret + "grant_type": "authorization_code", + "code": auth_code, + "client_id": self.cred.client_id, + "client_secret": self.cred.client_secret, } def grantless_data(self, scope_value: str): return { - 'grant_type': 'client_credentials', - 'client_id': self.cred.client_id, - 'scope': scope_value, - 'client_secret': self.cred.client_secret + "grant_type": "client_credentials", + "client_id": self.cred.client_id, + "scope": scope_value, + "client_secret": self.cred.client_secret, } @property def data(self): return { - 'grant_type': self.grant_type, - 'client_id': self.cred.client_id, - 'refresh_token': self.cred.refresh_token, - 'client_secret': self.cred.client_secret + "grant_type": self.grant_type, + "client_id": self.cred.client_id, + "refresh_token": self.cred.refresh_token, + "client_secret": self.cred.client_secret, } @property def headers(self): - return { - 'User-Agent': self.user_agent, - 'content-type': self.content_type - } - - def _get_cache_key(self, token_flavor=''): - return 'access_token_' + hashlib.md5( - (token_flavor + (self.cred.refresh_token or '__grantless__')).encode('utf-8') - ).hexdigest() - + return {"User-Agent": self.user_agent, "content-type": self.content_type} + + def _get_cache_key(self, token_flavor=""): + return ( + "access_token_" + + hashlib.md5( + (token_flavor + (self.cred.refresh_token or "__grantless__")).encode( + "utf-8" + ) + ).hexdigest() + ) diff --git a/sp_api/auth/access_token_response.py b/sp_api/auth/access_token_response.py index a18c68e68..efc299614 100644 --- a/sp_api/auth/access_token_response.py +++ b/sp_api/auth/access_token_response.py @@ -1,6 +1,6 @@ class AccessTokenResponse: def __init__(self, **kwargs): - self.access_token = kwargs.get('access_token') - self.refresh_token = kwargs.get('refresh_token') - self.expires_in = kwargs.get('expires_in') - self.token_type = kwargs.get('token_type') + self.access_token = kwargs.get("access_token") + self.refresh_token = kwargs.get("refresh_token") + self.expires_in = kwargs.get("expires_in") + self.token_type = kwargs.get("token_type") diff --git a/sp_api/base/ApiResponse.py b/sp_api/base/ApiResponse.py index 52d9ae3bf..7cf1fd922 100644 --- a/sp_api/base/ApiResponse.py +++ b/sp_api/base/ApiResponse.py @@ -48,10 +48,10 @@ def __init__( try: self.next_token = ( nextToken - or self.payload.get('pagination', {}).get("nextToken", None) + or self.payload.get("pagination", {}).get("nextToken", None) or self.payload.get("NextToken", None) or self.pagination.get("nextToken", None) - or self.payload.get('nextPageToken', None) + or self.payload.get("nextPageToken", None) ) except AttributeError: diff --git a/sp_api/base/__init__.py b/sp_api/base/__init__.py index 4fa16e053..d5ea92529 100644 --- a/sp_api/base/__init__.py +++ b/sp_api/base/__init__.py @@ -1,6 +1,13 @@ from .base_client import BaseClient from .client import Client -from .helpers import fill_query_params, sp_endpoint, create_md5, nest_dict, _nest_dict_rec, deprecated +from .helpers import ( + fill_query_params, + sp_endpoint, + create_md5, + nest_dict, + _nest_dict_rec, + deprecated, +) from .marketplaces import Marketplaces from .exceptions import SellingApiException from .exceptions import SellingApiBadRequestException @@ -16,7 +23,11 @@ from .report_status import ReportStatus from .sales_enum import FirstDayOfWeek, Granularity, BuyerType from .fulfillment_channel import FulfillmentChannel -from .included_data import IncludedData, ListingItemsIncludedData, CatalogItemsIncludedData +from .included_data import ( + IncludedData, + ListingItemsIncludedData, + CatalogItemsIncludedData, +) from .notifications import NotificationType from .credential_provider import CredentialProvider, MissingCredentials from .ApiResponse import ApiResponse @@ -30,44 +41,44 @@ __all__ = [ - 'Credentials', - 'AuthorizationError', - 'AccessTokenClient', - 'ReportType', - 'FeedType', - 'ProcessingStatus', - 'ApiResponse', - 'Client', - 'BaseClient', - 'Marketplaces', - 'fill_query_params', - 'sp_endpoint', - 'SellingApiException', - 'SellingApiBadRequestException', - 'SellingApiNotFoundException', - 'SellingApiServerException', - 'SellingApiForbiddenException', - 'SellingApiBadRequestException', - 'SellingApiRequestThrottledException', - 'SellingApiTemporarilyUnavailableException', - 'SellingApiTooLargeException', - 'SellingApiStateConflictException', - 'SellingApiUnsupportedFormatException', - 'Schedules', - 'ReportStatus', - 'FirstDayOfWeek', - 'Granularity', - 'BuyerType', - 'FulfillmentChannel', - 'deprecated', - 'NotificationType', - 'CredentialProvider', - 'MissingCredentials', - 'nest_dict', - '_nest_dict_rec', - 'IneligibilityReasonList', - 'IncludedData', - 'ListingItemsIncludedData', - 'CatalogItemsIncludedData', - 'AwsEnv' + "Credentials", + "AuthorizationError", + "AccessTokenClient", + "ReportType", + "FeedType", + "ProcessingStatus", + "ApiResponse", + "Client", + "BaseClient", + "Marketplaces", + "fill_query_params", + "sp_endpoint", + "SellingApiException", + "SellingApiBadRequestException", + "SellingApiNotFoundException", + "SellingApiServerException", + "SellingApiForbiddenException", + "SellingApiBadRequestException", + "SellingApiRequestThrottledException", + "SellingApiTemporarilyUnavailableException", + "SellingApiTooLargeException", + "SellingApiStateConflictException", + "SellingApiUnsupportedFormatException", + "Schedules", + "ReportStatus", + "FirstDayOfWeek", + "Granularity", + "BuyerType", + "FulfillmentChannel", + "deprecated", + "NotificationType", + "CredentialProvider", + "MissingCredentials", + "nest_dict", + "_nest_dict_rec", + "IneligibilityReasonList", + "IncludedData", + "ListingItemsIncludedData", + "CatalogItemsIncludedData", + "AwsEnv", ] diff --git a/sp_api/base/base_client.py b/sp_api/base/base_client.py index 6a1436416..38b9741e1 100644 --- a/sp_api/base/base_client.py +++ b/sp_api/base/base_client.py @@ -2,7 +2,7 @@ class BaseClient: - scheme = 'https://' - method = 'GET' - content_type = 'application/x-www-form-urlencoded;charset=UTF-8' - user_agent = f'python-sp-api-{__version__}' + scheme = "https://" + method = "GET" + content_type = "application/x-www-form-urlencoded;charset=UTF-8" + user_agent = f"python-sp-api-{__version__}" diff --git a/sp_api/base/client.py b/sp_api/base/client.py index 8ac19c92e..a842c4e89 100644 --- a/sp_api/base/client.py +++ b/sp_api/base/client.py @@ -19,43 +19,53 @@ def show_donation_message(): import os - if os.environ.get('ENV_DISABLE_DONATION_MSG', 0) == '1': + + if os.environ.get("ENV_DISABLE_DONATION_MSG", 0) == "1": return print("🌟 Thank you for using python-amazon-sp-api! 🌟") - print("This tool helps developers and businesses connect seamlessly with Amazon's vast marketplace,") + print( + "This tool helps developers and businesses connect seamlessly with Amazon's vast marketplace," + ) print("enabling powerful automations and data management.") - print("If you appreciate this project and find it useful, please consider supporting its continued development:") + print( + "If you appreciate this project and find it useful, please consider supporting its continued development:" + ) print(" - 🙌 GitHub Sponsors: https://github.com/sponsors/saleweaver") print(" - 🌐 BTC Address: bc1q6uqgczasmnvnc5upumarugw2mksnwneg0f65ws") print(" - 🌐 ETH Address: 0xf59534F7a7F5410DBCD0c779Ac3bB6503bd32Ae5") - print("\nYour support helps keep the project alive and evolving, and is greatly appreciated!") - print("\nTo disable this donation message, set the ENV_DISABLE_DONATION_MSG=1 environment variable.") + print( + "\nYour support helps keep the project alive and evolving, and is greatly appreciated!" + ) + print( + "\nTo disable this donation message, set the ENV_DISABLE_DONATION_MSG=1 environment variable." + ) class Client(BaseClient): - grantless_scope: str = '' + grantless_scope: str = "" keep_restricted_data_token: bool = False version = None def __init__( - self, - marketplace: Marketplaces = Marketplaces[ - os.environ.get('SP_API_DEFAULT_MARKETPLACE', Marketplaces.US.name)], - *, - refresh_token=None, - account='default', - credentials=None, - restricted_data_token=None, - proxies=None, - verify=True, - timeout=None, - version=None, - credential_providers=None, - auth_token_client_class=AccessTokenClient, + self, + marketplace: Marketplaces = Marketplaces[ + os.environ.get("SP_API_DEFAULT_MARKETPLACE", Marketplaces.US.name) + ], + *, + refresh_token=None, + account="default", + credentials=None, + restricted_data_token=None, + proxies=None, + verify=True, + timeout=None, + version=None, + credential_providers=None, + auth_token_client_class=AccessTokenClient, ): - if os.environ.get('SP_API_DEFAULT_MARKETPLACE', None): - marketplace = Marketplaces[os.environ.get('SP_API_DEFAULT_MARKETPLACE')] + if os.environ.get("SP_API_DEFAULT_MARKETPLACE", None): + marketplace = Marketplaces[os.environ.get("SP_API_DEFAULT_MARKETPLACE")] self.credentials = CredentialProvider( account, credentials, @@ -66,7 +76,12 @@ def __init__( self.marketplace_id = marketplace.marketplace_id self.region = marketplace.region self.restricted_data_token = restricted_data_token - self._auth = auth_token_client_class(refresh_token=refresh_token, credentials=self.credentials, proxies=proxies, verify=verify) + self._auth = auth_token_client_class( + refresh_token=refresh_token, + credentials=self.credentials, + proxies=proxies, + verify=verify, + ) self.proxies = proxies self.timeout = timeout self.version = version @@ -76,11 +91,11 @@ def __init__( @property def headers(self): return { - 'host': self.endpoint[8:], - 'user-agent': self.user_agent, - 'x-amz-access-token': self.restricted_data_token or self.auth.access_token, - 'x-amz-date': datetime.utcnow().strftime('%Y%m%dT%H%M%SZ'), - 'content-type': 'application/json' + "host": self.endpoint[8:], + "user-agent": self.user_agent, + "x-amz-access-token": self.restricted_data_token or self.auth.access_token, + "x-amz-date": datetime.utcnow().strftime("%Y%m%dT%H%M%SZ"), + "content-type": "application/json", } @property @@ -93,9 +108,18 @@ def grantless_auth(self) -> AccessTokenResponse: raise MissingScopeException("Grantless operations require scope") return self._auth.get_grantless_auth(self.grantless_scope) - def _request(self, path: str, *, data: dict = None, params: dict = None, headers=None, - add_marketplace=True, res_no_data: bool = False, bulk: bool = False, - wrap_list: bool = False) -> ApiResponse: + def _request( + self, + path: str, + *, + data: dict = None, + params: dict = None, + headers=None, + add_marketplace=True, + res_no_data: bool = False, + bulk: bool = False, + wrap_list: bool = False, + ) -> ApiResponse: if params is None: params = {} if data is None: @@ -103,28 +127,41 @@ def _request(self, path: str, *, data: dict = None, params: dict = None, headers # Note: The use of isinstance here is to support request schemas that are an array at the # top level, eg get_product_fees_estimate - self.method = params.pop('method', data.pop('method', 'GET') if isinstance(data, dict) else 'GET') + self.method = params.pop( + "method", data.pop("method", "GET") if isinstance(data, dict) else "GET" + ) if add_marketplace: - self._add_marketplaces(data if self.method in ('POST', 'PUT') else params) - - res = request(self.method, - self.endpoint + self._check_version(path), - params=params, - data=json.dumps(data) if data and self.method in ('POST', 'PUT', 'PATCH') else None, - headers=headers or self.headers, - timeout=self.timeout, - proxies=self.proxies, - verify=self.verify) + self._add_marketplaces(data if self.method in ("POST", "PUT") else params) + + res = request( + self.method, + self.endpoint + self._check_version(path), + params=params, + data=( + json.dumps(data) + if data and self.method in ("POST", "PUT", "PATCH") + else None + ), + headers=headers or self.headers, + timeout=self.timeout, + proxies=self.proxies, + verify=self.verify, + ) return self._check_response(res, res_no_data, bulk, wrap_list) - def _check_response(self, res, res_no_data: bool = False, bulk: bool = False, - wrap_list: bool = False) -> ApiResponse: - if (self.method == 'DELETE' or res_no_data) and 200 <= res.status_code < 300: + def _check_response( + self, + res, + res_no_data: bool = False, + bulk: bool = False, + wrap_list: bool = False, + ) -> ApiResponse: + if (self.method == "DELETE" or res_no_data) and 200 <= res.status_code < 300: try: js = res.json() or {} except JSONDecodeError: - js = {'status_code': res.status_code} + js = {"status_code": res.status_code} else: try: js = res.json() or {} @@ -138,7 +175,7 @@ def _check_response(self, res, res_no_data: bool = False, bulk: bool = False, else: js = js[0] - error = js.get('errors', None) + error = js.get("errors", None) if error: exception = get_exception_for_code(res.status_code) @@ -149,32 +186,48 @@ def _check_response(self, res, res_no_data: bool = False, bulk: bool = False, return ApiResponse(**js, headers=res.headers) def _add_marketplaces(self, data): - POST = ['marketplaceIds', 'MarketplaceIds'] - GET = ['MarketplaceId', 'MarketplaceIds', 'marketplace_ids', 'marketplaceIds'] + POST = ["marketplaceIds", "MarketplaceIds"] + GET = ["MarketplaceId", "MarketplaceIds", "marketplace_ids", "marketplaceIds"] - if self.method == 'POST': + if self.method == "POST": if any(x in data.keys() for x in POST): return - return data.update({k: self.marketplace_id if not k.endswith('s') else [self.marketplace_id] for k in POST}) + return data.update( + { + k: ( + self.marketplace_id + if not k.endswith("s") + else [self.marketplace_id] + ) + for k in POST + } + ) if any(x in data.keys() for x in GET): return - return data.update({k: self.marketplace_id if not k.endswith('s') else [self.marketplace_id] for k in GET}) - - def _request_grantless_operation(self, path: str, *, data: dict = None, params: dict = None): + return data.update( + { + k: self.marketplace_id if not k.endswith("s") else [self.marketplace_id] + for k in GET + } + ) + + def _request_grantless_operation( + self, path: str, *, data: dict = None, params: dict = None + ): headers = { - 'host': self.endpoint[8:], - 'user-agent': self.user_agent, - 'x-amz-access-token': self.grantless_auth.access_token, - 'x-amz-date': datetime.utcnow().strftime('%Y%m%dT%H%M%SZ'), - 'content-type': 'application/json' + "host": self.endpoint[8:], + "user-agent": self.user_agent, + "x-amz-access-token": self.grantless_auth.access_token, + "x-amz-date": datetime.utcnow().strftime("%Y%m%dT%H%M%SZ"), + "content-type": "application/json", } return self._request(path, data=data, params=params, headers=headers) def _check_version(self, path): - if '' not in path: + if "" not in path: return path - return path.replace('', self.version) + return path.replace("", self.version) def __enter__(self): self.keep_restricted_data_token = True diff --git a/sp_api/base/credential_provider.py b/sp_api/base/credential_provider.py index bc2598d6c..85bc8a4a8 100644 --- a/sp_api/base/credential_provider.py +++ b/sp_api/base/credential_provider.py @@ -15,16 +15,14 @@ SecretCache = None -required_credentials = [ - 'lwa_app_id', - 'lwa_client_secret' -] +required_credentials = ["lwa_app_id", "lwa_client_secret"] class MissingCredentials(Exception): """ Credentials are missing, see the error output to find possible causes """ + pass @@ -32,7 +30,7 @@ class BaseCredentialProvider(abc.ABC): errors = [] credentials = None - def __init__(self, account: str = 'default', *args, **kwargs): + def __init__(self, account: str = "default", *args, **kwargs): self.account = account def __call__(self, *args, **kwargs): @@ -40,15 +38,19 @@ def __call__(self, *args, **kwargs): return self.check_credentials() @abc.abstractmethod - def load_credentials(self): - ... + def load_credentials(self): ... def check_credentials(self): try: - self.errors = [c for c in required_credentials if - c not in self.credentials.keys() or not self.credentials[c]] + self.errors = [ + c + for c in required_credentials + if c not in self.credentials.keys() or not self.credentials[c] + ] except (AttributeError, TypeError): - raise MissingCredentials(f'Credentials are missing: {", ".join(required_credentials)}') + raise MissingCredentials( + f'Credentials are missing: {", ".join(required_credentials)}' + ) if not len(self.errors): return self.credentials raise MissingCredentials(f'Credentials are missing: {", ".join(self.errors)}') @@ -59,15 +61,15 @@ def load_credentials(self): return None def __init__(self, credentials: dict, *args, **kwargs): - super(FromCodeCredentialProvider, self).__init__('default', credentials) + super(FromCodeCredentialProvider, self).__init__("default", credentials) self.credentials = credentials class FromConfigFileCredentialProvider(BaseCredentialProvider): def load_credentials(self): try: - config = confuse.Configuration('python-sp-api') - config_filename = os.path.join(config.config_dir(), 'credentials.yml') + config = confuse.Configuration("python-sp-api") + config_filename = os.path.join(config.config_dir(), "credentials.yml") config.set_file(config_filename) account_data = config[self.account].get() self.credentials = account_data @@ -77,21 +79,20 @@ def load_credentials(self): class BaseFromSecretsCredentialProvider(BaseCredentialProvider): def load_credentials(self): - secret_id = os.environ.get('SP_API_AWS_SECRET_ID') + secret_id = os.environ.get("SP_API_AWS_SECRET_ID") if not secret_id: return secret = self.get_secret_content(secret_id) if not secret: return self.credentials = dict( - refresh_token=secret.get('SP_API_REFRESH_TOKEN'), - lwa_app_id=secret.get('LWA_APP_ID'), - lwa_client_secret=secret.get('LWA_CLIENT_SECRET'), + refresh_token=secret.get("SP_API_REFRESH_TOKEN"), + lwa_app_id=secret.get("LWA_APP_ID"), + lwa_client_secret=secret.get("LWA_CLIENT_SECRET"), ) @abc.abstractmethod - def get_secret_content(self, secret_id: str) -> Dict[str, str]: - ... + def get_secret_content(self, secret_id: str) -> Dict[str, str]: ... class FromSecretsCredentialProvider(BaseFromSecretsCredentialProvider): @@ -101,11 +102,11 @@ def get_secret_content(self, secret_id: str) -> Dict[str, str]: import boto3 from botocore.exceptions import ClientError - client = boto3.client('secretsmanager') + client = boto3.client("secretsmanager") response = client.get_secret_value(SecretId=secret_id) - return json.loads(response.get('SecretString')) + return json.loads(response.get("SecretString")) except ImportError: - print('boto3 not found') + print("boto3 not found") return {} except ClientError: return {} @@ -118,6 +119,7 @@ def get_secret_content(self, secret_id: str) -> Dict[str, str]: if not secret_cache: return {} from botocore.exceptions import ClientError + try: response = secret_cache.get_secret_string(secret_id=secret_id) return json.loads(response) @@ -135,15 +137,14 @@ def _get_secret_cache(cls): class FromEnvironmentVariablesCredentialProvider(BaseCredentialProvider): def load_credentials(self): account_data = dict( - refresh_token=self._get_env('SP_API_REFRESH_TOKEN'), - lwa_app_id=self._get_env('LWA_APP_ID'), - lwa_client_secret=self._get_env('LWA_CLIENT_SECRET'), + refresh_token=self._get_env("SP_API_REFRESH_TOKEN"), + lwa_app_id=self._get_env("LWA_APP_ID"), + lwa_client_secret=self._get_env("LWA_CLIENT_SECRET"), ) self.credentials = account_data def _get_env(self, key): - return os.environ.get(f'{key}_{self.account}', - os.environ.get(key)) + return os.environ.get(f"{key}_{self.account}", os.environ.get(key)) class CredentialProvider: @@ -155,17 +156,21 @@ class CredentialProvider: FromEnvironmentVariablesCredentialProvider, FromCachedSecretsCredentialProvider, FromSecretsCredentialProvider, - FromConfigFileCredentialProvider + FromConfigFileCredentialProvider, ) def __init__( self, - account: str = 'default', + account: str = "default", credentials: Optional[Dict[str, str]] = None, credential_providers: Optional[Iterable[Type[BaseCredentialProvider]]] = None, ): self.account = account - providers = self.CREDENTIAL_PROVIDERS if credential_providers is None else credential_providers + providers = ( + self.CREDENTIAL_PROVIDERS + if credential_providers is None + else credential_providers + ) for cp in providers: try: self.credentials = cp(account=account, credentials=credentials)() @@ -175,10 +180,12 @@ def __init__( if self.credentials: self.credentials = self.Config(**self.credentials) else: - raise MissingCredentials(f'Credentials are missing: {", ".join(required_credentials)}') + raise MissingCredentials( + f'Credentials are missing: {", ".join(required_credentials)}' + ) class Config: def __init__(self, **kwargs): - self.refresh_token = kwargs.get('refresh_token') - self.lwa_app_id = kwargs.get('lwa_app_id') - self.lwa_client_secret = kwargs.get('lwa_client_secret') + self.refresh_token = kwargs.get("refresh_token") + self.lwa_app_id = kwargs.get("lwa_app_id") + self.lwa_client_secret = kwargs.get("lwa_client_secret") diff --git a/sp_api/base/exceptions.py b/sp_api/base/exceptions.py index 0cb1b975b..3fb154d34 100644 --- a/sp_api/base/exceptions.py +++ b/sp_api/base/exceptions.py @@ -9,12 +9,13 @@ class SellingApiException(Exception): error: list Amazon Error list """ + code = 999 def __init__(self, error, headers): try: - self.message = error[0].get('message') - self.amzn_code = error[0].get('code') + self.message = error[0].get("message") + self.amzn_code = error[0].get("code") except IndexError: pass self.error = error @@ -25,6 +26,7 @@ class SellingApiBadRequestException(SellingApiException): """ 400 Request has missing or invalid parameters and cannot be parsed. """ + code = 400 def __init__(self, error, headers=None): @@ -35,6 +37,7 @@ class SellingApiForbiddenException(SellingApiException): """ 403 Indicates access to the resource is forbidden. Possible reasons include Access Denied, Unauthorized, Expired Token, or Invalid Signature. """ + code = 403 def __init__(self, error, headers=None): @@ -45,6 +48,7 @@ class SellingApiNotFoundException(SellingApiException): """ 404 The resource specified does not exist. """ + code = 404 def __init__(self, error, headers=None): @@ -55,6 +59,7 @@ class SellingApiStateConflictException(SellingApiException): """ 409 The resource specified conflicts with the current state. """ + code = 409 def __init__(self, error, headers=None): @@ -65,6 +70,7 @@ class SellingApiTooLargeException(SellingApiException): """ 413 The request size exceeded the maximum accepted size. """ + code = 413 def __init__(self, error, headers=None): @@ -75,6 +81,7 @@ class SellingApiUnsupportedFormatException(SellingApiException): """ 415 The request payload is in an unsupported format. """ + code = 415 def __init__(self, error, headers=None): @@ -85,6 +92,7 @@ class SellingApiRequestThrottledException(SellingApiException): """ 429 The frequency of requests was greater than allowed. """ + code = 429 def __init__(self, error, headers=None): @@ -95,6 +103,7 @@ class SellingApiServerException(SellingApiException): """ 500 An unexpected condition occurred that prevented the server from fulfilling the request. """ + code = 500 def __init__(self, error, headers=None): @@ -105,6 +114,7 @@ class SellingApiTemporarilyUnavailableException(SellingApiException): """ 503 Temporary overloading or maintenance of the server. """ + code = 503 def __init__(self, error, headers=None): @@ -115,6 +125,7 @@ class SellingApiGatewayTimeoutException(SellingApiException): """ 503 Temporary overloading or maintenance of the server. """ + code = 504 def __init__(self, error, headers=None): @@ -136,5 +147,5 @@ def get_exception_for_code(code: int): 429: SellingApiRequestThrottledException, 500: SellingApiServerException, 503: SellingApiTemporarilyUnavailableException, - 504: SellingApiGatewayTimeoutException + 504: SellingApiGatewayTimeoutException, }.get(code, SellingApiException) diff --git a/sp_api/base/feedTypes.py b/sp_api/base/feedTypes.py index 2ef2b20d1..c99445e2f 100644 --- a/sp_api/base/feedTypes.py +++ b/sp_api/base/feedTypes.py @@ -2,35 +2,47 @@ class FeedType(str, Enum): - JSON_LISTINGS_FEED = 'JSON_LISTINGS_FEED' - POST_PRODUCT_DATA = 'POST_PRODUCT_DATA' - POST_INVENTORY_AVAILABILITY_DATA = 'POST_INVENTORY_AVAILABILITY_DATA' - POST_PRODUCT_OVERRIDES_DATA = 'POST_PRODUCT_OVERRIDES_DATA' - POST_PRODUCT_PRICING_DATA = 'POST_PRODUCT_PRICING_DATA' - POST_PRODUCT_IMAGE_DATA = 'POST_PRODUCT_IMAGE_DATA' - POST_PRODUCT_RELATIONSHIP_DATA = 'POST_PRODUCT_RELATIONSHIP_DATA' - POST_FLAT_FILE_INVLOADER_DATA = 'POST_FLAT_FILE_INVLOADER_DATA' - POST_FLAT_FILE_LISTINGS_DATA = 'POST_FLAT_FILE_LISTINGS_DATA' - POST_FLAT_FILE_BOOKLOADER_DATA = 'POST_FLAT_FILE_BOOKLOADER_DATA' - POST_FLAT_FILE_CONVERGENCE_LISTINGS_DATA = 'POST_FLAT_FILE_CONVERGENCE_LISTINGS_DATA' - POST_FLAT_FILE_PRICEANDQUANTITYONLY_UPDATE_DATA = 'POST_FLAT_FILE_PRICEANDQUANTITYONLY_UPDATE_DATA' - POST_UIEE_BOOKLOADER_DATA = 'POST_UIEE_BOOKLOADER_DATA' - POST_STD_ACES_DATA = 'POST_STD_ACES_DATA' - POST_ORDER_ACKNOWLEDGEMENT_DATA = 'POST_ORDER_ACKNOWLEDGEMENT_DATA' - POST_PAYMENT_ADJUSTMENT_DATA = 'POST_PAYMENT_ADJUSTMENT_DATA' - POST_ORDER_FULFILLMENT_DATA = 'POST_ORDER_FULFILLMENT_DATA' - POST_INVOICE_CONFIRMATION_DATA = 'POST_INVOICE_CONFIRMATION_DATA' - POST_EXPECTED_SHIP_DATE_SOD = 'POST_EXPECTED_SHIP_DATE_SOD' - POST_FLAT_FILE_ORDER_ACKNOWLEDGEMENT_DATA = 'POST_FLAT_FILE_ORDER_ACKNOWLEDGEMENT_DATA' - POST_FLAT_FILE_PAYMENT_ADJUSTMENT_DATA = 'POST_FLAT_FILE_PAYMENT_ADJUSTMENT_DATA' - POST_FLAT_FILE_FULFILLMENT_DATA = 'POST_FLAT_FILE_FULFILLMENT_DATA' - POST_EXPECTED_SHIP_DATE_SOD_FLAT_FILE = 'POST_EXPECTED_SHIP_DATE_SOD_FLAT_FILE' - POST_FULFILLMENT_ORDER_REQUEST_DATA = 'POST_FULFILLMENT_ORDER_REQUEST_DATA' - POST_FULFILLMENT_ORDER_CANCELLATION_REQUEST_DATA = 'POST_FULFILLMENT_ORDER_CANCELLATION_REQUEST_DATA' - POST_FBA_INBOUND_CARTON_CONTENTS = 'POST_FBA_INBOUND_CARTON_CONTENTS' - POST_FLAT_FILE_FULFILLMENT_ORDER_REQUEST_DATA = 'POST_FLAT_FILE_FULFILLMENT_ORDER_REQUEST_DATA' - POST_FLAT_FILE_FULFILLMENT_ORDER_CANCELLATION_REQUEST_DATA = 'POST_FLAT_FILE_FULFILLMENT_ORDER_CANCELLATION_REQUEST_DATA' - POST_FLAT_FILE_FBA_CREATE_INBOUND_PLAN = 'POST_FLAT_FILE_FBA_CREATE_INBOUND_PLAN' - POST_FLAT_FILE_FBA_CREATE_REMOVAL = 'POST_FLAT_FILE_FBA_CREATE_REMOVAL' - RFQ_UPLOAD_FEED = 'RFQ_UPLOAD_FEED' - POST_EASYSHIP_DOCUMENTS = 'POST_EASYSHIP_DOCUMENTS' + JSON_LISTINGS_FEED = "JSON_LISTINGS_FEED" + POST_PRODUCT_DATA = "POST_PRODUCT_DATA" + POST_INVENTORY_AVAILABILITY_DATA = "POST_INVENTORY_AVAILABILITY_DATA" + POST_PRODUCT_OVERRIDES_DATA = "POST_PRODUCT_OVERRIDES_DATA" + POST_PRODUCT_PRICING_DATA = "POST_PRODUCT_PRICING_DATA" + POST_PRODUCT_IMAGE_DATA = "POST_PRODUCT_IMAGE_DATA" + POST_PRODUCT_RELATIONSHIP_DATA = "POST_PRODUCT_RELATIONSHIP_DATA" + POST_FLAT_FILE_INVLOADER_DATA = "POST_FLAT_FILE_INVLOADER_DATA" + POST_FLAT_FILE_LISTINGS_DATA = "POST_FLAT_FILE_LISTINGS_DATA" + POST_FLAT_FILE_BOOKLOADER_DATA = "POST_FLAT_FILE_BOOKLOADER_DATA" + POST_FLAT_FILE_CONVERGENCE_LISTINGS_DATA = ( + "POST_FLAT_FILE_CONVERGENCE_LISTINGS_DATA" + ) + POST_FLAT_FILE_PRICEANDQUANTITYONLY_UPDATE_DATA = ( + "POST_FLAT_FILE_PRICEANDQUANTITYONLY_UPDATE_DATA" + ) + POST_UIEE_BOOKLOADER_DATA = "POST_UIEE_BOOKLOADER_DATA" + POST_STD_ACES_DATA = "POST_STD_ACES_DATA" + POST_ORDER_ACKNOWLEDGEMENT_DATA = "POST_ORDER_ACKNOWLEDGEMENT_DATA" + POST_PAYMENT_ADJUSTMENT_DATA = "POST_PAYMENT_ADJUSTMENT_DATA" + POST_ORDER_FULFILLMENT_DATA = "POST_ORDER_FULFILLMENT_DATA" + POST_INVOICE_CONFIRMATION_DATA = "POST_INVOICE_CONFIRMATION_DATA" + POST_EXPECTED_SHIP_DATE_SOD = "POST_EXPECTED_SHIP_DATE_SOD" + POST_FLAT_FILE_ORDER_ACKNOWLEDGEMENT_DATA = ( + "POST_FLAT_FILE_ORDER_ACKNOWLEDGEMENT_DATA" + ) + POST_FLAT_FILE_PAYMENT_ADJUSTMENT_DATA = "POST_FLAT_FILE_PAYMENT_ADJUSTMENT_DATA" + POST_FLAT_FILE_FULFILLMENT_DATA = "POST_FLAT_FILE_FULFILLMENT_DATA" + POST_EXPECTED_SHIP_DATE_SOD_FLAT_FILE = "POST_EXPECTED_SHIP_DATE_SOD_FLAT_FILE" + POST_FULFILLMENT_ORDER_REQUEST_DATA = "POST_FULFILLMENT_ORDER_REQUEST_DATA" + POST_FULFILLMENT_ORDER_CANCELLATION_REQUEST_DATA = ( + "POST_FULFILLMENT_ORDER_CANCELLATION_REQUEST_DATA" + ) + POST_FBA_INBOUND_CARTON_CONTENTS = "POST_FBA_INBOUND_CARTON_CONTENTS" + POST_FLAT_FILE_FULFILLMENT_ORDER_REQUEST_DATA = ( + "POST_FLAT_FILE_FULFILLMENT_ORDER_REQUEST_DATA" + ) + POST_FLAT_FILE_FULFILLMENT_ORDER_CANCELLATION_REQUEST_DATA = ( + "POST_FLAT_FILE_FULFILLMENT_ORDER_CANCELLATION_REQUEST_DATA" + ) + POST_FLAT_FILE_FBA_CREATE_INBOUND_PLAN = "POST_FLAT_FILE_FBA_CREATE_INBOUND_PLAN" + POST_FLAT_FILE_FBA_CREATE_REMOVAL = "POST_FLAT_FILE_FBA_CREATE_REMOVAL" + RFQ_UPLOAD_FEED = "RFQ_UPLOAD_FEED" + POST_EASYSHIP_DOCUMENTS = "POST_EASYSHIP_DOCUMENTS" diff --git a/sp_api/base/fulfillment_channel.py b/sp_api/base/fulfillment_channel.py index 096f73455..eb70b912a 100644 --- a/sp_api/base/fulfillment_channel.py +++ b/sp_api/base/fulfillment_channel.py @@ -2,5 +2,5 @@ class FulfillmentChannel(str, Enum): - AFN = 'AFN' - MFN = 'MFN' + AFN = "AFN" + MFN = "MFN" diff --git a/sp_api/base/helpers.py b/sp_api/base/helpers.py index 29992dc91..fa215f600 100644 --- a/sp_api/base/helpers.py +++ b/sp_api/base/helpers.py @@ -7,17 +7,14 @@ def fill_query_params(query, *args): - return query.format(*[parse.quote(arg, safe='') for arg in args]) + return query.format(*[parse.quote(arg, safe="") for arg in args]) -def sp_endpoint(path, method='GET'): +def sp_endpoint(path, method="GET"): def decorator(function): @functools.wraps(function) def wrapper(*args, **kwargs): - kwargs.update({ - 'path': path, - 'method': method - }) + kwargs.update({"path": path, "method": method}) return function(*args, **kwargs) return wrapper @@ -28,16 +25,16 @@ def wrapper(*args, **kwargs): def create_md5(file): hash_md5 = hashlib.md5() if isinstance(file, BytesIO): - for chunk in iter(lambda: file.read(4096), b''): + for chunk in iter(lambda: file.read(4096), b""): hash_md5.update(chunk) file.seek(0) return base64.b64encode(hash_md5.digest()).decode() if isinstance(file, str): with open(file, "rb") as f: - for chunk in iter(lambda: f.read(4096), b''): + for chunk in iter(lambda: f.read(4096), b""): hash_md5.update(chunk) return base64.b64encode(hash_md5.digest()).decode() - for chunk in iter(lambda: file.read(4096), b''): + for chunk in iter(lambda: file.read(4096), b""): hash_md5.update(chunk) return base64.b64encode(hash_md5.digest()).decode() @@ -77,7 +74,7 @@ def nest_dict(flat: dict()): def _nest_dict_rec(k, v, out): - k, *rest = k.split('.', 1) + k, *rest = k.split(".", 1) if rest: _nest_dict_rec(rest[0], v, out.setdefault(k, {})) else: @@ -88,12 +85,16 @@ def deprecated(func): """This is a decorator which can be used to mark functions as deprecated. It will result in a warning being emitted when the function is used.""" + @functools.wraps(func) def new_func(*args, **kwargs): - warnings.simplefilter('always', DeprecationWarning) # turn off filter - warnings.warn("Call to deprecated function {}.".format(func.__name__), - category=DeprecationWarning, - stacklevel=2) - warnings.simplefilter('default', DeprecationWarning) # reset filter + warnings.simplefilter("always", DeprecationWarning) # turn off filter + warnings.warn( + "Call to deprecated function {}.".format(func.__name__), + category=DeprecationWarning, + stacklevel=2, + ) + warnings.simplefilter("default", DeprecationWarning) # reset filter return func(*args, **kwargs) + return new_func diff --git a/sp_api/base/identifiersType.py b/sp_api/base/identifiersType.py index dc75e1f61..b7d77fe3e 100644 --- a/sp_api/base/identifiersType.py +++ b/sp_api/base/identifiersType.py @@ -2,11 +2,11 @@ class IdentifiersType(str, Enum): - ASIN = 'ASIN' # doc: Amazon Standard Identification Number. - EAN = 'EAN' # doc: European Article Number. - GTIN = 'GTIN' # doc: Global Trade Item Number. - ISBN = 'ISBN' # doc: International Standard Book Number. - JAN = 'JAN' # doc: Japanese Article Number. - MINSAN = 'MINSAN' # doc: Minsan Code. - SKU = 'SKU' # doc: Stock Keeping Unit, a seller-specified identifier for an Amazon listing. Note: Must be accompanied by sellerId. - UPC = 'UPC' # doc: Universal Product Code. \ No newline at end of file + ASIN = "ASIN" # doc: Amazon Standard Identification Number. + EAN = "EAN" # doc: European Article Number. + GTIN = "GTIN" # doc: Global Trade Item Number. + ISBN = "ISBN" # doc: International Standard Book Number. + JAN = "JAN" # doc: Japanese Article Number. + MINSAN = "MINSAN" # doc: Minsan Code. + SKU = "SKU" # doc: Stock Keeping Unit, a seller-specified identifier for an Amazon listing. Note: Must be accompanied by sellerId. + UPC = "UPC" # doc: Universal Product Code. diff --git a/sp_api/base/included_data.py b/sp_api/base/included_data.py index d5c741ef2..da110a33d 100644 --- a/sp_api/base/included_data.py +++ b/sp_api/base/included_data.py @@ -7,22 +7,22 @@ class IncludedData(str, Enum): """ #: Summary details of the listing item. - SUMMARIES = 'summaries' + SUMMARIES = "summaries" #: JSON object containing structured listing item attribute data keyed by attribute name. - ATTRIBUTES = 'attributes' + ATTRIBUTES = "attributes" #: Issues associated with the listing item. - ISSUES = 'issues' + ISSUES = "issues" #: Current offers for the listing item. - OFFERS = 'offers' + OFFERS = "offers" #: Fulfillment availability details for the listing item. - FULFILLMENT_AVAILABILITY = 'fulfillmentAvailability' + FULFILLMENT_AVAILABILITY = "fulfillmentAvailability" #: Vendor procurement details for the listing item. - PROCUREMENT = 'procurement' + PROCUREMENT = "procurement" #: Dimensions for an item in the Amazon catalog. DIMENSIONS = "dimensions" @@ -49,22 +49,22 @@ class IncludedData(str, Enum): class ListingItemsIncludedData(str, Enum): #: Summary details of the listing item. - SUMMARIES = 'summaries' + SUMMARIES = "summaries" #: JSON object containing structured listing item attribute data keyed by attribute name. - ATTRIBUTES = 'attributes' + ATTRIBUTES = "attributes" #: Issues associated with the listing item. - ISSUES = 'issues' + ISSUES = "issues" #: Current offers for the listing item. - OFFERS = 'offers' + OFFERS = "offers" #: Fulfillment availability details for the listing item. - FULFILLMENT_AVAILABILITY = 'fulfillmentAvailability' + FULFILLMENT_AVAILABILITY = "fulfillmentAvailability" #: Vendor procurement details for the listing item. - PROCUREMENT = 'procurement' + PROCUREMENT = "procurement" class CatalogItemsIncludedData(str, Enum): diff --git a/sp_api/base/marketplaces.py b/sp_api/base/marketplaces.py index 6ee2aa5e7..fb3c62e2f 100644 --- a/sp_api/base/marketplaces.py +++ b/sp_api/base/marketplaces.py @@ -29,6 +29,7 @@ Australia A39IBJ37TRP1C6 AU Japan A1VC38T7YXB528 JP """ + import sys from enum import Enum import os @@ -129,4 +130,3 @@ def __init__(self, endpoint, marketplace_id, region): self.endpoint = endpoint self.marketplace_id = marketplace_id self.region = region - diff --git a/sp_api/base/notifications.py b/sp_api/base/notifications.py index b06fb11e1..241cec30e 100644 --- a/sp_api/base/notifications.py +++ b/sp_api/base/notifications.py @@ -67,4 +67,4 @@ class NotificationType(str, Enum): REPORT_PROCESSING_FINISHED = "REPORT_PROCESSING_FINISHED" #: DATA_KIOSK_QUERY_PROCESSING_FINISHED = "Sent when a Data Kiosk query finishes processing." - DATA_KIOSK_QUERY_PROCESSING_FINISHED = "DATA_KIOSK_QUERY_PROCESSING_FINISHED" \ No newline at end of file + DATA_KIOSK_QUERY_PROCESSING_FINISHED = "DATA_KIOSK_QUERY_PROCESSING_FINISHED" diff --git a/sp_api/base/processing_status.py b/sp_api/base/processing_status.py index 2a48eaf3f..c9a0701bd 100644 --- a/sp_api/base/processing_status.py +++ b/sp_api/base/processing_status.py @@ -2,8 +2,8 @@ class ProcessingStatus(str, Enum): - CANCELLED = 'CANCELLED' - DONE = 'DONE' - FATAL = 'FATAL' - IN_PROGRESS = 'IN_PROGRESS' - IN_QUEUE = 'IN_QUEUE' + CANCELLED = "CANCELLED" + DONE = "DONE" + FATAL = "FATAL" + IN_PROGRESS = "IN_PROGRESS" + IN_QUEUE = "IN_QUEUE" diff --git a/sp_api/base/reportTypes.py b/sp_api/base/reportTypes.py index d99abbc20..e5c3fb455 100644 --- a/sp_api/base/reportTypes.py +++ b/sp_api/base/reportTypes.py @@ -2,115 +2,189 @@ class ReportType(str, Enum): - GET_V2_SELLER_PERFORMANCE_REPORT = 'GET_V2_SELLER_PERFORMANCE_REPORT' - GET_FLAT_FILE_OPEN_LISTINGS_DATA = 'GET_FLAT_FILE_OPEN_LISTINGS_DATA' - GET_MERCHANT_LISTINGS_ALL_DATA = 'GET_MERCHANT_LISTINGS_ALL_DATA' - GET_MERCHANT_LISTINGS_DATA = 'GET_MERCHANT_LISTINGS_DATA' - GET_MERCHANT_LISTINGS_INACTIVE_DATA = 'GET_MERCHANT_LISTINGS_INACTIVE_DATA' - GET_MERCHANT_LISTINGS_DATA_BACK_COMPAT = 'GET_MERCHANT_LISTINGS_DATA_BACK_COMPAT' - GET_MERCHANT_LISTINGS_DATA_LITE = 'GET_MERCHANT_LISTINGS_DATA_LITE' - GET_MERCHANT_LISTINGS_DATA_LITER = 'GET_MERCHANT_LISTINGS_DATA_LITER' - GET_MERCHANT_CANCELLED_LISTINGS_DATA = 'GET_MERCHANT_CANCELLED_LISTINGS_DATA' - GET_MERCHANT_LISTINGS_DEFECT_DATA = 'GET_MERCHANT_LISTINGS_DEFECT_DATA' - GET_PAN_EU_OFFER_STATUS = 'GET_PAN_EU_OFFER_STATUS' - GET_MFN_PAN_EU_OFFER_STATUS = 'GET_MFN_PAN_EU_OFFER_STATUS' - GET_FLAT_FILE_GEO_OPPORTUNITIES = 'GET_FLAT_FILE_GEO_OPPORTUNITIES' - GET_REFERRAL_FEE_PREVIEW_REPORT = 'GET_REFERRAL_FEE_PREVIEW_REPORT' - GET_FLAT_FILE_ACTIONABLE_ORDER_DATA_SHIPPING = 'GET_FLAT_FILE_ACTIONABLE_ORDER_DATA_SHIPPING' - GET_ORDER_REPORT_DATA_INVOICING = 'GET_ORDER_REPORT_DATA_INVOICING' - GET_FLAT_FILE_ORDER_REPORT_DATA_INVOICING = 'GET_FLAT_FILE_ORDER_REPORT_DATA_INVOICING' - GET_ORDER_REPORT_DATA_TAX = 'GET_ORDER_REPORT_DATA_TAX' - GET_FLAT_FILE_ORDER_REPORT_DATA_TAX = 'GET_FLAT_FILE_ORDER_REPORT_DATA_TAX' - GET_ORDER_REPORT_DATA_SHIPPING = 'GET_ORDER_REPORT_DATA_SHIPPING' - GET_FLAT_FILE_ORDER_REPORT_DATA_SHIPPING = 'GET_FLAT_FILE_ORDER_REPORT_DATA_SHIPPING' - GET_FLAT_FILE_ALL_ORDERS_DATA_BY_LAST_UPDATE_GENERAL = 'GET_FLAT_FILE_ALL_ORDERS_DATA_BY_LAST_UPDATE_GENERAL' - GET_FLAT_FILE_ALL_ORDERS_DATA_BY_ORDER_DATE_GENERAL = 'GET_FLAT_FILE_ALL_ORDERS_DATA_BY_ORDER_DATE_GENERAL' - GET_FLAT_FILE_ARCHIVED_ORDERS_DATA_BY_ORDER_DATE = 'GET_FLAT_FILE_ARCHIVED_ORDERS_DATA_BY_ORDER_DATE' - GET_XML_ALL_ORDERS_DATA_BY_LAST_UPDATE_GENERAL = 'GET_XML_ALL_ORDERS_DATA_BY_LAST_UPDATE_GENERAL' - GET_XML_ALL_ORDERS_DATA_BY_ORDER_DATE_GENERAL = 'GET_XML_ALL_ORDERS_DATA_BY_ORDER_DATE_GENERAL' - GET_FLAT_FILE_PENDING_ORDERS_DATA = 'GET_FLAT_FILE_PENDING_ORDERS_DATA' - GET_PENDING_ORDERS_DATA = 'GET_PENDING_ORDERS_DATA' - GET_CONVERGED_FLAT_FILE_PENDING_ORDERS_DATA = 'GET_CONVERGED_FLAT_FILE_PENDING_ORDERS_DATA' - GET_XML_RETURNS_DATA_BY_RETURN_DATE = 'GET_XML_RETURNS_DATA_BY_RETURN_DATE' - GET_FLAT_FILE_RETURNS_DATA_BY_RETURN_DATE = 'GET_FLAT_FILE_RETURNS_DATA_BY_RETURN_DATE' - GET_XML_MFN_PRIME_RETURNS_REPORT = 'GET_XML_MFN_PRIME_RETURNS_REPORT' - GET_CSV_MFN_PRIME_RETURNS_REPORT = 'GET_CSV_MFN_PRIME_RETURNS_REPORT' - GET_XML_MFN_SKU_RETURN_ATTRIBUTES_REPORT = 'GET_XML_MFN_SKU_RETURN_ATTRIBUTES_REPORT' - GET_FLAT_FILE_MFN_SKU_RETURN_ATTRIBUTES_REPORT = 'GET_FLAT_FILE_MFN_SKU_RETURN_ATTRIBUTES_REPORT' - GET_SELLER_FEEDBACK_DATA = 'GET_SELLER_FEEDBACK_DATA' - GET_V1_SELLER_PERFORMANCE_REPORT = 'GET_V1_SELLER_PERFORMANCE_REPORT' - GET_V2_SETTLEMENT_REPORT_DATA_FLAT_FILE = 'GET_V2_SETTLEMENT_REPORT_DATA_FLAT_FILE' - GET_V2_SETTLEMENT_REPORT_DATA_XML = 'GET_V2_SETTLEMENT_REPORT_DATA_XML' - GET_V2_SETTLEMENT_REPORT_DATA_FLAT_FILE_V2 = 'GET_V2_SETTLEMENT_REPORT_DATA_FLAT_FILE_V2' - GET_AMAZON_FULFILLED_SHIPMENTS_DATA_GENERAL = 'GET_AMAZON_FULFILLED_SHIPMENTS_DATA_GENERAL' - GET_AMAZON_FULFILLED_SHIPMENTS_DATA_INVOICING = 'GET_AMAZON_FULFILLED_SHIPMENTS_DATA_INVOICING' - GET_AMAZON_FULFILLED_SHIPMENTS_DATA_TAX = 'GET_AMAZON_FULFILLED_SHIPMENTS_DATA_TAX' - GET_FBA_FULFILLMENT_CUSTOMER_SHIPMENT_SALES_DATA = 'GET_FBA_FULFILLMENT_CUSTOMER_SHIPMENT_SALES_DATA' - GET_FBA_FULFILLMENT_CUSTOMER_SHIPMENT_PROMOTION_DATA = 'GET_FBA_FULFILLMENT_CUSTOMER_SHIPMENT_PROMOTION_DATA' - GET_FBA_FULFILLMENT_CUSTOMER_TAXES_DATA = 'GET_FBA_FULFILLMENT_CUSTOMER_TAXES_DATA' - GET_REMOTE_FULFILLMENT_ELIGIBILITY = 'GET_REMOTE_FULFILLMENT_ELIGIBILITY' - GET_AFN_INVENTORY_DATA = 'GET_AFN_INVENTORY_DATA' - GET_AFN_INVENTORY_DATA_BY_COUNTRY = 'GET_AFN_INVENTORY_DATA_BY_COUNTRY' - GET_LEDGER_SUMMARY_VIEW_DATA = 'GET_LEDGER_SUMMARY_VIEW_DATA' - GET_LEDGER_DETAIL_VIEW_DATA = 'GET_LEDGER_DETAIL_VIEW_DATA' - GET_FBA_FULFILLMENT_CURRENT_INVENTORY_DATA = 'GET_FBA_FULFILLMENT_CURRENT_INVENTORY_DATA' - GET_FBA_FULFILLMENT_MONTHLY_INVENTORY_DATA = 'GET_FBA_FULFILLMENT_MONTHLY_INVENTORY_DATA' - GET_FBA_FULFILLMENT_INVENTORY_RECEIPTS_DATA = 'GET_FBA_FULFILLMENT_INVENTORY_RECEIPTS_DATA' - GET_RESERVED_INVENTORY_DATA = 'GET_RESERVED_INVENTORY_DATA' - GET_FBA_FULFILLMENT_INVENTORY_SUMMARY_DATA = 'GET_FBA_FULFILLMENT_INVENTORY_SUMMARY_DATA' - GET_FBA_FULFILLMENT_INVENTORY_ADJUSTMENTS_DATA = 'GET_FBA_FULFILLMENT_INVENTORY_ADJUSTMENTS_DATA' - GET_FBA_FULFILLMENT_INVENTORY_HEALTH_DATA = 'GET_FBA_FULFILLMENT_INVENTORY_HEALTH_DATA' - GET_FBA_MYI_UNSUPPRESSED_INVENTORY_DATA = 'GET_FBA_MYI_UNSUPPRESSED_INVENTORY_DATA' - GET_FBA_MYI_ALL_INVENTORY_DATA = 'GET_FBA_MYI_ALL_INVENTORY_DATA' - GET_RESTOCK_INVENTORY_RECOMMENDATIONS_REPORT = 'GET_RESTOCK_INVENTORY_RECOMMENDATIONS_REPORT' - GET_FBA_FULFILLMENT_INBOUND_NONCOMPLIANCE_DATA = 'GET_FBA_FULFILLMENT_INBOUND_NONCOMPLIANCE_DATA' - GET_STRANDED_INVENTORY_UI_DATA = 'GET_STRANDED_INVENTORY_UI_DATA' - GET_STRANDED_INVENTORY_LOADER_DATA = 'GET_STRANDED_INVENTORY_LOADER_DATA' - POST_FLAT_FILE_INVLOADER_DATA = 'POST_FLAT_FILE_INVLOADER_DATA' - GET_FBA_INVENTORY_AGED_DATA = 'GET_FBA_INVENTORY_AGED_DATA' - GET_EXCESS_INVENTORY_DATA = 'GET_EXCESS_INVENTORY_DATA' - GET_FBA_STORAGE_FEE_CHARGES_DATA = 'GET_FBA_STORAGE_FEE_CHARGES_DATA' - GET_PRODUCT_EXCHANGE_DATA = 'GET_PRODUCT_EXCHANGE_DATA' - GET_FBA_ESTIMATED_FBA_FEES_TXT_DATA = 'GET_FBA_ESTIMATED_FBA_FEES_TXT_DATA' - GET_FBA_REIMBURSEMENTS_DATA = 'GET_FBA_REIMBURSEMENTS_DATA' - GET_FBA_FULFILLMENT_LONGTERM_STORAGE_FEE_CHARGES_DATA = 'GET_FBA_FULFILLMENT_LONGTERM_STORAGE_FEE_CHARGES_DATA' - GET_FBA_FULFILLMENT_CUSTOMER_RETURNS_DATA = 'GET_FBA_FULFILLMENT_CUSTOMER_RETURNS_DATA' - GET_FBA_FULFILLMENT_CUSTOMER_SHIPMENT_REPLACEMENT_DATA = 'GET_FBA_FULFILLMENT_CUSTOMER_SHIPMENT_REPLACEMENT_DATA' - GET_FBA_RECOMMENDED_REMOVAL_DATA = 'GET_FBA_RECOMMENDED_REMOVAL_DATA' - GET_FBA_FULFILLMENT_REMOVAL_ORDER_DETAIL_DATA = 'GET_FBA_FULFILLMENT_REMOVAL_ORDER_DETAIL_DATA' - GET_FBA_FULFILLMENT_REMOVAL_SHIPMENT_DETAIL_DATA = 'GET_FBA_FULFILLMENT_REMOVAL_SHIPMENT_DETAIL_DATA' - GET_FBA_INVENTORY_PLANNING_DATA = 'GET_FBA_INVENTORY_PLANNING_DATA' - GET_FBA_UNO_INVENTORY_DATA = 'GET_FBA_UNO_INVENTORY_DATA' - GET_FLAT_FILE_SALES_TAX_DATA = 'GET_FLAT_FILE_SALES_TAX_DATA' - SC_VAT_TAX_REPORT = 'SC_VAT_TAX_REPORT' - GET_VAT_TRANSACTION_DATA = 'GET_VAT_TRANSACTION_DATA' - GET_GST_MTR_B2B_CUSTOM = 'GET_GST_MTR_B2B_CUSTOM' - GET_GST_MTR_B2C_CUSTOM = 'GET_GST_MTR_B2C_CUSTOM' - GET_XML_BROWSE_TREE_DATA = 'GET_XML_BROWSE_TREE_DATA' - GET_EASYSHIP_DOCUMENTS = 'GET_EASYSHIP_DOCUMENTS' - GET_EASYSHIP_PICKEDUP = 'GET_EASYSHIP_PICKEDUP' - GET_EASYSHIP_WAITING_FOR_PICKUP = 'GET_EASYSHIP_WAITING_FOR_PICKUP' - RFQD_BULK_DOWNLOAD = 'RFQD_BULK_DOWNLOAD' - FEE_DISCOUNTS_REPORT = 'FEE_DISCOUNTS_REPORT' - GET_FLAT_FILE_OFFAMAZONPAYMENTS_SANDBOX_SETTLEMENT_DATA = 'GET_FLAT_FILE_OFFAMAZONPAYMENTS_SANDBOX_SETTLEMENT_DATA' - GET_BRAND_ANALYTICS_SEARCH_TERMS_REPORT = 'GET_BRAND_ANALYTICS_SEARCH_TERMS_REPORT' - GET_VENDOR_FORECASTING_REPORT = 'GET_VENDOR_FORECASTING_REPORT' - GET_VENDOR_SALES_DIAGNOSTIC_REPORT = 'GET_VENDOR_SALES_DIAGNOSTIC_REPORT' - GET_VENDOR_SALES_REPORT = 'GET_VENDOR_SALES_REPORT' - GET_VENDOR_REAL_TIME_SALES_REPORT = 'GET_VENDOR_REAL_TIME_SALES_REPORT' - GET_VENDOR_TRAFFIC_REPORT = 'GET_VENDOR_TRAFFIC_REPORT' - GET_VENDOR_REAL_TIME_TRAFFIC_REPORT = 'GET_VENDOR_REAL_TIME_TRAFFIC_REPORT' - GET_VENDOR_INVENTORY_HEALTH_AND_PLANNING_REPORT = 'GET_VENDOR_INVENTORY_HEALTH_AND_PLANNING_REPORT' - GET_VENDOR_INVENTORY_REPORT = 'GET_VENDOR_INVENTORY_REPORT' - GET_VENDOR_REAL_TIME_INVENTORY_REPORT = 'GET_VENDOR_REAL_TIME_INVENTORY_REPORT' - GET_VENDOR_DEMAND_FORECAST_REPORT = 'GET_VENDOR_DEMAND_FORECAST_REPORT' - GET_PROMOTION_PERFORMANCE_REPORT = 'GET_PROMOTION_PERFORMANCE_REPORT' - GET_BRAND_ANALYTICS_MARKET_BASKET_REPORT = 'GET_BRAND_ANALYTICS_MARKET_BASKET_REPORT' - GET_BRAND_ANALYTICS_REPEAT_PURCHASE_REPORT = 'GET_BRAND_ANALYTICS_REPEAT_PURCHASE_REPORT' - GET_BRAND_ANALYTICS_ALTERNATE_PURCHASE_REPORT = 'GET_BRAND_ANALYTICS_ALTERNATE_PURCHASE_REPORT' - GET_BRAND_ANALYTICS_ITEM_COMPARISON_REPORT = 'GET_BRAND_ANALYTICS_ITEM_COMPARISON_REPORT' - GET_VENDOR_NET_PURE_PRODUCT_MARGIN_REPORT = 'GET_VENDOR_NET_PURE_PRODUCT_MARGIN_REPORT' - GET_MERCHANTS_LISTINGS_FYP_REPORT = 'GET_MERCHANTS_LISTINGS_FYP_REPORT' + GET_V2_SELLER_PERFORMANCE_REPORT = "GET_V2_SELLER_PERFORMANCE_REPORT" + GET_FLAT_FILE_OPEN_LISTINGS_DATA = "GET_FLAT_FILE_OPEN_LISTINGS_DATA" + GET_MERCHANT_LISTINGS_ALL_DATA = "GET_MERCHANT_LISTINGS_ALL_DATA" + GET_MERCHANT_LISTINGS_DATA = "GET_MERCHANT_LISTINGS_DATA" + GET_MERCHANT_LISTINGS_INACTIVE_DATA = "GET_MERCHANT_LISTINGS_INACTIVE_DATA" + GET_MERCHANT_LISTINGS_DATA_BACK_COMPAT = "GET_MERCHANT_LISTINGS_DATA_BACK_COMPAT" + GET_MERCHANT_LISTINGS_DATA_LITE = "GET_MERCHANT_LISTINGS_DATA_LITE" + GET_MERCHANT_LISTINGS_DATA_LITER = "GET_MERCHANT_LISTINGS_DATA_LITER" + GET_MERCHANT_CANCELLED_LISTINGS_DATA = "GET_MERCHANT_CANCELLED_LISTINGS_DATA" + GET_MERCHANT_LISTINGS_DEFECT_DATA = "GET_MERCHANT_LISTINGS_DEFECT_DATA" + GET_PAN_EU_OFFER_STATUS = "GET_PAN_EU_OFFER_STATUS" + GET_MFN_PAN_EU_OFFER_STATUS = "GET_MFN_PAN_EU_OFFER_STATUS" + GET_FLAT_FILE_GEO_OPPORTUNITIES = "GET_FLAT_FILE_GEO_OPPORTUNITIES" + GET_REFERRAL_FEE_PREVIEW_REPORT = "GET_REFERRAL_FEE_PREVIEW_REPORT" + GET_FLAT_FILE_ACTIONABLE_ORDER_DATA_SHIPPING = ( + "GET_FLAT_FILE_ACTIONABLE_ORDER_DATA_SHIPPING" + ) + GET_ORDER_REPORT_DATA_INVOICING = "GET_ORDER_REPORT_DATA_INVOICING" + GET_FLAT_FILE_ORDER_REPORT_DATA_INVOICING = ( + "GET_FLAT_FILE_ORDER_REPORT_DATA_INVOICING" + ) + GET_ORDER_REPORT_DATA_TAX = "GET_ORDER_REPORT_DATA_TAX" + GET_FLAT_FILE_ORDER_REPORT_DATA_TAX = "GET_FLAT_FILE_ORDER_REPORT_DATA_TAX" + GET_ORDER_REPORT_DATA_SHIPPING = "GET_ORDER_REPORT_DATA_SHIPPING" + GET_FLAT_FILE_ORDER_REPORT_DATA_SHIPPING = ( + "GET_FLAT_FILE_ORDER_REPORT_DATA_SHIPPING" + ) + GET_FLAT_FILE_ALL_ORDERS_DATA_BY_LAST_UPDATE_GENERAL = ( + "GET_FLAT_FILE_ALL_ORDERS_DATA_BY_LAST_UPDATE_GENERAL" + ) + GET_FLAT_FILE_ALL_ORDERS_DATA_BY_ORDER_DATE_GENERAL = ( + "GET_FLAT_FILE_ALL_ORDERS_DATA_BY_ORDER_DATE_GENERAL" + ) + GET_FLAT_FILE_ARCHIVED_ORDERS_DATA_BY_ORDER_DATE = ( + "GET_FLAT_FILE_ARCHIVED_ORDERS_DATA_BY_ORDER_DATE" + ) + GET_XML_ALL_ORDERS_DATA_BY_LAST_UPDATE_GENERAL = ( + "GET_XML_ALL_ORDERS_DATA_BY_LAST_UPDATE_GENERAL" + ) + GET_XML_ALL_ORDERS_DATA_BY_ORDER_DATE_GENERAL = ( + "GET_XML_ALL_ORDERS_DATA_BY_ORDER_DATE_GENERAL" + ) + GET_FLAT_FILE_PENDING_ORDERS_DATA = "GET_FLAT_FILE_PENDING_ORDERS_DATA" + GET_PENDING_ORDERS_DATA = "GET_PENDING_ORDERS_DATA" + GET_CONVERGED_FLAT_FILE_PENDING_ORDERS_DATA = ( + "GET_CONVERGED_FLAT_FILE_PENDING_ORDERS_DATA" + ) + GET_XML_RETURNS_DATA_BY_RETURN_DATE = "GET_XML_RETURNS_DATA_BY_RETURN_DATE" + GET_FLAT_FILE_RETURNS_DATA_BY_RETURN_DATE = ( + "GET_FLAT_FILE_RETURNS_DATA_BY_RETURN_DATE" + ) + GET_XML_MFN_PRIME_RETURNS_REPORT = "GET_XML_MFN_PRIME_RETURNS_REPORT" + GET_CSV_MFN_PRIME_RETURNS_REPORT = "GET_CSV_MFN_PRIME_RETURNS_REPORT" + GET_XML_MFN_SKU_RETURN_ATTRIBUTES_REPORT = ( + "GET_XML_MFN_SKU_RETURN_ATTRIBUTES_REPORT" + ) + GET_FLAT_FILE_MFN_SKU_RETURN_ATTRIBUTES_REPORT = ( + "GET_FLAT_FILE_MFN_SKU_RETURN_ATTRIBUTES_REPORT" + ) + GET_SELLER_FEEDBACK_DATA = "GET_SELLER_FEEDBACK_DATA" + GET_V1_SELLER_PERFORMANCE_REPORT = "GET_V1_SELLER_PERFORMANCE_REPORT" + GET_V2_SETTLEMENT_REPORT_DATA_FLAT_FILE = "GET_V2_SETTLEMENT_REPORT_DATA_FLAT_FILE" + GET_V2_SETTLEMENT_REPORT_DATA_XML = "GET_V2_SETTLEMENT_REPORT_DATA_XML" + GET_V2_SETTLEMENT_REPORT_DATA_FLAT_FILE_V2 = ( + "GET_V2_SETTLEMENT_REPORT_DATA_FLAT_FILE_V2" + ) + GET_AMAZON_FULFILLED_SHIPMENTS_DATA_GENERAL = ( + "GET_AMAZON_FULFILLED_SHIPMENTS_DATA_GENERAL" + ) + GET_AMAZON_FULFILLED_SHIPMENTS_DATA_INVOICING = ( + "GET_AMAZON_FULFILLED_SHIPMENTS_DATA_INVOICING" + ) + GET_AMAZON_FULFILLED_SHIPMENTS_DATA_TAX = "GET_AMAZON_FULFILLED_SHIPMENTS_DATA_TAX" + GET_FBA_FULFILLMENT_CUSTOMER_SHIPMENT_SALES_DATA = ( + "GET_FBA_FULFILLMENT_CUSTOMER_SHIPMENT_SALES_DATA" + ) + GET_FBA_FULFILLMENT_CUSTOMER_SHIPMENT_PROMOTION_DATA = ( + "GET_FBA_FULFILLMENT_CUSTOMER_SHIPMENT_PROMOTION_DATA" + ) + GET_FBA_FULFILLMENT_CUSTOMER_TAXES_DATA = "GET_FBA_FULFILLMENT_CUSTOMER_TAXES_DATA" + GET_REMOTE_FULFILLMENT_ELIGIBILITY = "GET_REMOTE_FULFILLMENT_ELIGIBILITY" + GET_AFN_INVENTORY_DATA = "GET_AFN_INVENTORY_DATA" + GET_AFN_INVENTORY_DATA_BY_COUNTRY = "GET_AFN_INVENTORY_DATA_BY_COUNTRY" + GET_LEDGER_SUMMARY_VIEW_DATA = "GET_LEDGER_SUMMARY_VIEW_DATA" + GET_LEDGER_DETAIL_VIEW_DATA = "GET_LEDGER_DETAIL_VIEW_DATA" + GET_FBA_FULFILLMENT_CURRENT_INVENTORY_DATA = ( + "GET_FBA_FULFILLMENT_CURRENT_INVENTORY_DATA" + ) + GET_FBA_FULFILLMENT_MONTHLY_INVENTORY_DATA = ( + "GET_FBA_FULFILLMENT_MONTHLY_INVENTORY_DATA" + ) + GET_FBA_FULFILLMENT_INVENTORY_RECEIPTS_DATA = ( + "GET_FBA_FULFILLMENT_INVENTORY_RECEIPTS_DATA" + ) + GET_RESERVED_INVENTORY_DATA = "GET_RESERVED_INVENTORY_DATA" + GET_FBA_FULFILLMENT_INVENTORY_SUMMARY_DATA = ( + "GET_FBA_FULFILLMENT_INVENTORY_SUMMARY_DATA" + ) + GET_FBA_FULFILLMENT_INVENTORY_ADJUSTMENTS_DATA = ( + "GET_FBA_FULFILLMENT_INVENTORY_ADJUSTMENTS_DATA" + ) + GET_FBA_FULFILLMENT_INVENTORY_HEALTH_DATA = ( + "GET_FBA_FULFILLMENT_INVENTORY_HEALTH_DATA" + ) + GET_FBA_MYI_UNSUPPRESSED_INVENTORY_DATA = "GET_FBA_MYI_UNSUPPRESSED_INVENTORY_DATA" + GET_FBA_MYI_ALL_INVENTORY_DATA = "GET_FBA_MYI_ALL_INVENTORY_DATA" + GET_RESTOCK_INVENTORY_RECOMMENDATIONS_REPORT = ( + "GET_RESTOCK_INVENTORY_RECOMMENDATIONS_REPORT" + ) + GET_FBA_FULFILLMENT_INBOUND_NONCOMPLIANCE_DATA = ( + "GET_FBA_FULFILLMENT_INBOUND_NONCOMPLIANCE_DATA" + ) + GET_STRANDED_INVENTORY_UI_DATA = "GET_STRANDED_INVENTORY_UI_DATA" + GET_STRANDED_INVENTORY_LOADER_DATA = "GET_STRANDED_INVENTORY_LOADER_DATA" + POST_FLAT_FILE_INVLOADER_DATA = "POST_FLAT_FILE_INVLOADER_DATA" + GET_FBA_INVENTORY_AGED_DATA = "GET_FBA_INVENTORY_AGED_DATA" + GET_EXCESS_INVENTORY_DATA = "GET_EXCESS_INVENTORY_DATA" + GET_FBA_STORAGE_FEE_CHARGES_DATA = "GET_FBA_STORAGE_FEE_CHARGES_DATA" + GET_PRODUCT_EXCHANGE_DATA = "GET_PRODUCT_EXCHANGE_DATA" + GET_FBA_ESTIMATED_FBA_FEES_TXT_DATA = "GET_FBA_ESTIMATED_FBA_FEES_TXT_DATA" + GET_FBA_REIMBURSEMENTS_DATA = "GET_FBA_REIMBURSEMENTS_DATA" + GET_FBA_FULFILLMENT_LONGTERM_STORAGE_FEE_CHARGES_DATA = ( + "GET_FBA_FULFILLMENT_LONGTERM_STORAGE_FEE_CHARGES_DATA" + ) + GET_FBA_FULFILLMENT_CUSTOMER_RETURNS_DATA = ( + "GET_FBA_FULFILLMENT_CUSTOMER_RETURNS_DATA" + ) + GET_FBA_FULFILLMENT_CUSTOMER_SHIPMENT_REPLACEMENT_DATA = ( + "GET_FBA_FULFILLMENT_CUSTOMER_SHIPMENT_REPLACEMENT_DATA" + ) + GET_FBA_RECOMMENDED_REMOVAL_DATA = "GET_FBA_RECOMMENDED_REMOVAL_DATA" + GET_FBA_FULFILLMENT_REMOVAL_ORDER_DETAIL_DATA = ( + "GET_FBA_FULFILLMENT_REMOVAL_ORDER_DETAIL_DATA" + ) + GET_FBA_FULFILLMENT_REMOVAL_SHIPMENT_DETAIL_DATA = ( + "GET_FBA_FULFILLMENT_REMOVAL_SHIPMENT_DETAIL_DATA" + ) + GET_FBA_INVENTORY_PLANNING_DATA = "GET_FBA_INVENTORY_PLANNING_DATA" + GET_FBA_UNO_INVENTORY_DATA = "GET_FBA_UNO_INVENTORY_DATA" + GET_FLAT_FILE_SALES_TAX_DATA = "GET_FLAT_FILE_SALES_TAX_DATA" + SC_VAT_TAX_REPORT = "SC_VAT_TAX_REPORT" + GET_VAT_TRANSACTION_DATA = "GET_VAT_TRANSACTION_DATA" + GET_GST_MTR_B2B_CUSTOM = "GET_GST_MTR_B2B_CUSTOM" + GET_GST_MTR_B2C_CUSTOM = "GET_GST_MTR_B2C_CUSTOM" + GET_XML_BROWSE_TREE_DATA = "GET_XML_BROWSE_TREE_DATA" + GET_EASYSHIP_DOCUMENTS = "GET_EASYSHIP_DOCUMENTS" + GET_EASYSHIP_PICKEDUP = "GET_EASYSHIP_PICKEDUP" + GET_EASYSHIP_WAITING_FOR_PICKUP = "GET_EASYSHIP_WAITING_FOR_PICKUP" + RFQD_BULK_DOWNLOAD = "RFQD_BULK_DOWNLOAD" + FEE_DISCOUNTS_REPORT = "FEE_DISCOUNTS_REPORT" + GET_FLAT_FILE_OFFAMAZONPAYMENTS_SANDBOX_SETTLEMENT_DATA = ( + "GET_FLAT_FILE_OFFAMAZONPAYMENTS_SANDBOX_SETTLEMENT_DATA" + ) + GET_BRAND_ANALYTICS_SEARCH_TERMS_REPORT = "GET_BRAND_ANALYTICS_SEARCH_TERMS_REPORT" + GET_VENDOR_FORECASTING_REPORT = "GET_VENDOR_FORECASTING_REPORT" + GET_VENDOR_SALES_DIAGNOSTIC_REPORT = "GET_VENDOR_SALES_DIAGNOSTIC_REPORT" + GET_VENDOR_SALES_REPORT = "GET_VENDOR_SALES_REPORT" + GET_VENDOR_REAL_TIME_SALES_REPORT = "GET_VENDOR_REAL_TIME_SALES_REPORT" + GET_VENDOR_TRAFFIC_REPORT = "GET_VENDOR_TRAFFIC_REPORT" + GET_VENDOR_REAL_TIME_TRAFFIC_REPORT = "GET_VENDOR_REAL_TIME_TRAFFIC_REPORT" + GET_VENDOR_INVENTORY_HEALTH_AND_PLANNING_REPORT = ( + "GET_VENDOR_INVENTORY_HEALTH_AND_PLANNING_REPORT" + ) + GET_VENDOR_INVENTORY_REPORT = "GET_VENDOR_INVENTORY_REPORT" + GET_VENDOR_REAL_TIME_INVENTORY_REPORT = "GET_VENDOR_REAL_TIME_INVENTORY_REPORT" + GET_VENDOR_DEMAND_FORECAST_REPORT = "GET_VENDOR_DEMAND_FORECAST_REPORT" + GET_PROMOTION_PERFORMANCE_REPORT = "GET_PROMOTION_PERFORMANCE_REPORT" + GET_BRAND_ANALYTICS_MARKET_BASKET_REPORT = ( + "GET_BRAND_ANALYTICS_MARKET_BASKET_REPORT" + ) + GET_BRAND_ANALYTICS_REPEAT_PURCHASE_REPORT = ( + "GET_BRAND_ANALYTICS_REPEAT_PURCHASE_REPORT" + ) + GET_BRAND_ANALYTICS_ALTERNATE_PURCHASE_REPORT = ( + "GET_BRAND_ANALYTICS_ALTERNATE_PURCHASE_REPORT" + ) + GET_BRAND_ANALYTICS_ITEM_COMPARISON_REPORT = ( + "GET_BRAND_ANALYTICS_ITEM_COMPARISON_REPORT" + ) + GET_VENDOR_NET_PURE_PRODUCT_MARGIN_REPORT = ( + "GET_VENDOR_NET_PURE_PRODUCT_MARGIN_REPORT" + ) + GET_MERCHANTS_LISTINGS_FYP_REPORT = "GET_MERCHANTS_LISTINGS_FYP_REPORT" GET_FBA_SNS_FORECAST_DATA = "GET_FBA_SNS_FORECAST_DATA" GET_FBA_SNS_PERFORMANCE_DATA = "GET_FBA_SNS_PERFORMANCE_DATA" GET_COUPON_PERFORMANCE_REPORT = "GET_COUPON_PERFORMANCE_REPORT" @@ -118,5 +192,9 @@ class ReportType(str, Enum): GET_GST_STR_ADHOC = "GET_GST_STR_ADHOC" GET_FLAT_FILE_VAT_INVOICE_DATA_REPORT = "GET_FLAT_FILE_VAT_INVOICE_DATA_REPORT" GET_XML_VAT_INVOICE_DATA_REPORT = "GET_XML_VAT_INVOICE_DATA_REPORT" - GET_B2B_PRODUCT_OPPORTUNITIES_RECOMMENDED_FOR_YOU = "GET_B2B_PRODUCT_OPPORTUNITIES_RECOMMENDED_FOR_YOU" - GET_B2B_PRODUCT_OPPORTUNITIES_NOT_YET_ON_AMAZON = "GET_B2B_PRODUCT_OPPORTUNITIES_NOT_YET_ON_AMAZON" + GET_B2B_PRODUCT_OPPORTUNITIES_RECOMMENDED_FOR_YOU = ( + "GET_B2B_PRODUCT_OPPORTUNITIES_RECOMMENDED_FOR_YOU" + ) + GET_B2B_PRODUCT_OPPORTUNITIES_NOT_YET_ON_AMAZON = ( + "GET_B2B_PRODUCT_OPPORTUNITIES_NOT_YET_ON_AMAZON" + ) diff --git a/sp_api/base/sales_enum.py b/sp_api/base/sales_enum.py index 76fb4b038..0b6da1bdd 100644 --- a/sp_api/base/sales_enum.py +++ b/sp_api/base/sales_enum.py @@ -2,22 +2,20 @@ class Granularity(str, Enum): - HOUR = 'Hour' - DAY = 'Day' - WEEK = 'Week' - MONTH = 'Month' - YEAR = 'Year' - TOTAL = 'Total' + HOUR = "Hour" + DAY = "Day" + WEEK = "Week" + MONTH = "Month" + YEAR = "Year" + TOTAL = "Total" class BuyerType(str, Enum): - B2B = 'B2B' # doc: Business to business. - B2C = 'B2C' # doc: Business to customer. - ALL = 'All' # doc: Both of above + B2B = "B2B" # doc: Business to business. + B2C = "B2C" # doc: Business to customer. + ALL = "All" # doc: Both of above class FirstDayOfWeek(str, Enum): - MO = 'Monday' - SU = 'Sunday' - - + MO = "Monday" + SU = "Sunday" diff --git a/sp_api/util/__init__.py b/sp_api/util/__init__.py index 86898919e..0dd8b5a4e 100644 --- a/sp_api/util/__init__.py +++ b/sp_api/util/__init__.py @@ -4,10 +4,10 @@ from .load_date_bound import load_date_bound __all__ = [ - 'retry', - 'sp_retry', - 'throttle_retry', - 'load_all_pages', - 'KeyMaker', - 'load_date_bound' + "retry", + "sp_retry", + "throttle_retry", + "load_all_pages", + "KeyMaker", + "load_date_bound", ] diff --git a/sp_api/util/key_maker.py b/sp_api/util/key_maker.py index d1e0cc882..65f7ac063 100644 --- a/sp_api/util/key_maker.py +++ b/sp_api/util/key_maker.py @@ -72,5 +72,7 @@ def _map_to_key_mapping(self, key): @staticmethod def _replace_dash(key): - return key[0].lower() + ''.join( - word.title() if i > 0 else word for i, word in enumerate(re.sub(r'[-\s]', '_', key[1:]).split('_'))) + return key[0].lower() + "".join( + word.title() if i > 0 else word + for i, word in enumerate(re.sub(r"[-\s]", "_", key[1:]).split("_")) + ) diff --git a/sp_api/util/load_all_pages.py b/sp_api/util/load_all_pages.py index fd509fe19..15011e9b4 100644 --- a/sp_api/util/load_all_pages.py +++ b/sp_api/util/load_all_pages.py @@ -7,9 +7,12 @@ def make_sleep_time(rate_limit, use_rate_limit_header, throttle_by_seconds): return throttle_by_seconds - -def load_all_pages(throttle_by_seconds: float = 2, next_token_param='NextToken', use_rate_limit_header: bool = False, - extras: dict = None): +def load_all_pages( + throttle_by_seconds: float = 2, + next_token_param="NextToken", + use_rate_limit_header: bool = False, + extras: dict = None, +): """ Load all pages if a next token is returned @@ -31,7 +34,9 @@ def wrapper(*args, **kwargs): res = function(*args, **kwargs) yield res if res.next_token: - sleep_time = make_sleep_time(res.rate_limit, use_rate_limit_header, throttle_by_seconds) + sleep_time = make_sleep_time( + res.rate_limit, use_rate_limit_header, throttle_by_seconds + ) if sleep_time > 0: time.sleep(sleep_time) kwargs.update({next_token_param: res.next_token, **extras}) diff --git a/sp_api/util/load_date_bound.py b/sp_api/util/load_date_bound.py index afea0b2b9..184213c77 100644 --- a/sp_api/util/load_date_bound.py +++ b/sp_api/util/load_date_bound.py @@ -17,20 +17,35 @@ def parse_if_needed(dt: datetime or str): def decorator(function): def wrapper(*args, **kwargs): - date_range.update({ - 'dataStartTime': parse_if_needed(kwargs['dataStartTime']), - 'dataEndTime': parse_if_needed(kwargs.get('dataEndTime', datetime.datetime.utcnow())) - }) - kwargs.update({ - 'dataEndTime': make_end_date(date_range['dataStartTime'], date_range['dataEndTime'], interval_days) - }) - while kwargs['dataStartTime'] < kwargs['dataEndTime']: + date_range.update( + { + "dataStartTime": parse_if_needed(kwargs["dataStartTime"]), + "dataEndTime": parse_if_needed( + kwargs.get("dataEndTime", datetime.datetime.utcnow()) + ), + } + ) + kwargs.update( + { + "dataEndTime": make_end_date( + date_range["dataStartTime"], + date_range["dataEndTime"], + interval_days, + ) + } + ) + while kwargs["dataStartTime"] < kwargs["dataEndTime"]: yield function(*args, **kwargs) - kwargs.update({ - 'dataStartTime': parse_if_needed(kwargs['dataEndTime']), - 'dataEndTime': make_end_date(parse_if_needed(kwargs['dataEndTime']), date_range['dataEndTime'], - interval_days) - }) + kwargs.update( + { + "dataStartTime": parse_if_needed(kwargs["dataEndTime"]), + "dataEndTime": make_end_date( + parse_if_needed(kwargs["dataEndTime"]), + date_range["dataEndTime"], + interval_days, + ), + } + ) wrapper.__doc__ = function.__doc__ return wrapper diff --git a/sp_api/util/retry.py b/sp_api/util/retry.py index a48fec287..ed48123a9 100644 --- a/sp_api/util/retry.py +++ b/sp_api/util/retry.py @@ -20,31 +20,28 @@ def retry(exception_classes=None, tries=10, delay=5, rate=1.3): if exception_classes is None: exception_classes = (Exception,) - tries_counter = { - 'count': 1, - 'last_delay': delay - } + tries_counter = {"count": 1, "last_delay": delay} def decorator(function): def wrapper(*args, **kwargs): try: return function(*args, **kwargs) except exception_classes as e: - if tries_counter.get('count') + 1 > tries: + if tries_counter.get("count") + 1 > tries: raise e - delay_now = delay if tries_counter.get('count') == 1 else tries_counter.get('last_delay') * rate - tries_counter.update({ - 'count': tries_counter.get('count') + 1, - 'last_delay': delay_now - }) + delay_now = ( + delay + if tries_counter.get("count") == 1 + else tries_counter.get("last_delay") * rate + ) + tries_counter.update( + {"count": tries_counter.get("count") + 1, "last_delay": delay_now} + ) time.sleep(delay_now) return wrapper(*args, **kwargs) finally: - tries_counter.update({ - 'count': 1, - 'last_delay': delay - }) + tries_counter.update({"count": 1, "last_delay": delay}) wrapper.__doc__ = function.__doc__ return wrapper @@ -67,6 +64,7 @@ def sp_retry(exception_classes=(), tries=10, delay=5, rate=1.3): """ from sp_api.base import SellingApiException + return retry((SellingApiException,) + exception_classes, tries, delay, rate) @@ -85,4 +83,7 @@ def throttle_retry(exception_classes=(), tries=10, delay=5, rate=1.3): """ from sp_api.base import SellingApiRequestThrottledException - return retry((SellingApiRequestThrottledException,) + exception_classes, tries, delay, rate) + + return retry( + (SellingApiRequestThrottledException,) + exception_classes, tries, delay, rate + )