Services_Ebay
[ class tree: Services_Ebay ] [ index: Services_Ebay ] [ all elements ]

Source for file Call.php

Documentation is available at Call.php

  1. <?PHP
  2. /**
  3.  * base class for API call objects
  4.  *
  5.  * $Id: Call.php,v 1.5 2004/12/23 18:04:15 amt Exp $
  6.  *
  7.  * @package     Services_Ebay
  8.  * @author      Stephan Schmidt <schst@php.net>
  9.  *
  10.  * @todo        implement __toString()
  11.  * @todo        allow rules for parameters
  12.  */
  13. abstract class Services_Ebay_Call
  14. {
  15.    /**
  16.     * verb of the API call
  17.     *
  18.     * @var  string 
  19.     */
  20.     protected $verb = null;
  21.  
  22.    /**
  23.     * arguments of the call
  24.     *
  25.     * @var  array 
  26.     */
  27.     protected $args = array();
  28.  
  29.    /**
  30.     * authentication type of the call
  31.     *
  32.     * @var  int 
  33.     */
  34.     protected $authType = Services_Ebay::AUTH_TYPE_TOKEN;
  35.  
  36.    /**
  37.     * parameter map that is used, when scalar parameters are passed
  38.     *
  39.     * @var  array 
  40.     */
  41.     protected $paramMap = array();
  42.  
  43.    /**
  44.     * options that will be passed to the serializer
  45.     *
  46.     * @var  array 
  47.     */
  48.     protected $serializerOptions = array();
  49.     
  50.    /**
  51.     * compatibility level this method was introduced
  52.     *
  53.     * @var  integer 
  54.     */
  55.     protected $since = null;
  56.  
  57.    /**
  58.     * deprecated since API version
  59.     *
  60.     * @var  integer 
  61.     */
  62.     protected $deprecated = null;
  63.  
  64.    /**
  65.     * constructor
  66.     *
  67.     * @param    array   arguments to the call
  68.     */
  69.     public function __construct($args = null)
  70.     {
  71.         if ($this->verb === null{
  72.             $this->verb = substr(get_class($this)19);
  73.         }
  74.  
  75.         // no arguments
  76.         if (is_null($args)) {
  77.             return;
  78.         }
  79.     
  80.         // arguments have been passed as assoc array
  81.         if (isset($args[0]&& is_array($args[0])) {
  82.             $this->args = $args[0];
  83.             return;
  84.         }
  85.  
  86.         $cnt count($args);
  87.         if ($cnt count($this->paramMap)) {
  88.             throw new Services_Ebay_Exception('To many parameters have been passed');
  89.         }
  90.  
  91.         for ($i = 0; $i $cnt$i++{
  92.             $this->args[$this->paramMap[$i]] $args[$i];
  93.         }
  94.     }
  95.  
  96.    /**
  97.     * make the API call
  98.     *
  99.     * @param  object Services_Ebay_Session 
  100.     * @return array 
  101.     */
  102.     public function call(Services_Ebay_Session $session)
  103.     {
  104.         $session->setSerializerOptions($this->serializerOptions);
  105.         $return $session->sendRequest($this->verb$this->args$this->authType);
  106.         return $return;
  107.     }
  108.     
  109.    /**
  110.     * set arguments for the API call
  111.     *
  112.     * @param    array 
  113.     * @return   boolean 
  114.     */
  115.     public function setArgs($args)
  116.     {
  117.         $this->args = $args;
  118.         return true;
  119.     }
  120.  
  121.    /**
  122.     * set the detail level for this call
  123.     *
  124.     * @param    integer 
  125.     * @return   boolean 
  126.     */
  127.     public function setDetailLevel($level)
  128.     {
  129.         $this->args['DetailLevel'$level;
  130.         return true;
  131.     }
  132.  
  133.    /**
  134.     * describe the call
  135.     *
  136.     * This returns information about the possible parameters
  137.     */
  138.     public function describeCall()
  139.     {
  140.         echo 'API Call : '.$this->verb."\n";
  141.         if ($this->since !== null{
  142.             echo 'Added in API version : ' $this->since . "\n";
  143.         }
  144.         if ($this->deprecated !== null{
  145.             echo 'Deprecated in API version : ' $this->deprecated . "\n";
  146.         }
  147.         echo "\n";
  148.         echo 'Parameters (max. '.count($this->paramMap).')'."\n";
  149.         $i = 0;
  150.         foreach ($this->paramMap as $param{
  151.             echo ' '.++$i.'. '.$param;
  152.             if (isset($this->args[$param])) {
  153.                 echo '('.$this->args[$param].')';
  154.             else {
  155.                 echo '(no default value)';
  156.             }
  157.             echo "\n";
  158.         }
  159.         $rc = new ReflectionClass($this);
  160.         $dc $rc->getDocComment();
  161.         if (preg_match('/@link +(.+)/'$dc$matches)) {
  162.             echo 'API Documentation : '.$matches[1]."\n";            
  163.         }
  164.     }
  165. }
  166. ?>

Documentation generated on Mon, 11 Mar 2019 14:00:22 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.