Skip to content

Commit

Permalink
Merge pull request #2 from norman-thomas/implement-availability
Browse files Browse the repository at this point in the history
Implement availability
  • Loading branch information
norman-thomas committed Feb 3, 2017
2 parents 1d330a9 + 9d864c8 commit aa02f32
Show file tree
Hide file tree
Showing 4 changed files with 155 additions and 27 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
language: python
python:
- 2.7
- 3.5
install:
- pip install .
- pip install pep8
Expand All @@ -9,4 +10,7 @@ install:
script:
- "pep8 --ignore=E501,E225,E128 amazon"
- "sphinx-build -b html -d _build/doctrees ./docs/ _build/html"
- nosetests --with-flaky --with-coverage
after_success:
- coveralls
sudo: false
43 changes: 40 additions & 3 deletions amazon/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,8 @@ def cart_modify(self, items, CartId=None, HMAC=None, **kwargs):

return new_cart

def _check_for_cart_error(self, cart):
@staticmethod
def _check_for_cart_error(cart):
if cart._safe_get_element('Cart.Request.Errors') is not None:
error = cart._safe_get_element(
'Cart.Request.Errors.Error.Code').text
Expand Down Expand Up @@ -582,7 +583,7 @@ def _query(self, ResponseGroup="Large", **kwargs):
else:
raise SearchException(
"Amazon Search Error: '{0}', '{1}'".format(code, msg))
if (hasattr(root.Items, 'TotalPages') and (root.Items.TotalPages == self.current_page)):
if hasattr(root.Items, 'TotalPages') and root.Items.TotalPages == self.current_page:
self.is_last_page = True
return root

Expand Down Expand Up @@ -950,7 +951,7 @@ def reviews(self):
"""
iframe = self._safe_get_element_text('CustomerReviews.IFrameURL')
has_reviews = self._safe_get_element_text('CustomerReviews.HasReviews')
if has_reviews and has_reviews == 'true':
if has_reviews is not None and has_reviews == 'true':
has_reviews = True
else:
has_reviews = False
Expand Down Expand Up @@ -1324,6 +1325,42 @@ def is_preorder(self):
"""
return self._safe_get_element_text('Offers.Offer.OfferListing.AvailabilityAttributes.IsPreorder')

@property
def availability(self):
"""Availability
:return:
Availability (string).
"""
return self._safe_get_element_text('Offers.Offer.OfferListing.Availability')

@property
def availability_type(self):
"""AvailabilityAttributes.AvailabilityType
:return:
AvailabilityType (string).
"""
return self._safe_get_element_text('Offers.Offer.OfferListing.AvailabilityAttributes.AvailabilityType')

@property
def availability_min_hours(self):
"""AvailabilityAttributes.MinimumHours
:return:
MinimumHours (int).
"""
return self._safe_get_element_text('Offers.Offer.OfferListing.AvailabilityAttributes.MinimumHours')

@property
def availability_max_hours(self):
"""AvailabilityAttributes.MaximumHours
:return:
MaximumHours (int).
"""
return self._safe_get_element_text('Offers.Offer.OfferListing.AvailabilityAttributes.MaximumHours')

@property
def detail_page_url(self):
"""DetailPageURL.
Expand Down
3 changes: 3 additions & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
Sphinx==1.1.3
coverage
coveralls
flaky
Loading

0 comments on commit aa02f32

Please sign in to comment.