Skip to content

Commit 268adf8

Browse files
committed
Solved bugs and updated documentation
1 parent 951341a commit 268adf8

File tree

5 files changed

+29
-22
lines changed

5 files changed

+29
-22
lines changed

PRODUCT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
height
1818
value
1919
unit
20-
lenght
20+
length
2121
value
2222
unit
2323
width

README.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Features
1818
* Get browse nodes information.
1919
* Get multiple results at once without the 10 items limitation from Amazon.
2020
* Configurable throttling to avoid requests exceptions.
21+
* Built-in serializer for Django REST framework.
2122
* Support for [all available countries](https://github.com/sergioteula/python-amazon-paapi/blob/master/amazon/paapi.py#L31).
2223
* Reorganized product information [structure](https://github.com/sergioteula/python-amazon-paapi/blob/master/PRODUCT.md) for simple use.
2324
* Ask for new features through the [issues](https://github.com/sergioteula/python-amazon-paapi/issues) section.
@@ -30,6 +31,10 @@ You can install or upgrade the module with:
3031

3132
pip install python-amazon-paapi --upgrade
3233

34+
If you get `ModuleNotFoundError`, try installing this:
35+
36+
pip install amightygirl.paapi5-python-sdk
37+
3338
Usage guide
3439
-----------
3540
**Basic usage:**
@@ -75,34 +80,32 @@ Throttling value must be `greater than 0` or `False` to disable it. This value t
7580
amazon = AmazonAPI(KEY, SECRET, TAG, COUNTRY, throttling=0.5) # Max one request every two seconds
7681
amazon = AmazonAPI(KEY, SECRET, TAG, COUNTRY, throttling=False) # Unlimited requests per second
7782

78-
**API support**
79-
We provide a serializer for django rest framework, which speeds up your api
83+
**Serializer for Django:**
84+
85+
We provide a serializer for Django REST framework, which speeds up your API
8086
implementation.
8187

82-
from amazon.paapi import AmazonAPI
8388
from amazon.serializers import AmazonProductSerializer
8489
from rest_framework import serializers
85-
amazon = AmazonAPI(KEY, SECRET, TAG, COUNTRY)
8690

87-
product = amazon.get_product('B01N5IB20Q')
8891
serialized_product = AmazonProductSerializer(product)
89-
serialized.data # this prints serialized product
92+
serialized_product.data
9093

91-
if you like to serialize a list of products:
94+
If you want to serialize a list of products:
9295

93-
products = amazon.search_products(item_count=40, keywords='Harry')
9496
serialized_products = AmazonProductSerializer(products, many=True)
9597
serialized_products.data
9698

97-
For more Information how to work with serializers see the documentation of
98-
[django rest framework](https://www.django-rest-framework.org/api-guide/serializers/)
99+
For more information on how to work with serializers, check the documentation for
100+
[Django REST framework](https://www.django-rest-framework.org/api-guide/serializers/).
99101

100102

101103
Changelog
102104
-------------
103-
Version 3.2.1 (unreleased)
104-
- Added serializer class for django rest framework
105-
- Added serialized data for your convenience
105+
Version 3.3.0
106+
- Added serializer class for Django REST framework.
107+
- Solved bugs and typos.
108+
106109
Version 3.2.0
107110
- Added new method for getting browse nodes information.
108111
- Removed the 10 pages limit on search_products and get_variations methods.

amazon/paapi.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,12 @@ def get_product(self, product_id: str, condition='Any', merchant='All',
164164
if len(check_product_id) > 1:
165165
raise AmazonException('ValueError', 'Only 1 product ID is allowed, use '
166166
'get_products for multiple requests')
167-
return self.get_products(product_id, condition=condition, merchant=merchant,
168-
async_req=async_req)[0]
167+
product = self.get_products(product_id, condition=condition, merchant=merchant,
168+
async_req=async_req)
169+
if product:
170+
return product[0]
171+
else:
172+
return None
169173

170174
def search_products(self, item_count=10, item_page=1, items_per_page=10, keywords=None,
171175
actor=None, artist=None, author=None, brand=None, title=None,

amazon/parse.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,15 +225,15 @@ def parse_product(item):
225225
product.product.dimensions.height.unit = item.item_info.product_info.item_dimensions.height.unit
226226
except Exception:
227227
product.product.dimensions.height.unit = None
228-
product.product.dimensions.lenght = Class()
228+
product.product.dimensions.length = Class()
229229
try:
230-
product.product.dimensions.lenght.value = item.item_info.product_info.item_dimensions.lenght.display_value
230+
product.product.dimensions.length.value = item.item_info.product_info.item_dimensions.length.display_value
231231
except Exception:
232-
product.product.dimensions.lenght.value = None
232+
product.product.dimensions.length.value = None
233233
try:
234-
product.product.dimensions.lenght.unit = item.item_info.product_info.item_dimensions.lenght.unit
234+
product.product.dimensions.length.unit = item.item_info.product_info.item_dimensions.length.unit
235235
except Exception:
236-
product.product.dimensions.lenght.unit = None
236+
product.product.dimensions.length.unit = None
237237
product.product.dimensions.width = Class()
238238
try:
239239
product.product.dimensions.width.value = item.item_info.product_info.item_dimensions.width.display_value

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name='python-amazon-paapi',
8-
version='3.2.0',
8+
version='3.3.0',
99
author='Sergio Abad',
1010
author_email='sergio.abad@bytelix.com',
1111
description='Amazon Product Advertising API 5.0 wrapper for Python',

0 commit comments

Comments
 (0)