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

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