File indexing completed on 2024-05-26 06:03:25

0001 <?php
0002 
0003 /**
0004  * Zend Framework
0005  *
0006  * LICENSE
0007  *
0008  * This source file is subject to the new BSD license that is bundled
0009  * with this package in the file LICENSE.txt.
0010  * It is also available through the world-wide-web at this URL:
0011  * http://framework.zend.com/license/new-bsd
0012  * If you did not receive a copy of the license and are unable to
0013  * obtain it through the world-wide-web, please send an email
0014  * to license@zend.com so we can send you a copy immediately.
0015  *
0016  * @category   Zend
0017  * @package    Zend_Service
0018  * @subpackage Amazon
0019  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0020  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0021  * @version    $Id$
0022  */
0023 
0024 
0025 /**
0026  * @category   Zend
0027  * @package    Zend_Service
0028  * @subpackage Amazon
0029  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0030  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0031  */
0032 class Zend_Service_Amazon_OfferSet
0033 {
0034     /**
0035      * @var string
0036      */
0037     public $LowestNewPrice;
0038 
0039     /**
0040      * @var string
0041      */
0042     public $LowestNewPriceCurrency;
0043 
0044     /**
0045      * @var string
0046      */
0047     public $LowestUsedPrice;
0048 
0049     /**
0050      * @var string
0051      */
0052     public $LowestUsedPriceCurrency;
0053 
0054     /**
0055      * @var int
0056      */
0057     public $TotalNew;
0058 
0059     /**
0060      * @var int
0061      */
0062     public $TotalUsed;
0063 
0064     /**
0065      * @var int
0066      */
0067     public $TotalCollectible;
0068 
0069     /**
0070      * @var int
0071      */
0072     public $TotalRefurbished;
0073 
0074     /**
0075      * @var Zend_Service_Amazon_Offer[]
0076      */
0077     public $Offers;
0078 
0079     /**
0080      * Parse the given Offer Set Element
0081      *
0082      * @param  DOMElement $dom
0083      * @return void
0084      */
0085     public function __construct(DOMElement $dom)
0086     {
0087         $xpath = new DOMXPath($dom->ownerDocument);
0088         $xpath->registerNamespace('az', 'http://webservices.amazon.com/AWSECommerceService/2011-08-01');
0089 
0090         $offer = $xpath->query('./az:OfferSummary', $dom);
0091         if ($offer->length == 1) {
0092             $lowestNewPrice = $xpath->query('./az:OfferSummary/az:LowestNewPrice/az:Amount', $dom);
0093             if ($lowestNewPrice->length == 1) {
0094                 $this->LowestNewPrice = (int) $xpath->query('./az:OfferSummary/az:LowestNewPrice/az:Amount/text()', $dom)->item(0)->data;
0095                 $this->LowestNewPriceCurrency = (string) $xpath->query('./az:OfferSummary/az:LowestNewPrice/az:CurrencyCode/text()', $dom)->item(0)->data;
0096             }
0097             $lowestUsedPrice = $xpath->query('./az:OfferSummary/az:LowestUsedPrice/az:Amount', $dom);
0098             if ($lowestUsedPrice->length == 1) {
0099                 $this->LowestUsedPrice = (int) $xpath->query('./az:OfferSummary/az:LowestUsedPrice/az:Amount/text()', $dom)->item(0)->data;
0100                 $this->LowestUsedPriceCurrency = (string) $xpath->query('./az:OfferSummary/az:LowestUsedPrice/az:CurrencyCode/text()', $dom)->item(0)->data;
0101             }
0102             $this->TotalNew = (int) $xpath->query('./az:OfferSummary/az:TotalNew/text()', $dom)->item(0)->data;
0103             $this->TotalUsed = (int) $xpath->query('./az:OfferSummary/az:TotalUsed/text()', $dom)->item(0)->data;
0104             $this->TotalCollectible = (int) $xpath->query('./az:OfferSummary/az:TotalCollectible/text()', $dom)->item(0)->data;
0105             $this->TotalRefurbished = (int) $xpath->query('./az:OfferSummary/az:TotalRefurbished/text()', $dom)->item(0)->data;
0106         }
0107         $offers = $xpath->query('./az:Offers/az:Offer', $dom);
0108         if ($offers->length >= 1) {
0109             /**
0110              * @see Zend_Service_Amazon_Offer
0111              */
0112             // require_once 'Zend/Service/Amazon/Offer.php';
0113             foreach ($offers as $offer) {
0114                 $this->Offers[] = new Zend_Service_Amazon_Offer($offer);
0115             }
0116         }
0117     }
0118 }