source: trunk/www.guidonia.net/wp/wp-content/plugins/webtv/Drivers/Zend/Gdata/Health/Query.php@ 44

Last change on this file since 44 was 44, checked in by luciano, 14 years ago
File size: 8.4 KB
Line 
1<?php
2
3/**
4 * Zend Framework
5 *
6 * LICENSE
7 *
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.
15 *
16 * @category Zend
17 * @package Zend_Gdata
18 * @subpackage Health
19 * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
20 * @license http://framework.zend.com/license/new-bsd New BSD License
21 */
22
23/**
24 * @see Zend_Gdata_Query
25 */
26require_once('Zend/Gdata/Query.php');
27
28/**
29 * Assists in constructing queries for Google Health
30 *
31 * @link http://code.google.com/apis/health
32 *
33 * @category Zend
34 * @package Zend_Gdata
35 * @subpackage Health
36 * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
37 * @license http://framework.zend.com/license/new-bsd New BSD License
38 */
39class Zend_Gdata_Health_Query extends Zend_Gdata_Query
40{
41 /**
42 * URI of a user's profile feed.
43 */
44 const HEALTH_PROFILE_FEED_URI =
45 'https://www.google.com/health/feeds/profile/default';
46
47 /**
48 * URI of register (notices) feed.
49 */
50 const HEALTH_REGISTER_FEED_URI =
51 'https://www.google.com/health/feeds/register/default';
52
53 /**
54 * Namespace for an item category
55 */
56 const ITEM_CATEGORY_NS = 'http://schemas.google.com/health/item';
57
58 /**
59 * The default URI for POST methods
60 *
61 * @var string
62 */
63 protected $_defaultFeedUri = self::HEALTH_PROFILE_FEED_URI;
64
65 /**
66 * Sets the digest parameter's value.
67 *
68 * @param string $value
69 * @return Zend_Gdata_Health_Query Provides a fluent interface
70 */
71 public function setDigest($value)
72 {
73 if ($value !== null) {
74 $this->_params['digest'] = $value;
75 }
76 return $this;
77 }
78
79 /**
80 * Returns the digest parameter's value.
81 *
82 * @return string The value set for the digest parameter.
83 */
84 public function getDigest()
85 {
86 if (array_key_exists('digest', $this->_params)) {
87 return $this->_params['digest'];
88 } else {
89 return null;
90 }
91 }
92
93 /**
94 * Setter for category queries.
95 *
96 * @param string $item A category to query.
97 * @param string $name (optional) A specific item to search a category for.
98 * An example would be 'Lipitor' if $item is set to 'medication'.
99 * @return Zend_Gdata_Health_Query Provides a fluent interface
100 */
101 public function setCategory($item, $name = null)
102 {
103 $this->_category = $item .
104 ($name ? '/' . urlencode('{' . self::ITEM_CATEGORY_NS . '}' . $name) : null);
105 return $this;
106 }
107
108 /**
109 * Returns the query object's category.
110 *
111 * @return string id
112 */
113 public function getCategory()
114 {
115 return $this->_category;
116 }
117
118 /**
119 * Setter for the grouped parameter.
120 *
121 * @param string $value setting a count of results per group.
122 * @return Zend_Gdata_Health_Query Provides a fluent interface
123 */
124 public function setGrouped($value)
125 {
126 if ($value !== null) {
127 $this->_params['grouped'] = $value;
128 }
129 return $this;
130 }
131
132 /**
133 * Returns the value set for the grouped parameter.
134 *
135 * @return string grouped parameter.
136 */
137 public function getGrouped()
138 {
139 if (array_key_exists('grouped', $this->_params)) {
140 return $this->_params['grouped'];
141 } else {
142 return null;
143 }
144 }
145
146 /**
147 * Setter for the max-results-group parameter.
148 *
149 * @param int $value Specifies the maximum number of groups to be
150 * retrieved. Must be an integer value greater than zero. This parameter
151 * is only valid if grouped=true.
152 * @return Zend_Gdata_Health_Query Provides a fluent interface
153 */
154 public function setMaxResultsGroup($value)
155 {
156 if ($value !== null) {
157 if ($value <= 0 || $this->getGrouped() !== 'true') {
158 require_once 'Zend/Gdata/App/InvalidArgumentException.php';
159 throw new Zend_Gdata_App_InvalidArgumentException(
160 'The max-results-group parameter must be set to a value
161 greater than 0 and can only be used if grouped=true');
162 } else {
163 $this->_params['max-results-group'] = $value;
164 }
165 }
166 return $this;
167 }
168
169 /**
170 * Returns the value set for max-results-group.
171 *
172 * @return int Returns max-results-group parameter.
173 */
174 public function getMaxResultsGroup()
175 {
176 if (array_key_exists('max-results-group', $this->_params)) {
177 return $this->_params['max-results-group'];
178 } else {
179 return null;
180 }
181 }
182
183 /**
184 * Setter for the max-results-group parameter.
185 *
186 * @param int $value Specifies the maximum number of records to be
187 * retrieved from each group. The limits that you specify with this
188 * parameter apply to all groups. Must be an integer value greater than
189 * zero. This parameter is only valid if grouped=true.
190 * @return Zend_Gdata_Health_Query Provides a fluent interface
191 */
192 public function setMaxResultsInGroup($value)
193 {
194 if ($value !== null) {
195 if ($value <= 0 || $this->getGrouped() !== 'true') {
196 throw new Zend_Gdata_App_InvalidArgumentException(
197 'The max-results-in-group parameter must be set to a value
198 greater than 0 and can only be used if grouped=true');
199 } else {
200 $this->_params['max-results-in-group'] = $value;
201 }
202 }
203 return $this;
204 }
205
206 /**
207 * Returns the value set for max-results-in-group.
208 *
209 * @return int Returns max-results-in-group parameter.
210 */
211 public function getMaxResultsInGroup()
212 {
213 if (array_key_exists('max-results-in-group', $this->_params)) {
214 return $this->_params['max-results-in-group'];
215 } else {
216 return null;
217 }
218 }
219
220 /**
221 * Setter for the start-index-group parameter.
222 *
223 * @param int $value Retrieves only items whose group ranking is at
224 * least start-index-group. This should be set to a 1-based index of the
225 * first group to be retrieved. The range is applied per category.
226 * This parameter is only valid if grouped=true.
227 * @return Zend_Gdata_Health_Query Provides a fluent interface
228 */
229 public function setStartIndexGroup($value)
230 {
231 if ($value !== null && $this->getGrouped() !== 'true') {
232 throw new Zend_Gdata_App_InvalidArgumentException(
233 'The start-index-group can only be used if grouped=true');
234 } else {
235 $this->_params['start-index-group'] = $value;
236 }
237 return $this;
238 }
239
240 /**
241 * Returns the value set for start-index-group.
242 *
243 * @return int Returns start-index-group parameter.
244 */
245 public function getStartIndexGroup()
246 {
247 if (array_key_exists('start-index-group', $this->_params)) {
248 return $this->_params['start-index-group'];
249 } else {
250 return null;
251 }
252 }
253
254 /**
255 * Setter for the start-index-in-group parameter.
256 *
257 * @param int $value A 1-based index of the records to be retrieved from
258 * each group. This parameter is only valid if grouped=true.
259 * @return Zend_Gdata_Health_Query Provides a fluent interface
260 */
261 public function setStartIndexInGroup($value)
262 {
263 if ($value !== null && $this->getGrouped() !== 'true') {
264 throw new Zend_Gdata_App_InvalidArgumentException('start-index-in-group');
265 } else {
266 $this->_params['start-index-in-group'] = $value;
267 }
268 return $this;
269 }
270
271 /**
272 * Returns the value set for start-index-in-group.
273 *
274 * @return int Returns start-index-in-group parameter.
275 */
276 public function getStartIndexInGroup()
277 {
278 if (array_key_exists('start-index-in-group', $this->_params)) {
279 return $this->_params['start-index-in-group'];
280 } else {
281 return null;
282 }
283 }
284}
Note: See TracBrowser for help on using the repository browser.