home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / php / PEAR / Services / Ebay / Call / AddItem.php < prev    next >
Encoding:
PHP Script  |  2008-07-02  |  2.9 KB  |  112 lines

  1. <?PHP
  2. /**
  3.  * Add an item to Ebay
  4.  *
  5.  * $Id: AddItem.php,v 1.5 2004/12/14 19:08:25 schst Exp $
  6.  *
  7.  * @package Services_Ebay
  8.  * @author  Stephan Schmidt <schst@php.net>
  9.  * @link    http://developer.ebay.com/DevZone/docs/API_Doc/Functions/AddItem/AddItemLogic.htm
  10.  */
  11. class Services_Ebay_Call_AddItem extends Services_Ebay_Call 
  12. {
  13.    /**
  14.     * verb of the API call
  15.     *
  16.     * @var  string
  17.     */
  18.     protected $verb = 'AddItem';
  19.  
  20.    /**
  21.     * parameter map that is used, when scalar parameters are passed
  22.     *
  23.     * @var  array
  24.     */
  25.     protected $paramMap = array();
  26.  
  27.    /**
  28.     * options that will be passed to the serializer
  29.     *
  30.     * @var  array
  31.     */
  32.     protected $serializerOptions = array(
  33.                                             'mode' => 'simplexml'
  34.                                         );
  35.    /**
  36.     * default parameters that will be used when
  37.     * adding an item
  38.     *
  39.     * @var  array
  40.     */
  41.     protected $args = array(
  42.                             'CheckoutDetailsSpecified' => 0,
  43.                             'Country'                  => 'us',
  44.                             'Currency'                 => '1',
  45.                             'Duration'                 => '7',
  46.                             'MinimumBid'               => '1.0',
  47.                             'Quantity'                 => '1',
  48.                             'Region'                   => '0',
  49.                             'Version'                  => '2'
  50.                             );
  51.  
  52.    /**
  53.     * item that should be added
  54.     *
  55.     * @var  object Services_Ebay_Model_Item
  56.     */
  57.     protected $item;
  58.  
  59.    /**
  60.     * constructor
  61.     *
  62.     * @param    array
  63.     */
  64.     public function __construct($args)
  65.     {
  66.         $item = $args[0];
  67.         
  68.         if (!$item instanceof Services_Ebay_Model_Item) {
  69.             throw new Services_Ebay_Exception( 'No item passed.' );
  70.         }
  71.         
  72.         $this->setItem($item);
  73.     }
  74.  
  75.    /**
  76.     * set the item that should be added
  77.     *
  78.     * @param    Services_Ebay_Model_Item
  79.     * @return   boolean
  80.     */
  81.     public function setItem(Services_Ebay_Model_Item $item)
  82.     {
  83.         $this->item = $item;
  84.         $this->args = array_merge( $this->args, $item->toArray() );
  85.         
  86.         return true;
  87.     }
  88.     
  89.    /**
  90.     * make the API call
  91.     *
  92.     * @param    object Services_Ebay_Session
  93.     * @return   string
  94.     */
  95.     public function call(Services_Ebay_Session $session)
  96.     {
  97.         $return = parent::call($session);
  98.  
  99.         if (isset($return['Item'])) {
  100.             $returnItem = $return['Item'];
  101.  
  102.             $this->item->Id = $returnItem['Id'];
  103.             $this->item->StartTime = $returnItem['StartTime'];
  104.             $this->item->EndTime = $returnItem['EndTime'];
  105.             $this->item->Fees = $returnItem['Fees'];
  106.         
  107.             return true;
  108.         }
  109.         return false;
  110.     }
  111. }
  112. ?>