File indexing completed on 2024-12-22 05:37:02

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_Offer
0033 {
0034     /**
0035      * @var string
0036      */
0037     public $MerchantId;
0038 
0039     /**
0040      * @var string
0041      */
0042     public $MerchantName;
0043 
0044     /**
0045      * @var string
0046      */
0047     public $GlancePage;
0048 
0049     /**
0050      * @var string
0051      */
0052     public $Condition;
0053 
0054     /**
0055      * @var string
0056      */
0057     public $OfferListingId;
0058 
0059     /**
0060      * @var string
0061      */
0062     public $Price;
0063 
0064     /**
0065      * @var string
0066      */
0067     public $CurrencyCode;
0068 
0069     /**
0070      * @var string
0071      */
0072     public $Availability;
0073 
0074     /**
0075      * @var boolean
0076      */
0077     public $IsEligibleForSuperSaverShipping = false;
0078 
0079     /**
0080      * Parse the given Offer 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         $this->MerchantId = (string) $xpath->query('./az:Merchant/az:MerchantId/text()', $dom)->item(0)->data;
0090         $name = $xpath->query('./az:Merchant/az:Name/text()', $dom);
0091         if ($name->length == 1) {
0092           $this->MerchantName = (string) $name->item(0)->data;
0093         }
0094         $this->GlancePage = (string) $xpath->query('./az:Merchant/az:GlancePage/text()', $dom)->item(0)->data;
0095         $this->Condition = (string) $xpath->query('./az:OfferAttributes/az:Condition/text()', $dom)->item(0)->data;
0096         $this->OfferListingId = (string) $xpath->query('./az:OfferListing/az:OfferListingId/text()', $dom)->item(0)->data;
0097         $Price = $xpath->query('./az:OfferListing/az:Price/az:Amount', $dom);
0098         if ($Price->length == 1) {
0099             $this->Price = (int) $xpath->query('./az:OfferListing/az:Price/az:Amount/text()', $dom)->item(0)->data;
0100             $this->CurrencyCode = (string) $xpath->query('./az:OfferListing/az:Price/az:CurrencyCode/text()', $dom)->item(0)->data;
0101         }
0102         $availability = $xpath->query('./az:OfferListing/az:Availability/text()', $dom)->item(0);
0103         if($availability instanceof DOMText) {
0104             $this->Availability = (string) $availability->data;
0105         }
0106         $result = $xpath->query('./az:OfferListing/az:IsEligibleForSuperSaverShipping/text()', $dom);
0107         if ($result->length >= 1) {
0108             $this->IsEligibleForSuperSaverShipping = (bool) $result->item(0)->data;
0109         }
0110     }
0111 }