Skip to content

Commit

Permalink
refactored to return an ApiResponse instead of multiple different wit…
Browse files Browse the repository at this point in the history
…h the same properties
  • Loading branch information
saleweaver committed Feb 7, 2021
1 parent b33b631 commit 5301483
Show file tree
Hide file tree
Showing 77 changed files with 279 additions and 6,113 deletions.
4 changes: 1 addition & 3 deletions docs/endpoints/finances.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ Finances





Nothing here yet.
.. autoclass:: sp_api.api.Finances
3 changes: 1 addition & 2 deletions docs/endpoints/product_fees.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ Product Fees




Nothing here yet.
.. autoclass:: sp_api.api.ProductFees
4 changes: 1 addition & 3 deletions docs/endpoints/reports.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ Reports





Nothing here yet.
.. autoclass:: sp_api.api.Reports
5 changes: 1 addition & 4 deletions docs/endpoints/sales.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@ Sales
=====





Nothing here yet.
.. autoclass:: sp_api.api.Sales
3 changes: 1 addition & 2 deletions docs/endpoints/sellers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ Sellers




Nothing here yet.
.. autoclass:: sp_api.api.Sellers
11 changes: 2 additions & 9 deletions docs/responses.rst
Original file line number Diff line number Diff line change
@@ -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

29 changes: 17 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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'
)
22 changes: 9 additions & 13 deletions sp_api/api/catalog/catalog.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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:**
Expand All @@ -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:**
Expand All @@ -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)

1 change: 0 additions & 1 deletion sp_api/api/catalog/models/__init__.py

This file was deleted.

137 changes: 0 additions & 137 deletions sp_api/api/catalog/models/get_catalog_item_response.py

This file was deleted.

Loading

0 comments on commit 5301483

Please sign in to comment.