lib/service_adaptors/amazon.rb in umlaut-3.0.0beta5 vs lib/service_adaptors/amazon.rb in umlaut-3.0.0beta6
- old
+ new
@@ -92,12 +92,19 @@
def handle(request)
isbn = request.referent.metadata['isbn']
isbn = isbn.gsub(/[^0-9X]/,'') if isbn
- return request.dispatched(self, true) if isbn.blank?
+ # does it look like a good ISBN?
+ return request.dispatched(self, true) if isbn.blank? || ! [10,13].include?(isbn.length)
+ # Make sure it's REALLY a good ISBN, and
+ # Convert 13 to 10 if neccesary, cause we're using it as an ASIN.
+ # An ISBN-13 is never an ASIN.
+ isbn = ISBN.ten( isbn )
+
+
begin
selected_aws_vals = {}
if ( @make_aws_call )
aws_response = make_aws_request( isbn )
@@ -135,13 +142,10 @@
def make_aws_request(isbn)
# We're assuming the ISBN is the ASIN Amazon ID. Not neccesarily valid
# assumption, but works enough of the time and there's no easy
# alternative.
- # Convert 13 to 10 if neccesary.
-
- # got to try converting to 10. An ISBN-13 is never an ASIN.
- isbn = ISBN.ten( isbn )
+
query_params = {
"Service"=>"AWSECommerceService",
"AWSAccessKeyId"=>@api_key,