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

Source for file Item.php

Documentation is available at Item.php

  1. <?PHP
  2. /**
  3.  * Model for an eBay item
  4.  *
  5.  * $Id: Item.php,v 1.1 2004/10/28 17:14:53 schst Exp $
  6.  *
  7.  * @package Services_Ebay
  8.  * @author  Stephan Schmidt <schst@php.net>
  9.  */
  10. {
  11.    /**
  12.     * property that stores the unique identifier (=pk) of the model
  13.     *
  14.     * @var string 
  15.     */
  16.     protected $primaryKey = 'Id';
  17.  
  18.     /**
  19.     * create new item
  20.     *
  21.     * @param    array   properties
  22.     */
  23.     public function __construct($props$session = null)
  24.     {
  25.         if (is_array($props&& isset($props['Seller'])) {
  26.             if (isset($props['Seller']['User']&& is_array($props['Seller']['User'])) {
  27.                 $props['Seller'Services_Ebay::loadModel('User'$props['Seller']['User']$session);
  28.             }
  29.         }
  30.         parent::__construct($props$session);
  31.     }
  32.  
  33.    /**
  34.     * create a string representation of the item
  35.     *
  36.     * @return   string 
  37.     */
  38.     public function __toString()
  39.     {
  40.         if (isset($this->properties['Title'])) {
  41.             return $this->properties['Title''(# '.$this->properties['Id'].')';
  42.         }
  43.         return '# '.$this->properties['Id'];
  44.     }
  45.  
  46.    /**
  47.     * get the item from eBay
  48.     *
  49.     * Use this to query by a previously set itemId.
  50.     *
  51.     * <code>
  52.     * $item = Services_Ebay::loadModel('Item', null, $session);
  53.     * $item->Id = 4501296414;
  54.     * $item->Get();
  55.     * </code>
  56.     *
  57.     * @param    int     DetailLevel
  58.     * @param    int     DescFormat
  59.     * @see      Services_Ebay_Call_GetItem
  60.     */
  61.     public function Get($DetailLevel = null$DescFormat = 0)
  62.     {
  63.         $args = array(
  64.                         'Id'         => $this->properties['Id'],
  65.                         'DescFormat' => $DescFormat
  66.                     );
  67.         if (!is_null($DetailLevel)) {
  68.             $args['DetailLevel'$DetailLevel;
  69.         }
  70.  
  71.         $call Services_Ebay::loadAPICall('GetItem');
  72.         $call->setArgs($args);
  73.         
  74.         $tmp $call->call($this->session);
  75.         $this->properties = $tmp->toArray();
  76.         $this->eBayProperties = $this->properties;
  77.         unset($tmp);
  78.         return true;
  79.     }
  80.  
  81.    /**
  82.     * get cross promotions
  83.     *
  84.     * @param    int     DetailLevel
  85.     * @param    int     DescFormat
  86.     * @see      Services_Ebay_Call_GetCrossPromotions
  87.     */
  88.     public function GetCrossPromotions($PromotionMethod 'CrossSell'$PromotionViewMode = null)
  89.     {
  90.         $args = array(
  91.                         'ItemId'          => $this->properties['Id'],
  92.                         'PromotionMethod' => $PromotionMethod
  93.                     );
  94.         if (!is_null($PromotionViewMode)) {
  95.             $args['PromotionViewMode'$PromotionViewMode;
  96.         }
  97.  
  98.         $call Services_Ebay::loadAPICall('GetCrossPromotions');
  99.         $call->setArgs($args);
  100.         
  101.         return $call->call($this->session);
  102.     }
  103.     
  104.    /**
  105.     * add text to the item description
  106.     *
  107.     * @param    string 
  108.     * @return   boolean 
  109.     * @see      Services_Ebay_Call_AddToItemDescription
  110.     */
  111.     public function AddToItemDescription($Description)
  112.     {
  113.         $args = array(
  114.                         'ItemId'          => $this->properties['Id'],
  115.                         'Description'     => $Description
  116.                     );
  117.         $call Services_Ebay::loadAPICall('AddToItemDescription');
  118.         $call->setArgs($args);
  119.         
  120.         return $call->call($this->session);
  121.     }
  122.  
  123.    /**
  124.     * and an auction
  125.     *
  126.     * @param    integer 
  127.     * @return   array 
  128.     * @see      Services_Ebay_Call_EndItem
  129.     */
  130.     public function EndItem($EndCode)
  131.     {
  132.         $args = array(
  133.                         'ItemId'  => $this->properties['Id'],
  134.                         'EndCode' => $EndCode
  135.                     );
  136.         $call Services_Ebay::loadAPICall('EndItem');
  137.         $call->setArgs($args);
  138.         
  139.         return $call->call($this->session);
  140.     }
  141.  
  142.    /**
  143.     * Re-list the item
  144.     *
  145.     * This adds a new auction with exactly the same item data
  146.     *
  147.     * @todo     check return value
  148.     * @see      Services_Ebay_Call_RelistItem
  149.     */
  150.     public function RelistItem()
  151.     {
  152.         $args = array(
  153.                         'ItemId'  => $this->properties['Id']
  154.                     );
  155.         $call Services_Ebay::loadAPICall('RelistItem');
  156.         $call->setArgs($args);
  157.         
  158.         return $call->call($this->session);
  159.     }
  160.  
  161.    /**
  162.     * Revise the item
  163.     *
  164.     * @return   boolean 
  165.     * @see      Services_Ebay_Call_ReviseItem
  166.     */
  167.     public function ReviseItem()
  168.     {
  169.         $call Services_Ebay::loadAPICall('ReviseItem'array($this));
  170.         return $call->call($this->session);
  171.     }
  172.  
  173.    /**
  174.     * Add a second chance offer
  175.     *
  176.     * This adds a new auction with exactly the same item data
  177.     *
  178.     * @return   object Services_Ebay_Model_Item 
  179.     * @see      Services_Ebay_Call_AddSecondChanceItem
  180.     */
  181.     public function AddSecondChance($RecipientBidderUserId$Duration = 3$CopyEmailToSeller = 0$BuyItNowPrice = null)
  182.     {
  183.         $args = array(
  184.                         'OriginalItemId'        => $this->properties['Id'],
  185.                         'RecipientBidderUserId' => $RecipientBidderUserId,
  186.                         'Duration'              => $Duration,
  187.                         'CopyEmailToSeller'     => $CopyEmailToSeller
  188.                     );
  189.         if ($BuyItNowPrice !== null{
  190.             $args['BuyItNowPrice'$BuyItNowPrice;
  191.         }
  192.         $call Services_Ebay::loadAPICall('AddSecondChanceItem');
  193.         $call->setArgs($args);
  194.         
  195.         return $call->call($this->session);
  196.     }
  197. }
  198. ?>

Documentation generated on Mon, 11 Mar 2019 13:58:28 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.