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