53 |
58 |
54 /** |
59 /** |
55 * Namespace for an item category |
60 * Namespace for an item category |
56 */ |
61 */ |
57 const ITEM_CATEGORY_NS = 'http://schemas.google.com/health/item'; |
62 const ITEM_CATEGORY_NS = 'http://schemas.google.com/health/item'; |
58 |
63 |
59 /** |
64 /** |
60 * The default URI for POST methods |
65 * Create Gdata_Query object |
61 * |
|
62 * @var string |
|
63 */ |
66 */ |
64 protected $_defaultFeedUri = self::HEALTH_PROFILE_FEED_URI; |
67 public function __construct($url = null) |
65 |
|
66 /** |
|
67 * Sets the digest parameter's value. |
|
68 * |
|
69 * @param string $value |
|
70 * @return Zend_Gdata_Health_Query Provides a fluent interface |
|
71 */ |
|
72 public function setDigest($value) |
|
73 { |
68 { |
74 if ($value !== null) { |
69 throw new Zend_Exception( |
75 $this->_params['digest'] = $value; |
70 'Google Health API has been discontinued by Google and was removed' |
76 } |
71 . ' from Zend Framework in 1.12.0. For more information see: ' |
77 return $this; |
72 . 'http://googleblog.blogspot.ca/2011/06/update-on-google-health-and-google.html' |
78 } |
73 ); |
79 |
|
80 /** |
|
81 * Returns the digest parameter's value. |
|
82 * |
|
83 * @return string The value set for the digest parameter. |
|
84 */ |
|
85 public function getDigest() |
|
86 { |
|
87 if (array_key_exists('digest', $this->_params)) { |
|
88 return $this->_params['digest']; |
|
89 } else { |
|
90 return null; |
|
91 } |
|
92 } |
|
93 |
|
94 /** |
|
95 * Setter for category queries. |
|
96 * |
|
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 |
|
101 */ |
|
102 public function setCategory($item, $name = null) |
|
103 { |
|
104 $this->_category = $item . |
|
105 ($name ? '/' . urlencode('{' . self::ITEM_CATEGORY_NS . '}' . $name) : null); |
|
106 return $this; |
|
107 } |
|
108 |
|
109 /** |
|
110 * Returns the query object's category. |
|
111 * |
|
112 * @return string id |
|
113 */ |
|
114 public function getCategory() |
|
115 { |
|
116 return $this->_category; |
|
117 } |
|
118 |
|
119 /** |
|
120 * Setter for the grouped parameter. |
|
121 * |
|
122 * @param string $value setting a count of results per group. |
|
123 * @return Zend_Gdata_Health_Query Provides a fluent interface |
|
124 */ |
|
125 public function setGrouped($value) |
|
126 { |
|
127 if ($value !== null) { |
|
128 $this->_params['grouped'] = $value; |
|
129 } |
|
130 return $this; |
|
131 } |
|
132 |
|
133 /** |
|
134 * Returns the value set for the grouped parameter. |
|
135 * |
|
136 * @return string grouped parameter. |
|
137 */ |
|
138 public function getGrouped() |
|
139 { |
|
140 if (array_key_exists('grouped', $this->_params)) { |
|
141 return $this->_params['grouped']; |
|
142 } else { |
|
143 return null; |
|
144 } |
|
145 } |
|
146 |
|
147 /** |
|
148 * Setter for the max-results-group parameter. |
|
149 * |
|
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 |
|
154 */ |
|
155 public function setMaxResultsGroup($value) |
|
156 { |
|
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'); |
|
163 } else { |
|
164 $this->_params['max-results-group'] = $value; |
|
165 } |
|
166 } |
|
167 return $this; |
|
168 } |
|
169 |
|
170 /** |
|
171 * Returns the value set for max-results-group. |
|
172 * |
|
173 * @return int Returns max-results-group parameter. |
|
174 */ |
|
175 public function getMaxResultsGroup() |
|
176 { |
|
177 if (array_key_exists('max-results-group', $this->_params)) { |
|
178 return $this->_params['max-results-group']; |
|
179 } else { |
|
180 return null; |
|
181 } |
|
182 } |
|
183 |
|
184 /** |
|
185 * Setter for the max-results-group parameter. |
|
186 * |
|
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 |
|
192 */ |
|
193 public function setMaxResultsInGroup($value) |
|
194 { |
|
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'); |
|
200 } else { |
|
201 $this->_params['max-results-in-group'] = $value; |
|
202 } |
|
203 } |
|
204 return $this; |
|
205 } |
|
206 |
|
207 /** |
|
208 * Returns the value set for max-results-in-group. |
|
209 * |
|
210 * @return int Returns max-results-in-group parameter. |
|
211 */ |
|
212 public function getMaxResultsInGroup() |
|
213 { |
|
214 if (array_key_exists('max-results-in-group', $this->_params)) { |
|
215 return $this->_params['max-results-in-group']; |
|
216 } else { |
|
217 return null; |
|
218 } |
|
219 } |
|
220 |
|
221 /** |
|
222 * Setter for the start-index-group parameter. |
|
223 * |
|
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 |
|
229 */ |
|
230 public function setStartIndexGroup($value) |
|
231 { |
|
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'); |
|
235 } else { |
|
236 $this->_params['start-index-group'] = $value; |
|
237 } |
|
238 return $this; |
|
239 } |
|
240 |
|
241 /** |
|
242 * Returns the value set for start-index-group. |
|
243 * |
|
244 * @return int Returns start-index-group parameter. |
|
245 */ |
|
246 public function getStartIndexGroup() |
|
247 { |
|
248 if (array_key_exists('start-index-group', $this->_params)) { |
|
249 return $this->_params['start-index-group']; |
|
250 } else { |
|
251 return null; |
|
252 } |
|
253 } |
|
254 |
|
255 /** |
|
256 * Setter for the start-index-in-group parameter. |
|
257 * |
|
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 |
|
261 */ |
|
262 public function setStartIndexInGroup($value) |
|
263 { |
|
264 if ($value !== null && $this->getGrouped() !== 'true') { |
|
265 throw new Zend_Gdata_App_InvalidArgumentException('start-index-in-group'); |
|
266 } else { |
|
267 $this->_params['start-index-in-group'] = $value; |
|
268 } |
|
269 return $this; |
|
270 } |
|
271 |
|
272 /** |
|
273 * Returns the value set for start-index-in-group. |
|
274 * |
|
275 * @return int Returns start-index-in-group parameter. |
|
276 */ |
|
277 public function getStartIndexInGroup() |
|
278 { |
|
279 if (array_key_exists('start-index-in-group', $this->_params)) { |
|
280 return $this->_params['start-index-in-group']; |
|
281 } else { |
|
282 return null; |
|
283 } |
|
284 } |
74 } |
285 } |
75 } |