diff -r 5b37998e522e -r 162c1de6545a web/lib/Zend/Service/Amazon/Query.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/lib/Zend/Service/Amazon/Query.php Fri Mar 11 15:05:35 2011 +0100 @@ -0,0 +1,98 @@ +_searchIndex = 'asin'; + $this->_search['ItemId'] = $args[0]; + return $this; + } + + if (strtolower($method) === 'category') { + $this->_searchIndex = $args[0]; + $this->_search['SearchIndex'] = $args[0]; + } else if (isset($this->_search['SearchIndex']) || $this->_searchIndex !== null || $this->_searchIndex === 'asin') { + $this->_search[$method] = $args[0]; + } else { + /** + * @see Zend_Service_Exception + */ + require_once 'Zend/Service/Exception.php'; + throw new Zend_Service_Exception('You must set a category before setting the search parameters'); + } + + return $this; + } + + /** + * Search using the prepared query + * + * @return Zend_Service_Amazon_Item|Zend_Service_Amazon_ResultSet + */ + public function search() + { + if ($this->_searchIndex === 'asin') { + return $this->itemLookup($this->_search['ItemId'], $this->_search); + } + return $this->itemSearch($this->_search); + } +}