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

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