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.3 2004/11/16 19:34:05 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.     * set the locations you will ship the item to
  35.     *
  36.     * @param    array 
  37.     */
  38.     public function setShipToLocations($ShipToLocations)
  39.     {
  40.         $this->properties['ShipToLocations'= array(
  41.                                                       'ShipToLocation' => $ShipToLocations
  42.                                                     );
  43.         return true;
  44.     }
  45.  
  46.    /**
  47.     * add a shipping service option
  48.     *
  49.     * @param    integer     shipping service, {@link http://developer.ebay.com/DevZone/docs/API_Doc/Appendixes/AppendixN.htm#shippingservices}
  50.     * @param    float 
  51.     * @param    float 
  52.     * @param    array 
  53.     */
  54.     public function addShippingServiceOption($ShippingService$ShippingServicePriority$ShippingServiceCost$ShippingServiceAdditionalCost$ShipToLocations)
  55.     {
  56.         $option = array(
  57.                         'ShippingService'               => $ShippingService,
  58.                         'ShippingServicePriority'       => $ShippingServicePriority,
  59.                         'ShippingServiceCost'           => $ShippingServiceCost,
  60.                         'ShippingServiceAdditionalCost' => $ShippingServiceAdditionalCost,
  61.                         'ShipToLocations'               => array(
  62.                                                                 'ShipToLocation' => $ShipToLocations
  63.                                                                 )
  64.                     );
  65.         if (!isset($this->properties['ShippingServiceOptions'])) {
  66.             $this->properties['ShippingServiceOptions'= array(
  67.                                                                   'ShippingServiceOption' => array()
  68.                                                                );
  69.         }
  70.         array_push($this->properties['ShippingServiceOptions']['ShippingServiceOption']$option);
  71.         return true;
  72.     }
  73.     
  74.    /**
  75.     * create a string representation of the item
  76.     *
  77.     * @return   string 
  78.     */
  79.     public function __toString()
  80.     {
  81.         if (isset($this->properties['Title'])) {
  82.             return $this->properties['Title''(# '.$this->properties['Id'].')';
  83.         }
  84.         return '# '.$this->properties['Id'];
  85.     }
  86.  
  87.    /**
  88.     * get the item from eBay
  89.     *
  90.     * Use this to query by a previously set itemId.
  91.     *
  92.     * <code>
  93.     * $item = Services_Ebay::loadModel('Item', null, $session);
  94.     * $item->Id = 4501296414;
  95.     * $item->Get();
  96.     * </code>
  97.     *
  98.     * @param    int     DetailLevel
  99.     * @param    int     DescFormat
  100.     * @see      Services_Ebay_Call_GetItem
  101.     */
  102.     public function Get($DetailLevel = null$DescFormat = 0)
  103.     {
  104.         $args = array(
  105.                         'Id'         => $this->properties['Id'],
  106.                         'DescFormat' => $DescFormat
  107.                     );
  108.         if (!is_null($DetailLevel)) {
  109.             $args['DetailLevel'$DetailLevel;
  110.         }
  111.  
  112.         $call Services_Ebay::loadAPICall('GetItem');
  113.         $call->setArgs($args);
  114.         
  115.         $tmp $call->call($this->session);
  116.         $this->properties = $tmp->toArray();
  117.         $this->eBayProperties = $this->properties;
  118.         unset($tmp);
  119.         return true;
  120.     }
  121.  
  122.    /**
  123.     * get cross promotions
  124.     *
  125.     * @param    int     DetailLevel
  126.     * @param    int     DescFormat
  127.     * @see      Services_Ebay_Call_GetCrossPromotions
  128.     */
  129.     public function GetCrossPromotions($PromotionMethod 'CrossSell'$PromotionViewMode = null)
  130.     {
  131.         $args = array(
  132.                         'ItemId'          => $this->properties['Id'],
  133.                         'PromotionMethod' => $PromotionMethod
  134.                     );
  135.         if (!is_null($PromotionViewMode)) {
  136.             $args['PromotionViewMode'$PromotionViewMode;
  137.         }
  138.  
  139.         $call Services_Ebay::loadAPICall('GetCrossPromotions');
  140.         $call->setArgs($args);
  141.         
  142.         return $call->call($this->session);
  143.     }
  144.     
  145.    /**
  146.     * add text to the item description
  147.     *
  148.     * @param    string 
  149.     * @return   boolean 
  150.     * @see      Services_Ebay_Call_AddToItemDescription
  151.     */
  152.     public function AddToDescription($Description)
  153.     {
  154.         $args = array(
  155.                         'ItemId'          => $this->properties['Id'],
  156.                         'Description'     => $Description
  157.                     );
  158.         $call Services_Ebay::loadAPICall('AddToItemDescription');
  159.         $call->setArgs($args);
  160.         
  161.         return $call->call($this->session);
  162.     }
  163.  
  164.    /**
  165.     * and an auction
  166.     *
  167.     * @param    integer 
  168.     * @return   array 
  169.     * @see      Services_Ebay_Call_EndItem
  170.     */
  171.     public function End($EndCode)
  172.     {
  173.         $args = array(
  174.                         'ItemId'  => $this->properties['Id'],
  175.                         'EndCode' => $EndCode
  176.                     );
  177.         $call Services_Ebay::loadAPICall('EndItem');
  178.         $call->setArgs($args);
  179.         
  180.         return $call->call($this->session);
  181.     }
  182.  
  183.    /**
  184.     * Add the item to eBay
  185.     *
  186.     * This starts a new auction
  187.     *
  188.     * @see      Services_Ebay_Call_RelistItem
  189.     */
  190.     public function Add()
  191.     {
  192.         if (isset($this->properties['ItemId']&& !is_null($this->properties['ItemId'])) {
  193.             throw new Services_Ebay_Exception('This item already has an ItemId and thus cannot be added.');
  194.         }
  195.         $call Services_Ebay::loadAPICall('AddItem'array($this));
  196.         
  197.         return $call->call($this->session);
  198.     }
  199.  
  200.    /**
  201.     * Re-list the item
  202.     *
  203.     * This adds a new auction with exactly the same item data
  204.     *
  205.     * @todo     check return value
  206.     * @see      Services_Ebay_Call_RelistItem
  207.     */
  208.     public function Relist()
  209.     {
  210.         $args = array(
  211.                         'ItemId'  => $this->properties['Id']
  212.                     );
  213.         $call Services_Ebay::loadAPICall('RelistItem');
  214.         $call->setArgs($args);
  215.         
  216.         return $call->call($this->session);
  217.     }
  218.  
  219.    /**
  220.     * Revise the item
  221.     *
  222.     * @return   boolean 
  223.     * @see      Services_Ebay_Call_ReviseItem
  224.     */
  225.     public function Revise()
  226.     {
  227.         $call Services_Ebay::loadAPICall('ReviseItem'array($this));
  228.         return $call->call($this->session);
  229.     }
  230.  
  231.    /**
  232.     * Add a second chance offer
  233.     *
  234.     * This adds a new auction with exactly the same item data
  235.     *
  236.     * @return   object Services_Ebay_Model_Item 
  237.     * @see      Services_Ebay_Call_AddSecondChanceItem
  238.     */
  239.     public function AddSecondChance($RecipientBidderUserId$Duration = 3$CopyEmailToSeller = 0$BuyItNowPrice = null)
  240.     {
  241.         $args = array(
  242.                         'OriginalItemId'        => $this->properties['Id'],
  243.                         'RecipientBidderUserId' => $RecipientBidderUserId,
  244.                         'Duration'              => $Duration,
  245.                         'CopyEmailToSeller'     => $CopyEmailToSeller
  246.                     );
  247.         if ($BuyItNowPrice !== null{
  248.             $args['BuyItNowPrice'$BuyItNowPrice;
  249.         }
  250.         $call Services_Ebay::loadAPICall('AddSecondChanceItem');
  251.         $call->setArgs($args);
  252.         
  253.         return $call->call($this->session);
  254.     }
  255. }
  256. ?>

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