|
1 <?php |
|
2 |
|
3 /** |
|
4 * Zend Framework |
|
5 * |
|
6 * LICENSE |
|
7 * |
|
8 * This source file is subject to the new BSD license that is bundled |
|
9 * with this package in the file LICENSE.txt. |
|
10 * It is also available through the world-wide-web at this URL: |
|
11 * http://framework.zend.com/license/new-bsd |
|
12 * If you did not receive a copy of the license and are unable to |
|
13 * obtain it through the world-wide-web, please send an email |
|
14 * to license@zend.com so we can send you a copy immediately. |
|
15 * |
|
16 * @category Zend |
|
17 * @package Zend_Service |
|
18 * @subpackage Amazon |
|
19 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
20 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
21 * @version $Id: OfferSet.php 20096 2010-01-06 02:05:09Z bkarwin $ |
|
22 */ |
|
23 |
|
24 |
|
25 /** |
|
26 * @category Zend |
|
27 * @package Zend_Service |
|
28 * @subpackage Amazon |
|
29 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
30 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
31 */ |
|
32 class Zend_Service_Amazon_OfferSet |
|
33 { |
|
34 /** |
|
35 * @var string |
|
36 */ |
|
37 public $LowestNewPrice; |
|
38 |
|
39 /** |
|
40 * @var string |
|
41 */ |
|
42 public $LowestNewPriceCurrency; |
|
43 |
|
44 /** |
|
45 * @var string |
|
46 */ |
|
47 public $LowestUsedPrice; |
|
48 |
|
49 /** |
|
50 * @var string |
|
51 */ |
|
52 public $LowestUsedPriceCurrency; |
|
53 |
|
54 /** |
|
55 * @var int |
|
56 */ |
|
57 public $TotalNew; |
|
58 |
|
59 /** |
|
60 * @var int |
|
61 */ |
|
62 public $TotalUsed; |
|
63 |
|
64 /** |
|
65 * @var int |
|
66 */ |
|
67 public $TotalCollectible; |
|
68 |
|
69 /** |
|
70 * @var int |
|
71 */ |
|
72 public $TotalRefurbished; |
|
73 |
|
74 /** |
|
75 * @var Zend_Service_Amazon_Offer[] |
|
76 */ |
|
77 public $Offers; |
|
78 |
|
79 /** |
|
80 * Parse the given Offer Set Element |
|
81 * |
|
82 * @param DOMElement $dom |
|
83 * @return void |
|
84 */ |
|
85 public function __construct(DOMElement $dom) |
|
86 { |
|
87 $xpath = new DOMXPath($dom->ownerDocument); |
|
88 $xpath->registerNamespace('az', 'http://webservices.amazon.com/AWSECommerceService/2005-10-05'); |
|
89 |
|
90 $offer = $xpath->query('./az:OfferSummary', $dom); |
|
91 if ($offer->length == 1) { |
|
92 $lowestNewPrice = $xpath->query('./az:OfferSummary/az:LowestNewPrice/az:Amount', $dom); |
|
93 if ($lowestNewPrice->length == 1) { |
|
94 $this->LowestNewPrice = (int) $xpath->query('./az:OfferSummary/az:LowestNewPrice/az:Amount/text()', $dom)->item(0)->data; |
|
95 $this->LowestNewPriceCurrency = (string) $xpath->query('./az:OfferSummary/az:LowestNewPrice/az:CurrencyCode/text()', $dom)->item(0)->data; |
|
96 } |
|
97 $lowestUsedPrice = $xpath->query('./az:OfferSummary/az:LowestUsedPrice/az:Amount', $dom); |
|
98 if ($lowestUsedPrice->length == 1) { |
|
99 $this->LowestUsedPrice = (int) $xpath->query('./az:OfferSummary/az:LowestUsedPrice/az:Amount/text()', $dom)->item(0)->data; |
|
100 $this->LowestUsedPriceCurrency = (string) $xpath->query('./az:OfferSummary/az:LowestUsedPrice/az:CurrencyCode/text()', $dom)->item(0)->data; |
|
101 } |
|
102 $this->TotalNew = (int) $xpath->query('./az:OfferSummary/az:TotalNew/text()', $dom)->item(0)->data; |
|
103 $this->TotalUsed = (int) $xpath->query('./az:OfferSummary/az:TotalUsed/text()', $dom)->item(0)->data; |
|
104 $this->TotalCollectible = (int) $xpath->query('./az:OfferSummary/az:TotalCollectible/text()', $dom)->item(0)->data; |
|
105 $this->TotalRefurbished = (int) $xpath->query('./az:OfferSummary/az:TotalRefurbished/text()', $dom)->item(0)->data; |
|
106 } |
|
107 $offers = $xpath->query('./az:Offers/az:Offer', $dom); |
|
108 if ($offers->length >= 1) { |
|
109 /** |
|
110 * @see Zend_Service_Amazon_Offer |
|
111 */ |
|
112 require_once 'Zend/Service/Amazon/Offer.php'; |
|
113 foreach ($offers as $offer) { |
|
114 $this->Offers[] = new Zend_Service_Amazon_Offer($offer); |
|
115 } |
|
116 } |
|
117 } |
|
118 } |