Item.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http:framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Service
  17. * @subpackage Ebay
  18. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http:framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id: Item.php 22824 2010-08-09 18:59:54Z renanbr $
  21. */
  22. /**
  23. * @see Zend_Service_Ebay_Finding_Abstract
  24. */
  25. require_once 'Zend/Service/Ebay/Finding/Abstract.php';
  26. /**
  27. * @category Zend
  28. * @package Zend_Service
  29. * @subpackage Ebay
  30. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  31. * @license http:framework.zend.com/license/new-bsd New BSD License
  32. * @uses Zend_Service_Ebay_Finding_Abstract
  33. */
  34. class Zend_Service_Ebay_Finding_Search_Item extends Zend_Service_Ebay_Finding_Abstract
  35. {
  36. /**
  37. * If true, the seller requires immediate payment for the item. If false (or
  38. * not specified), immediate payment is not requested. Buyers must have a
  39. * PayPal account to purchase items that require immediate payment.
  40. *
  41. * A seller can choose to require immediate payment for Fixed Price and Buy
  42. * It Now listings, including eBay Stores Inventory listings. If a Buy It
  43. * Now item ends as an auction (that is, if the Buy It Now option is removed
  44. * due to bids being placed on the listing), the immediate payment
  45. * requirement does not apply.
  46. *
  47. * @var boolean
  48. */
  49. public $autoPay;
  50. /**
  51. * A unique identification number assigned by eBay to registered nonprofit
  52. * charity organizations.
  53. *
  54. * @var integer
  55. */
  56. public $charityId;
  57. /**
  58. * Two-letter ISO 3166 country code to indicate the country where the item
  59. * is located.
  60. *
  61. * @link http://www.iso.org/iso/country_codes/iso_3166_code_lists/english_country_names_and_code_elements.htm
  62. * @var string
  63. */
  64. public $country;
  65. /**
  66. * The distance that the item is from the buyer, calculated usin
  67. * buyerPostalCode.
  68. *
  69. * The unit for distance varies by site, and is either miles or kilometers.
  70. * If the country whose site you are searching uses kilometers to measure
  71. * distance (for example, India/EBAY-IN), the unit is kilometers. If the
  72. * site is either the US or UK, the distance unit is miles.
  73. *
  74. * This value is only returned for distance-based searches. You must
  75. * specify a buyerPostalCode and either sort by Distance, or use a
  76. * combination of the MaxDistance LocalSearch itemFilters.
  77. *
  78. * @var float
  79. */
  80. public $distance;
  81. /**
  82. * URL for the Gallery Plus image.
  83. *
  84. * The size of Gallery Plus images (up to 400 x 400 pixels) is bigger than
  85. * the size of standard gallery images. In site search results, you can view
  86. * the Gallery Plus image by hovering over or clicking the Enlarge link or
  87. * magifying glass icon. The image uses one of the following graphics
  88. * formats: JPEG, BMP, TIFF, or GIF. This field is only returned when the
  89. * seller has opted for the Gallery Plus option for the given item.
  90. *
  91. * @var string[]
  92. */
  93. public $galleryPlusPictureURL;
  94. /**
  95. * URL for the Gallery thumbnail image.
  96. *
  97. * The image must be provided in one of the following graphics formats:
  98. * JPEG, BMP, TIF, or GIF. Returned only if the seller chose to show a
  99. * gallery image.
  100. *
  101. * @var string
  102. */
  103. public $galleryURL;
  104. /**
  105. * The identifier for the site on which the item is listed.
  106. *
  107. * Returns a Global ID, which is a unique identifier that specifies the
  108. * combination of the site, language, and territory. In other eBay APIs
  109. * (such as the Shopping API), this value is know as the site ID.
  110. *
  111. * @link http://developer.ebay.com/DevZone/finding/CallRef/Enums/GlobalIdList.html
  112. * @var string
  113. */
  114. public $globalId;
  115. /**
  116. * The ID that uniquely identifies the item listing.
  117. *
  118. * eBay generates this ID when an item is listed. ID values are unique
  119. * across all eBay sites.
  120. *
  121. * @var string
  122. */
  123. public $itemId;
  124. /**
  125. * The format type of the listing, such as online auction, fixed price, or
  126. * advertisement.
  127. *
  128. * @var Zend_Service_Ebay_Finding_ListingInfo
  129. */
  130. public $listingInfo;
  131. /**
  132. * Physical location of the item, as specified by the seller.
  133. *
  134. * This gives a general indication from where the item will be shipped (or
  135. * delivered).
  136. *
  137. * @var string
  138. */
  139. public $location;
  140. /**
  141. * Identifies the payment method (or methods) the seller will accept for the
  142. * item (such as PayPal).
  143. *
  144. * Payment methods are not applicable to eBay Real Estate advertisement
  145. * listings or other Classified Ad listing formats.
  146. *
  147. * @link http://developer.ebay.com/DevZone/shopping/docs/CallRef/types/BuyerPaymentMethodCodeType.html
  148. * @var string[]
  149. */
  150. public $paymentMethod;
  151. /**
  152. * The postal code where the listed item is located.
  153. *
  154. * This field is returned only if a postal code has been specified by the
  155. * seller. eBay proximity and local search behavior can use the combination
  156. * of buyerPostalCode and postalCode values.
  157. *
  158. * @var string
  159. */
  160. public $postalCode;
  161. /**
  162. * Details about the first (or only) category in which the item is listed.
  163. *
  164. * Note that items can be listed in more than a single category.
  165. *
  166. * @var Zend_Service_Ebay_Finding_Category
  167. */
  168. public $primaryCategory;
  169. /**
  170. * Unique identifier for the eBay catalog product with which the item was
  171. * listed.
  172. *
  173. * An eBay catalog product consists of pre-filled Item Specifics, additional
  174. * descriptive information, plus a stock photo (if available). These product
  175. * details are used to pre-fill item information, which is used to describe
  176. * the item and can also help surface the item in searches.
  177. *
  178. * eBay supports the following types of product ID types: ISBN, UPC, EAN,
  179. * and ReferenceID (ePID, also known as an eBay Product Reference ID).
  180. * ReferenceID values are returned when available. A UPC, ISBN, or EAN
  181. * product identifier will be returned only when a ReferenceID is not
  182. * available.
  183. *
  184. * This productId value can be used as input with findItemsByProduct to
  185. * retrieve items that were listed with the specified eBay catalog product.
  186. *
  187. * This field is only returned when a product was used to list the item.
  188. *
  189. * @var string
  190. */
  191. public $productId;
  192. /**
  193. * Details about the second category in which the item is listed.
  194. *
  195. * This element is not returned if the seller did not specify a secondary
  196. * category.
  197. *
  198. * @var Zend_Service_Ebay_Finding_Category
  199. */
  200. public $secondaryCategory;
  201. /**
  202. * Information about the item's seller.
  203. *
  204. * Only returned if SellerInfo is specified in the outputSelector field in
  205. * the request.
  206. *
  207. * @var Zend_Service_Ebay_Finding_SellerInfo
  208. */
  209. public $sellerInfo;
  210. /**
  211. * Specifies the item's selling status with regards to eBay's processing
  212. * workflow.
  213. *
  214. * @var Zend_Service_Ebay_Finding_SellingStatus
  215. */
  216. public $sellingStatus;
  217. /**
  218. * Container for data about a listing's shipping details.
  219. *
  220. * @var Zend_Service_Ebay_Finding_ShippingInfo
  221. */
  222. public $shippingInfo;
  223. /**
  224. * Information about the eBay store in which the item is listed.
  225. *
  226. * Only returned if the item is listed in a store and StoreInfo is specified
  227. * in the outputSelector field in the request.
  228. *
  229. * @var Zend_Service_Ebay_Finding_Storefront
  230. */
  231. public $storeInfo;
  232. /**
  233. * Subtitle of the item.
  234. *
  235. * Only returned if the seller included a subtitle for the listing.
  236. *
  237. * @var string
  238. */
  239. public $subtitle;
  240. /**
  241. * Name of the item as it appears in the listing title, or in search and
  242. * browse results.
  243. *
  244. * @var string
  245. */
  246. public $title;
  247. /**
  248. * The URL to view this specific listing on eBay.
  249. *
  250. * The returned URL is optimized to support natural search. That is, the URL
  251. * is designed to make items on eBay easier to find via popular internet
  252. * search engines. The URL includes the item title along with other
  253. * optimizations. To note, "?" (question mark) optimizes to "_W0QQ", "&"
  254. * (ampersand) optimizes to "QQ", and "=" (equals sign) optimizes to "Z".
  255. *
  256. * Do not modify the returned URLs in your application queries (for example,
  257. * eBay won't recognize the URL if you change QQ to &). In the Sandbox
  258. * environment (and on the Hong Kong site), the data returned in this field
  259. * is a standard ViewItem URL rather than the ViewItemURL for natural
  260. * search.
  261. *
  262. * @var string
  263. */
  264. public $viewItemURL;
  265. /**
  266. * @return void
  267. */
  268. protected function _init()
  269. {
  270. parent::_init();
  271. $ns = Zend_Service_Ebay_Finding::XMLNS_FINDING;
  272. $this->autoPay = $this->_query(".//$ns:autoPay[1]", 'boolean');
  273. $this->charityId = $this->_query(".//$ns:charityId[1]", 'integer');
  274. $this->country = $this->_query(".//$ns:country[1]", 'string');
  275. $this->distance = $this->_query(".//$ns:distance[1]", 'float');
  276. $this->galleryPlusPictureURL = $this->_query(".//$ns:galleryPlusPictureURL", 'string', true);
  277. $this->galleryURL = $this->_query(".//$ns:galleryURL[1]", 'string');
  278. $this->globalId = $this->_query(".//$ns:globalId[1]", 'string');
  279. $this->itemId = $this->_query(".//$ns:itemId[1]", 'string');
  280. $this->location = $this->_query(".//$ns:location[1]", 'string');
  281. $this->paymentMethod = $this->_query(".//$ns:paymentMethod", 'string', true);
  282. $this->postalCode = $this->_query(".//$ns:postalCode[1]", 'string');
  283. $this->productId = $this->_query(".//$ns:productId[1]", 'string');
  284. $this->subtitle = $this->_query(".//$ns:subtitle[1]", 'string');
  285. $this->title = $this->_query(".//$ns:title[1]", 'string');
  286. $this->viewItemURL = $this->_query(".//$ns:viewItemURL[1]", 'string');
  287. $this->_attributes['distance'] = array(
  288. 'unit' => $this->_query(".//$ns:distance[1]/@unit[1]", 'string')
  289. );
  290. $this->_attributes['productId'] = array(
  291. 'type' => $this->_query(".//$ns:productId[1]/@type[1]", 'string')
  292. );
  293. $node = $this->_xPath->query(".//$ns:listingInfo[1]", $this->_dom)->item(0);
  294. if ($node) {
  295. /**
  296. * @see Zend_Service_Ebay_Finding_ListingInfo
  297. */
  298. require_once 'Zend/Service/Ebay/Finding/ListingInfo.php';
  299. $this->listingInfo = new Zend_Service_Ebay_Finding_ListingInfo($node);
  300. }
  301. $node = $this->_xPath->query(".//$ns:primaryCategory[1]", $this->_dom)->item(0);
  302. if ($node) {
  303. /**
  304. * @see Zend_Service_Ebay_Finding_Category
  305. */
  306. require_once 'Zend/Service/Ebay/Finding/Category.php';
  307. $this->primaryCategory = new Zend_Service_Ebay_Finding_Category($node);
  308. }
  309. $node = $this->_xPath->query(".//$ns:secondaryCategory[1]", $this->_dom)->item(0);
  310. if ($node) {
  311. /**
  312. * @see Zend_Service_Ebay_Finding_Category
  313. */
  314. require_once 'Zend/Service/Ebay/Finding/Category.php';
  315. $this->secondaryCategory = new Zend_Service_Ebay_Finding_Category($node);
  316. }
  317. $node = $this->_xPath->query(".//$ns:sellerInfo[1]", $this->_dom)->item(0);
  318. if ($node) {
  319. /**
  320. * @see Zend_Service_Ebay_Finding_SellerInfo
  321. */
  322. require_once 'Zend/Service/Ebay/Finding/SellerInfo.php';
  323. $this->sellerInfo = new Zend_Service_Ebay_Finding_SellerInfo($node);
  324. }
  325. $node = $this->_xPath->query(".//$ns:sellingStatus[1]", $this->_dom)->item(0);
  326. if ($node) {
  327. /**
  328. * @see Zend_Service_Ebay_Finding_SellingStatus
  329. */
  330. require_once 'Zend/Service/Ebay/Finding/SellingStatus.php';
  331. $this->sellingStatus = new Zend_Service_Ebay_Finding_SellingStatus($node);
  332. }
  333. $node = $this->_xPath->query("./$ns:shippingInfo", $this->_dom)->item(0);
  334. if ($node) {
  335. /**
  336. * @see Zend_Service_Ebay_Finding_ShippingInfo
  337. */
  338. require_once 'Zend/Service/Ebay/Finding/ShippingInfo.php';
  339. $this->shippingInfo = new Zend_Service_Ebay_Finding_ShippingInfo($node);
  340. }
  341. $node = $this->_xPath->query(".//$ns:storeInfo[1]", $this->_dom)->item(0);
  342. if ($node) {
  343. /**
  344. * @see Zend_Service_Ebay_Finding_Storefront
  345. */
  346. require_once 'Zend/Service/Ebay/Finding/Storefront.php';
  347. $this->storeInfo = new Zend_Service_Ebay_Finding_Storefront($node);
  348. }
  349. }
  350. /**
  351. * @param Zend_Service_Ebay_Finding $proxy
  352. * @param Zend_Config|array $options
  353. * @return Zend_Service_Ebay_Finding_Response_Items
  354. */
  355. public function findItemsByProduct(Zend_Service_Ebay_Finding $proxy, $options = null)
  356. {
  357. $type = $this->attributes('productId', 'type');
  358. return $proxy->findItemsByProduct($this->productId, $type, $options);
  359. }
  360. }