import v1.0.0-RC4 | 2009-05-20
This commit is contained in:
48
libs/Zend/Service/Amazon/Accessories.php
Normal file
48
libs/Zend/Service/Amazon/Accessories.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Service
|
||||
* @subpackage Amazon
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Accessories.php 8064 2008-02-16 10:58:39Z thomas $
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Service
|
||||
* @subpackage Amazon
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Service_Amazon_Accessories
|
||||
{
|
||||
/**
|
||||
* Assigns values to properties relevant to Accessories
|
||||
*
|
||||
* @param DOMElement $dom
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(DOMElement $dom)
|
||||
{
|
||||
$xpath = new DOMXPath($dom->ownerDocument);
|
||||
$xpath->registerNamespace('az', 'http://webservices.amazon.com/AWSECommerceService/2005-10-05');
|
||||
foreach (array('ASIN', 'Title') as $el) {
|
||||
$this->$el = (string) $xpath->query("./az:$el/text()", $dom)->item(0)->data;
|
||||
}
|
||||
}
|
||||
}
|
51
libs/Zend/Service/Amazon/CustomerReview.php
Normal file
51
libs/Zend/Service/Amazon/CustomerReview.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Service
|
||||
* @subpackage Amazon
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: CustomerReview.php 8064 2008-02-16 10:58:39Z thomas $
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Service
|
||||
* @subpackage Amazon
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Service_Amazon_CustomerReview
|
||||
{
|
||||
/**
|
||||
* Assigns values to properties relevant to CustomerReview
|
||||
*
|
||||
* @param DOMElement $dom
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(DOMElement $dom)
|
||||
{
|
||||
$xpath = new DOMXPath($dom->ownerDocument);
|
||||
$xpath->registerNamespace('az', 'http://webservices.amazon.com/AWSECommerceService/2005-10-05');
|
||||
foreach (array('Rating', 'HelpfulVotes', 'CustomerId', 'TotalVotes', 'Date', 'Summary', 'Content') as $el) {
|
||||
$result = $xpath->query("./az:$el/text()", $dom);
|
||||
if ($result->length == 1) {
|
||||
$this->$el = (string) $result->item(0)->data;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
48
libs/Zend/Service/Amazon/EditorialReview.php
Normal file
48
libs/Zend/Service/Amazon/EditorialReview.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Service
|
||||
* @subpackage Amazon
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: EditorialReview.php 8064 2008-02-16 10:58:39Z thomas $
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Service
|
||||
* @subpackage Amazon
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Service_Amazon_EditorialReview
|
||||
{
|
||||
/**
|
||||
* Assigns values to properties relevant to EditorialReview
|
||||
*
|
||||
* @param DOMElement $dom
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(DOMElement $dom)
|
||||
{
|
||||
$xpath = new DOMXPath($dom->ownerDocument);
|
||||
$xpath->registerNamespace('az', 'http://webservices.amazon.com/AWSECommerceService/2005-10-05');
|
||||
foreach (array('Source', 'Content') as $el) {
|
||||
$this->$el = (string) $xpath->query("./az:$el/text()", $dom)->item(0)->data;
|
||||
}
|
||||
}
|
||||
}
|
69
libs/Zend/Service/Amazon/Image.php
Normal file
69
libs/Zend/Service/Amazon/Image.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Service
|
||||
* @subpackage Amazon
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Image.php 8064 2008-02-16 10:58:39Z thomas $
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Service
|
||||
* @subpackage Amazon
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Service_Amazon_Image
|
||||
{
|
||||
/**
|
||||
* Image URL
|
||||
*
|
||||
* @var Zend_Uri
|
||||
*/
|
||||
public $Url;
|
||||
|
||||
/**
|
||||
* Image height in pixels
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $Height;
|
||||
|
||||
/**
|
||||
* Image width in pixels
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $Width;
|
||||
|
||||
/**
|
||||
* Assigns values to properties relevant to Image
|
||||
*
|
||||
* @param DOMElement $dom
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(DOMElement $dom)
|
||||
{
|
||||
$xpath = new DOMXPath($dom->ownerDocument);
|
||||
$xpath->registerNamespace('az', 'http://webservices.amazon.com/AWSECommerceService/2005-10-05');
|
||||
$this->Url = Zend_Uri::factory($xpath->query('./az:URL/text()', $dom)->item(0)->data);
|
||||
$this->Height = (int) $xpath->query('./az:Height/text()', $dom)->item(0)->data;
|
||||
$this->Width = (int) $xpath->query('./az:Width/text()', $dom)->item(0)->data;
|
||||
}
|
||||
}
|
199
libs/Zend/Service/Amazon/Item.php
Normal file
199
libs/Zend/Service/Amazon/Item.php
Normal file
@ -0,0 +1,199 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Service
|
||||
* @subpackage Amazon
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Item.php 8064 2008-02-16 10:58:39Z thomas $
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Service
|
||||
* @subpackage Amazon
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Service_Amazon_Item
|
||||
{
|
||||
public $ASIN;
|
||||
public $DetailPageURL;
|
||||
public $SalesRank;
|
||||
public $SmallImage;
|
||||
public $MediumImage;
|
||||
public $LargeImage;
|
||||
public $Subjects;
|
||||
public $Offers;
|
||||
public $CustomerReviews;
|
||||
public $SimilarProducts;
|
||||
public $Accessories;
|
||||
public $Tracks;
|
||||
public $ListmaniaLists;
|
||||
public $PromotionalTag;
|
||||
|
||||
protected $_dom;
|
||||
|
||||
|
||||
/**
|
||||
* Parse the given <Item> element
|
||||
*
|
||||
* @param DOMElement $dom
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(DOMElement $dom)
|
||||
{
|
||||
$xpath = new DOMXPath($dom->ownerDocument);
|
||||
$xpath->registerNamespace('az', 'http://webservices.amazon.com/AWSECommerceService/2005-10-05');
|
||||
$this->ASIN = $xpath->query('./az:ASIN/text()', $dom)->item(0)->data;
|
||||
|
||||
$result = $xpath->query('./az:DetailPageURL/text()', $dom);
|
||||
if ($result->length == 1) {
|
||||
$this->DetailPageURL = $result->item(0)->data;
|
||||
}
|
||||
|
||||
if ($xpath->query('./az:ItemAttributes/az:ListPrice', $dom)->length >= 1) {
|
||||
$this->CurrencyCode = (string) $xpath->query('./az:ItemAttributes/az:ListPrice/az:CurrencyCode/text()', $dom)->item(0)->data;
|
||||
$this->Amount = (int) $xpath->query('./az:ItemAttributes/az:ListPrice/az:Amount/text()', $dom)->item(0)->data;
|
||||
$this->FormattedPrice = (string) $xpath->query('./az:ItemAttributes/az:ListPrice/az:FormattedPrice/text()', $dom)->item(0)->data;
|
||||
}
|
||||
|
||||
$result = $xpath->query('./az:ItemAttributes/az:*/text()', $dom);
|
||||
if ($result->length >= 1) {
|
||||
foreach ($result as $v) {
|
||||
if (isset($this->{$v->parentNode->tagName})) {
|
||||
if (is_array($this->{$v->parentNode->tagName})) {
|
||||
array_push($this->{$v->parentNode->tagName}, (string) $v->data);
|
||||
} else {
|
||||
$this->{$v->parentNode->tagName} = array($this->{$v->parentNode->tagName}, (string) $v->data);
|
||||
}
|
||||
} else {
|
||||
$this->{$v->parentNode->tagName} = (string) $v->data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (array('SmallImage', 'MediumImage', 'LargeImage') as $im) {
|
||||
$result = $xpath->query("./az:ImageSets/az:ImageSet[position() = 1]/az:$im", $dom);
|
||||
if ($result->length == 1) {
|
||||
/**
|
||||
* @see Zend_Service_Amazon_Image
|
||||
*/
|
||||
require_once 'Zend/Service/Amazon/Image.php';
|
||||
$this->$im = new Zend_Service_Amazon_Image($result->item(0));
|
||||
}
|
||||
}
|
||||
|
||||
$result = $xpath->query('./az:SalesRank/text()', $dom);
|
||||
if ($result->length == 1) {
|
||||
$this->SalesRank = (int) $result->item(0)->data;
|
||||
}
|
||||
|
||||
$result = $xpath->query('./az:CustomerReviews/az:Review', $dom);
|
||||
if ($result->length >= 1) {
|
||||
/**
|
||||
* @see Zend_Service_Amazon_CustomerReview
|
||||
*/
|
||||
require_once 'Zend/Service/Amazon/CustomerReview.php';
|
||||
foreach ($result as $review) {
|
||||
$this->CustomerReviews[] = new Zend_Service_Amazon_CustomerReview($review);
|
||||
}
|
||||
$this->AverageRating = (float) $xpath->query('./az:CustomerReviews/az:AverageRating/text()', $dom)->item(0)->data;
|
||||
$this->TotalReviews = (int) $xpath->query('./az:CustomerReviews/az:TotalReviews/text()', $dom)->item(0)->data;
|
||||
}
|
||||
|
||||
$result = $xpath->query('./az:EditorialReviews/az:*', $dom);
|
||||
if ($result->length >= 1) {
|
||||
/**
|
||||
* @see Zend_Service_Amazon_EditorialReview
|
||||
*/
|
||||
require_once 'Zend/Service/Amazon/EditorialReview.php';
|
||||
foreach ($result as $r) {
|
||||
$this->EditorialReviews[] = new Zend_Service_Amazon_EditorialReview($r);
|
||||
}
|
||||
}
|
||||
|
||||
$result = $xpath->query('./az:SimilarProducts/az:*', $dom);
|
||||
if ($result->length >= 1) {
|
||||
/**
|
||||
* @see Zend_Service_Amazon_SimilarProduct
|
||||
*/
|
||||
require_once 'Zend/Service/Amazon/SimilarProduct.php';
|
||||
foreach ($result as $r) {
|
||||
$this->SimilarProducts[] = new Zend_Service_Amazon_SimilarProduct($r);
|
||||
}
|
||||
}
|
||||
|
||||
$result = $xpath->query('./az:ListmaniaLists/*', $dom);
|
||||
if ($result->length >= 1) {
|
||||
/**
|
||||
* @see Zend_Service_Amazon_ListmaniaList
|
||||
*/
|
||||
require_once 'Zend/Service/Amazon/ListmaniaList.php';
|
||||
foreach ($result as $r) {
|
||||
$this->ListmaniaLists[] = new Zend_Service_Amazon_ListmaniaList($r);
|
||||
}
|
||||
}
|
||||
|
||||
$result = $xpath->query('./az:Tracks/az:Disc', $dom);
|
||||
if ($result->length > 1) {
|
||||
foreach ($result as $disk) {
|
||||
foreach ($xpath->query('./*/text()', $disk) as $t) {
|
||||
$this->Tracks[$disk->getAttribute('number')] = (string) $t->data;
|
||||
}
|
||||
}
|
||||
} else if ($result->length == 1) {
|
||||
foreach ($xpath->query('./*/text()', $result->item(0)) as $t) {
|
||||
$this->Tracks[] = (string) $t->data;
|
||||
}
|
||||
}
|
||||
|
||||
$result = $xpath->query('./az:Offers', $dom);
|
||||
$resultSummary = $xpath->query('./az:OfferSummary', $dom);
|
||||
if ($result->length > 1 || $resultSummary->length == 1) {
|
||||
/**
|
||||
* @see Zend_Service_Amazon_OfferSet
|
||||
*/
|
||||
require_once 'Zend/Service/Amazon/OfferSet.php';
|
||||
$this->Offers = new Zend_Service_Amazon_OfferSet($dom);
|
||||
}
|
||||
|
||||
$result = $xpath->query('./az:Accessories/*', $dom);
|
||||
if ($result->length > 1) {
|
||||
/**
|
||||
* @see Zend_Service_Amazon_Accessories
|
||||
*/
|
||||
require_once 'Zend/Service/Amazon/Accessories.php';
|
||||
foreach ($result as $r) {
|
||||
$this->Accessories[] = new Zend_Service_Amazon_Accessories($r);
|
||||
}
|
||||
}
|
||||
|
||||
$this->_dom = $dom;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the item's original XML
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function asXml()
|
||||
{
|
||||
return $this->_dom->ownerDocument->saveXML($this->_dom);
|
||||
}
|
||||
}
|
48
libs/Zend/Service/Amazon/ListmaniaList.php
Normal file
48
libs/Zend/Service/Amazon/ListmaniaList.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Service
|
||||
* @subpackage Amazon
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: ListmaniaList.php 8064 2008-02-16 10:58:39Z thomas $
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Service
|
||||
* @subpackage Amazon
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Service_Amazon_ListmaniaList
|
||||
{
|
||||
/**
|
||||
* Assigns values to properties relevant to ListmaniaList
|
||||
*
|
||||
* @param DOMElement $dom
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(DOMElement $dom)
|
||||
{
|
||||
$xpath = new DOMXPath($dom->ownerDocument);
|
||||
$xpath->registerNamespace('az', 'http://webservices.amazon.com/AWSECommerceService/2005-10-05');
|
||||
foreach (array('ListId', 'ListName') as $el) {
|
||||
$this->$el = (string) $xpath->query("./az:$el/text()", $dom)->item(0)->data;
|
||||
}
|
||||
}
|
||||
}
|
56
libs/Zend/Service/Amazon/Offer.php
Normal file
56
libs/Zend/Service/Amazon/Offer.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Service
|
||||
* @subpackage Amazon
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Offer.php 8064 2008-02-16 10:58:39Z thomas $
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Service
|
||||
* @subpackage Amazon
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Service_Amazon_Offer
|
||||
{
|
||||
/**
|
||||
* Parse the given Offer element
|
||||
*
|
||||
* @param DOMElement $dom
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(DOMElement $dom)
|
||||
{
|
||||
$xpath = new DOMXPath($dom->ownerDocument);
|
||||
$xpath->registerNamespace('az', 'http://webservices.amazon.com/AWSECommerceService/2005-10-05');
|
||||
$this->MerchantId = (string) $xpath->query('./az:Merchant/az:MerchantId/text()', $dom)->item(0)->data;
|
||||
$this->GlancePage = (string) $xpath->query('./az:Merchant/az:GlancePage/text()', $dom)->item(0)->data;
|
||||
$this->Condition = (string) $xpath->query('./az:OfferAttributes/az:Condition/text()', $dom)->item(0)->data;
|
||||
$this->OfferListingId = (string) $xpath->query('./az:OfferListing/az:OfferListingId/text()', $dom)->item(0)->data;
|
||||
$this->Price = (int) $xpath->query('./az:OfferListing/az:Price/az:Amount/text()', $dom)->item(0)->data;
|
||||
$this->CurrencyCode = (string) $xpath->query('./az:OfferListing/az:Price/az:CurrencyCode/text()', $dom)->item(0)->data;
|
||||
$this->Availability = (string) $xpath->query('./az:OfferListing/az:Availability/text()', $dom)->item(0)->data;
|
||||
$result = $xpath->query('./az:OfferListing/az:IsEligibleForSuperSaverShipping/text()', $dom);
|
||||
if ($result->length >= 1) {
|
||||
$this->IsEligibleForSuperSaverShipping = (bool) $result->item(0)->data;
|
||||
}
|
||||
}
|
||||
}
|
73
libs/Zend/Service/Amazon/OfferSet.php
Normal file
73
libs/Zend/Service/Amazon/OfferSet.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Service
|
||||
* @subpackage Amazon
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: OfferSet.php 8064 2008-02-16 10:58:39Z thomas $
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Service
|
||||
* @subpackage Amazon
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Service_Amazon_OfferSet
|
||||
{
|
||||
/**
|
||||
* Parse the given Offer Set Element
|
||||
*
|
||||
* @param DOMElement $dom
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(DOMElement $dom)
|
||||
{
|
||||
$xpath = new DOMXPath($dom->ownerDocument);
|
||||
$xpath->registerNamespace('az', 'http://webservices.amazon.com/AWSECommerceService/2005-10-05');
|
||||
|
||||
$offer = $xpath->query('./az:OfferSummary', $dom);
|
||||
if ($offer->length == 1) {
|
||||
$lowestNewPrice = $xpath->query('./az:OfferSummary/az:LowestNewPrice', $dom);
|
||||
if ($lowestNewPrice->length == 1) {
|
||||
$this->LowestNewPrice = (int) $xpath->query('./az:OfferSummary/az:LowestNewPrice/az:Amount/text()', $dom)->item(0)->data;
|
||||
$this->LowestNewPriceCurrency = (string) $xpath->query('./az:OfferSummary/az:LowestNewPrice/az:CurrencyCode/text()', $dom)->item(0)->data;
|
||||
}
|
||||
$lowestUsedPrice = $xpath->query('./az:OfferSummary/az:LowestUsedPrice', $dom);
|
||||
if ($lowestUsedPrice->length == 1) {
|
||||
$this->LowestUsedPrice = (int) $xpath->query('./az:OfferSummary/az:LowestUsedPrice/az:Amount/text()', $dom)->item(0)->data;
|
||||
$this->LowestUsedPriceCurrency = (string) $xpath->query('./az:OfferSummary/az:LowestUsedPrice/az:CurrencyCode/text()', $dom)->item(0)->data;
|
||||
}
|
||||
$this->TotalNew = (int) $xpath->query('./az:OfferSummary/az:TotalNew/text()', $dom)->item(0)->data;
|
||||
$this->TotalUsed = (int) $xpath->query('./az:OfferSummary/az:TotalUsed/text()', $dom)->item(0)->data;
|
||||
$this->TotalCollectible = (int) $xpath->query('./az:OfferSummary/az:TotalCollectible/text()', $dom)->item(0)->data;
|
||||
$this->TotalRefurbished = (int) $xpath->query('./az:OfferSummary/az:TotalRefurbished/text()', $dom)->item(0)->data;
|
||||
}
|
||||
$offers = $xpath->query('./az:Offers/az:Offer', $dom);
|
||||
if ($offers->length >= 1) {
|
||||
/**
|
||||
* @see Zend_Service_Amazon_Offer
|
||||
*/
|
||||
require_once 'Zend/Service/Amazon/Offer.php';
|
||||
foreach ($offers as $offer) {
|
||||
$this->Offers[] = new Zend_Service_Amazon_Offer($offer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
98
libs/Zend/Service/Amazon/Query.php
Normal file
98
libs/Zend/Service/Amazon/Query.php
Normal file
@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Service
|
||||
* @subpackage Amazon
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Query.php 8064 2008-02-16 10:58:39Z thomas $
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @see Zend_Service_Amazon
|
||||
*/
|
||||
require_once 'Zend/Service/Amazon.php';
|
||||
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Service
|
||||
* @subpackage Amazon
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Service_Amazon_Query extends Zend_Service_Amazon
|
||||
{
|
||||
/**
|
||||
* Search parameters
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_search = array();
|
||||
|
||||
/**
|
||||
* Search index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_searchIndex = null;
|
||||
|
||||
/**
|
||||
* Prepares query parameters
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $args
|
||||
* @throws Zend_Service_Exception
|
||||
* @return Zend_Service_Amazon_Query Provides a fluent interface
|
||||
*/
|
||||
public function __call($method, $args)
|
||||
{
|
||||
if (strtolower($method) === 'asin') {
|
||||
$this->_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);
|
||||
}
|
||||
}
|
170
libs/Zend/Service/Amazon/ResultSet.php
Normal file
170
libs/Zend/Service/Amazon/ResultSet.php
Normal file
@ -0,0 +1,170 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Service
|
||||
* @subpackage Amazon
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: ResultSet.php 8064 2008-02-16 10:58:39Z thomas $
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @see Zend_Service_Amazon_Item
|
||||
*/
|
||||
require_once 'Zend/Service/Amazon/Item.php';
|
||||
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Service
|
||||
* @subpackage Amazon
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Service_Amazon_ResultSet implements SeekableIterator
|
||||
{
|
||||
/**
|
||||
* A DOMNodeList of <Item> elements
|
||||
*
|
||||
* @var DOMNodeList
|
||||
*/
|
||||
protected $_results = null;
|
||||
|
||||
/**
|
||||
* Amazon Web Service Return Document
|
||||
*
|
||||
* @var DOMDocument
|
||||
*/
|
||||
protected $_dom;
|
||||
|
||||
/**
|
||||
* XPath Object for $this->_dom
|
||||
*
|
||||
* @var DOMXPath
|
||||
*/
|
||||
protected $_xpath;
|
||||
|
||||
/**
|
||||
* Current index for SeekableIterator
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_currentIndex = 0;
|
||||
|
||||
/**
|
||||
* Create an instance of Zend_Service_Amazon_ResultSet and create the necessary data objects
|
||||
*
|
||||
* @param DOMDocument $dom
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(DOMDocument $dom)
|
||||
{
|
||||
$this->_dom = $dom;
|
||||
$this->_xpath = new DOMXPath($dom);
|
||||
$this->_xpath->registerNamespace('az', 'http://webservices.amazon.com/AWSECommerceService/2005-10-05');
|
||||
$this->_results = $this->_xpath->query('//az:Item');
|
||||
}
|
||||
|
||||
/**
|
||||
* Total Number of results returned
|
||||
*
|
||||
* @return int Total number of results returned
|
||||
*/
|
||||
public function totalResults()
|
||||
{
|
||||
$result = $this->_xpath->query('//az:TotalResults/text()');
|
||||
return (int) $result->item(0)->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Total Number of pages returned
|
||||
*
|
||||
* @return int Total number of pages returned
|
||||
*/
|
||||
public function totalPages()
|
||||
{
|
||||
$result = $this->_xpath->query('//az:TotalPages/text()');
|
||||
return (int) $result->item(0)->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement SeekableIterator::current()
|
||||
*
|
||||
* @return Zend_Service_Amazon_Item
|
||||
*/
|
||||
public function current()
|
||||
{
|
||||
return new Zend_Service_Amazon_Item($this->_results->item($this->_currentIndex));
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement SeekableIterator::key()
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function key()
|
||||
{
|
||||
return $this->_currentIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement SeekableIterator::next()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function next()
|
||||
{
|
||||
$this->_currentIndex += 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement SeekableIterator::rewind()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function rewind()
|
||||
{
|
||||
$this->_currentIndex = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement SeekableIterator::seek()
|
||||
*
|
||||
* @param int $index
|
||||
* @throws OutOfBoundsException
|
||||
* @return void
|
||||
*/
|
||||
public function seek($index)
|
||||
{
|
||||
$indexInt = (int) $index;
|
||||
if ($indexInt >= 0 && (null === $this->_results || $indexInt < $this->_results->length)) {
|
||||
$this->_currentIndex = $indexInt;
|
||||
} else {
|
||||
throw new OutOfBoundsException("Illegal index '$index'");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement SeekableIterator::valid()
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function valid()
|
||||
{
|
||||
return null !== $this->_results && $this->_currentIndex < $this->_results->length;
|
||||
}
|
||||
}
|
48
libs/Zend/Service/Amazon/SimilarProduct.php
Normal file
48
libs/Zend/Service/Amazon/SimilarProduct.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Service
|
||||
* @subpackage Amazon
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: SimilarProduct.php 8064 2008-02-16 10:58:39Z thomas $
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Service
|
||||
* @subpackage Amazon
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Service_Amazon_SimilarProduct
|
||||
{
|
||||
/**
|
||||
* Assigns values to properties relevant to SimilarProduct
|
||||
*
|
||||
* @param DOMElement $dom
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(DOMElement $dom)
|
||||
{
|
||||
$xpath = new DOMXPath($dom->ownerDocument);
|
||||
$xpath->registerNamespace('az', 'http://webservices.amazon.com/AWSECommerceService/2005-10-05');
|
||||
foreach (array('ASIN', 'Title') as $el) {
|
||||
$this->$el = (string) $xpath->query("./az:$el/text()", $dom)->item(0)->data;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user