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
25 * @see Zend_Gdata_Query
27 require_once('Zend/Gdata/Query.php');
30 * Assists in constructing queries for Google Health
32 * @link http://code.google.com/apis/health
37 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
38 * @license http://framework.zend.com/license/new-bsd New BSD License
40 class Zend_Gdata_Health_Query extends Zend_Gdata_Query
43 * URI of a user's profile feed.
45 const HEALTH_PROFILE_FEED_URI =
46 'https://www.google.com/health/feeds/profile/default';
49 * URI of register (notices) feed.
51 const HEALTH_REGISTER_FEED_URI =
52 'https://www.google.com/health/feeds/register/default';
55 * Namespace for an item category
57 const ITEM_CATEGORY_NS = 'http://schemas.google.com/health/item';
60 * The default URI for POST methods
64 protected $_defaultFeedUri = self::HEALTH_PROFILE_FEED_URI;
67 * Sets the digest parameter's value.
69 * @param string $value
70 * @return Zend_Gdata_Health_Query Provides a fluent interface
72 public function setDigest($value)
74 if ($value !== null) {
75 $this->_params['digest'] = $value;
81 * Returns the digest parameter's value.
83 * @return string The value set for the digest parameter.
85 public function getDigest()
87 if (array_key_exists('digest', $this->_params)) {
88 return $this->_params['digest'];
95 * Setter for category queries.
97 * @param string $item A category to query.
98 * @param string $name (optional) A specific item to search a category for.
99 * An example would be 'Lipitor' if $item is set to 'medication'.
100 * @return Zend_Gdata_Health_Query Provides a fluent interface
102 public function setCategory($item, $name = null)
104 $this->_category = $item .
105 ($name ? '/' . urlencode('{' . self::ITEM_CATEGORY_NS . '}' . $name) : null);
110 * Returns the query object's category.
114 public function getCategory()
116 return $this->_category;
120 * Setter for the grouped parameter.
122 * @param string $value setting a count of results per group.
123 * @return Zend_Gdata_Health_Query Provides a fluent interface
125 public function setGrouped($value)
127 if ($value !== null) {
128 $this->_params['grouped'] = $value;
134 * Returns the value set for the grouped parameter.
136 * @return string grouped parameter.
138 public function getGrouped()
140 if (array_key_exists('grouped', $this->_params)) {
141 return $this->_params['grouped'];
148 * Setter for the max-results-group parameter.
150 * @param int $value Specifies the maximum number of groups to be
151 * retrieved. Must be an integer value greater than zero. This parameter
152 * is only valid if grouped=true.
153 * @return Zend_Gdata_Health_Query Provides a fluent interface
155 public function setMaxResultsGroup($value)
157 if ($value !== null) {
158 if ($value <= 0 || $this->getGrouped() !== 'true') {
159 require_once 'Zend/Gdata/App/InvalidArgumentException.php';
160 throw new Zend_Gdata_App_InvalidArgumentException(
161 'The max-results-group parameter must be set to a value
162 greater than 0 and can only be used if grouped=true');
164 $this->_params['max-results-group'] = $value;
171 * Returns the value set for max-results-group.
173 * @return int Returns max-results-group parameter.
175 public function getMaxResultsGroup()
177 if (array_key_exists('max-results-group', $this->_params)) {
178 return $this->_params['max-results-group'];
185 * Setter for the max-results-group parameter.
187 * @param int $value Specifies the maximum number of records to be
188 * retrieved from each group. The limits that you specify with this
189 * parameter apply to all groups. Must be an integer value greater than
190 * zero. This parameter is only valid if grouped=true.
191 * @return Zend_Gdata_Health_Query Provides a fluent interface
193 public function setMaxResultsInGroup($value)
195 if ($value !== null) {
196 if ($value <= 0 || $this->getGrouped() !== 'true') {
197 throw new Zend_Gdata_App_InvalidArgumentException(
198 'The max-results-in-group parameter must be set to a value
199 greater than 0 and can only be used if grouped=true');
201 $this->_params['max-results-in-group'] = $value;
208 * Returns the value set for max-results-in-group.
210 * @return int Returns max-results-in-group parameter.
212 public function getMaxResultsInGroup()
214 if (array_key_exists('max-results-in-group', $this->_params)) {
215 return $this->_params['max-results-in-group'];
222 * Setter for the start-index-group parameter.
224 * @param int $value Retrieves only items whose group ranking is at
225 * least start-index-group. This should be set to a 1-based index of the
226 * first group to be retrieved. The range is applied per category.
227 * This parameter is only valid if grouped=true.
228 * @return Zend_Gdata_Health_Query Provides a fluent interface
230 public function setStartIndexGroup($value)
232 if ($value !== null && $this->getGrouped() !== 'true') {
233 throw new Zend_Gdata_App_InvalidArgumentException(
234 'The start-index-group can only be used if grouped=true');
236 $this->_params['start-index-group'] = $value;
242 * Returns the value set for start-index-group.
244 * @return int Returns start-index-group parameter.
246 public function getStartIndexGroup()
248 if (array_key_exists('start-index-group', $this->_params)) {
249 return $this->_params['start-index-group'];
256 * Setter for the start-index-in-group parameter.
258 * @param int $value A 1-based index of the records to be retrieved from
259 * each group. This parameter is only valid if grouped=true.
260 * @return Zend_Gdata_Health_Query Provides a fluent interface
262 public function setStartIndexInGroup($value)
264 if ($value !== null && $this->getGrouped() !== 'true') {
265 throw new Zend_Gdata_App_InvalidArgumentException('start-index-in-group');
267 $this->_params['start-index-in-group'] = $value;
273 * Returns the value set for start-index-in-group.
275 * @return int Returns start-index-in-group parameter.
277 public function getStartIndexInGroup()
279 if (array_key_exists('start-index-in-group', $this->_params)) {
280 return $this->_params['start-index-in-group'];