/lib/ZendGdata-1.8.4PL1/library/Zend/Gdata/Health/Query.php

https://github.com/jung921/MIT-Mobile-Web · PHP · 284 lines · 129 code · 20 blank · 135 comment · 28 complexity · 68a1d36ee8edfffee6a80a21e9d1a5ca MD5 · raw file

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