From 53014836d254af2dbe7697cde12e99e785eb0501 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 7 Feb 2021 19:59:47 +0100 Subject: [PATCH] refactored to return an ApiResponse instead of multiple different with the same properties --- docs/endpoints/finances.rst | 4 +- docs/endpoints/product_fees.rst | 3 +- docs/endpoints/reports.rst | 4 +- docs/endpoints/sales.rst | 5 +- docs/endpoints/sellers.rst | 3 +- docs/responses.rst | 11 +- setup.py | 29 +-- sp_api/api/catalog/catalog.py | 22 +-- sp_api/api/catalog/models/__init__.py | 1 - .../models/get_catalog_item_response.py | 137 --------------- .../list_catalog_categories_response.py | 137 --------------- .../models/list_catalog_items_response.py | 137 --------------- .../models/list_matching_items_response.py | 111 ------------ sp_api/api/feeds/feeds.py | 40 ++--- sp_api/api/feeds/models/__init__.py | 1 - .../api/feeds/models/cancel_feed_response.py | 111 ------------ .../models/create_feed_document_response.py | 137 --------------- .../api/feeds/models/create_feed_response.py | 137 --------------- .../models/get_feed_document_response.py | 137 --------------- sp_api/api/feeds/models/get_feed_response.py | 137 --------------- sp_api/api/feeds/models/get_feeds_response.py | 165 ------------------ sp_api/api/finances/finances.py | 21 ++- sp_api/api/finances/models/__init__.py | 1 - .../list_financial_event_groups_response.py | 137 --------------- .../models/list_financial_events_response.py | 137 --------------- sp_api/api/inventories/inventories.py | 8 +- sp_api/api/inventories/models/__init__.py | 1 - .../get_inventory_summaries_response.py | 164 ----------------- sp_api/api/notifications/models/__init__.py | 1 - .../models/create_destination_response.py | 137 --------------- .../models/create_subscription_response.py | 137 --------------- .../models/delete_destination_response.py | 111 ------------ .../delete_subscription_by_id_response.py | 112 ------------ .../destination_resource_specification.py | 137 --------------- .../models/get_destination_response.py | 137 --------------- .../models/get_destinations_response.py | 137 --------------- .../models/get_subscription_by_id_response.py | 137 --------------- .../models/get_subscription_response.py | 137 --------------- sp_api/api/notifications/notifications.py | 101 +++++------ sp_api/api/orders/models/__init__.py | 1 - .../models/get_order_address_response.py | 137 --------------- .../models/get_order_buyer_info_response.py | 137 --------------- .../get_order_items_buyer_info_response.py | 137 --------------- .../orders/models/get_order_items_response.py | 137 --------------- .../api/orders/models/get_order_response.py | 137 --------------- .../api/orders/models/get_orders_response.py | 137 --------------- sp_api/api/orders/orders.py | 65 +++---- sp_api/api/product_fees/models/__init__.py | 1 - .../models/get_my_fees_estimate_response.py | 137 --------------- sp_api/api/product_fees/product_fees.py | 68 ++++++-- sp_api/api/products/models/__init__.py | 1 - .../products/models/get_offers_response.py | 137 --------------- .../products/models/get_pricing_response.py | 137 --------------- sp_api/api/products/products.py | 58 ++---- sp_api/api/reports/models/__init__.py | 1 - .../reports/models/cancel_report_response.py | 111 ------------ .../models/cancel_report_schedule_response.py | 111 ------------ .../reports/models/create_report_response.py | 137 --------------- .../models/create_report_schedule_response.py | 137 --------------- .../models/get_report_document_response.py | 137 --------------- .../api/reports/models/get_report_response.py | 137 --------------- .../models/get_report_schedule_response.py | 137 --------------- .../models/get_report_schedules_response.py | 137 --------------- .../reports/models/get_reports_response.py | 165 ------------------ sp_api/api/reports/reports.py | 66 +++---- sp_api/api/sales/models/__init__.py | 1 - .../models/get_order_metrics_response.py | 137 --------------- sp_api/api/sales/sales.py | 23 ++- sp_api/api/sellers/models/__init__.py | 1 - ...get_marketplace_participations_response.py | 137 --------------- sp_api/api/sellers/sellers.py | 7 +- sp_api/api/upload/models/__init__.py | 1 - .../create_upload_destination_response.py | 137 --------------- sp_api/base/ApiResponse.py | 13 ++ sp_api/base/__init__.py | 2 + sp_api/base/client.py | 5 +- tests/api/catalog/test_catalog.py | 3 +- 77 files changed, 279 insertions(+), 6113 deletions(-) delete mode 100644 sp_api/api/catalog/models/__init__.py delete mode 100644 sp_api/api/catalog/models/get_catalog_item_response.py delete mode 100644 sp_api/api/catalog/models/list_catalog_categories_response.py delete mode 100644 sp_api/api/catalog/models/list_catalog_items_response.py delete mode 100644 sp_api/api/catalog/models/list_matching_items_response.py delete mode 100644 sp_api/api/feeds/models/__init__.py delete mode 100644 sp_api/api/feeds/models/cancel_feed_response.py delete mode 100644 sp_api/api/feeds/models/create_feed_document_response.py delete mode 100644 sp_api/api/feeds/models/create_feed_response.py delete mode 100644 sp_api/api/feeds/models/get_feed_document_response.py delete mode 100644 sp_api/api/feeds/models/get_feed_response.py delete mode 100644 sp_api/api/feeds/models/get_feeds_response.py delete mode 100644 sp_api/api/finances/models/__init__.py delete mode 100644 sp_api/api/finances/models/list_financial_event_groups_response.py delete mode 100644 sp_api/api/finances/models/list_financial_events_response.py delete mode 100644 sp_api/api/inventories/models/__init__.py delete mode 100644 sp_api/api/inventories/models/get_inventory_summaries_response.py delete mode 100644 sp_api/api/notifications/models/__init__.py delete mode 100644 sp_api/api/notifications/models/create_destination_response.py delete mode 100644 sp_api/api/notifications/models/create_subscription_response.py delete mode 100644 sp_api/api/notifications/models/delete_destination_response.py delete mode 100644 sp_api/api/notifications/models/delete_subscription_by_id_response.py delete mode 100644 sp_api/api/notifications/models/destination_resource_specification.py delete mode 100644 sp_api/api/notifications/models/get_destination_response.py delete mode 100644 sp_api/api/notifications/models/get_destinations_response.py delete mode 100644 sp_api/api/notifications/models/get_subscription_by_id_response.py delete mode 100644 sp_api/api/notifications/models/get_subscription_response.py delete mode 100644 sp_api/api/orders/models/__init__.py delete mode 100644 sp_api/api/orders/models/get_order_address_response.py delete mode 100644 sp_api/api/orders/models/get_order_buyer_info_response.py delete mode 100644 sp_api/api/orders/models/get_order_items_buyer_info_response.py delete mode 100644 sp_api/api/orders/models/get_order_items_response.py delete mode 100644 sp_api/api/orders/models/get_order_response.py delete mode 100644 sp_api/api/orders/models/get_orders_response.py delete mode 100644 sp_api/api/product_fees/models/__init__.py delete mode 100644 sp_api/api/product_fees/models/get_my_fees_estimate_response.py delete mode 100644 sp_api/api/products/models/__init__.py delete mode 100644 sp_api/api/products/models/get_offers_response.py delete mode 100644 sp_api/api/products/models/get_pricing_response.py delete mode 100644 sp_api/api/reports/models/__init__.py delete mode 100644 sp_api/api/reports/models/cancel_report_response.py delete mode 100644 sp_api/api/reports/models/cancel_report_schedule_response.py delete mode 100644 sp_api/api/reports/models/create_report_response.py delete mode 100644 sp_api/api/reports/models/create_report_schedule_response.py delete mode 100644 sp_api/api/reports/models/get_report_document_response.py delete mode 100644 sp_api/api/reports/models/get_report_response.py delete mode 100644 sp_api/api/reports/models/get_report_schedule_response.py delete mode 100644 sp_api/api/reports/models/get_report_schedules_response.py delete mode 100644 sp_api/api/reports/models/get_reports_response.py delete mode 100644 sp_api/api/sales/models/__init__.py delete mode 100644 sp_api/api/sales/models/get_order_metrics_response.py delete mode 100644 sp_api/api/sellers/models/__init__.py delete mode 100644 sp_api/api/sellers/models/get_marketplace_participations_response.py delete mode 100644 sp_api/api/upload/models/__init__.py delete mode 100644 sp_api/api/upload/models/create_upload_destination_response.py create mode 100644 sp_api/base/ApiResponse.py diff --git a/docs/endpoints/finances.rst b/docs/endpoints/finances.rst index e8da93e0d..639ea42ae 100644 --- a/docs/endpoints/finances.rst +++ b/docs/endpoints/finances.rst @@ -3,6 +3,4 @@ Finances - - -Nothing here yet. +.. autoclass:: sp_api.api.Finances diff --git a/docs/endpoints/product_fees.rst b/docs/endpoints/product_fees.rst index 7079a85a0..6e639c611 100644 --- a/docs/endpoints/product_fees.rst +++ b/docs/endpoints/product_fees.rst @@ -3,5 +3,4 @@ Product Fees - -Nothing here yet. +.. autoclass:: sp_api.api.ProductFees diff --git a/docs/endpoints/reports.rst b/docs/endpoints/reports.rst index cd0cba249..40c87abd5 100644 --- a/docs/endpoints/reports.rst +++ b/docs/endpoints/reports.rst @@ -3,6 +3,4 @@ Reports - - -Nothing here yet. +.. autoclass:: sp_api.api.Reports diff --git a/docs/endpoints/sales.rst b/docs/endpoints/sales.rst index f932fc1b8..0ac497eaa 100644 --- a/docs/endpoints/sales.rst +++ b/docs/endpoints/sales.rst @@ -2,7 +2,4 @@ Sales ===== - - - -Nothing here yet. +.. autoclass:: sp_api.api.Sales diff --git a/docs/endpoints/sellers.rst b/docs/endpoints/sellers.rst index cac05b533..42c59bc35 100644 --- a/docs/endpoints/sellers.rst +++ b/docs/endpoints/sellers.rst @@ -5,5 +5,4 @@ Sellers - -Nothing here yet. +.. autoclass:: sp_api.api.Sellers diff --git a/docs/responses.rst b/docs/responses.rst index b492739fa..afd8d03c3 100644 --- a/docs/responses.rst +++ b/docs/responses.rst @@ -1,14 +1,7 @@ Responses ========= +All endpoints return `sp_api.base.ApiResponse` with the following signature. `payload` contains Amazon's response. - -All responses have the following signature. `Payload` contains Amazon's response. - - - -.. code-block:: python - - Response(payload, error) - +.. autoclass:: sp_api.base.ApiResponse diff --git a/setup.py b/setup.py index 1495fb54f..7af40cd6a 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name='python-amazon-sp-api', - version='0.1.10', + version='0.2.0', install_requires=[ "requests", "six~=1.15.0", @@ -13,20 +13,25 @@ "confuse~=1.4.0", ], packages=['tests', 'tests.api', 'tests.api.orders', 'tests.api.sellers', 'tests.api.finances', - 'tests.api.product_fees', 'tests.api.notifications', 'tests.api.reports', 'tests.client', 'sp_api', + 'tests.api.product_fees', 'tests.api.notifications', 'tests.api.reports', 'tests.client', + 'sp_api', 'sp_api.api', - 'sp_api.api.orders', 'sp_api.api.orders.models', 'sp_api.api.sellers', 'sp_api.api.sellers.models', - 'sp_api.api.finances', 'sp_api.api.finances.models', 'sp_api.api.product_fees', - 'sp_api.api.product_fees.models', 'sp_api.api.products', 'sp_api.api.products.models', - 'sp_api.api.feeds', 'sp_api.api.feeds.models', - 'sp_api.api.sales', 'sp_api.api.sales.models', - 'sp_api.api.catalog', 'sp_api.api.catalog.models', - 'sp_api.api.notifications', 'sp_api.api.notifications.models', 'sp_api.api.reports', - 'sp_api.api.inventories', 'sp_api.api.inventories.models', - 'sp_api.api.reports.models', 'sp_api.auth', 'sp_api.base'], + 'sp_api.api.orders', + 'sp_api.api.sellers', + 'sp_api.api.finances', + 'sp_api.api.product_fees', + 'sp_api.api.products', + 'sp_api.api.feeds', + 'sp_api.api.sales', + 'sp_api.api.catalog', + 'sp_api.api.notifications', + 'sp_api.api.reports', + 'sp_api.api.inventories', + 'sp_api.auth', + 'sp_api.base'], url='https://github.com/saleweaver/python-amazon-sp-api', license='mit', author='Michael Primke', author_email='info@saleweaver.com', - description='python wrapper for amazon selling partner api' + description='Python wrapper for the Amazon Selling-Partner API' ) diff --git a/sp_api/api/catalog/catalog.py b/sp_api/api/catalog/catalog.py index c4253aee1..0e2672e67 100644 --- a/sp_api/api/catalog/catalog.py +++ b/sp_api/api/catalog/catalog.py @@ -1,6 +1,5 @@ -from sp_api.api.catalog.models.get_catalog_item_response import GetCatalogItemResponse -from sp_api.api.catalog.models.list_catalog_items_response import ListCatalogItemsResponse -from sp_api.base import Client, sp_endpoint, fill_query_params + +from sp_api.base import Client, sp_endpoint, fill_query_params, ApiResponse class Catalog(Client): @@ -10,9 +9,9 @@ class Catalog(Client): """ @sp_endpoint('/catalog/v0/items/{}') - def get_item(self, asin: str, **kwargs) -> GetCatalogItemResponse: + def get_item(self, asin: str, **kwargs) -> ApiResponse: """ - get_item(self, asin: str, **kwargs) -> GetCatalogItemResponse + get_item(self, asin: str, **kwargs) -> ApiResponse Returns a specified item and its attributes. **Usage Plan:** @@ -33,14 +32,12 @@ def get_item(self, asin: str, **kwargs) -> GetCatalogItemResponse: Returns: GetCatalogItemResponse: """ - return GetCatalogItemResponse( - **self._request(fill_query_params(kwargs.pop('path'), asin), params=kwargs).json() - ) + return self._request(fill_query_params(kwargs.pop('path'), asin), params=kwargs) @sp_endpoint('/catalog/v0/items') - def list_items(self, **kwargs) -> ListCatalogItemsResponse: + def list_items(self, **kwargs) -> ApiResponse: """ - list_items(self, **kwargs) -> ListCatalogItemsResponse + list_items(self, **kwargs) -> ApiResponse Returns a list of items and their attributes, based on a search query or item identifiers that you specify. When based on a search query, provide the Query parameter and optionally, the QueryContextId parameter. When based on item identifiers, provide a single appropriate parameter based on the identifier type, and specify the associated item value. MarketplaceId is always required. **Usage Plan:** @@ -67,6 +64,5 @@ def list_items(self, **kwargs) -> ListCatalogItemsResponse: Returns: ListCatalogItemsResponse: """ - return ListCatalogItemsResponse( - **self._request(kwargs.pop('path'), params=kwargs).json() - ) + return self._request(kwargs.pop('path'), params=kwargs) + diff --git a/sp_api/api/catalog/models/__init__.py b/sp_api/api/catalog/models/__init__.py deleted file mode 100644 index bedfd9285..000000000 --- a/sp_api/api/catalog/models/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from sp_api.api.catalog.models import * diff --git a/sp_api/api/catalog/models/get_catalog_item_response.py b/sp_api/api/catalog/models/get_catalog_item_response.py deleted file mode 100644 index a4b2a3f65..000000000 --- a/sp_api/api/catalog/models/get_catalog_item_response.py +++ /dev/null @@ -1,137 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for Catalog Items - - The Selling Partner API for Catalog Items helps you programmatically retrieve item details for items in the catalog. # noqa: E501 - - OpenAPI spec version: v0 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - -class GetCatalogItemResponse(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'payload': 'Item', - 'errors': 'ErrorList' - } - - attribute_map = { - 'payload': 'payload', - 'errors': 'errors' - } - - def __init__(self, payload=None, errors=None): # noqa: E501 - """GetCatalogItemResponse - a model defined in Swagger""" # noqa: E501 - self._payload = None - self._errors = None - self.discriminator = None - if payload is not None: - self.payload = payload - if errors is not None: - self.errors = errors - - @property - def payload(self): - """Gets the payload of this GetCatalogItemResponse. # noqa: E501 - - - :return: The payload of this GetCatalogItemResponse. # noqa: E501 - :rtype: Item - """ - return self._payload - - @payload.setter - def payload(self, payload): - """Sets the payload of this GetCatalogItemResponse. - - - :param payload: The payload of this GetCatalogItemResponse. # noqa: E501 - :type: Item - """ - - self._payload = payload - - @property - def errors(self): - """Gets the errors of this GetCatalogItemResponse. # noqa: E501 - - - :return: The errors of this GetCatalogItemResponse. # noqa: E501 - :rtype: ErrorList - """ - return self._errors - - @errors.setter - def errors(self, errors): - """Sets the errors of this GetCatalogItemResponse. - - - :param errors: The errors of this GetCatalogItemResponse. # noqa: E501 - :type: ErrorList - """ - - self._errors = errors - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(GetCatalogItemResponse, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, GetCatalogItemResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/api/catalog/models/list_catalog_categories_response.py b/sp_api/api/catalog/models/list_catalog_categories_response.py deleted file mode 100644 index 2678303ae..000000000 --- a/sp_api/api/catalog/models/list_catalog_categories_response.py +++ /dev/null @@ -1,137 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for Catalog Items - - The Selling Partner API for Catalog Items helps you programmatically retrieve item details for items in the catalog. # noqa: E501 - - OpenAPI spec version: v0 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - -class ListCatalogCategoriesResponse(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'payload': 'ListOfCategories', - 'errors': 'ErrorList' - } - - attribute_map = { - 'payload': 'payload', - 'errors': 'errors' - } - - def __init__(self, payload=None, errors=None): # noqa: E501 - """ListCatalogCategoriesResponse - a model defined in Swagger""" # noqa: E501 - self._payload = None - self._errors = None - self.discriminator = None - if payload is not None: - self.payload = payload - if errors is not None: - self.errors = errors - - @property - def payload(self): - """Gets the payload of this ListCatalogCategoriesResponse. # noqa: E501 - - - :return: The payload of this ListCatalogCategoriesResponse. # noqa: E501 - :rtype: ListOfCategories - """ - return self._payload - - @payload.setter - def payload(self, payload): - """Sets the payload of this ListCatalogCategoriesResponse. - - - :param payload: The payload of this ListCatalogCategoriesResponse. # noqa: E501 - :type: ListOfCategories - """ - - self._payload = payload - - @property - def errors(self): - """Gets the errors of this ListCatalogCategoriesResponse. # noqa: E501 - - - :return: The errors of this ListCatalogCategoriesResponse. # noqa: E501 - :rtype: ErrorList - """ - return self._errors - - @errors.setter - def errors(self, errors): - """Sets the errors of this ListCatalogCategoriesResponse. - - - :param errors: The errors of this ListCatalogCategoriesResponse. # noqa: E501 - :type: ErrorList - """ - - self._errors = errors - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(ListCatalogCategoriesResponse, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, ListCatalogCategoriesResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/api/catalog/models/list_catalog_items_response.py b/sp_api/api/catalog/models/list_catalog_items_response.py deleted file mode 100644 index 407418bc9..000000000 --- a/sp_api/api/catalog/models/list_catalog_items_response.py +++ /dev/null @@ -1,137 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for Catalog Items - - The Selling Partner API for Catalog Items helps you programmatically retrieve item details for items in the catalog. # noqa: E501 - - OpenAPI spec version: v0 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - -class ListCatalogItemsResponse(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'payload': 'ListMatchingItemsResponse', - 'errors': 'ErrorList' - } - - attribute_map = { - 'payload': 'payload', - 'errors': 'errors' - } - - def __init__(self, payload=None, errors=None): # noqa: E501 - """ListCatalogItemsResponse - a model defined in Swagger""" # noqa: E501 - self._payload = None - self._errors = None - self.discriminator = None - if payload is not None: - self.payload = payload - if errors is not None: - self.errors = errors - - @property - def payload(self): - """Gets the payload of this ListCatalogItemsResponse. # noqa: E501 - - - :return: The payload of this ListCatalogItemsResponse. # noqa: E501 - :rtype: ListMatchingItemsResponse - """ - return self._payload - - @payload.setter - def payload(self, payload): - """Sets the payload of this ListCatalogItemsResponse. - - - :param payload: The payload of this ListCatalogItemsResponse. # noqa: E501 - :type: ListMatchingItemsResponse - """ - - self._payload = payload - - @property - def errors(self): - """Gets the errors of this ListCatalogItemsResponse. # noqa: E501 - - - :return: The errors of this ListCatalogItemsResponse. # noqa: E501 - :rtype: ErrorList - """ - return self._errors - - @errors.setter - def errors(self, errors): - """Sets the errors of this ListCatalogItemsResponse. - - - :param errors: The errors of this ListCatalogItemsResponse. # noqa: E501 - :type: ErrorList - """ - - self._errors = errors - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(ListCatalogItemsResponse, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, ListCatalogItemsResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/api/catalog/models/list_matching_items_response.py b/sp_api/api/catalog/models/list_matching_items_response.py deleted file mode 100644 index 828bfe9ab..000000000 --- a/sp_api/api/catalog/models/list_matching_items_response.py +++ /dev/null @@ -1,111 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for Catalog Items - - The Selling Partner API for Catalog Items helps you programmatically retrieve item details for items in the catalog. # noqa: E501 - - OpenAPI spec version: v0 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - -class ListMatchingItemsResponse(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'items': 'ItemList' - } - - attribute_map = { - 'items': 'Items' - } - - def __init__(self, items=None): # noqa: E501 - """ListMatchingItemsResponse - a model defined in Swagger""" # noqa: E501 - self._items = None - self.discriminator = None - if items is not None: - self.items = items - - @property - def items(self): - """Gets the items of this ListMatchingItemsResponse. # noqa: E501 - - - :return: The items of this ListMatchingItemsResponse. # noqa: E501 - :rtype: ItemList - """ - return self._items - - @items.setter - def items(self, items): - """Sets the items of this ListMatchingItemsResponse. - - - :param items: The items of this ListMatchingItemsResponse. # noqa: E501 - :type: ItemList - """ - - self._items = items - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(ListMatchingItemsResponse, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, ListMatchingItemsResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/api/feeds/feeds.py b/sp_api/api/feeds/feeds.py index 346b87a46..7ac24a0fb 100644 --- a/sp_api/api/feeds/feeds.py +++ b/sp_api/api/feeds/feeds.py @@ -1,14 +1,5 @@ -import os -import struct -from io import BytesIO - import requests - -from sp_api.api.feeds.models.create_feed_document_response import CreateFeedDocumentResponse -from sp_api.api.feeds.models.create_feed_response import CreateFeedResponse -from sp_api.api.feeds.models.get_feed_document_response import GetFeedDocumentResponse -from sp_api.api.feeds.models.get_feed_response import GetFeedResponse -from sp_api.base import Client, sp_endpoint, Marketplaces, fill_query_params +from sp_api.base import Client, sp_endpoint, Marketplaces, fill_query_params, ApiResponse import zlib @@ -23,9 +14,9 @@ class Feeds(Client): """ @sp_endpoint('/feeds/2020-09-04/feeds', method='POST') - def create_feed(self, feed_type: str, input_feed_document_id: str, **kwargs) -> CreateFeedResponse: + def create_feed(self, feed_type: str, input_feed_document_id: str, **kwargs) -> ApiResponse: """ - create_feed(self, feed_type: str, input_feed_document_id: str, **kwargs) -> CreateFeedResponse + create_feed(self, feed_type: str, input_feed_document_id: str, **kwargs) -> ApiResponse Creates a feed. Call `create_feed_document` to upload the feed first. `submit_feed` combines both. @@ -53,12 +44,12 @@ def create_feed(self, feed_type: str, input_feed_document_id: str, **kwargs) -> 'inputFeedDocumentId': input_feed_document_id, **kwargs } - return CreateFeedResponse(**self._request(kwargs.get('path'), data=data).json()) + return self._request(kwargs.get('path'), data=data) @sp_endpoint('/feeds/2020-09-04/documents', method='POST') - def create_feed_document(self, file, content_type='text/tsv', **kwargs) -> CreateFeedDocumentResponse: + def create_feed_document(self, file, content_type='text/tsv', **kwargs) -> ApiResponse: """ - create_feed_document(self, file: File or FileLike, content_type='text/tsv', **kwargs) -> CreateFeedDocumentResponse + create_feed_document(self, file: File or FileLike, content_type='text/tsv', **kwargs) -> ApiResponse Creates a feed document for the feed type that you specify. This method also encrypts and uploads the file you specify. @@ -84,7 +75,7 @@ def create_feed_document(self, file, content_type='text/tsv', **kwargs) -> Creat data = { 'contentType': content_type } - response = CreateFeedDocumentResponse(**self._request(kwargs.get('path'), data={**data, **kwargs}).json()) + response = self._request(kwargs.get('path'), data={**data, **kwargs}) upload = requests.put( response.payload.get('url'), data=encrypt_aes(file, @@ -98,9 +89,9 @@ def create_feed_document(self, file, content_type='text/tsv', **kwargs) -> Creat from sp_api.base.exceptions import SellingApiException raise SellingApiException(upload.headers) - def submit_feed(self, feed_type, file, content_type='text/tsv', **kwargs) -> [CreateFeedDocumentResponse, CreateFeedResponse]: + 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) -> [CreateFeedDocumentResponse, CreateFeedResponse] + 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 encrypted file and sends the feed to amazon. **Usage Plan:** @@ -125,9 +116,9 @@ def submit_feed(self, feed_type, file, content_type='text/tsv', **kwargs) -> [Cr return document_response, self.create_feed(feed_type, document_response.payload.get('feedDocumentId'), **kwargs) @sp_endpoint('/feeds/2020-09-04/feeds/{}') - def get_feed(self, feed_id: str, **kwargs) -> GetFeedResponse: + def get_feed(self, feed_id: str, **kwargs) -> ApiResponse: """ - get_feed(self, feed_id: str, **kwargs) -> GetFeedResponse + get_feed(self, feed_id: str, **kwargs) -> ApiResponse Returns feed details (including the resultDocumentId, if available) for the feed that you specify. **Usage Plan:** @@ -147,8 +138,8 @@ def get_feed(self, feed_id: str, **kwargs) -> GetFeedResponse: Returns: GetFeedResponse: """ - return GetFeedResponse(**self._request(fill_query_params(kwargs.pop('path'), feed_id), params=kwargs, - add_marketplace=False).json()) + return self._request(fill_query_params(kwargs.pop('path'), feed_id), params=kwargs, + add_marketplace=False) @sp_endpoint('/feeds/2020-09-04/documents/{}') def get_feed_result_document(self, feed_id, **kwargs) -> str: @@ -171,9 +162,8 @@ def get_feed_result_document(self, feed_id, **kwargs) -> str: Returns: str: The feed results' contents """ - response = GetFeedDocumentResponse( - **self._request(fill_query_params(kwargs.pop('path'), feed_id), params=kwargs, - add_marketplace=False).json()) + response = self._request(fill_query_params(kwargs.pop('path'), feed_id), params=kwargs, + add_marketplace=False) url = response.payload.get('url') decrypted = decrypt_aes( requests.get(url).content, diff --git a/sp_api/api/feeds/models/__init__.py b/sp_api/api/feeds/models/__init__.py deleted file mode 100644 index fc2f4f411..000000000 --- a/sp_api/api/feeds/models/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from sp_api.api.feeds.models import * diff --git a/sp_api/api/feeds/models/cancel_feed_response.py b/sp_api/api/feeds/models/cancel_feed_response.py deleted file mode 100644 index c1a574199..000000000 --- a/sp_api/api/feeds/models/cancel_feed_response.py +++ /dev/null @@ -1,111 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for Feeds - - The Selling Partner API for Feeds lets you upload data to Amazon on behalf of a selling partner. # noqa: E501 - - OpenAPI spec version: 2020-09-04 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - -class CancelFeedResponse(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'errors': 'ErrorList' - } - - attribute_map = { - 'errors': 'errors' - } - - def __init__(self, errors=None): # noqa: E501 - """CancelFeedResponse - a model defined in Swagger""" # noqa: E501 - self._errors = None - self.discriminator = None - if errors is not None: - self.errors = errors - - @property - def errors(self): - """Gets the errors of this CancelFeedResponse. # noqa: E501 - - - :return: The errors of this CancelFeedResponse. # noqa: E501 - :rtype: ErrorList - """ - return self._errors - - @errors.setter - def errors(self, errors): - """Sets the errors of this CancelFeedResponse. - - - :param errors: The errors of this CancelFeedResponse. # noqa: E501 - :type: ErrorList - """ - - self._errors = errors - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(CancelFeedResponse, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, CancelFeedResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/api/feeds/models/create_feed_document_response.py b/sp_api/api/feeds/models/create_feed_document_response.py deleted file mode 100644 index d1cec0f48..000000000 --- a/sp_api/api/feeds/models/create_feed_document_response.py +++ /dev/null @@ -1,137 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for Feeds - - The Selling Partner API for Feeds lets you upload data to Amazon on behalf of a selling partner. # noqa: E501 - - OpenAPI spec version: 2020-09-04 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - -class CreateFeedDocumentResponse(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'payload': 'CreateFeedDocumentResult', - 'errors': 'ErrorList' - } - - attribute_map = { - 'payload': 'payload', - 'errors': 'errors' - } - - def __init__(self, payload=None, errors=None): # noqa: E501 - """CreateFeedDocumentResponse - a model defined in Swagger""" # noqa: E501 - self._payload = None - self._errors = None - self.discriminator = None - if payload is not None: - self.payload = payload - if errors is not None: - self.errors = errors - - @property - def payload(self): - """Gets the payload of this CreateFeedDocumentResponse. # noqa: E501 - - - :return: The payload of this CreateFeedDocumentResponse. # noqa: E501 - :rtype: CreateFeedDocumentResult - """ - return self._payload - - @payload.setter - def payload(self, payload): - """Sets the payload of this CreateFeedDocumentResponse. - - - :param payload: The payload of this CreateFeedDocumentResponse. # noqa: E501 - :type: CreateFeedDocumentResult - """ - - self._payload = payload - - @property - def errors(self): - """Gets the errors of this CreateFeedDocumentResponse. # noqa: E501 - - - :return: The errors of this CreateFeedDocumentResponse. # noqa: E501 - :rtype: ErrorList - """ - return self._errors - - @errors.setter - def errors(self, errors): - """Sets the errors of this CreateFeedDocumentResponse. - - - :param errors: The errors of this CreateFeedDocumentResponse. # noqa: E501 - :type: ErrorList - """ - - self._errors = errors - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(CreateFeedDocumentResponse, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, CreateFeedDocumentResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/api/feeds/models/create_feed_response.py b/sp_api/api/feeds/models/create_feed_response.py deleted file mode 100644 index 3850e79f3..000000000 --- a/sp_api/api/feeds/models/create_feed_response.py +++ /dev/null @@ -1,137 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for Feeds - - The Selling Partner API for Feeds lets you upload data to Amazon on behalf of a selling partner. # noqa: E501 - - OpenAPI spec version: 2020-09-04 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - -class CreateFeedResponse(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'payload': 'CreateFeedResult', - 'errors': 'ErrorList' - } - - attribute_map = { - 'payload': 'payload', - 'errors': 'errors' - } - - def __init__(self, payload=None, errors=None): # noqa: E501 - """CreateFeedResponse - a model defined in Swagger""" # noqa: E501 - self._payload = None - self._errors = None - self.discriminator = None - if payload is not None: - self.payload = payload - if errors is not None: - self.errors = errors - - @property - def payload(self): - """Gets the payload of this CreateFeedResponse. # noqa: E501 - - - :return: The payload of this CreateFeedResponse. # noqa: E501 - :rtype: CreateFeedResult - """ - return self._payload - - @payload.setter - def payload(self, payload): - """Sets the payload of this CreateFeedResponse. - - - :param payload: The payload of this CreateFeedResponse. # noqa: E501 - :type: CreateFeedResult - """ - - self._payload = payload - - @property - def errors(self): - """Gets the errors of this CreateFeedResponse. # noqa: E501 - - - :return: The errors of this CreateFeedResponse. # noqa: E501 - :rtype: ErrorList - """ - return self._errors - - @errors.setter - def errors(self, errors): - """Sets the errors of this CreateFeedResponse. - - - :param errors: The errors of this CreateFeedResponse. # noqa: E501 - :type: ErrorList - """ - - self._errors = errors - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(CreateFeedResponse, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, CreateFeedResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/api/feeds/models/get_feed_document_response.py b/sp_api/api/feeds/models/get_feed_document_response.py deleted file mode 100644 index c34ae3bee..000000000 --- a/sp_api/api/feeds/models/get_feed_document_response.py +++ /dev/null @@ -1,137 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for Feeds - - The Selling Partner API for Feeds lets you upload data to Amazon on behalf of a selling partner. # noqa: E501 - - OpenAPI spec version: 2020-09-04 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - -class GetFeedDocumentResponse(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'payload': 'FeedDocument', - 'errors': 'ErrorList' - } - - attribute_map = { - 'payload': 'payload', - 'errors': 'errors' - } - - def __init__(self, payload=None, errors=None): # noqa: E501 - """GetFeedDocumentResponse - a model defined in Swagger""" # noqa: E501 - self._payload = None - self._errors = None - self.discriminator = None - if payload is not None: - self.payload = payload - if errors is not None: - self.errors = errors - - @property - def payload(self): - """Gets the payload of this GetFeedDocumentResponse. # noqa: E501 - - - :return: The payload of this GetFeedDocumentResponse. # noqa: E501 - :rtype: FeedDocument - """ - return self._payload - - @payload.setter - def payload(self, payload): - """Sets the payload of this GetFeedDocumentResponse. - - - :param payload: The payload of this GetFeedDocumentResponse. # noqa: E501 - :type: FeedDocument - """ - - self._payload = payload - - @property - def errors(self): - """Gets the errors of this GetFeedDocumentResponse. # noqa: E501 - - - :return: The errors of this GetFeedDocumentResponse. # noqa: E501 - :rtype: ErrorList - """ - return self._errors - - @errors.setter - def errors(self, errors): - """Sets the errors of this GetFeedDocumentResponse. - - - :param errors: The errors of this GetFeedDocumentResponse. # noqa: E501 - :type: ErrorList - """ - - self._errors = errors - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(GetFeedDocumentResponse, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, GetFeedDocumentResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/api/feeds/models/get_feed_response.py b/sp_api/api/feeds/models/get_feed_response.py deleted file mode 100644 index 9a7f504ba..000000000 --- a/sp_api/api/feeds/models/get_feed_response.py +++ /dev/null @@ -1,137 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for Feeds - - The Selling Partner API for Feeds lets you upload data to Amazon on behalf of a selling partner. # noqa: E501 - - OpenAPI spec version: 2020-09-04 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - -class GetFeedResponse(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'payload': 'Feed', - 'errors': 'ErrorList' - } - - attribute_map = { - 'payload': 'payload', - 'errors': 'errors' - } - - def __init__(self, payload=None, errors=None): # noqa: E501 - """GetFeedResponse - a model defined in Swagger""" # noqa: E501 - self._payload = None - self._errors = None - self.discriminator = None - if payload is not None: - self.payload = payload - if errors is not None: - self.errors = errors - - @property - def payload(self): - """Gets the payload of this GetFeedResponse. # noqa: E501 - - - :return: The payload of this GetFeedResponse. # noqa: E501 - :rtype: Feed - """ - return self._payload - - @payload.setter - def payload(self, payload): - """Sets the payload of this GetFeedResponse. - - - :param payload: The payload of this GetFeedResponse. # noqa: E501 - :type: Feed - """ - - self._payload = payload - - @property - def errors(self): - """Gets the errors of this GetFeedResponse. # noqa: E501 - - - :return: The errors of this GetFeedResponse. # noqa: E501 - :rtype: ErrorList - """ - return self._errors - - @errors.setter - def errors(self, errors): - """Sets the errors of this GetFeedResponse. - - - :param errors: The errors of this GetFeedResponse. # noqa: E501 - :type: ErrorList - """ - - self._errors = errors - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(GetFeedResponse, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, GetFeedResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/api/feeds/models/get_feeds_response.py b/sp_api/api/feeds/models/get_feeds_response.py deleted file mode 100644 index 46251f56c..000000000 --- a/sp_api/api/feeds/models/get_feeds_response.py +++ /dev/null @@ -1,165 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for Feeds - - The Selling Partner API for Feeds lets you upload data to Amazon on behalf of a selling partner. # noqa: E501 - - OpenAPI spec version: 2020-09-04 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - -class GetFeedsResponse(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'payload': 'FeedList', - 'next_token': 'str', - 'errors': 'ErrorList' - } - - attribute_map = { - 'payload': 'payload', - 'next_token': 'nextToken', - 'errors': 'errors' - } - - def __init__(self, payload=None, next_token=None, errors=None): # noqa: E501 - """GetFeedsResponse - a model defined in Swagger""" # noqa: E501 - self._payload = None - self._next_token = None - self._errors = None - self.discriminator = None - if payload is not None: - self.payload = payload - if next_token is not None: - self.next_token = next_token - if errors is not None: - self.errors = errors - - @property - def payload(self): - """Gets the payload of this GetFeedsResponse. # noqa: E501 - - - :return: The payload of this GetFeedsResponse. # noqa: E501 - :rtype: FeedList - """ - return self._payload - - @payload.setter - def payload(self, payload): - """Sets the payload of this GetFeedsResponse. - - - :param payload: The payload of this GetFeedsResponse. # noqa: E501 - :type: FeedList - """ - - self._payload = payload - - @property - def next_token(self): - """Gets the next_token of this GetFeedsResponse. # noqa: E501 - - Returned when the number of results exceeds pageSize. To get the next page of results, call the getFeeds operation with this token as the only parameter. # noqa: E501 - - :return: The next_token of this GetFeedsResponse. # noqa: E501 - :rtype: str - """ - return self._next_token - - @next_token.setter - def next_token(self, next_token): - """Sets the next_token of this GetFeedsResponse. - - Returned when the number of results exceeds pageSize. To get the next page of results, call the getFeeds operation with this token as the only parameter. # noqa: E501 - - :param next_token: The next_token of this GetFeedsResponse. # noqa: E501 - :type: str - """ - - self._next_token = next_token - - @property - def errors(self): - """Gets the errors of this GetFeedsResponse. # noqa: E501 - - - :return: The errors of this GetFeedsResponse. # noqa: E501 - :rtype: ErrorList - """ - return self._errors - - @errors.setter - def errors(self, errors): - """Sets the errors of this GetFeedsResponse. - - - :param errors: The errors of this GetFeedsResponse. # noqa: E501 - :type: ErrorList - """ - - self._errors = errors - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(GetFeedsResponse, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, GetFeedsResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/api/finances/finances.py b/sp_api/api/finances/finances.py index 773d1f6e1..3b3fc8901 100644 --- a/sp_api/api/finances/finances.py +++ b/sp_api/api/finances/finances.py @@ -1,12 +1,21 @@ -from sp_api.api.finances.models.list_financial_events_response import ListFinancialEventsResponse -from sp_api.base import Client, Marketplaces +from sp_api.base import Client, Marketplaces, ApiResponse from sp_api.base import sp_endpoint, fill_query_params class Finances(Client): @sp_endpoint('/finances/v0/orders/{}/financialEvents') - def get_financial_events_for_order(self, order_id, **kwargs): - return ListFinancialEventsResponse( - **self._request(fill_query_params(kwargs.pop('path'), order_id), params={**kwargs}).json() - ) + def get_financial_events_for_order(self, order_id, **kwargs) -> ApiResponse: + """ + get_financial_events_for_order(self, order_id, **kwargs) -> ApiResponse + + + Args: + order_id: + **kwargs: + + Returns: + + """ + return self._request(fill_query_params(kwargs.pop('path'), order_id), params={**kwargs}) + diff --git a/sp_api/api/finances/models/__init__.py b/sp_api/api/finances/models/__init__.py deleted file mode 100644 index c018eb46e..000000000 --- a/sp_api/api/finances/models/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from sp_api.api.finances.models import * diff --git a/sp_api/api/finances/models/list_financial_event_groups_response.py b/sp_api/api/finances/models/list_financial_event_groups_response.py deleted file mode 100644 index 668984c29..000000000 --- a/sp_api/api/finances/models/list_financial_event_groups_response.py +++ /dev/null @@ -1,137 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for Finances - - The Selling Partner API for Finances helps you obtain financial information relevant to a seller's business. You can obtain financial events for a given order, financial event group, or date range without having to wait until a statement period closes. You can also obtain financial event groups for a given date range. # noqa: E501 - - OpenAPI spec version: v0 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - -class ListFinancialEventGroupsResponse(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'payload': 'ListFinancialEventGroupsPayload', - 'errors': 'ErrorList' - } - - attribute_map = { - 'payload': 'payload', - 'errors': 'errors' - } - - def __init__(self, payload=None, errors=None): # noqa: E501 - """ListFinancialEventGroupsResponse - a model defined in Swagger""" # noqa: E501 - self._payload = None - self._errors = None - self.discriminator = None - if payload is not None: - self.payload = payload - if errors is not None: - self.errors = errors - - @property - def payload(self): - """Gets the payload of this ListFinancialEventGroupsResponse. # noqa: E501 - - - :return: The payload of this ListFinancialEventGroupsResponse. # noqa: E501 - :rtype: ListFinancialEventGroupsPayload - """ - return self._payload - - @payload.setter - def payload(self, payload): - """Sets the payload of this ListFinancialEventGroupsResponse. - - - :param payload: The payload of this ListFinancialEventGroupsResponse. # noqa: E501 - :type: ListFinancialEventGroupsPayload - """ - - self._payload = payload - - @property - def errors(self): - """Gets the errors of this ListFinancialEventGroupsResponse. # noqa: E501 - - - :return: The errors of this ListFinancialEventGroupsResponse. # noqa: E501 - :rtype: ErrorList - """ - return self._errors - - @errors.setter - def errors(self, errors): - """Sets the errors of this ListFinancialEventGroupsResponse. - - - :param errors: The errors of this ListFinancialEventGroupsResponse. # noqa: E501 - :type: ErrorList - """ - - self._errors = errors - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(ListFinancialEventGroupsResponse, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, ListFinancialEventGroupsResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/api/finances/models/list_financial_events_response.py b/sp_api/api/finances/models/list_financial_events_response.py deleted file mode 100644 index 4aa9b4c39..000000000 --- a/sp_api/api/finances/models/list_financial_events_response.py +++ /dev/null @@ -1,137 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for Finances - - The Selling Partner API for Finances helps you obtain financial information relevant to a seller's business. You can obtain financial events for a given order, financial event group, or date range without having to wait until a statement period closes. You can also obtain financial event groups for a given date range. # noqa: E501 - - OpenAPI spec version: v0 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - -class ListFinancialEventsResponse(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'payload': 'ListFinancialEventsPayload', - 'errors': 'ErrorList' - } - - attribute_map = { - 'payload': 'payload', - 'errors': 'errors' - } - - def __init__(self, payload=None, errors=None): # noqa: E501 - """ListFinancialEventsResponse - a model defined in Swagger""" # noqa: E501 - self._payload = None - self._errors = None - self.discriminator = None - if payload is not None: - self.payload = payload - if errors is not None: - self.errors = errors - - @property - def payload(self): - """Gets the payload of this ListFinancialEventsResponse. # noqa: E501 - - - :return: The payload of this ListFinancialEventsResponse. # noqa: E501 - :rtype: ListFinancialEventsPayload - """ - return self._payload - - @payload.setter - def payload(self, payload): - """Sets the payload of this ListFinancialEventsResponse. - - - :param payload: The payload of this ListFinancialEventsResponse. # noqa: E501 - :type: ListFinancialEventsPayload - """ - - self._payload = payload - - @property - def errors(self): - """Gets the errors of this ListFinancialEventsResponse. # noqa: E501 - - - :return: The errors of this ListFinancialEventsResponse. # noqa: E501 - :rtype: ErrorList - """ - return self._errors - - @errors.setter - def errors(self, errors): - """Sets the errors of this ListFinancialEventsResponse. - - - :param errors: The errors of this ListFinancialEventsResponse. # noqa: E501 - :type: ErrorList - """ - - self._errors = errors - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(ListFinancialEventsResponse, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, ListFinancialEventsResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/api/inventories/inventories.py b/sp_api/api/inventories/inventories.py index e06cb172d..c33f21931 100644 --- a/sp_api/api/inventories/inventories.py +++ b/sp_api/api/inventories/inventories.py @@ -1,7 +1,6 @@ import urllib -from sp_api.api.inventories.models.get_inventory_summaries_response import GetInventorySummariesResponse -from sp_api.base import Client, Marketplaces, sp_endpoint +from sp_api.base import Client, Marketplaces, sp_endpoint, ApiResponse from sp_api.base.InventoryEnums import InventoryGranularity @@ -11,8 +10,7 @@ class Inventories(Client): """ @sp_endpoint('/fba/inventory/v1/summaries') - def get_inventory_summary_marketplace(self, **kwargs) -> GetInventorySummariesResponse: - + def get_inventory_summary_marketplace(self, **kwargs) -> ApiResponse: """ get_inventory_summary_marketplace(self, **kwargs) -> GetInventorySummariesResponse @@ -60,4 +58,4 @@ def get_inventory_summary_marketplace(self, **kwargs) -> GetInventorySummariesRe if 'sellerSkus' in kwargs: kwargs.update({'sellerSkus': ','.join([urllib.parse.quote_plus(s) for s in kwargs.get('sellerSkus')])}) - return GetInventorySummariesResponse(**self._request(kwargs.pop('path'), params=kwargs).json()) + return self._request(kwargs.pop('path'), params=kwargs) diff --git a/sp_api/api/inventories/models/__init__.py b/sp_api/api/inventories/models/__init__.py deleted file mode 100644 index 880677efc..000000000 --- a/sp_api/api/inventories/models/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from sp_api.api.inventories.models import * diff --git a/sp_api/api/inventories/models/get_inventory_summaries_response.py b/sp_api/api/inventories/models/get_inventory_summaries_response.py deleted file mode 100644 index 90eeb4c8b..000000000 --- a/sp_api/api/inventories/models/get_inventory_summaries_response.py +++ /dev/null @@ -1,164 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for FBA Inventory - - The Selling Partner API for FBA Inventory lets you programmatically retrieve information about inventory in Amazon's fulfillment network. # noqa: E501 - - OpenAPI spec version: v1 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - - -class GetInventorySummariesResponse(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'payload': 'GetInventorySummariesResult', - 'pagination': 'Pagination', - 'errors': 'ErrorList' - } - - attribute_map = { - 'payload': 'payload', - 'pagination': 'pagination', - 'errors': 'errors' - } - - def __init__(self, payload=None, pagination=None, errors=None): # noqa: E501 - """GetInventorySummariesResponse - a model defined in Swagger""" # noqa: E501 - self._payload = None - self._pagination = None - self._errors = None - self.discriminator = None - if payload is not None: - self.payload = payload - if pagination is not None: - self.pagination = pagination - if errors is not None: - self.errors = errors - - @property - def payload(self): - """Gets the payload of this GetInventorySummariesResponse. # noqa: E501 - - - :return: The payload of this GetInventorySummariesResponse. # noqa: E501 - :rtype: GetInventorySummariesResult - """ - return self._payload - - @payload.setter - def payload(self, payload): - """Sets the payload of this GetInventorySummariesResponse. - - - :param payload: The payload of this GetInventorySummariesResponse. # noqa: E501 - :type: GetInventorySummariesResult - """ - - self._payload = payload - - @property - def pagination(self): - """Gets the pagination of this GetInventorySummariesResponse. # noqa: E501 - - - :return: The pagination of this GetInventorySummariesResponse. # noqa: E501 - :rtype: Pagination - """ - return self._pagination - - @pagination.setter - def pagination(self, pagination): - """Sets the pagination of this GetInventorySummariesResponse. - - - :param pagination: The pagination of this GetInventorySummariesResponse. # noqa: E501 - :type: Pagination - """ - - self._pagination = pagination - - @property - def errors(self): - """Gets the errors of this GetInventorySummariesResponse. # noqa: E501 - - - :return: The errors of this GetInventorySummariesResponse. # noqa: E501 - :rtype: ErrorList - """ - return self._errors - - @errors.setter - def errors(self, errors): - """Sets the errors of this GetInventorySummariesResponse. - - - :param errors: The errors of this GetInventorySummariesResponse. # noqa: E501 - :type: ErrorList - """ - - self._errors = errors - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(GetInventorySummariesResponse, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, GetInventorySummariesResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/api/notifications/models/__init__.py b/sp_api/api/notifications/models/__init__.py deleted file mode 100644 index bdc624767..000000000 --- a/sp_api/api/notifications/models/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from sp_api.api.notifications.models import * diff --git a/sp_api/api/notifications/models/create_destination_response.py b/sp_api/api/notifications/models/create_destination_response.py deleted file mode 100644 index feb2a24c8..000000000 --- a/sp_api/api/notifications/models/create_destination_response.py +++ /dev/null @@ -1,137 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for Notifications - - The Selling Partner API for Notifications lets you subscribe to notifications that are relevant to a selling partner's business. Using this API you can create a destination to receive notifications, subscribe to notifications, delete notification subscriptions, and more. # noqa: E501 - - OpenAPI spec version: v1 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - -class CreateDestinationResponse(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'payload': 'Destination', - 'errors': 'ErrorList' - } - - attribute_map = { - 'payload': 'payload', - 'errors': 'errors' - } - - def __init__(self, payload=None, errors=None): # noqa: E501 - """CreateDestinationResponse - a model defined in Swagger""" # noqa: E501 - self._payload = None - self._errors = None - self.discriminator = None - if payload is not None: - self.payload = payload - if errors is not None: - self.errors = errors - - @property - def payload(self): - """Gets the payload of this CreateDestinationResponse. # noqa: E501 - - - :return: The payload of this CreateDestinationResponse. # noqa: E501 - :rtype: Destination - """ - return self._payload - - @payload.setter - def payload(self, payload): - """Sets the payload of this CreateDestinationResponse. - - - :param payload: The payload of this CreateDestinationResponse. # noqa: E501 - :type: Destination - """ - - self._payload = payload - - @property - def errors(self): - """Gets the errors of this CreateDestinationResponse. # noqa: E501 - - - :return: The errors of this CreateDestinationResponse. # noqa: E501 - :rtype: ErrorList - """ - return self._errors - - @errors.setter - def errors(self, errors): - """Sets the errors of this CreateDestinationResponse. - - - :param errors: The errors of this CreateDestinationResponse. # noqa: E501 - :type: ErrorList - """ - - self._errors = errors - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(CreateDestinationResponse, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, CreateDestinationResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/api/notifications/models/create_subscription_response.py b/sp_api/api/notifications/models/create_subscription_response.py deleted file mode 100644 index 7241ac38e..000000000 --- a/sp_api/api/notifications/models/create_subscription_response.py +++ /dev/null @@ -1,137 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for Notifications - - The Selling Partner API for Notifications lets you subscribe to notifications that are relevant to a selling partner's business. Using this API you can create a destination to receive notifications, subscribe to notifications, delete notification subscriptions, and more. # noqa: E501 - - OpenAPI spec version: v1 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - -class CreateSubscriptionResponse(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'payload': 'Subscription', - 'errors': 'ErrorList' - } - - attribute_map = { - 'payload': 'payload', - 'errors': 'errors' - } - - def __init__(self, payload=None, errors=None): # noqa: E501 - """CreateSubscriptionResponse - a model defined in Swagger""" # noqa: E501 - self._payload = None - self._errors = None - self.discriminator = None - if payload is not None: - self.payload = payload - if errors is not None: - self.errors = errors - - @property - def payload(self): - """Gets the payload of this CreateSubscriptionResponse. # noqa: E501 - - - :return: The payload of this CreateSubscriptionResponse. # noqa: E501 - :rtype: Subscription - """ - return self._payload - - @payload.setter - def payload(self, payload): - """Sets the payload of this CreateSubscriptionResponse. - - - :param payload: The payload of this CreateSubscriptionResponse. # noqa: E501 - :type: Subscription - """ - - self._payload = payload - - @property - def errors(self): - """Gets the errors of this CreateSubscriptionResponse. # noqa: E501 - - - :return: The errors of this CreateSubscriptionResponse. # noqa: E501 - :rtype: ErrorList - """ - return self._errors - - @errors.setter - def errors(self, errors): - """Sets the errors of this CreateSubscriptionResponse. - - - :param errors: The errors of this CreateSubscriptionResponse. # noqa: E501 - :type: ErrorList - """ - - self._errors = errors - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(CreateSubscriptionResponse, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, CreateSubscriptionResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/api/notifications/models/delete_destination_response.py b/sp_api/api/notifications/models/delete_destination_response.py deleted file mode 100644 index 4d62e3ef2..000000000 --- a/sp_api/api/notifications/models/delete_destination_response.py +++ /dev/null @@ -1,111 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for Notifications - - The Selling Partner API for Notifications lets you subscribe to notifications that are relevant to a selling partner's business. Using this API you can create a destination to receive notifications, subscribe to notifications, delete notification subscriptions, and more. # noqa: E501 - - OpenAPI spec version: v1 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - -class DeleteDestinationResponse(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'errors': 'ErrorList' - } - - attribute_map = { - 'errors': 'errors' - } - - def __init__(self, errors=None): # noqa: E501 - """DeleteDestinationResponse - a model defined in Swagger""" # noqa: E501 - self._errors = None - self.discriminator = None - if errors is not None: - self.errors = errors - - @property - def errors(self): - """Gets the errors of this DeleteDestinationResponse. # noqa: E501 - - - :return: The errors of this DeleteDestinationResponse. # noqa: E501 - :rtype: ErrorList - """ - return self._errors - - @errors.setter - def errors(self, errors): - """Sets the errors of this DeleteDestinationResponse. - - - :param errors: The errors of this DeleteDestinationResponse. # noqa: E501 - :type: ErrorList - """ - - self._errors = errors - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(DeleteDestinationResponse, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, DeleteDestinationResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/api/notifications/models/delete_subscription_by_id_response.py b/sp_api/api/notifications/models/delete_subscription_by_id_response.py deleted file mode 100644 index 53b2e6650..000000000 --- a/sp_api/api/notifications/models/delete_subscription_by_id_response.py +++ /dev/null @@ -1,112 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for Notifications - - The Selling Partner API for Notifications lets you subscribe to notifications that are relevant to a selling partner's business. Using this API you can create a destination to receive notifications, subscribe to notifications, delete notification subscriptions, and more. # noqa: E501 - - OpenAPI spec version: v1 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - -class DeleteSubscriptionByIdResponse(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'errors': 'ErrorList', - } - - attribute_map = { - 'errors': 'errors', - } - - def __init__(self, errors=None): # noqa: E501 - """DeleteSubscriptionByIdResponse - a model defined in Swagger""" # noqa: E501 - self._errors = None - self.discriminator = None - if errors is not None: - self.errors = errors - - - @property - def errors(self): - """Gets the errors of this DeleteSubscriptionByIdResponse. # noqa: E501 - - - :return: The errors of this DeleteSubscriptionByIdResponse. # noqa: E501 - :rtype: ErrorList - """ - return self._errors - - @errors.setter - def errors(self, errors): - """Sets the errors of this DeleteSubscriptionByIdResponse. - - - :param errors: The errors of this DeleteSubscriptionByIdResponse. # noqa: E501 - :type: ErrorList - """ - - self._errors = errors - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(DeleteSubscriptionByIdResponse, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, DeleteSubscriptionByIdResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/api/notifications/models/destination_resource_specification.py b/sp_api/api/notifications/models/destination_resource_specification.py deleted file mode 100644 index 80e6b2f15..000000000 --- a/sp_api/api/notifications/models/destination_resource_specification.py +++ /dev/null @@ -1,137 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for Notifications - - The Selling Partner API for Notifications lets you subscribe to notifications that are relevant to a selling partner's business. Using this API you can create a destination to receive notifications, subscribe to notifications, delete notification subscriptions, and more. # noqa: E501 - - OpenAPI spec version: v1 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - -class DestinationResourceSpecification(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'sqs': 'SqsResource', - 'event_bridge': 'EventBridgeResourceSpecification' - } - - attribute_map = { - 'sqs': 'sqs', - 'event_bridge': 'eventBridge' - } - - def __init__(self, sqs=None, event_bridge=None): # noqa: E501 - """DestinationResourceSpecification - a model defined in Swagger""" # noqa: E501 - self._sqs = None - self._event_bridge = None - self.discriminator = None - if sqs is not None: - self.sqs = sqs - if event_bridge is not None: - self.event_bridge = event_bridge - - @property - def sqs(self): - """Gets the sqs of this DestinationResourceSpecification. # noqa: E501 - - - :return: The sqs of this DestinationResourceSpecification. # noqa: E501 - :rtype: SqsResource - """ - return self._sqs - - @sqs.setter - def sqs(self, sqs): - """Sets the sqs of this DestinationResourceSpecification. - - - :param sqs: The sqs of this DestinationResourceSpecification. # noqa: E501 - :type: SqsResource - """ - - self._sqs = sqs - - @property - def event_bridge(self): - """Gets the event_bridge of this DestinationResourceSpecification. # noqa: E501 - - - :return: The event_bridge of this DestinationResourceSpecification. # noqa: E501 - :rtype: EventBridgeResourceSpecification - """ - return self._event_bridge - - @event_bridge.setter - def event_bridge(self, event_bridge): - """Sets the event_bridge of this DestinationResourceSpecification. - - - :param event_bridge: The event_bridge of this DestinationResourceSpecification. # noqa: E501 - :type: EventBridgeResourceSpecification - """ - - self._event_bridge = event_bridge - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(DestinationResourceSpecification, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, DestinationResourceSpecification): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/api/notifications/models/get_destination_response.py b/sp_api/api/notifications/models/get_destination_response.py deleted file mode 100644 index 903266f0c..000000000 --- a/sp_api/api/notifications/models/get_destination_response.py +++ /dev/null @@ -1,137 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for Notifications - - The Selling Partner API for Notifications lets you subscribe to notifications that are relevant to a selling partner's business. Using this API you can create a destination to receive notifications, subscribe to notifications, delete notification subscriptions, and more. # noqa: E501 - - OpenAPI spec version: v1 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - -class GetDestinationResponse(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'payload': 'Destination', - 'errors': 'ErrorList' - } - - attribute_map = { - 'payload': 'payload', - 'errors': 'errors' - } - - def __init__(self, payload=None, errors=None): # noqa: E501 - """GetDestinationResponse - a model defined in Swagger""" # noqa: E501 - self._payload = None - self._errors = None - self.discriminator = None - if payload is not None: - self.payload = payload - if errors is not None: - self.errors = errors - - @property - def payload(self): - """Gets the payload of this GetDestinationResponse. # noqa: E501 - - - :return: The payload of this GetDestinationResponse. # noqa: E501 - :rtype: Destination - """ - return self._payload - - @payload.setter - def payload(self, payload): - """Sets the payload of this GetDestinationResponse. - - - :param payload: The payload of this GetDestinationResponse. # noqa: E501 - :type: Destination - """ - - self._payload = payload - - @property - def errors(self): - """Gets the errors of this GetDestinationResponse. # noqa: E501 - - - :return: The errors of this GetDestinationResponse. # noqa: E501 - :rtype: ErrorList - """ - return self._errors - - @errors.setter - def errors(self, errors): - """Sets the errors of this GetDestinationResponse. - - - :param errors: The errors of this GetDestinationResponse. # noqa: E501 - :type: ErrorList - """ - - self._errors = errors - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(GetDestinationResponse, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, GetDestinationResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/api/notifications/models/get_destinations_response.py b/sp_api/api/notifications/models/get_destinations_response.py deleted file mode 100644 index 97be6e134..000000000 --- a/sp_api/api/notifications/models/get_destinations_response.py +++ /dev/null @@ -1,137 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for Notifications - - The Selling Partner API for Notifications lets you subscribe to notifications that are relevant to a selling partner's business. Using this API you can create a destination to receive notifications, subscribe to notifications, delete notification subscriptions, and more. # noqa: E501 - - OpenAPI spec version: v1 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - -class GetDestinationsResponse(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'payload': 'DestinationList', - 'errors': 'ErrorList' - } - - attribute_map = { - 'payload': 'payload', - 'errors': 'errors' - } - - def __init__(self, payload=None, errors=None): # noqa: E501 - """GetDestinationsResponse - a model defined in Swagger""" # noqa: E501 - self._payload = None - self._errors = None - self.discriminator = None - if payload is not None: - self.payload = payload - if errors is not None: - self.errors = errors - - @property - def payload(self): - """Gets the payload of this GetDestinationsResponse. # noqa: E501 - - - :return: The payload of this GetDestinationsResponse. # noqa: E501 - :rtype: DestinationList - """ - return self._payload - - @payload.setter - def payload(self, payload): - """Sets the payload of this GetDestinationsResponse. - - - :param payload: The payload of this GetDestinationsResponse. # noqa: E501 - :type: DestinationList - """ - - self._payload = payload - - @property - def errors(self): - """Gets the errors of this GetDestinationsResponse. # noqa: E501 - - - :return: The errors of this GetDestinationsResponse. # noqa: E501 - :rtype: ErrorList - """ - return self._errors - - @errors.setter - def errors(self, errors): - """Sets the errors of this GetDestinationsResponse. - - - :param errors: The errors of this GetDestinationsResponse. # noqa: E501 - :type: ErrorList - """ - - self._errors = errors - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(GetDestinationsResponse, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, GetDestinationsResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/api/notifications/models/get_subscription_by_id_response.py b/sp_api/api/notifications/models/get_subscription_by_id_response.py deleted file mode 100644 index dc64b806a..000000000 --- a/sp_api/api/notifications/models/get_subscription_by_id_response.py +++ /dev/null @@ -1,137 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for Notifications - - The Selling Partner API for Notifications lets you subscribe to notifications that are relevant to a selling partner's business. Using this API you can create a destination to receive notifications, subscribe to notifications, delete notification subscriptions, and more. # noqa: E501 - - OpenAPI spec version: v1 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - -class GetSubscriptionByIdResponse(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'payload': 'Subscription', - 'errors': 'ErrorList' - } - - attribute_map = { - 'payload': 'payload', - 'errors': 'errors' - } - - def __init__(self, payload=None, errors=None): # noqa: E501 - """GetSubscriptionByIdResponse - a model defined in Swagger""" # noqa: E501 - self._payload = None - self._errors = None - self.discriminator = None - if payload is not None: - self.payload = payload - if errors is not None: - self.errors = errors - - @property - def payload(self): - """Gets the payload of this GetSubscriptionByIdResponse. # noqa: E501 - - - :return: The payload of this GetSubscriptionByIdResponse. # noqa: E501 - :rtype: Subscription - """ - return self._payload - - @payload.setter - def payload(self, payload): - """Sets the payload of this GetSubscriptionByIdResponse. - - - :param payload: The payload of this GetSubscriptionByIdResponse. # noqa: E501 - :type: Subscription - """ - - self._payload = payload - - @property - def errors(self): - """Gets the errors of this GetSubscriptionByIdResponse. # noqa: E501 - - - :return: The errors of this GetSubscriptionByIdResponse. # noqa: E501 - :rtype: ErrorList - """ - return self._errors - - @errors.setter - def errors(self, errors): - """Sets the errors of this GetSubscriptionByIdResponse. - - - :param errors: The errors of this GetSubscriptionByIdResponse. # noqa: E501 - :type: ErrorList - """ - - self._errors = errors - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(GetSubscriptionByIdResponse, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, GetSubscriptionByIdResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/api/notifications/models/get_subscription_response.py b/sp_api/api/notifications/models/get_subscription_response.py deleted file mode 100644 index e277c23d5..000000000 --- a/sp_api/api/notifications/models/get_subscription_response.py +++ /dev/null @@ -1,137 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for Notifications - - The Selling Partner API for Notifications lets you subscribe to notifications that are relevant to a selling partner's business. Using this API you can create a destination to receive notifications, subscribe to notifications, delete notification subscriptions, and more. # noqa: E501 - - OpenAPI spec version: v1 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - -class GetSubscriptionResponse(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'payload': 'Subscription', - 'errors': 'ErrorList' - } - - attribute_map = { - 'payload': 'payload', - 'errors': 'errors' - } - - def __init__(self, payload=None, errors=None): # noqa: E501 - """GetSubscriptionResponse - a model defined in Swagger""" # noqa: E501 - self._payload = None - self._errors = None - self.discriminator = None - if payload is not None: - self.payload = payload - if errors is not None: - self.errors = errors - - @property - def payload(self): - """Gets the payload of this GetSubscriptionResponse. # noqa: E501 - - - :return: The payload of this GetSubscriptionResponse. # noqa: E501 - :rtype: Subscription - """ - return self._payload - - @payload.setter - def payload(self, payload): - """Sets the payload of this GetSubscriptionResponse. - - - :param payload: The payload of this GetSubscriptionResponse. # noqa: E501 - :type: Subscription - """ - - self._payload = payload - - @property - def errors(self): - """Gets the errors of this GetSubscriptionResponse. # noqa: E501 - - - :return: The errors of this GetSubscriptionResponse. # noqa: E501 - :rtype: ErrorList - """ - return self._errors - - @errors.setter - def errors(self, errors): - """Sets the errors of this GetSubscriptionResponse. - - - :param errors: The errors of this GetSubscriptionResponse. # noqa: E501 - :type: ErrorList - """ - - self._errors = errors - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(GetSubscriptionResponse, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, GetSubscriptionResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/api/notifications/notifications.py b/sp_api/api/notifications/notifications.py index 1b06a7576..1f212d87b 100644 --- a/sp_api/api/notifications/notifications.py +++ b/sp_api/api/notifications/notifications.py @@ -1,13 +1,5 @@ from sp_api.base.helpers import sp_endpoint, fill_query_params -from sp_api.api.notifications.models.create_destination_response import CreateDestinationResponse -from sp_api.api.notifications.models.create_subscription_response import CreateSubscriptionResponse -from sp_api.api.notifications.models.delete_destination_response import DeleteDestinationResponse -from sp_api.api.notifications.models.delete_subscription_by_id_response import DeleteSubscriptionByIdResponse -from sp_api.api.notifications.models.get_destination_response import GetDestinationResponse -from sp_api.api.notifications.models.get_destinations_response import GetDestinationsResponse -from sp_api.api.notifications.models.get_subscription_by_id_response import GetSubscriptionByIdResponse -from sp_api.api.notifications.models.get_subscription_response import GetSubscriptionResponse -from sp_api.base import Client, Marketplaces, deprecated, NotificationType +from sp_api.base import Client, Marketplaces, deprecated, NotificationType, ApiResponse class Notifications(Client): @@ -21,9 +13,10 @@ def add_subscription(self, notification_type: NotificationType or str, **kwargs) 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) -> CreateSubscriptionResponse: + 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) -> CreateSubscriptionResponse + 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. Before you can subscribe, you must first create the destination by calling the createDestination operation. @@ -44,24 +37,22 @@ def create_subscription(self, notification_type: NotificationType or str, destin Returns: - CreateSubscriptionResponse: + ApiResponse: """ data = { 'destinationId': kwargs.pop('destinationId', destination_id), 'payloadVersion': kwargs.pop('payload_version', '1.0') } - return CreateSubscriptionResponse( - **self._request(fill_query_params(kwargs.pop('path'), - notification_type if isinstance(notification_type, - str) else notification_type.value), - data={**kwargs, **data}).json() - ) + 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) -> GetSubscriptionResponse: + def get_subscription(self, notification_type: NotificationType or str, **kwargs) -> ApiResponse: """ - get_subscription(self, notification_type: NotificationType or str, **kwargs) -> GetSubscriptionResponse + 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. **Usage Plan:** @@ -80,18 +71,18 @@ def get_subscription(self, notification_type: NotificationType or str, **kwargs) **kwargs: Returns: - GetSubscriptionResponse: + ApiResponse: """ - return GetSubscriptionResponse( - **self._request(fill_query_params(kwargs.pop('path'), notification_type if isinstance(notification_type, str) else notification_type.value), - params={**kwargs}).json() - ) + 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) -> DeleteSubscriptionByIdResponse: + 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) -> DeleteSubscriptionByIdResponse + 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. The subscription identifier can be for any subscription associated with your application. After you successfully call this operation, notifications will stop being sent for the associated subscription. The deleteSubscriptionById API is grantless. For more information, see "Grantless operations" in the Selling Partner API Developer Guide. @@ -111,19 +102,19 @@ def delete_notification_subscription(self, notification_type: NotificationType o **kwargs: Returns: - DeleteSubscriptionByIdResponse: + ApiResponse: """ - return DeleteSubscriptionByIdResponse( - **self._request( - fill_query_params(kwargs.pop('path'), notification_type if isinstance(notification_type, str) else notification_type.value, subscription_id), - params={**kwargs}).json() - ) + 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, **kwargs) -> CreateDestinationResponse: + def create_destination(self, name: str, arn: str, **kwargs) -> ApiResponse: """ - create_destination(self, name: str, arn: str, **kwargs) -> CreateDestinationResponse + 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. **Usage Plan:** @@ -141,7 +132,7 @@ def create_destination(self, name: str, arn: str, **kwargs) -> CreateDestination **kwargs: Returns: - CreateDestinationResponse: + ApiResponse: """ @@ -154,14 +145,12 @@ def create_destination(self, name: str, arn: str, **kwargs) -> CreateDestination 'name': name, } - return CreateDestinationResponse( - **self._request_grantless_operation(kwargs.pop('path'), data={**kwargs, **data}).json() - ) + return self._request_grantless_operation(kwargs.pop('path'), data={**kwargs, **data}) @sp_endpoint('/notifications/v1/destinations', method='GET') - def get_destinations(self, **kwargs) -> GetDestinationsResponse: + def get_destinations(self, **kwargs) -> ApiResponse: """ - get_destinations(self, **kwargs) -> GetDestinationsResponse + get_destinations(self, **kwargs) -> ApiResponse Returns information about all destinations. The getDestinations API is grantless. For more information, see "Grantless operations" in the Selling Partner API Developer Guide. **Usage Plan:** @@ -179,17 +168,15 @@ def get_destinations(self, **kwargs) -> GetDestinationsResponse: **kwargs: Returns: - GetDestinationsResponse: + ApiResponse: """ - return GetDestinationsResponse( - **self._request_grantless_operation(kwargs.pop('path'), params={**kwargs}).json() - ) + return self._request_grantless_operation(kwargs.pop('path'), params={**kwargs}) @sp_endpoint('/notifications/v1/destinations/{}', method='GET') - def get_destination(self, destination_id: str, **kwargs) -> GetDestinationResponse: + def get_destination(self, destination_id: str, **kwargs) -> ApiResponse: """ - get_destination(self, destination_id: str, **kwargs) -> GetDestinationResponse + get_destination(self, destination_id: str, **kwargs) -> ApiResponse Returns information about all destinations. The getDestinations API is grantless. For more information, see "Grantless operations" in the Selling Partner API Developer Guide. **Usage Plan:** @@ -208,19 +195,17 @@ def get_destination(self, destination_id: str, **kwargs) -> GetDestinationRespon **kwargs: Returns: - GetDestinationResponse: + ApiResponse: """ - return GetDestinationResponse( - **self._request_grantless_operation(fill_query_params(kwargs.pop('path'), destination_id), - params={**kwargs}).json() - ) + return self._request_grantless_operation(fill_query_params(kwargs.pop('path'), destination_id), + params={**kwargs}) @sp_endpoint('/notifications/v1/destinations/{}', method='DELETE') - def delete_destination(self, destination_id: str, **kwargs) -> DeleteDestinationResponse: + def delete_destination(self, destination_id: str, **kwargs) -> ApiResponse: """ - delete_destination(self, destination_id: str, **kwargs) -> DeleteDestinationResponse + delete_destination(self, destination_id: str, **kwargs) -> ApiResponse Deletes the destination that you specify. The deleteDestination API is grantless. For more information, see "Grantless operations" in the Selling Partner API Developer Guide. **Usage Plan:** @@ -238,10 +223,8 @@ def delete_destination(self, destination_id: str, **kwargs) -> DeleteDestination **kwargs: Returns: - DeleteDestinationResponse: + ApiResponse: """ - return DeleteDestinationResponse( - **self._request_grantless_operation(fill_query_params(kwargs.pop('path'), destination_id), - params={**kwargs}).json() - ) + return self._request_grantless_operation(fill_query_params(kwargs.pop('path'), destination_id), + params={**kwargs}) diff --git a/sp_api/api/orders/models/__init__.py b/sp_api/api/orders/models/__init__.py deleted file mode 100644 index 8939af923..000000000 --- a/sp_api/api/orders/models/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from sp_api.api.orders.models import * diff --git a/sp_api/api/orders/models/get_order_address_response.py b/sp_api/api/orders/models/get_order_address_response.py deleted file mode 100644 index 72516d816..000000000 --- a/sp_api/api/orders/models/get_order_address_response.py +++ /dev/null @@ -1,137 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for Orders - - The Selling Partner API for Orders helps you programmatically retrieve order information. These APIs let you develop fast, flexible, custom applications in areas like order synchronization, order research, and demand-based decision support tools. # noqa: E501 - - OpenAPI spec version: v0 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - -class GetOrderAddressResponse(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'payload': 'OrderAddress', - 'errors': 'ErrorList' - } - - attribute_map = { - 'payload': 'payload', - 'errors': 'errors' - } - - def __init__(self, payload=None, errors=None): # noqa: E501 - """GetOrderAddressResponse - a model defined in Swagger""" # noqa: E501 - self._payload = None - self._errors = None - self.discriminator = None - if payload is not None: - self.payload = payload - if errors is not None: - self.errors = errors - - @property - def payload(self): - """Gets the payload of this GetOrderAddressResponse. # noqa: E501 - - - :return: The payload of this GetOrderAddressResponse. # noqa: E501 - :rtype: OrderAddress - """ - return self._payload - - @payload.setter - def payload(self, payload): - """Sets the payload of this GetOrderAddressResponse. - - - :param payload: The payload of this GetOrderAddressResponse. # noqa: E501 - :type: OrderAddress - """ - - self._payload = payload - - @property - def errors(self): - """Gets the errors of this GetOrderAddressResponse. # noqa: E501 - - - :return: The errors of this GetOrderAddressResponse. # noqa: E501 - :rtype: ErrorList - """ - return self._errors - - @errors.setter - def errors(self, errors): - """Sets the errors of this GetOrderAddressResponse. - - - :param errors: The errors of this GetOrderAddressResponse. # noqa: E501 - :type: ErrorList - """ - - self._errors = errors - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(GetOrderAddressResponse, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, GetOrderAddressResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/api/orders/models/get_order_buyer_info_response.py b/sp_api/api/orders/models/get_order_buyer_info_response.py deleted file mode 100644 index 4d2e7034a..000000000 --- a/sp_api/api/orders/models/get_order_buyer_info_response.py +++ /dev/null @@ -1,137 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for Orders - - The Selling Partner API for Orders helps you programmatically retrieve order information. These APIs let you develop fast, flexible, custom applications in areas like order synchronization, order research, and demand-based decision support tools. # noqa: E501 - - OpenAPI spec version: v0 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - -class GetOrderBuyerInfoResponse(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'payload': 'OrderBuyerInfo', - 'errors': 'ErrorList' - } - - attribute_map = { - 'payload': 'payload', - 'errors': 'errors' - } - - def __init__(self, payload=None, errors=None): # noqa: E501 - """GetOrderBuyerInfoResponse - a model defined in Swagger""" # noqa: E501 - self._payload = None - self._errors = None - self.discriminator = None - if payload is not None: - self.payload = payload - if errors is not None: - self.errors = errors - - @property - def payload(self): - """Gets the payload of this GetOrderBuyerInfoResponse. # noqa: E501 - - - :return: The payload of this GetOrderBuyerInfoResponse. # noqa: E501 - :rtype: OrderBuyerInfo - """ - return self._payload - - @payload.setter - def payload(self, payload): - """Sets the payload of this GetOrderBuyerInfoResponse. - - - :param payload: The payload of this GetOrderBuyerInfoResponse. # noqa: E501 - :type: OrderBuyerInfo - """ - - self._payload = payload - - @property - def errors(self): - """Gets the errors of this GetOrderBuyerInfoResponse. # noqa: E501 - - - :return: The errors of this GetOrderBuyerInfoResponse. # noqa: E501 - :rtype: ErrorList - """ - return self._errors - - @errors.setter - def errors(self, errors): - """Sets the errors of this GetOrderBuyerInfoResponse. - - - :param errors: The errors of this GetOrderBuyerInfoResponse. # noqa: E501 - :type: ErrorList - """ - - self._errors = errors - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(GetOrderBuyerInfoResponse, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, GetOrderBuyerInfoResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/api/orders/models/get_order_items_buyer_info_response.py b/sp_api/api/orders/models/get_order_items_buyer_info_response.py deleted file mode 100644 index e8f33b871..000000000 --- a/sp_api/api/orders/models/get_order_items_buyer_info_response.py +++ /dev/null @@ -1,137 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for Orders - - The Selling Partner API for Orders helps you programmatically retrieve order information. These APIs let you develop fast, flexible, custom applications in areas like order synchronization, order research, and demand-based decision support tools. # noqa: E501 - - OpenAPI spec version: v0 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - -class GetOrderItemsBuyerInfoResponse(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'payload': 'OrderItemsBuyerInfoList', - 'errors': 'ErrorList' - } - - attribute_map = { - 'payload': 'payload', - 'errors': 'errors' - } - - def __init__(self, payload=None, errors=None): # noqa: E501 - """GetOrderItemsBuyerInfoResponse - a model defined in Swagger""" # noqa: E501 - self._payload = None - self._errors = None - self.discriminator = None - if payload is not None: - self.payload = payload - if errors is not None: - self.errors = errors - - @property - def payload(self): - """Gets the payload of this GetOrderItemsBuyerInfoResponse. # noqa: E501 - - - :return: The payload of this GetOrderItemsBuyerInfoResponse. # noqa: E501 - :rtype: OrderItemsBuyerInfoList - """ - return self._payload - - @payload.setter - def payload(self, payload): - """Sets the payload of this GetOrderItemsBuyerInfoResponse. - - - :param payload: The payload of this GetOrderItemsBuyerInfoResponse. # noqa: E501 - :type: OrderItemsBuyerInfoList - """ - - self._payload = payload - - @property - def errors(self): - """Gets the errors of this GetOrderItemsBuyerInfoResponse. # noqa: E501 - - - :return: The errors of this GetOrderItemsBuyerInfoResponse. # noqa: E501 - :rtype: ErrorList - """ - return self._errors - - @errors.setter - def errors(self, errors): - """Sets the errors of this GetOrderItemsBuyerInfoResponse. - - - :param errors: The errors of this GetOrderItemsBuyerInfoResponse. # noqa: E501 - :type: ErrorList - """ - - self._errors = errors - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(GetOrderItemsBuyerInfoResponse, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, GetOrderItemsBuyerInfoResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/api/orders/models/get_order_items_response.py b/sp_api/api/orders/models/get_order_items_response.py deleted file mode 100644 index 6e0625517..000000000 --- a/sp_api/api/orders/models/get_order_items_response.py +++ /dev/null @@ -1,137 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for Orders - - The Selling Partner API for Orders helps you programmatically retrieve order information. These APIs let you develop fast, flexible, custom applications in areas like order synchronization, order research, and demand-based decision support tools. # noqa: E501 - - OpenAPI spec version: v0 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - -class GetOrderItemsResponse(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'payload': 'OrderItemsList', - 'errors': 'ErrorList' - } - - attribute_map = { - 'payload': 'payload', - 'errors': 'errors' - } - - def __init__(self, payload=None, errors=None): # noqa: E501 - """GetOrderItemsResponse - a model defined in Swagger""" # noqa: E501 - self._payload = None - self._errors = None - self.discriminator = None - if payload is not None: - self.payload = payload - if errors is not None: - self.errors = errors - - @property - def payload(self): - """Gets the payload of this GetOrderItemsResponse. # noqa: E501 - - - :return: The payload of this GetOrderItemsResponse. # noqa: E501 - :rtype: OrderItemsList - """ - return self._payload - - @payload.setter - def payload(self, payload): - """Sets the payload of this GetOrderItemsResponse. - - - :param payload: The payload of this GetOrderItemsResponse. # noqa: E501 - :type: OrderItemsList - """ - - self._payload = payload - - @property - def errors(self): - """Gets the errors of this GetOrderItemsResponse. # noqa: E501 - - - :return: The errors of this GetOrderItemsResponse. # noqa: E501 - :rtype: ErrorList - """ - return self._errors - - @errors.setter - def errors(self, errors): - """Sets the errors of this GetOrderItemsResponse. - - - :param errors: The errors of this GetOrderItemsResponse. # noqa: E501 - :type: ErrorList - """ - - self._errors = errors - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(GetOrderItemsResponse, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, GetOrderItemsResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/api/orders/models/get_order_response.py b/sp_api/api/orders/models/get_order_response.py deleted file mode 100644 index 1f4291197..000000000 --- a/sp_api/api/orders/models/get_order_response.py +++ /dev/null @@ -1,137 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for Orders - - The Selling Partner API for Orders helps you programmatically retrieve order information. These APIs let you develop fast, flexible, custom applications in areas like order synchronization, order research, and demand-based decision support tools. # noqa: E501 - - OpenAPI spec version: v0 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - -class GetOrderResponse(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'payload': 'Order', - 'errors': 'ErrorList' - } - - attribute_map = { - 'payload': 'payload', - 'errors': 'errors' - } - - def __init__(self, payload=None, errors=None): # noqa: E501 - """GetOrderResponse - a model defined in Swagger""" # noqa: E501 - self._payload = None - self._errors = None - self.discriminator = None - if payload is not None: - self.payload = payload - if errors is not None: - self.errors = errors - - @property - def payload(self): - """Gets the payload of this GetOrderResponse. # noqa: E501 - - - :return: The payload of this GetOrderResponse. # noqa: E501 - :rtype: Order - """ - return self._payload - - @payload.setter - def payload(self, payload): - """Sets the payload of this GetOrderResponse. - - - :param payload: The payload of this GetOrderResponse. # noqa: E501 - :type: Order - """ - - self._payload = payload - - @property - def errors(self): - """Gets the errors of this GetOrderResponse. # noqa: E501 - - - :return: The errors of this GetOrderResponse. # noqa: E501 - :rtype: ErrorList - """ - return self._errors - - @errors.setter - def errors(self, errors): - """Sets the errors of this GetOrderResponse. - - - :param errors: The errors of this GetOrderResponse. # noqa: E501 - :type: ErrorList - """ - - self._errors = errors - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(GetOrderResponse, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, GetOrderResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/api/orders/models/get_orders_response.py b/sp_api/api/orders/models/get_orders_response.py deleted file mode 100644 index b620ac24f..000000000 --- a/sp_api/api/orders/models/get_orders_response.py +++ /dev/null @@ -1,137 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for Orders - - The Selling Partner API for Orders helps you programmatically retrieve order information. These APIs let you develop fast, flexible, custom applications in areas like order synchronization, order research, and demand-based decision support tools. # noqa: E501 - - OpenAPI spec version: v0 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - - -class GetOrdersResponse(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'payload': 'OrdersList', - 'errors': 'ErrorList' - } - - attribute_map = { - 'payload': 'payload', - 'errors': 'errors' - } - - def __init__(self, payload=None, errors=None): # noqa: E501 - """GetOrdersResponse - a model defined in Swagger""" # noqa: E501 - self._payload = None - self._errors = None - self.discriminator = None - if payload is not None: - self.payload = payload - if errors is not None: - self.errors = errors - - @property - def payload(self): - """Gets the payload of this GetOrdersResponse. # noqa: E501 - - - :return: The payload of this GetOrdersResponse. # noqa: E501 - :rtype: OrdersList - """ - return self._payload - - @payload.setter - def payload(self, payload): - """Sets the payload of this GetOrdersResponse. - - - :param payload: The payload of this GetOrdersResponse. # noqa: E501 - :type: OrdersList - """ - self._payload = payload - - @property - def errors(self): - """Gets the errors of this GetOrdersResponse. # noqa: E501 - - - :return: The errors of this GetOrdersResponse. # noqa: E501 - :rtype: ErrorList - """ - return self._errors - - @errors.setter - def errors(self, errors): - """Sets the errors of this GetOrdersResponse. - - - :param errors: The errors of this GetOrdersResponse. # noqa: E501 - :type: ErrorList - """ - - self._errors = errors - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(GetOrdersResponse, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, GetOrdersResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/api/orders/orders.py b/sp_api/api/orders/orders.py index da460b4f4..0ed85d16b 100644 --- a/sp_api/api/orders/orders.py +++ b/sp_api/api/orders/orders.py @@ -1,10 +1,4 @@ -from sp_api.api.orders.models.get_order_address_response import GetOrderAddressResponse -from sp_api.api.orders.models.get_order_buyer_info_response import GetOrderBuyerInfoResponse -from sp_api.api.orders.models.get_order_items_buyer_info_response import GetOrderItemsBuyerInfoResponse -from sp_api.base import sp_endpoint, fill_query_params -from sp_api.api.orders.models.get_order_items_response import GetOrderItemsResponse -from sp_api.api.orders.models.get_order_response import GetOrderResponse -from sp_api.api.orders.models.get_orders_response import GetOrdersResponse +from sp_api.base import sp_endpoint, fill_query_params, ApiResponse from sp_api.base import Client, Marketplaces @@ -14,9 +8,9 @@ class Orders(Client): """ @sp_endpoint('/orders/v0/orders') - def get_orders(self, **kwargs) -> GetOrdersResponse: + def get_orders(self, **kwargs) -> ApiResponse: """ - get_orders(self, **kwargs) -> GetOrdersResponse + get_orders(self, **kwargs) -> ApiResponse Returns orders created or updated during the time frame indicated by the specified parameters. You can also apply a range of filtering criteria to narrow the list of orders returned. If NextToken is present, that will be used to retrieve the orders instead of other criteria. @@ -50,17 +44,16 @@ def get_orders(self, **kwargs) -> GetOrdersResponse: Returns: - GetOrdersResponse: + ApiResponse: """ - return GetOrdersResponse( - **self._request(kwargs.pop('path'), params={**kwargs}).json()) + return self._request(kwargs.pop('path'), params={**kwargs}) @sp_endpoint('/orders/v0/orders/{}') - def get_order(self, order_id: str, **kwargs) -> GetOrderResponse: + def get_order(self, order_id: str, **kwargs) -> ApiResponse: """ - get_order(self, order_id: str, **kwargs) -> GetOrderResponse + get_order(self, order_id: str, **kwargs) -> ApiResponse Returns the order indicated by the specified order ID. **Usage Plan:** @@ -79,18 +72,17 @@ def get_order(self, order_id: str, **kwargs) -> GetOrderResponse: **kwargs: Returns: - GetOrderResponse: + ApiResponse: """ - return GetOrderResponse( - **self._request(fill_query_params(kwargs.pop('path'), order_id), params={**kwargs}, add_marketplace=False).json() - ) + return self._request(fill_query_params(kwargs.pop('path'), order_id), params={**kwargs}, add_marketplace=False) @sp_endpoint('/orders/v0/orders/{}/orderItems') - def get_order_items(self, order_id: str, **kwargs) -> GetOrderItemsResponse: + def get_order_items(self, order_id: str, **kwargs) -> ApiResponse: """ - get_order_items(self, order_id: str, **kwargs) -> GetOrderItemsResponse + get_order_items(self, order_id: str, **kwargs) -> ApiResponse + Returns detailed order item information for the order indicated by the specified order ID. If NextToken is provided, it's used to retrieve the next page of order items. @@ -119,15 +111,16 @@ def get_order_items(self, order_id: str, **kwargs) -> GetOrderItemsResponse: **kwargs: Returns: - GetOrderItemsResponse: + ApiResponse: """ - return GetOrderItemsResponse( - **self._request(fill_query_params(kwargs.pop('path'), order_id), params={**kwargs}).json()) + return self._request(fill_query_params(kwargs.pop('path'), order_id), params={**kwargs}) @sp_endpoint('/orders/v0/orders/{}/address') - def get_order_address(self, order_id, **kwargs): + def get_order_address(self, order_id, **kwargs) -> ApiResponse: """ + get_order_address(self, order_id, **kwargs) -> ApiResponse + Returns the shipping address for the order indicated by the specified order ID. :note: To get useful information from this method, you need to have access to PII. @@ -146,16 +139,14 @@ def get_order_address(self, order_id, **kwargs): **kwargs: Returns: - + ApiResponse """ - return GetOrderAddressResponse( - **self._request(fill_query_params(kwargs.pop('path'), order_id), params={**kwargs}).json() - ) + return self._request(fill_query_params(kwargs.pop('path'), order_id), params={**kwargs}) @sp_endpoint('/orders/v0/orders/{}/buyerInfo') - def get_order_buyer_info(self, order_id: str, **kwargs) -> GetOrderBuyerInfoResponse: + def get_order_buyer_info(self, order_id: str, **kwargs) -> ApiResponse: """ - get_order_buyer_info(self, order_id: str, **kwargs) -> GetOrderBuyerInfoResponse + get_order_buyer_info(self, order_id: str, **kwargs) -> ApiResponse Returns buyer information for the order indicated by the specified order ID. :note: To get useful information from this method, you need to have access to PII. @@ -180,14 +171,12 @@ def get_order_buyer_info(self, order_id: str, **kwargs) -> GetOrderBuyerInfoResp GetOrderBuyerInfoResponse: """ - return GetOrderBuyerInfoResponse( - **self._request(fill_query_params(kwargs.pop('path'), order_id), params={**kwargs}).json() - ) + return self._request(fill_query_params(kwargs.pop('path'), order_id), params={**kwargs}) @sp_endpoint('/orders/v0/orders/{}/orderItems/buyerInfo') - def get_order_items_buyer_info(self, order_id: str, **kwargs) -> GetOrderItemsBuyerInfoResponse: + def get_order_items_buyer_info(self, order_id: str, **kwargs) -> ApiResponse: """ - get_order_items_buyer_info(self, order_id: str, **kwargs) -> GetOrderItemsBuyerInfoResponse + get_order_items_buyer_info(self, order_id: str, **kwargs) -> ApiResponse Returns buyer information in the order items of the order indicated by the specified order ID. @@ -206,8 +195,6 @@ def get_order_items_buyer_info(self, order_id: str, **kwargs) -> GetOrderItemsBu key NextToken: str | retrieve data by next token Returns: - GetOrderItemsBuyerInfoResponse + ApiResponse """ - return GetOrderItemsBuyerInfoResponse( - **self._request(fill_query_params(kwargs.pop('path'), order_id), params=kwargs).json() - ) + return self._request(fill_query_params(kwargs.pop('path'), order_id), params=kwargs) diff --git a/sp_api/api/product_fees/models/__init__.py b/sp_api/api/product_fees/models/__init__.py deleted file mode 100644 index 36acf877c..000000000 --- a/sp_api/api/product_fees/models/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from sp_api.api.product_fees.models import * diff --git a/sp_api/api/product_fees/models/get_my_fees_estimate_response.py b/sp_api/api/product_fees/models/get_my_fees_estimate_response.py deleted file mode 100644 index eab592def..000000000 --- a/sp_api/api/product_fees/models/get_my_fees_estimate_response.py +++ /dev/null @@ -1,137 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for Product Fees - - The Selling Partner API for Product Fees lets you programmatically retrieve estimated fees for a product. You can then account for those fees in your pricing. # noqa: E501 - - OpenAPI spec version: v0 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - -class GetMyFeesEstimateResponse(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'payload': 'GetMyFeesEstimateResult', - 'errors': 'ErrorList' - } - - attribute_map = { - 'payload': 'payload', - 'errors': 'errors' - } - - def __init__(self, payload=None, errors=None): # noqa: E501 - """GetMyFeesEstimateResponse - a model defined in Swagger""" # noqa: E501 - self._payload = None - self._errors = None - self.discriminator = None - if payload is not None: - self.payload = payload - if errors is not None: - self.errors = errors - - @property - def payload(self): - """Gets the payload of this GetMyFeesEstimateResponse. # noqa: E501 - - - :return: The payload of this GetMyFeesEstimateResponse. # noqa: E501 - :rtype: GetMyFeesEstimateResult - """ - return self._payload - - @payload.setter - def payload(self, payload): - """Sets the payload of this GetMyFeesEstimateResponse. - - - :param payload: The payload of this GetMyFeesEstimateResponse. # noqa: E501 - :type: GetMyFeesEstimateResult - """ - - self._payload = payload - - @property - def errors(self): - """Gets the errors of this GetMyFeesEstimateResponse. # noqa: E501 - - - :return: The errors of this GetMyFeesEstimateResponse. # noqa: E501 - :rtype: ErrorList - """ - return self._errors - - @errors.setter - def errors(self, errors): - """Sets the errors of this GetMyFeesEstimateResponse. - - - :param errors: The errors of this GetMyFeesEstimateResponse. # noqa: E501 - :type: ErrorList - """ - - self._errors = errors - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(GetMyFeesEstimateResponse, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, GetMyFeesEstimateResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/api/product_fees/product_fees.py b/sp_api/api/product_fees/product_fees.py index cced1fab7..e00bcead0 100644 --- a/sp_api/api/product_fees/product_fees.py +++ b/sp_api/api/product_fees/product_fees.py @@ -1,28 +1,76 @@ -import json - -from sp_api.api.product_fees.models.get_my_fees_estimate_response import GetMyFeesEstimateResponse from sp_api.base.helpers import sp_endpoint, fill_query_params -from sp_api.base import Client, Marketplaces +from sp_api.base import Client, ApiResponse 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 = dict, **kwargs): + is_fba=False, points: dict = dict, **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 + + Returns fees for sku + + Args: + seller_sku: + price: + shipping_price: + currency: + is_fba: + points: + **kwargs: + + Returns: + ApiResponse: + + """ kwargs.update(self._create_body(price, shipping_price, currency, is_fba, seller_sku, points)) - return GetMyFeesEstimateResponse( - **self._request(fill_query_params(kwargs.pop('path'), seller_sku), data=kwargs).json()) + 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 = dict, - **kwargs): + **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 + + Returns fees for asin + + Args: + asin: + price: + currency: + shipping_price: + is_fba: + points: + **kwargs: + + Returns: + ApiResponse: + + """ kwargs.update(self._create_body(price, shipping_price, currency, is_fba, asin, points)) - return GetMyFeesEstimateResponse( - **self._request(fill_query_params(kwargs.pop('path'), asin), data=kwargs).json()) + return self._request(fill_query_params(kwargs.pop('path'), asin), data=kwargs) def _create_body(self, price, shipping_price=None, currency='USD', is_fba=False, identifier=None, points=dict): + """ + Create request body + + Args: + price: + shipping_price: + currency: + is_fba: + identifier: + points: + + Returns: + + """ return { 'FeesEstimateRequest': { 'Identifier': identifier or str(price), diff --git a/sp_api/api/products/models/__init__.py b/sp_api/api/products/models/__init__.py deleted file mode 100644 index 11f99f8da..000000000 --- a/sp_api/api/products/models/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from sp_api.api.products.models import * diff --git a/sp_api/api/products/models/get_offers_response.py b/sp_api/api/products/models/get_offers_response.py deleted file mode 100644 index caeada541..000000000 --- a/sp_api/api/products/models/get_offers_response.py +++ /dev/null @@ -1,137 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for Pricing - - The Selling Partner API for Pricing helps you programmatically retrieve product pricing and offer information for Amazon Marketplace products. # noqa: E501 - - OpenAPI spec version: v0 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - -class GetOffersResponse(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'payload': 'GetOffersResult', - 'errors': 'ErrorList' - } - - attribute_map = { - 'payload': 'payload', - 'errors': 'errors' - } - - def __init__(self, payload=None, errors=None): # noqa: E501 - """GetOffersResponse - a model defined in Swagger""" # noqa: E501 - self._payload = None - self._errors = None - self.discriminator = None - if payload is not None: - self.payload = payload - if errors is not None: - self.errors = errors - - @property - def payload(self): - """Gets the payload of this GetOffersResponse. # noqa: E501 - - - :return: The payload of this GetOffersResponse. # noqa: E501 - :rtype: GetOffersResult - """ - return self._payload - - @payload.setter - def payload(self, payload): - """Sets the payload of this GetOffersResponse. - - - :param payload: The payload of this GetOffersResponse. # noqa: E501 - :type: GetOffersResult - """ - - self._payload = payload - - @property - def errors(self): - """Gets the errors of this GetOffersResponse. # noqa: E501 - - - :return: The errors of this GetOffersResponse. # noqa: E501 - :rtype: ErrorList - """ - return self._errors - - @errors.setter - def errors(self, errors): - """Sets the errors of this GetOffersResponse. - - - :param errors: The errors of this GetOffersResponse. # noqa: E501 - :type: ErrorList - """ - - self._errors = errors - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(GetOffersResponse, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, GetOffersResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/api/products/models/get_pricing_response.py b/sp_api/api/products/models/get_pricing_response.py deleted file mode 100644 index d26ac0f24..000000000 --- a/sp_api/api/products/models/get_pricing_response.py +++ /dev/null @@ -1,137 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for Pricing - - The Selling Partner API for Pricing helps you programmatically retrieve product pricing and offer information for Amazon Marketplace products. # noqa: E501 - - OpenAPI spec version: v0 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - -class GetPricingResponse(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'payload': 'PriceList', - 'errors': 'ErrorList' - } - - attribute_map = { - 'payload': 'payload', - 'errors': 'errors' - } - - def __init__(self, payload=None, errors=None): # noqa: E501 - """GetPricingResponse - a model defined in Swagger""" # noqa: E501 - self._payload = None - self._errors = None - self.discriminator = None - if payload is not None: - self.payload = payload - if errors is not None: - self.errors = errors - - @property - def payload(self): - """Gets the payload of this GetPricingResponse. # noqa: E501 - - - :return: The payload of this GetPricingResponse. # noqa: E501 - :rtype: PriceList - """ - return self._payload - - @payload.setter - def payload(self, payload): - """Sets the payload of this GetPricingResponse. - - - :param payload: The payload of this GetPricingResponse. # noqa: E501 - :type: PriceList - """ - - self._payload = payload - - @property - def errors(self): - """Gets the errors of this GetPricingResponse. # noqa: E501 - - - :return: The errors of this GetPricingResponse. # noqa: E501 - :rtype: ErrorList - """ - return self._errors - - @errors.setter - def errors(self, errors): - """Sets the errors of this GetPricingResponse. - - - :param errors: The errors of this GetPricingResponse. # noqa: E501 - :type: ErrorList - """ - - self._errors = errors - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(GetPricingResponse, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, GetPricingResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/api/products/products.py b/sp_api/api/products/products.py index 2fa8325e1..289959e47 100644 --- a/sp_api/api/products/products.py +++ b/sp_api/api/products/products.py @@ -1,7 +1,5 @@ import urllib.parse - -from sp_api.api.products.models.get_pricing_response import GetPricingResponse -from sp_api.base import Client, Marketplaces, sp_endpoint +from sp_api.base import Client, Marketplaces, sp_endpoint, ApiResponse class Products(Client): @@ -9,12 +7,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, **kwargs) -> GetPricingResponse: + def get_product_pricing_for_skus(self, seller_sku_list: [str], item_condition=None, **kwargs) -> ApiResponse: """ - get_product_pricing_for_skus(self, seller_sku_list: [str], item_condition: str = None, **kwargs) -> GetPricingResponse + 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. **Usage Plan:** @@ -32,7 +28,7 @@ def get_product_pricing_for_skus(self, seller_sku_list: [str], item_condition=No **kwargs: Returns: - GetPricingResponse: + ApiResponse: """ if item_condition is not None: kwargs['ItemCondition'] = item_condition @@ -40,9 +36,9 @@ def get_product_pricing_for_skus(self, seller_sku_list: [str], item_condition=No 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, **kwargs) -> GetPricingResponse: + def get_product_pricing_for_asins(self, asin_list: [str], item_condition=None, **kwargs) -> ApiResponse: """ - get_product_pricing_for_asins(self, asin_list: [str], item_condition=None, **kwargs) -> GetPricingResponse + 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. **Usage Plan:** @@ -59,7 +55,7 @@ def get_product_pricing_for_asins(self, asin_list: [str], item_condition=None, * Filters the offer listings based on item condition. Possible values: New, Used, Collectible, Refurbished, Club. Available values : New, Used, Collectible, Refurbished, Club :param kwargs: - :return: + :return: ApiResponse """ if item_condition is not None: kwargs['ItemCondition'] = item_condition @@ -67,9 +63,9 @@ def get_product_pricing_for_asins(self, asin_list: [str], item_condition=None, * 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], **kwargs): + def get_competitive_pricing_for_skus(self, seller_sku_list: [str], **kwargs) -> ApiResponse: """ - get_competitive_pricing_for_skus(self, seller_sku_list, **kwargs) + 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 **Usage Plan:** @@ -83,14 +79,14 @@ def get_competitive_pricing_for_skus(self, seller_sku_list: [str], **kwargs): :param seller_sku_list: [str] :param kwargs: - :return: + :return: ApiResponse """ 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], **kwargs) -> GetPricingResponse: + def get_competitive_pricing_for_asins(self, asin_list: [str], **kwargs) -> ApiResponse: """ - get_competitive_pricing_for_asins(self, asin_list, **kwargs) -> GetPricingResponse + get_competitive_pricing_for_asins(self, asin_list, **kwargs) -> ApiResponse Returns competitive pricing information for a seller's offer listings based on ASIN **Usage Plan:** @@ -110,26 +106,10 @@ def get_competitive_pricing_for_asins(self, asin_list: [str], **kwargs) -> GetPr return self._create_get_pricing_request(asin_list, 'Asin', **kwargs) def _create_get_pricing_request(self, item_list, item_type, **kwargs): - """ - Returns pricing information for a seller's offer listings based on seller SKU or ASIN. - - **Usage Plan:** - - | Rate (requests per second) | Burst | - | ---- | ---- | - | 1 | 1 | - - For more information, see "Usage Plans and Rate Limits" in the Selling Partner API documentation. - - :param item_list: - :param item_type: - :param kwargs: - :return: - """ - return GetPricingResponse( - **self._request(kwargs.pop('path'), - params={**{f"{item_type}s": ','.join( - [urllib.parse.quote_plus(s) for s in item_list])}, - 'ItemType': item_type, - **({'ItemCondition': kwargs.pop('ItemCondition')} if 'ItemCondition' in kwargs else {}), - 'MarketplaceId': kwargs.get('MarketplaceId', self.marketplace_id)}).json()) + return self._request(kwargs.pop('path'), + params={**{f"{item_type}s": ','.join( + [urllib.parse.quote_plus(s) for s in item_list])}, + 'ItemType': item_type, + **({'ItemCondition': kwargs.pop( + 'ItemCondition')} if 'ItemCondition' in kwargs else {}), + 'MarketplaceId': kwargs.get('MarketplaceId', self.marketplace_id)}) diff --git a/sp_api/api/reports/models/__init__.py b/sp_api/api/reports/models/__init__.py deleted file mode 100644 index f673ca164..000000000 --- a/sp_api/api/reports/models/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from sp_api.api.reports.models import * diff --git a/sp_api/api/reports/models/cancel_report_response.py b/sp_api/api/reports/models/cancel_report_response.py deleted file mode 100644 index 6ad371060..000000000 --- a/sp_api/api/reports/models/cancel_report_response.py +++ /dev/null @@ -1,111 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for Reports - - The Selling Partner API for Reports lets you retrieve and manage a variety of reports that can help selling partners manage their businesses. # noqa: E501 - - OpenAPI spec version: 2020-09-04 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - -class CancelReportResponse(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'errors': 'ErrorList' - } - - attribute_map = { - 'errors': 'errors' - } - - def __init__(self, errors=None): # noqa: E501 - """CancelReportResponse - a model defined in Swagger""" # noqa: E501 - self._errors = None - self.discriminator = None - if errors is not None: - self.errors = errors - - @property - def errors(self): - """Gets the errors of this CancelReportResponse. # noqa: E501 - - - :return: The errors of this CancelReportResponse. # noqa: E501 - :rtype: ErrorList - """ - return self._errors - - @errors.setter - def errors(self, errors): - """Sets the errors of this CancelReportResponse. - - - :param errors: The errors of this CancelReportResponse. # noqa: E501 - :type: ErrorList - """ - - self._errors = errors - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(CancelReportResponse, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, CancelReportResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/api/reports/models/cancel_report_schedule_response.py b/sp_api/api/reports/models/cancel_report_schedule_response.py deleted file mode 100644 index 132fc295f..000000000 --- a/sp_api/api/reports/models/cancel_report_schedule_response.py +++ /dev/null @@ -1,111 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for Reports - - The Selling Partner API for Reports lets you retrieve and manage a variety of reports that can help selling partners manage their businesses. # noqa: E501 - - OpenAPI spec version: 2020-09-04 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - -class CancelReportScheduleResponse(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'errors': 'ErrorList' - } - - attribute_map = { - 'errors': 'errors' - } - - def __init__(self, errors=None): # noqa: E501 - """CancelReportScheduleResponse - a model defined in Swagger""" # noqa: E501 - self._errors = None - self.discriminator = None - if errors is not None: - self.errors = errors - - @property - def errors(self): - """Gets the errors of this CancelReportScheduleResponse. # noqa: E501 - - - :return: The errors of this CancelReportScheduleResponse. # noqa: E501 - :rtype: ErrorList - """ - return self._errors - - @errors.setter - def errors(self, errors): - """Sets the errors of this CancelReportScheduleResponse. - - - :param errors: The errors of this CancelReportScheduleResponse. # noqa: E501 - :type: ErrorList - """ - - self._errors = errors - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(CancelReportScheduleResponse, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, CancelReportScheduleResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/api/reports/models/create_report_response.py b/sp_api/api/reports/models/create_report_response.py deleted file mode 100644 index e3ef34117..000000000 --- a/sp_api/api/reports/models/create_report_response.py +++ /dev/null @@ -1,137 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for Reports - - The Selling Partner API for Reports lets you retrieve and manage a variety of reports that can help selling partners manage their businesses. # noqa: E501 - - OpenAPI spec version: 2020-09-04 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - -class CreateReportResponse(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'payload': 'CreateReportResult', - 'errors': 'ErrorList' - } - - attribute_map = { - 'payload': 'payload', - 'errors': 'errors' - } - - def __init__(self, payload=None, errors=None): # noqa: E501 - """CreateReportResponse - a model defined in Swagger""" # noqa: E501 - self._payload = None - self._errors = None - self.discriminator = None - if payload is not None: - self.payload = payload - if errors is not None: - self.errors = errors - - @property - def payload(self): - """Gets the payload of this CreateReportResponse. # noqa: E501 - - - :return: The payload of this CreateReportResponse. # noqa: E501 - :rtype: CreateReportResult - """ - return self._payload - - @payload.setter - def payload(self, payload): - """Sets the payload of this CreateReportResponse. - - - :param payload: The payload of this CreateReportResponse. # noqa: E501 - :type: CreateReportResult - """ - - self._payload = payload - - @property - def errors(self): - """Gets the errors of this CreateReportResponse. # noqa: E501 - - - :return: The errors of this CreateReportResponse. # noqa: E501 - :rtype: ErrorList - """ - return self._errors - - @errors.setter - def errors(self, errors): - """Sets the errors of this CreateReportResponse. - - - :param errors: The errors of this CreateReportResponse. # noqa: E501 - :type: ErrorList - """ - - self._errors = errors - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(CreateReportResponse, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, CreateReportResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/api/reports/models/create_report_schedule_response.py b/sp_api/api/reports/models/create_report_schedule_response.py deleted file mode 100644 index 343474a0b..000000000 --- a/sp_api/api/reports/models/create_report_schedule_response.py +++ /dev/null @@ -1,137 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for Reports - - The Selling Partner API for Reports lets you retrieve and manage a variety of reports that can help selling partners manage their businesses. # noqa: E501 - - OpenAPI spec version: 2020-09-04 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - -class CreateReportScheduleResponse(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'payload': 'CreateReportScheduleResult', - 'errors': 'ErrorList' - } - - attribute_map = { - 'payload': 'payload', - 'errors': 'errors' - } - - def __init__(self, payload=None, errors=None): # noqa: E501 - """CreateReportScheduleResponse - a model defined in Swagger""" # noqa: E501 - self._payload = None - self._errors = None - self.discriminator = None - if payload is not None: - self.payload = payload - if errors is not None: - self.errors = errors - - @property - def payload(self): - """Gets the payload of this CreateReportScheduleResponse. # noqa: E501 - - - :return: The payload of this CreateReportScheduleResponse. # noqa: E501 - :rtype: CreateReportScheduleResult - """ - return self._payload - - @payload.setter - def payload(self, payload): - """Sets the payload of this CreateReportScheduleResponse. - - - :param payload: The payload of this CreateReportScheduleResponse. # noqa: E501 - :type: CreateReportScheduleResult - """ - - self._payload = payload - - @property - def errors(self): - """Gets the errors of this CreateReportScheduleResponse. # noqa: E501 - - - :return: The errors of this CreateReportScheduleResponse. # noqa: E501 - :rtype: ErrorList - """ - return self._errors - - @errors.setter - def errors(self, errors): - """Sets the errors of this CreateReportScheduleResponse. - - - :param errors: The errors of this CreateReportScheduleResponse. # noqa: E501 - :type: ErrorList - """ - - self._errors = errors - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(CreateReportScheduleResponse, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, CreateReportScheduleResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/api/reports/models/get_report_document_response.py b/sp_api/api/reports/models/get_report_document_response.py deleted file mode 100644 index 2d08698b2..000000000 --- a/sp_api/api/reports/models/get_report_document_response.py +++ /dev/null @@ -1,137 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for Reports - - The Selling Partner API for Reports lets you retrieve and manage a variety of reports that can help selling partners manage their businesses. # noqa: E501 - - OpenAPI spec version: 2020-09-04 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - -class GetReportDocumentResponse(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'payload': 'ReportDocument', - 'errors': 'ErrorList' - } - - attribute_map = { - 'payload': 'payload', - 'errors': 'errors' - } - - def __init__(self, payload=None, errors=None): # noqa: E501 - """GetReportDocumentResponse - a model defined in Swagger""" # noqa: E501 - self._payload = None - self._errors = None - self.discriminator = None - if payload is not None: - self.payload = payload - if errors is not None: - self.errors = errors - - @property - def payload(self): - """Gets the payload of this GetReportDocumentResponse. # noqa: E501 - - - :return: The payload of this GetReportDocumentResponse. # noqa: E501 - :rtype: ReportDocument - """ - return self._payload - - @payload.setter - def payload(self, payload): - """Sets the payload of this GetReportDocumentResponse. - - - :param payload: The payload of this GetReportDocumentResponse. # noqa: E501 - :type: ReportDocument - """ - - self._payload = payload - - @property - def errors(self): - """Gets the errors of this GetReportDocumentResponse. # noqa: E501 - - - :return: The errors of this GetReportDocumentResponse. # noqa: E501 - :rtype: ErrorList - """ - return self._errors - - @errors.setter - def errors(self, errors): - """Sets the errors of this GetReportDocumentResponse. - - - :param errors: The errors of this GetReportDocumentResponse. # noqa: E501 - :type: ErrorList - """ - - self._errors = errors - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(GetReportDocumentResponse, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, GetReportDocumentResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/api/reports/models/get_report_response.py b/sp_api/api/reports/models/get_report_response.py deleted file mode 100644 index 9fefe5110..000000000 --- a/sp_api/api/reports/models/get_report_response.py +++ /dev/null @@ -1,137 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for Reports - - The Selling Partner API for Reports lets you retrieve and manage a variety of reports that can help selling partners manage their businesses. # noqa: E501 - - OpenAPI spec version: 2020-09-04 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - -class GetReportResponse(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'payload': 'Report', - 'errors': 'ErrorList' - } - - attribute_map = { - 'payload': 'payload', - 'errors': 'errors' - } - - def __init__(self, payload=None, errors=None): # noqa: E501 - """GetReportResponse - a model defined in Swagger""" # noqa: E501 - self._payload = None - self._errors = None - self.discriminator = None - if payload is not None: - self.payload = payload - if errors is not None: - self.errors = errors - - @property - def payload(self): - """Gets the payload of this GetReportResponse. # noqa: E501 - - - :return: The payload of this GetReportResponse. # noqa: E501 - :rtype: Report - """ - return self._payload - - @payload.setter - def payload(self, payload): - """Sets the payload of this GetReportResponse. - - - :param payload: The payload of this GetReportResponse. # noqa: E501 - :type: Report - """ - - self._payload = payload - - @property - def errors(self): - """Gets the errors of this GetReportResponse. # noqa: E501 - - - :return: The errors of this GetReportResponse. # noqa: E501 - :rtype: ErrorList - """ - return self._errors - - @errors.setter - def errors(self, errors): - """Sets the errors of this GetReportResponse. - - - :param errors: The errors of this GetReportResponse. # noqa: E501 - :type: ErrorList - """ - - self._errors = errors - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(GetReportResponse, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, GetReportResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/api/reports/models/get_report_schedule_response.py b/sp_api/api/reports/models/get_report_schedule_response.py deleted file mode 100644 index da9cff77d..000000000 --- a/sp_api/api/reports/models/get_report_schedule_response.py +++ /dev/null @@ -1,137 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for Reports - - The Selling Partner API for Reports lets you retrieve and manage a variety of reports that can help selling partners manage their businesses. # noqa: E501 - - OpenAPI spec version: 2020-09-04 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - -class GetReportScheduleResponse(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'payload': 'ReportSchedule', - 'errors': 'ErrorList' - } - - attribute_map = { - 'payload': 'payload', - 'errors': 'errors' - } - - def __init__(self, payload=None, errors=None): # noqa: E501 - """GetReportScheduleResponse - a model defined in Swagger""" # noqa: E501 - self._payload = None - self._errors = None - self.discriminator = None - if payload is not None: - self.payload = payload - if errors is not None: - self.errors = errors - - @property - def payload(self): - """Gets the payload of this GetReportScheduleResponse. # noqa: E501 - - - :return: The payload of this GetReportScheduleResponse. # noqa: E501 - :rtype: ReportSchedule - """ - return self._payload - - @payload.setter - def payload(self, payload): - """Sets the payload of this GetReportScheduleResponse. - - - :param payload: The payload of this GetReportScheduleResponse. # noqa: E501 - :type: ReportSchedule - """ - - self._payload = payload - - @property - def errors(self): - """Gets the errors of this GetReportScheduleResponse. # noqa: E501 - - - :return: The errors of this GetReportScheduleResponse. # noqa: E501 - :rtype: ErrorList - """ - return self._errors - - @errors.setter - def errors(self, errors): - """Sets the errors of this GetReportScheduleResponse. - - - :param errors: The errors of this GetReportScheduleResponse. # noqa: E501 - :type: ErrorList - """ - - self._errors = errors - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(GetReportScheduleResponse, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, GetReportScheduleResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/api/reports/models/get_report_schedules_response.py b/sp_api/api/reports/models/get_report_schedules_response.py deleted file mode 100644 index 7fbf56114..000000000 --- a/sp_api/api/reports/models/get_report_schedules_response.py +++ /dev/null @@ -1,137 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for Reports - - The Selling Partner API for Reports lets you retrieve and manage a variety of reports that can help selling partners manage their businesses. # noqa: E501 - - OpenAPI spec version: 2020-09-04 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - -class GetReportSchedulesResponse(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'payload': 'ReportScheduleList', - 'errors': 'ErrorList' - } - - attribute_map = { - 'payload': 'payload', - 'errors': 'errors' - } - - def __init__(self, payload=None, errors=None): # noqa: E501 - """GetReportSchedulesResponse - a model defined in Swagger""" # noqa: E501 - self._payload = None - self._errors = None - self.discriminator = None - if payload is not None: - self.payload = payload - if errors is not None: - self.errors = errors - - @property - def payload(self): - """Gets the payload of this GetReportSchedulesResponse. # noqa: E501 - - - :return: The payload of this GetReportSchedulesResponse. # noqa: E501 - :rtype: ReportScheduleList - """ - return self._payload - - @payload.setter - def payload(self, payload): - """Sets the payload of this GetReportSchedulesResponse. - - - :param payload: The payload of this GetReportSchedulesResponse. # noqa: E501 - :type: ReportScheduleList - """ - - self._payload = payload - - @property - def errors(self): - """Gets the errors of this GetReportSchedulesResponse. # noqa: E501 - - - :return: The errors of this GetReportSchedulesResponse. # noqa: E501 - :rtype: ErrorList - """ - return self._errors - - @errors.setter - def errors(self, errors): - """Sets the errors of this GetReportSchedulesResponse. - - - :param errors: The errors of this GetReportSchedulesResponse. # noqa: E501 - :type: ErrorList - """ - - self._errors = errors - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(GetReportSchedulesResponse, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, GetReportSchedulesResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/api/reports/models/get_reports_response.py b/sp_api/api/reports/models/get_reports_response.py deleted file mode 100644 index 614f91575..000000000 --- a/sp_api/api/reports/models/get_reports_response.py +++ /dev/null @@ -1,165 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for Reports - - The Selling Partner API for Reports lets you retrieve and manage a variety of reports that can help selling partners manage their businesses. # noqa: E501 - - OpenAPI spec version: 2020-09-04 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - -class GetReportsResponse(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'payload': 'ReportList', - 'next_token': 'str', - 'errors': 'ErrorList' - } - - attribute_map = { - 'payload': 'payload', - 'next_token': 'nextToken', - 'errors': 'errors' - } - - def __init__(self, payload=None, next_token=None, errors=None): # noqa: E501 - """GetReportsResponse - a model defined in Swagger""" # noqa: E501 - self._payload = None - self._next_token = None - self._errors = None - self.discriminator = None - if payload is not None: - self.payload = payload - if next_token is not None: - self.next_token = next_token - if errors is not None: - self.errors = errors - - @property - def payload(self): - """Gets the payload of this GetReportsResponse. # noqa: E501 - - - :return: The payload of this GetReportsResponse. # noqa: E501 - :rtype: ReportList - """ - return self._payload - - @payload.setter - def payload(self, payload): - """Sets the payload of this GetReportsResponse. - - - :param payload: The payload of this GetReportsResponse. # noqa: E501 - :type: ReportList - """ - - self._payload = payload - - @property - def next_token(self): - """Gets the next_token of this GetReportsResponse. # noqa: E501 - - Returned when the number of results exceeds pageSize. To get the next page of results, call getReports with this token as the only parameter. # noqa: E501 - - :return: The next_token of this GetReportsResponse. # noqa: E501 - :rtype: str - """ - return self._next_token - - @next_token.setter - def next_token(self, next_token): - """Sets the next_token of this GetReportsResponse. - - Returned when the number of results exceeds pageSize. To get the next page of results, call getReports with this token as the only parameter. # noqa: E501 - - :param next_token: The next_token of this GetReportsResponse. # noqa: E501 - :type: str - """ - - self._next_token = next_token - - @property - def errors(self): - """Gets the errors of this GetReportsResponse. # noqa: E501 - - - :return: The errors of this GetReportsResponse. # noqa: E501 - :rtype: ErrorList - """ - return self._errors - - @errors.setter - def errors(self, errors): - """Sets the errors of this GetReportsResponse. - - - :param errors: The errors of this GetReportsResponse. # noqa: E501 - :type: ErrorList - """ - - self._errors = errors - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(GetReportsResponse, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, GetReportsResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/api/reports/reports.py b/sp_api/api/reports/reports.py index 375e7e07f..c1d46183b 100644 --- a/sp_api/api/reports/reports.py +++ b/sp_api/api/reports/reports.py @@ -2,13 +2,7 @@ import requests -from sp_api.api.notifications.models.delete_subscription_by_id_response import DeleteSubscriptionByIdResponse -from sp_api.api.notifications.models.get_subscription_by_id_response import GetSubscriptionByIdResponse -from sp_api.api.reports.models.create_report_response import CreateReportResponse -from sp_api.api.reports.models.create_report_schedule_response import CreateReportScheduleResponse -from sp_api.api.reports.models.get_report_document_response import GetReportDocumentResponse -from sp_api.api.reports.models.get_report_response import GetReportResponse -from sp_api.base import sp_endpoint, fill_query_params, SellingApiException +from sp_api.base import sp_endpoint, fill_query_params, SellingApiException, ApiResponse from sp_api.base import Client from sp_api.base.helpers import decrypt_aes @@ -16,8 +10,9 @@ class Reports(Client): @sp_endpoint('/reports/2020-09-04/reports', method='POST') - def create_report(self, **kwargs): + def create_report(self, **kwargs) -> ApiResponse: """ + create_report(self, **kwargs) -> ApiResponse Creates a report. **Usage Plan:** @@ -30,13 +25,12 @@ def create_report(self, **kwargs): :param kwargs: :return: """ - return CreateReportResponse( - **self._request(kwargs.pop('path'), data=kwargs).json() - ) + return self._request(kwargs.pop('path'), data=kwargs) @sp_endpoint('/reports/2020-09-04/reports/{}') - def get_report(self, report_id, **kwargs): + def get_report(self, report_id, **kwargs) -> ApiResponse: """ + get_report(self, report_id, **kwargs) Returns report details (including the reportDocumentId, if available) for the report that you specify. **Usage Plan:** @@ -49,13 +43,12 @@ def get_report(self, report_id, **kwargs): :param report_id: :return: """ - return GetReportResponse( - **self._request(fill_query_params(kwargs.pop('path'), report_id), add_marketplace=False).json() - ) + return self._request(fill_query_params(kwargs.pop('path'), report_id), add_marketplace=False) @sp_endpoint('/reports/2020-09-04/documents/{}') - def get_report_document(self, document_id, decrypt: bool = False, file=None, ** kwargs): + def get_report_document(self, document_id, decrypt: bool = False, file=None, ** kwargs) -> ApiResponse: """ + get_report_document(self, document_id, decrypt: bool = False, file=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. **Usage Plan:** @@ -69,29 +62,29 @@ def get_report_document(self, document_id, decrypt: bool = False, file=None, ** :param decrypt: :param document_id: :param kwargs: - :return: + :return: ApiResponse """ - res = self._request(fill_query_params(kwargs.pop('path'), document_id), add_marketplace=False).json() + res = self._request(fill_query_params(kwargs.pop('path'), document_id), add_marketplace=False) if decrypt: document = self.decrypt_report_document( - res.get('payload').get('url'), - res.get('payload').get('encryptionDetails').get('initializationVector'), - res.get('payload').get('encryptionDetails').get('key'), - res.get('payload').get('encryptionDetails').get('standard'), - res.get('payload') + res.payload.get('url'), + res.payload.get('encryptionDetails').get('initializationVector'), + res.payload.get('encryptionDetails').get('key'), + res.payload.get('encryptionDetails').get('standard'), + res.payload ) - res.get('payload').update({ + res.payload.update({ 'document': document }) if file: file.write(document) - return GetReportDocumentResponse( - **res - ) + + return res @sp_endpoint('/reports/2020-09-04/schedules', method='POST') - def create_report_schedule(self, **kwargs): + def create_report_schedule(self, **kwargs) -> ApiResponse: """ + create_report_schedule(self, **kwargs) -> ApiResponse Creates a report schedule. If a report schedule with the same report type and marketplace IDs already exists, it will be cancelled and replaced with this one. **Usage Plan:** @@ -104,11 +97,12 @@ def create_report_schedule(self, **kwargs): :param kwargs: :return: """ - return CreateReportScheduleResponse(**self._request(kwargs.pop('path'), data=kwargs).json()) + return self._request(kwargs.pop('path'), data=kwargs) @sp_endpoint('/reports/2020-09-04/schedules/{}', method='DELETE') - def delete_report_schedule(self, schedule_id, **kwargs): + def delete_report_schedule(self, schedule_id, **kwargs) -> ApiResponse: """ + delete_report_schedule(self, schedule_id, **kwargs) -> ApiResponse Cancels the report schedule that you specify. **Usage Plan:** @@ -122,12 +116,10 @@ def delete_report_schedule(self, schedule_id, **kwargs): :param kwargs: :return: """ - return DeleteSubscriptionByIdResponse( - **self._request(fill_query_params(kwargs.pop('path'), schedule_id), params=kwargs).json() - ) + return self._request(fill_query_params(kwargs.pop('path'), schedule_id), params=kwargs) @sp_endpoint('/reports/2020-09-04/schedules/{}') - def get_report_schedule(self, schedule_id, **kwargs): + def get_report_schedule(self, schedule_id, **kwargs) -> ApiResponse: """ Cancels the report schedule that you specify. @@ -142,9 +134,7 @@ def get_report_schedule(self, schedule_id, **kwargs): :param kwargs: :return: """ - return GetSubscriptionByIdResponse( - **self._request(fill_query_params(kwargs.pop('path'), schedule_id), params=kwargs).json() - ) + return self._request(fill_query_params(kwargs.pop('path'), schedule_id), params=kwargs) @staticmethod def decrypt_report_document(url, initialization_vector, key, encryption_standard, payload): @@ -154,7 +144,9 @@ def decrypt_report_document(url, initialization_vector, key, encryption_standard :param initialization_vector: :param key: :param encryption_standard: + :param payload: :return: + """ if encryption_standard == 'AES': decrypted = decrypt_aes(requests.get(url).content, key, initialization_vector) diff --git a/sp_api/api/sales/models/__init__.py b/sp_api/api/sales/models/__init__.py deleted file mode 100644 index e9125b593..000000000 --- a/sp_api/api/sales/models/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from sp_api.api.sales.models import * diff --git a/sp_api/api/sales/models/get_order_metrics_response.py b/sp_api/api/sales/models/get_order_metrics_response.py deleted file mode 100644 index 422f571d1..000000000 --- a/sp_api/api/sales/models/get_order_metrics_response.py +++ /dev/null @@ -1,137 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for Sales - - The Selling Partner API for Sales provides APIs related to sales performance. # noqa: E501 - - OpenAPI spec version: v1 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - -class GetOrderMetricsResponse(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'payload': 'OrderMetricsList', - 'errors': 'ErrorList' - } - - attribute_map = { - 'payload': 'payload', - 'errors': 'errors' - } - - def __init__(self, payload=None, errors=None): # noqa: E501 - """GetOrderMetricsResponse - a model defined in Swagger""" # noqa: E501 - self._payload = None - self._errors = None - self.discriminator = None - if payload is not None: - self.payload = payload - if errors is not None: - self.errors = errors - - @property - def payload(self): - """Gets the payload of this GetOrderMetricsResponse. # noqa: E501 - - - :return: The payload of this GetOrderMetricsResponse. # noqa: E501 - :rtype: OrderMetricsList - """ - return self._payload - - @payload.setter - def payload(self, payload): - """Sets the payload of this GetOrderMetricsResponse. - - - :param payload: The payload of this GetOrderMetricsResponse. # noqa: E501 - :type: OrderMetricsList - """ - - self._payload = payload - - @property - def errors(self): - """Gets the errors of this GetOrderMetricsResponse. # noqa: E501 - - - :return: The errors of this GetOrderMetricsResponse. # noqa: E501 - :rtype: ErrorList - """ - return self._errors - - @errors.setter - def errors(self, errors): - """Sets the errors of this GetOrderMetricsResponse. - - - :param errors: The errors of this GetOrderMetricsResponse. # noqa: E501 - :type: ErrorList - """ - - self._errors = errors - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(GetOrderMetricsResponse, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, GetOrderMetricsResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/api/sales/sales.py b/sp_api/api/sales/sales.py index 123bb42f2..305dacd18 100644 --- a/sp_api/api/sales/sales.py +++ b/sp_api/api/sales/sales.py @@ -1,7 +1,6 @@ from datetime import datetime -from sp_api.api.sales.models.get_order_metrics_response import GetOrderMetricsResponse -from sp_api.base import Client, Marketplaces, sp_endpoint, Granularity +from sp_api.base import Client, Marketplaces, sp_endpoint, Granularity, ApiResponse import logging @@ -11,10 +10,9 @@ class Sales(Client): """ @sp_endpoint('/sales/v1/orderMetrics') - def get_order_metrics(self, interval: tuple, granularity: Granularity, granularityTimeZone: str = None, **kwargs): - + 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) + get_order_metrics(self, interval: tuple, granularity: Granularity, granularityTimeZone: str = None, **kwargs) -> ApiResponse Returns aggregated order metrics for given interval, broken down by granularity, for given buyer type. @@ -100,7 +98,9 @@ def get_order_metrics(self, interval: tuple, granularity: Granularity, granulari :param granularityTimeZone: :param granularity: :param kwargs: - :return: + + :return: ApiResponse + """ kwargs.update({ 'interval': '--'.join([self._create_datetime_stamp(_interval) for _interval in interval]), @@ -108,10 +108,19 @@ def get_order_metrics(self, interval: tuple, granularity: Granularity, granulari }) if granularityTimeZone: kwargs.update({'granularityTimeZone': granularityTimeZone}) - return GetOrderMetricsResponse(**self._request(kwargs.pop('path'), params=kwargs).json()) + return self._request(kwargs.pop('path'), params=kwargs) @staticmethod def _create_datetime_stamp(datetime_obj: datetime or str): + """ + Create datetimestring + + Args: + datetime_obj: + + Returns: + + """ if isinstance(datetime_obj, str): return datetime_obj fmt = '%Y-%m-%dT%H:%M:%S%z' diff --git a/sp_api/api/sellers/models/__init__.py b/sp_api/api/sellers/models/__init__.py deleted file mode 100644 index 766aa946a..000000000 --- a/sp_api/api/sellers/models/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from sp_api.api.sellers.models import * diff --git a/sp_api/api/sellers/models/get_marketplace_participations_response.py b/sp_api/api/sellers/models/get_marketplace_participations_response.py deleted file mode 100644 index adb87792e..000000000 --- a/sp_api/api/sellers/models/get_marketplace_participations_response.py +++ /dev/null @@ -1,137 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for Sellers - - The Selling Partner API for Sellers lets you retrieve information on behalf of sellers about their seller account, such as the marketplaces they participate in. Along with listing the marketplaces that a seller can sell in, the API also provides additional information about the marketplace such as the default language and the default currency. The API also provides seller-specific information such as whether the seller has suspended listings in that marketplace. # noqa: E501 - - OpenAPI spec version: v1 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - -class GetMarketplaceParticipationsResponse(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'payload': 'MarketplaceParticipationList', - 'errors': 'ErrorList' - } - - attribute_map = { - 'payload': 'payload', - 'errors': 'errors' - } - - def __init__(self, payload=None, errors=None): # noqa: E501 - """GetMarketplaceParticipationsResponse - a model defined in Swagger""" # noqa: E501 - self._payload = None - self._errors = None - self.discriminator = None - if payload is not None: - self.payload = payload - if errors is not None: - self.errors = errors - - @property - def payload(self): - """Gets the payload of this GetMarketplaceParticipationsResponse. # noqa: E501 - - - :return: The payload of this GetMarketplaceParticipationsResponse. # noqa: E501 - :rtype: MarketplaceParticipationList - """ - return self._payload - - @payload.setter - def payload(self, payload): - """Sets the payload of this GetMarketplaceParticipationsResponse. - - - :param payload: The payload of this GetMarketplaceParticipationsResponse. # noqa: E501 - :type: MarketplaceParticipationList - """ - - self._payload = payload - - @property - def errors(self): - """Gets the errors of this GetMarketplaceParticipationsResponse. # noqa: E501 - - - :return: The errors of this GetMarketplaceParticipationsResponse. # noqa: E501 - :rtype: ErrorList - """ - return self._errors - - @errors.setter - def errors(self, errors): - """Sets the errors of this GetMarketplaceParticipationsResponse. - - - :param errors: The errors of this GetMarketplaceParticipationsResponse. # noqa: E501 - :type: ErrorList - """ - - self._errors = errors - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(GetMarketplaceParticipationsResponse, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, GetMarketplaceParticipationsResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/api/sellers/sellers.py b/sp_api/api/sellers/sellers.py index 69b57b009..266bce7cb 100644 --- a/sp_api/api/sellers/sellers.py +++ b/sp_api/api/sellers/sellers.py @@ -1,10 +1,9 @@ from sp_api.base.helpers import sp_endpoint -from sp_api.api.sellers.models.get_marketplace_participations_response import GetMarketplaceParticipationsResponse -from sp_api.base import Client, Marketplaces +from sp_api.base import Client, Marketplaces, ApiResponse class Sellers(Client): @sp_endpoint('/sellers/v1/marketplaceParticipations') - def get_marketplace_participation(self, **kwargs): - return GetMarketplaceParticipationsResponse(**self._request(kwargs.pop('path')).json()) + def get_marketplace_participation(self, **kwargs) -> ApiResponse: + return self._request(kwargs.pop('path')) diff --git a/sp_api/api/upload/models/__init__.py b/sp_api/api/upload/models/__init__.py deleted file mode 100644 index 86c81a1ea..000000000 --- a/sp_api/api/upload/models/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from sp_api.api.upload.models import * diff --git a/sp_api/api/upload/models/create_upload_destination_response.py b/sp_api/api/upload/models/create_upload_destination_response.py deleted file mode 100644 index a4903e11e..000000000 --- a/sp_api/api/upload/models/create_upload_destination_response.py +++ /dev/null @@ -1,137 +0,0 @@ -# coding: utf-8 - -""" - Selling Partner API for Uploads - - The Selling Partner API for Uploads provides operations that support uploading files. # noqa: E501 - - OpenAPI spec version: 2020-11-01 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -import pprint -import re # noqa: F401 - -import six - - -class CreateUploadDestinationResponse(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'payload': 'UploadDestination', - 'errors': 'ErrorList' - } - - attribute_map = { - 'payload': 'payload', - 'errors': 'errors' - } - - def __init__(self, payload=None, errors=None): # noqa: E501 - """CreateUploadDestinationResponse - a model defined in Swagger""" # noqa: E501 - self._payload = None - self._errors = None - self.discriminator = None - if payload is not None: - self.payload = payload - if errors is not None: - self.errors = errors - - @property - def payload(self): - """Gets the payload of this CreateUploadDestinationResponse. # noqa: E501 - - - :return: The payload of this CreateUploadDestinationResponse. # noqa: E501 - :rtype: UploadDestination - """ - return self._payload - - @payload.setter - def payload(self, payload): - """Sets the payload of this CreateUploadDestinationResponse. - - - :param payload: The payload of this CreateUploadDestinationResponse. # noqa: E501 - :type: UploadDestination - """ - - self._payload = payload - - @property - def errors(self): - """Gets the errors of this CreateUploadDestinationResponse. # noqa: E501 - - - :return: The errors of this CreateUploadDestinationResponse. # noqa: E501 - :rtype: ErrorList - """ - return self._errors - - @errors.setter - def errors(self, errors): - """Sets the errors of this CreateUploadDestinationResponse. - - - :param errors: The errors of this CreateUploadDestinationResponse. # noqa: E501 - :type: ErrorList - """ - - self._errors = errors - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - if issubclass(CreateUploadDestinationResponse, dict): - for key, value in self.items(): - result[key] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, CreateUploadDestinationResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/sp_api/base/ApiResponse.py b/sp_api/base/ApiResponse.py new file mode 100644 index 000000000..6b5fd7331 --- /dev/null +++ b/sp_api/base/ApiResponse.py @@ -0,0 +1,13 @@ +import pprint + + +class ApiResponse: + def __init__(self, payload=None, errors=None, pagination=None, headers=None): + self.payload = payload + self.errors = errors + self.pagination = pagination + self.headers = headers + + def __str__(self): + return pprint.pformat(self.__dict__) + diff --git a/sp_api/base/__init__.py b/sp_api/base/__init__.py index 81a7ec218..a72563666 100644 --- a/sp_api/base/__init__.py +++ b/sp_api/base/__init__.py @@ -17,8 +17,10 @@ from .deprecated import deprecated from .notifications import NotificationType from .config import CredentialProvider, MissingCredentials +from .ApiResponse import ApiResponse __all__ = [ + 'ApiResponse', 'Client', 'BaseClient', 'AWSSigV4', diff --git a/sp_api/base/client.py b/sp_api/base/client.py index 9262809e4..b15718fee 100644 --- a/sp_api/base/client.py +++ b/sp_api/base/client.py @@ -7,6 +7,7 @@ from requests import request from sp_api.auth import AccessTokenClient, AccessTokenResponse +from .ApiResponse import ApiResponse from .base_client import BaseClient from .exceptions import get_exception_for_code, SellingApiBadRequestException from .marketplaces import Marketplaces @@ -82,7 +83,7 @@ def _sign_request(self): aws_session_token=role.get('SessionToken') ) - def _request(self, path: str, *, data: dict = None, params: dict = None, headers=None, add_marketplace=True): + def _request(self, path: str, *, data: dict = None, params: dict = None, headers=None, add_marketplace=True) -> ApiResponse: if params is None: params = {} if data is None: @@ -106,7 +107,7 @@ def _request(self, path: str, *, data: dict = None, params: dict = None, headers if error: exception = get_exception_for_code(res.status_code) raise exception(error) - return res + return ApiResponse(**res.json(), headers=res.headers) def _request_grantless_operation(self, path: str, *, data: dict = None, params: dict = None): headers = { diff --git a/tests/api/catalog/test_catalog.py b/tests/api/catalog/test_catalog.py index 9ff97d23e..bde5d9821 100644 --- a/tests/api/catalog/test_catalog.py +++ b/tests/api/catalog/test_catalog.py @@ -1,10 +1,11 @@ from sp_api.api import Catalog -from sp_api.base import Marketplaces, SellingApiBadRequestException +from sp_api.base import Marketplaces, SellingApiBadRequestException, ApiResponse def test_get_catalog_item(): res = Catalog().get_item('ASIN_200', MarketplaceId='TEST_CASE_200') assert res.errors is None + assert isinstance(res, ApiResponse) def test_list_catalog_items():