web/Zend/Service/Ebay/Finding/Response/Abstract.php
changeset 0 4eba9c11703f
equal deleted inserted replaced
-1:000000000000 0:4eba9c11703f
       
     1 <?php
       
     2 /**
       
     3  * Zend Framework
       
     4  *
       
     5  * LICENSE
       
     6  *
       
     7  * This source file is subject to the new BSD license that is bundled
       
     8  * with this package in the file LICENSE.txt.
       
     9  * It is also available through the world-wide-web at this URL:
       
    10  * http://framework.zend.com/license/new-bsd
       
    11  * If you did not receive a copy of the license and are unable to
       
    12  * obtain it through the world-wide-web, please send an email
       
    13  * to license@zend.com so we can send you a copy immediately.
       
    14  *
       
    15  * @category   Zend
       
    16  * @package    Zend_Service
       
    17  * @subpackage Ebay
       
    18  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    20  * @version    $Id: Abstract.php 22824 2010-08-09 18:59:54Z renanbr $
       
    21  */
       
    22 
       
    23 /**
       
    24  * @see Zend_Service_Ebay_Finding_Abstract
       
    25  */
       
    26 require_once 'Zend/Service/Ebay/Finding/Abstract.php';
       
    27 
       
    28 /**
       
    29  * @category   Zend
       
    30  * @package    Zend_Service
       
    31  * @subpackage Ebay
       
    32  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    33  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    34  * @uses       Zend_Service_Ebay_Finding_Abstract
       
    35  */
       
    36 abstract class Zend_Service_Ebay_Finding_Response_Abstract extends Zend_Service_Ebay_Finding_Abstract
       
    37 {
       
    38     /**
       
    39      * Indicates whether or not errors or warnings were generated during the
       
    40      * processing of the request.
       
    41      *
       
    42      * Applicable values:
       
    43      *
       
    44      *     Failure
       
    45      *     eBay encountered a fatal error during the processing of the request,
       
    46      *     causing the request to fail. When a serious application-level error
       
    47      *     occurs, the error is returned instead of the business data.
       
    48      *
       
    49      *     PartialFailure
       
    50      *     eBay successfully processed the request, but one or more non-fatal
       
    51      *     errors occurred during the processing. For best results, requests
       
    52      *     should return without warning messages. Inspect the message details
       
    53      *     and resolve any problems before resubmitting the request.
       
    54      *
       
    55      *     Success
       
    56      *     eBay successfully processed the request and the business data is
       
    57      *     returned in the response. Note that it is possible for a response to
       
    58      *     return Success, but still not contain the expected data in the result.
       
    59      *
       
    60      *     Warning
       
    61      *     The request was successfully processed, but eBay encountered a
       
    62      *     non-fatal error during the processing. For best results, requests
       
    63      *     should return without warnings. Inspect the warning details and
       
    64      *     resolve the problem before resubmitting the request.
       
    65      *
       
    66      * @var string
       
    67      */
       
    68     public $ack;
       
    69 
       
    70     /**
       
    71      * Information regarding an error or warning that occurred when eBay
       
    72      * processed the request.
       
    73      *
       
    74      * Not returned when the ack value is Success. Run-time errors are not
       
    75      * reported here.
       
    76      *
       
    77      * @var Zend_Service_Ebay_Finding_Error_Message
       
    78      */
       
    79     public $errorMessage;
       
    80 
       
    81     /**
       
    82      * This value represents the date and time when eBay processed the request.
       
    83      *
       
    84      * This value is returned in GMT, the ISO 8601 date and time format
       
    85      * (YYYY-MM-DDTHH:MM:SS.SSSZ). See the "dateTime" type for information about
       
    86      * the time format, and for details on converting to and from the GMT time
       
    87      * zone.
       
    88      *
       
    89      * @var string
       
    90      */
       
    91     public $timestamp;
       
    92 
       
    93     /**
       
    94      * The release version that eBay used to process the request.
       
    95      *
       
    96      * Developer Technical Support may ask you for the version value if you work
       
    97      * with them to troubleshoot issues.
       
    98      *
       
    99      * @var string
       
   100      */
       
   101     public $version;
       
   102 
       
   103     /**
       
   104      * @var string
       
   105      */
       
   106     protected $_operation;
       
   107 
       
   108     /**
       
   109      * @var array
       
   110      */
       
   111     protected $_options = array();
       
   112 
       
   113     /**
       
   114      * @return void
       
   115      */
       
   116     protected function _init()
       
   117     {
       
   118         parent::_init();
       
   119         $ns = Zend_Service_Ebay_Finding::XMLNS_FINDING;
       
   120 
       
   121         $this->ack       = $this->_query(".//$ns:ack[1]", 'string');
       
   122         $this->timestamp = $this->_query(".//$ns:timestamp[1]", 'string');
       
   123         $this->version   = $this->_query(".//$ns:version[1]", 'string');
       
   124 
       
   125         $node = $this->_xPath->query(".//$ns:errorMessage[1]", $this->_dom)->item(0);
       
   126         if ($node) {
       
   127             /**
       
   128              * @see Zend_Service_Ebay_Finding_Error_Message
       
   129              */
       
   130             require_once 'Zend/Service/Ebay/Finding/Error/Message.php';
       
   131             $this->errorMessage = new Zend_Service_Ebay_Finding_Error_Message($node);
       
   132         }
       
   133     }
       
   134 
       
   135     /**
       
   136      * @param  string $operation
       
   137      * @return Zend_Service_Ebay_Finding_Response_Abstract Provides a fluent interface
       
   138      */
       
   139     public function setOperation($operation)
       
   140     {
       
   141         $this->_operation = (string) $operation;
       
   142         return $this;
       
   143     }
       
   144 
       
   145     /**
       
   146      * @return string
       
   147      */
       
   148     public function getOperation()
       
   149     {
       
   150         return $this->_operation;
       
   151     }
       
   152 
       
   153     /**
       
   154      * @param  string|Zend_Config|array $name
       
   155      * @param  mixed                    $value
       
   156      * @return Zend_Service_Ebay_Finding_Response_Abstract Provides a fluent interface
       
   157      */
       
   158     public function setOption($name, $value = null)
       
   159     {
       
   160         if ($name instanceof Zend_Config) {
       
   161             $name = $name->toArray();
       
   162         }
       
   163         if (is_array($name)) {
       
   164             $this->_options = $name;
       
   165         } else {
       
   166             $this->_options[$name] = $value;
       
   167         }
       
   168         return $this;
       
   169     }
       
   170 
       
   171     /**
       
   172      * @param  string $name
       
   173      * @return mixed
       
   174      */
       
   175     public function getOption($name = null)
       
   176     {
       
   177         if (null === $name) {
       
   178             return $this->_options;
       
   179         }
       
   180         if (array_key_exists($name, $this->_options)) {
       
   181             return $this->_options[$name];
       
   182         }
       
   183         return null;
       
   184     }
       
   185 }