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

Source for file AbstractAuction.php

Documentation is available at AbstractAuction.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  3.  
  4. /**
  5.  * Abstract Auctio class
  6.  *
  7.  * PHP version 5
  8.  *
  9.  * LICENSE: This source file is subject to the New BSD license that is
  10.  * available through the world-wide-web at the following URI:
  11.  * http://www.opensource.org/licenses/bsd-license.php. If you did not receive
  12.  * a copy of the New BSD License and are unable to obtain it through the web,
  13.  * please send a note to license@php.net so we can mail you a copy immediately.
  14.  *
  15.  * @category  Services
  16.  * @package   Services_Yahoo_JP
  17.  * @author    Tetsuya Nakase <phpizer@gmail.com>
  18.  * @copyright 2008 Tetsuya Nakase
  19.  * @license   http://www.opensource.org/licenses/bsd-license.php BSD
  20.  * @version   CVS: $Id: AbstractAuction.php,v 1.1 2008/04/28 15:59:30 tetsuya Exp $
  21.  * @link      http://phpize.net
  22.  */
  23.  
  24. require_once 'Services/Yahoo/JP/Auction/Response.php';
  25. require_once 'HTTP/Request.php';
  26.  
  27. /**
  28.  * Abstract Auction class
  29.  *
  30.  * This abstract class serves as the base class for all different
  31.  * types of categories that available through Services_Yahoo.
  32.  *
  33.  * @category  Services
  34.  * @package   Services_Yahoo_JP
  35.  * @author    Tetsuya Nakase <phpizer@gmail.com>
  36.  * @copyright 2008 Tetsuya Nakase
  37.  * @license   http://www.opensource.org/licenses/bsd-license.php BSD
  38.  * @version   Release: 0.0.1
  39.  * @link      http://phpize.net
  40.  */
  41. {
  42.     /**
  43.      * parameter
  44.      *
  45.      * @access protected
  46.      * @var    array 
  47.      */
  48.     protected $parameters = array('appid' => 'PEAR_Services_Y_JP');
  49.  
  50.     /**
  51.      * Submits the Auction
  52.      *
  53.      * This method submits the auction and handles the response.  It
  54.      * returns an instance of Services_Yahoo_Result which may be used
  55.      * to further make use of the result.
  56.      *
  57.      * @return object Services_Yahoo_Response Auction Tree result
  58.      * @throws Services_Yahoo_Exception
  59.      */
  60.     public function submit()
  61.     {
  62.         $url $this->requestURL '?';
  63.  
  64.         foreach ($this->parameters as $key => $value{
  65.             if (is_array($value)) {
  66.                 foreach ($value as $value2{
  67.                     $url .= $key '=' urlencode($value2'&';
  68.                 }
  69.                 continue;
  70.             }
  71.  
  72.             $url .= $key '=' urlencode($value'&';
  73.         }
  74.  
  75.         $request = new HTTP_Request($url);
  76.  
  77.         $result $request->sendRequest();
  78.         if (PEAR::isError($result)) {
  79.             throw new Services_Yahoo_Exception($result->getMessage());
  80.         }
  81.  
  82.         return new Services_Yahoo_JP_Auction_Response($request);
  83.     }
  84.  
  85.     /**
  86.      * Set Application ID for the Auction
  87.      *
  88.      * An Application ID is a string that uniquely identifies your
  89.      * application. Think of it as like a User-Agent string. If you
  90.      * have multiple applications, you should use a different ID for
  91.      * each one. You can register your ID and make sure nobody is
  92.      * already using your ID on Yahoo's Application ID registration
  93.      * page.
  94.      *
  95.      * The ID defaults to "PEAR_Services_Y_JP", but you are free to
  96.      * change it to whatever you want.  Please note that the access
  97.      * to the Yahoo API is not limited via the Application ID but via
  98.      * the IP address of the host where the package is used.
  99.      *
  100.      * @param string $id Application
  101.      *
  102.      * @return void 
  103.      */
  104.     public function withAppID($id)
  105.     {
  106.         $this->parameters['appid'$id;
  107.     }
  108.  
  109.     /**
  110.      * Set the id to category for
  111.      *
  112.      * @param string $id to category for
  113.      *
  114.      * @return void 
  115.      */
  116.     public function setCategory($id)
  117.     {
  118.         $this->parameters['category'$id;
  119.     }
  120.  
  121.     /**
  122.      * Set the page to auction
  123.      *
  124.      * @param string $page to auction
  125.      *
  126.      * @return void 
  127.      */
  128.     public function setPage($page)
  129.     {
  130.         $this->parameters['page'$page;
  131.     }
  132.  
  133.     /**
  134.      * Set the store to auction
  135.      *
  136.      * @param string $store to auction
  137.      *
  138.      * @return void 
  139.      */
  140.     public function setStore($store)
  141.     {
  142.         $this->parameters['store'$store;
  143.     }
  144.  
  145.     /**
  146.      * Set the escrow to auction
  147.      *
  148.      * @return void 
  149.      */
  150.     public function setEscrow()
  151.     {
  152.         $this->parameters['escrow'= 1;
  153.     }
  154.  
  155.     /**
  156.      * Set the easypayment to auction
  157.      *
  158.      * @return void 
  159.      */
  160.     public function setEasypayment()
  161.     {
  162.         $this->parameters['easypayment'= 1;
  163.     }
  164.  
  165.     /**
  166.      * Set the new to auction
  167.      *
  168.      * @return void 
  169.      */
  170.     public function setNew()
  171.     {
  172.         $this->parameters['new'= 1;
  173.     }
  174.  
  175.     /**
  176.      * Set the largeimg to auction
  177.      *
  178.      * @return void 
  179.      */
  180.     public function setLargeimg()
  181.     {
  182.         $this->parameters['largeimg'= 1;
  183.     }
  184.  
  185.     /**
  186.      * Set the freeshipping to auction
  187.      *
  188.      * @return void 
  189.      */
  190.     public function setFreeshipping()
  191.     {
  192.         $this->parameters['freeshipping'= 1;
  193.     }
  194.  
  195.     /**
  196.      * Set the wrappingicon to auction
  197.      *
  198.      * @return void 
  199.      */
  200.     public function setWrappingicon()
  201.     {
  202.         $this->parameters['wrappingicon'= 1;
  203.     }
  204.  
  205.     /**
  206.      * Set the buynow to auction
  207.      *
  208.      * @return void 
  209.      */
  210.     public function setBuynow()
  211.     {
  212.         $this->parameters['buynow'= 1;
  213.     }
  214.  
  215.     /**
  216.      * Set the thumbnail to auction
  217.      *
  218.      * @param string $thumbnail to auction
  219.      *
  220.      * @return void 
  221.      */
  222.     public function setThumbnail($thumbnail = 1)
  223.     {
  224.         $this->parameters['thumbnail'$thumbnail;
  225.     }
  226.  
  227.     /**
  228.      * Set the attn to auction
  229.      *
  230.      * @param string $attn to auction
  231.      *
  232.      * @return void 
  233.      */
  234.     public function setAttn($attn = 1)
  235.     {
  236.         $this->parameters['attn'$attn;
  237.     }
  238.  
  239.     /**
  240.      * Set the gift_icon to auction
  241.      *
  242.      * @param string $gift_icon to auction
  243.      *
  244.      * @return void 
  245.      */
  246.     public function setGiftIcon($gift_icon)
  247.     {
  248.         $this->parameters['gift_icon'$gift_icon;
  249.     }
  250.  
  251.     /**
  252.      * Set the sort to auction
  253.      *
  254.      * @param string $sort to auction
  255.      *
  256.      * @return void 
  257.      */
  258.     public function setSort($sort)
  259.     {
  260.         $this->parameters['sort'$sort;
  261.     }
  262.  
  263.     /**
  264.      * Set the order to auction
  265.      *
  266.      * @param string $order to auction
  267.      *
  268.      * @return void 
  269.      */
  270.     public function setOrder($order)
  271.     {
  272.         $this->parameters['order'$order;
  273.     }
  274.  
  275.     /**
  276.      * Set the sellerID to auction
  277.      *
  278.      * @param string $seller to auction
  279.      *
  280.      * @return void 
  281.      */
  282.     public function setSellerID($seller)
  283.     {
  284.          $this->parameters['sellerID'$seller;
  285.     }
  286.  
  287.     /**
  288.      * Returns an element from the parameters
  289.      *
  290.      * @param string $name Name of the element
  291.      *
  292.      * @return string Value of the parameter idenfied by $name
  293.      */
  294.     protected function getParameter($name)
  295.     {
  296.         if (isset($this->parameters[$name])) {
  297.             return $this->parameters[$name];
  298.         }
  299.  
  300.         return '';
  301.     }
  302. }
  303. ?>

Documentation generated on Fri, 19 Sep 2008 21:30:04 -0400 by phpDocumentor 1.4.0. PEAR Logo Copyright © PHP Group 2004.