8 * This source file is subject to the new BSD license that is bundled
9 * with this package in the file LICENSE.txt.
10 * It is also available through the world-wide-web at this URL:
11 * http://framework.zend.com/license/new-bsd
12 * If you did not receive a copy of the license and are unable to
13 * obtain it through the world-wide-web, please send an email
14 * to license@zend.com so we can send you a copy immediately.
19 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
20 * @license http://framework.zend.com/license/new-bsd New BSD License
27 require_once 'Zend/Gdata.php';
30 * @see Zend_Gdata_DublinCore
32 require_once 'Zend/Gdata/DublinCore.php';
35 * @see Zend_Gdata_Books_CollectionEntry
37 require_once 'Zend/Gdata/Books/CollectionEntry.php';
40 * @see Zend_Gdata_Books_CollectionFeed
42 require_once 'Zend/Gdata/Books/CollectionFeed.php';
45 * @see Zend_Gdata_Books_VolumeEntry
47 require_once 'Zend/Gdata/Books/VolumeEntry.php';
50 * @see Zend_Gdata_Books_VolumeFeed
52 require_once 'Zend/Gdata/Books/VolumeFeed.php';
55 * Service class for interacting with the Books service
60 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
61 * @license http://framework.zend.com/license/new-bsd New BSD License
63 class Zend_Gdata_Books extends Zend_Gdata
65 const VOLUME_FEED_URI = 'http://books.google.com/books/feeds/volumes';
66 const MY_LIBRARY_FEED_URI = 'http://books.google.com/books/feeds/users/me/collections/library/volumes';
67 const MY_ANNOTATION_FEED_URI = 'http://books.google.com/books/feeds/users/me/volumes';
68 const AUTH_SERVICE_NAME = 'print';
71 * Namespaces used for Zend_Gdata_Books
75 public static $namespaces = array(
76 array('gbs', 'http://schemas.google.com/books/2008', 1, 0),
77 array('dc', 'http://purl.org/dc/terms', 1, 0)
81 * Create Zend_Gdata_Books object
83 * @param Zend_Http_Client $client (optional) The HTTP client to use when
84 * when communicating with the Google servers.
85 * @param string $applicationId The identity of the app in the form of Company-AppName-Version
87 public function __construct($client = null, $applicationId = 'MyCompany-MyApp-1.0')
89 $this->registerPackage('Zend_Gdata_Books');
90 $this->registerPackage('Zend_Gdata_Books_Extension');
91 parent::__construct($client, $applicationId);
92 $this->_httpClient->setParameterPost('service', self::AUTH_SERVICE_NAME);
96 * Retrieves a feed of volumes.
98 * @param Zend_Gdata_Query|string|null $location (optional) The URL to
99 * query or a Zend_Gdata_Query object from which a URL can be
101 * @return Zend_Gdata_Books_VolumeFeed The feed of volumes found at the
104 public function getVolumeFeed($location = null)
106 if ($location == null) {
107 $uri = self::VOLUME_FEED_URI;
108 } else if ($location instanceof Zend_Gdata_Query) {
109 $uri = $location->getQueryUrl();
113 return parent::getFeed($uri, 'Zend_Gdata_Books_VolumeFeed');
117 * Retrieves a specific volume entry.
119 * @param string|null $volumeId The volumeId of interest.
120 * @param Zend_Gdata_Query|string|null $location (optional) The URL to
121 * query or a Zend_Gdata_Query object from which a URL can be
123 * @return Zend_Gdata_Books_VolumeEntry The feed of volumes found at the
126 public function getVolumeEntry($volumeId = null, $location = null)
128 if ($volumeId !== null) {
129 $uri = self::VOLUME_FEED_URI . "/" . $volumeId;
130 } else if ($location instanceof Zend_Gdata_Query) {
131 $uri = $location->getQueryUrl();
135 return parent::getEntry($uri, 'Zend_Gdata_Books_VolumeEntry');
139 * Retrieves a feed of volumes, by default the User library feed.
141 * @param Zend_Gdata_Query|string|null $location (optional) The URL to
143 * @return Zend_Gdata_Books_VolumeFeed The feed of volumes found at the
146 public function getUserLibraryFeed($location = null)
148 if ($location == null) {
149 $uri = self::MY_LIBRARY_FEED_URI;
153 return parent::getFeed($uri, 'Zend_Gdata_Books_VolumeFeed');
157 * Retrieves a feed of volumes, by default the User annotation feed
159 * @param Zend_Gdata_Query|string|null $location (optional) The URL to
161 * @return Zend_Gdata_Books_VolumeFeed The feed of volumes found at the
164 public function getUserAnnotationFeed($location = null)
166 if ($location == null) {
167 $uri = self::MY_ANNOTATION_FEED_URI;
171 return parent::getFeed($uri, 'Zend_Gdata_Books_VolumeFeed');
175 * Insert a Volume / Annotation
177 * @param Zend_Gdata_Books_VolumeEntry $entry
178 * @param Zend_Gdata_Query|string|null $location (optional) The URL to
180 * @return Zend_Gdata_Books_VolumeEntry The inserted volume entry.
182 public function insertVolume($entry, $location = null)
184 if ($location == null) {
185 $uri = self::MY_LIBRARY_FEED_URI;
189 return parent::insertEntry(
190 $entry, $uri, 'Zend_Gdata_Books_VolumeEntry');
196 * @param Zend_Gdata_Books_VolumeEntry $entry
199 public function deleteVolume($entry)