|
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: Offer.php 21154 2010-02-23 17:10:34Z matthew $ |
|
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_Offer |
|
33 { |
|
34 /** |
|
35 * @var string |
|
36 */ |
|
37 public $MerchantId; |
|
38 |
|
39 /** |
|
40 * @var string |
|
41 */ |
|
42 public $MerchantName; |
|
43 |
|
44 /** |
|
45 * @var string |
|
46 */ |
|
47 public $GlancePage; |
|
48 |
|
49 /** |
|
50 * @var string |
|
51 */ |
|
52 public $Condition; |
|
53 |
|
54 /** |
|
55 * @var string |
|
56 */ |
|
57 public $OfferListingId; |
|
58 |
|
59 /** |
|
60 * @var string |
|
61 */ |
|
62 public $Price; |
|
63 |
|
64 /** |
|
65 * @var string |
|
66 */ |
|
67 public $CurrencyCode; |
|
68 |
|
69 /** |
|
70 * @var string |
|
71 */ |
|
72 public $Availability; |
|
73 |
|
74 /** |
|
75 * @var boolean |
|
76 */ |
|
77 public $IsEligibleForSuperSaverShipping = false; |
|
78 |
|
79 /** |
|
80 * Parse the given Offer 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 $this->MerchantId = (string) $xpath->query('./az:Merchant/az:MerchantId/text()', $dom)->item(0)->data; |
|
90 $name = $xpath->query('./az:Merchant/az:Name/text()', $dom); |
|
91 if ($name->length == 1) { |
|
92 $this->MerchantName = (string) $name->item(0)->data; |
|
93 } |
|
94 $this->GlancePage = (string) $xpath->query('./az:Merchant/az:GlancePage/text()', $dom)->item(0)->data; |
|
95 $this->Condition = (string) $xpath->query('./az:OfferAttributes/az:Condition/text()', $dom)->item(0)->data; |
|
96 $this->OfferListingId = (string) $xpath->query('./az:OfferListing/az:OfferListingId/text()', $dom)->item(0)->data; |
|
97 $Price = $xpath->query('./az:OfferListing/az:Price/az:Amount', $dom); |
|
98 if ($Price->length == 1) { |
|
99 $this->Price = (int) $xpath->query('./az:OfferListing/az:Price/az:Amount/text()', $dom)->item(0)->data; |
|
100 $this->CurrencyCode = (string) $xpath->query('./az:OfferListing/az:Price/az:CurrencyCode/text()', $dom)->item(0)->data; |
|
101 } |
|
102 $availability = $xpath->query('./az:OfferListing/az:Availability/text()', $dom)->item(0); |
|
103 if($availability instanceof DOMText) { |
|
104 $this->Availability = (string) $availability->data; |
|
105 } |
|
106 $result = $xpath->query('./az:OfferListing/az:IsEligibleForSuperSaverShipping/text()', $dom); |
|
107 if ($result->length >= 1) { |
|
108 $this->IsEligibleForSuperSaverShipping = (bool) $result->item(0)->data; |
|
109 } |
|
110 } |
|
111 } |