PageRenderTime 24ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/library/Service/DeveloperGarden/BaseUserService.php

https://github.com/kervin/kyzstudio
PHP | 399 lines | 168 code | 32 blank | 199 comment | 2 complexity | af64e0ce0b7d5d0b5076dc1c84697357 MD5 | raw file
  1. <?php
  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_Service
  17. * @subpackage DeveloperGarden
  18. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id: BaseUserService.php 20166 2010-01-09 19:00:17Z bkarwin $
  21. */
  22. /**
  23. * @see Zend_Service_DeveloperGarden_Client_ClientAbstract
  24. */
  25. #require_once 'Zend/Service/DeveloperGarden/Client/ClientAbstract.php';
  26. /**
  27. * @see Zend_Service_DeveloperGarden_Response_BaseUserService_GetQuotaInformationResponse
  28. */
  29. #require_once 'Zend/Service/DeveloperGarden/Response/BaseUserService/GetQuotaInformationResponse.php';
  30. /**
  31. * @see Zend_Service_DeveloperGarden_Response_BaseUserService_ChangeQuotaPoolResponse
  32. */
  33. #require_once 'Zend/Service/DeveloperGarden/Response/BaseUserService/ChangeQuotaPoolResponse.php';
  34. /**
  35. * @see Zend_Service_DeveloperGarden_Response_BaseUserService_GetAccountBalanceResponse
  36. */
  37. #require_once 'Zend/Service/DeveloperGarden/Response/BaseUserService/GetAccountBalanceResponse.php';
  38. /**
  39. * @see Zend_Service_DeveloperGarden_BaseUserService_AccountBalance
  40. */
  41. #require_once 'Zend/Service/DeveloperGarden/BaseUserService/AccountBalance.php';
  42. /**
  43. * @see Zend_Service_DeveloperGarden_Request_BaseUserService_GetQuotaInformation
  44. */
  45. #require_once 'Zend/Service/DeveloperGarden/Request/BaseUserService/GetQuotaInformation.php';
  46. /**
  47. * @see Zend_Service_DeveloperGarden_Request_BaseUserService_ChangeQuotaPool
  48. */
  49. #require_once 'Zend/Service/DeveloperGarden/Request/BaseUserService/ChangeQuotaPool.php';
  50. /**
  51. * @see Zend_Service_DeveloperGarden_Request_BaseUserService_GetAccountBalance
  52. */
  53. #require_once 'Zend/Service/DeveloperGarden/Request/BaseUserService/GetAccountBalance.php';
  54. /**
  55. * @category Zend
  56. * @package Zend_Service
  57. * @subpackage DeveloperGarden
  58. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  59. * @author Marco Kaiser
  60. * @license http://framework.zend.com/license/new-bsd New BSD License
  61. */
  62. class Zend_Service_DeveloperGarden_BaseUserService extends Zend_Service_DeveloperGarden_Client_ClientAbstract
  63. {
  64. /**
  65. * wsdl file
  66. *
  67. * @var string
  68. */
  69. protected $_wsdlFile = 'https://gateway.developer.telekom.com/p3gw-mod-odg-admin/services/ODGBaseUserService?wsdl';
  70. /**
  71. * wsdl file local
  72. *
  73. * @var string
  74. */
  75. protected $_wsdlFileLocal = 'Wsdl/ODGBaseUserService.wsdl';
  76. /**
  77. * Response, Request Classmapping
  78. *
  79. * @var array
  80. *
  81. */
  82. protected $_classMap = array(
  83. 'getQuotaInformationResponse' =>
  84. 'Zend_Service_DeveloperGarden_Response_BaseUserService_GetQuotaInformationResponse',
  85. 'changeQuotaPoolResponse' =>
  86. 'Zend_Service_DeveloperGarden_Response_BaseUserService_ChangeQuotaPoolResponse',
  87. 'getAccountBalanceResponse' =>
  88. 'Zend_Service_DeveloperGarden_Response_BaseUserService_GetAccountBalanceResponse',
  89. 'AccountBalance' =>
  90. 'Zend_Service_DeveloperGarden_BaseUserService_AccountBalance',
  91. );
  92. /**
  93. * array with all QuotaModuleIds
  94. *
  95. * @var array
  96. */
  97. protected $_moduleIds = array(
  98. 'SmsProduction' => 'SmsProduction',
  99. 'SmsSandbox' => 'SmsSandbox',
  100. 'VoiceCallProduction' => 'VoiceButlerProduction',
  101. 'VoiceCallSandbox' => 'VoiceButlerSandbox',
  102. 'ConferenceCallProduction' => 'CCSProduction',
  103. 'ConferenceCallSandbox' => 'CCSSandbox',
  104. 'LocalSearchProduction' => 'localsearchProduction',
  105. 'LocalSearchSandbox' => 'localsearchSandbox',
  106. 'IPLocationProduction' => 'IPLocationProduction',
  107. 'IPLocationSandbox' => 'IPLocationSandbox'
  108. );
  109. /**
  110. * returns an array with all possible ModuleIDs
  111. *
  112. * @return array
  113. */
  114. public function getModuleIds()
  115. {
  116. return $this->_moduleIds;
  117. }
  118. /**
  119. * checks the moduleId and throws exception if not valid
  120. *
  121. * @param string $moduleId
  122. * @throws Zend_Service_DeveloperGarden_Client_Exception
  123. * @return void
  124. */
  125. protected function _checkModuleId($moduleId)
  126. {
  127. if (!in_array($moduleId, $this->_moduleIds)) {
  128. #require_once 'Zend/Service/DeveloperGarden/Client/Exception.php';
  129. throw new Zend_Service_DeveloperGarden_Client_Exception('moduleId not valid');
  130. }
  131. }
  132. /**
  133. * returns the correct module string
  134. *
  135. * @param string $module
  136. * @param integer $environment
  137. * @return string
  138. */
  139. protected function _buildModuleString($module, $environment)
  140. {
  141. $moduleString = $module;
  142. switch($environment) {
  143. case self::ENV_PRODUCTION :
  144. $moduleString .= 'Production';
  145. break;
  146. case self::ENV_SANDBOX :
  147. $moduleString .= 'Sandbox';
  148. break;
  149. default:
  150. #require_once 'Zend/Service/DeveloperGarden/Client/Exception.php';
  151. throw new Zend_Service_DeveloperGarden_Client_Exception(
  152. 'Not a valid environment supplied.'
  153. );
  154. }
  155. if (!in_array($moduleString, $this->_moduleIds)) {
  156. #require_once 'Zend/Service/DeveloperGarden/Client/Exception.php';
  157. throw new Zend_Service_DeveloperGarden_Client_Exception(
  158. 'Not a valid module name supplied.'
  159. );
  160. }
  161. return $moduleString;
  162. }
  163. /**
  164. * returns the request object with the specific moduleId
  165. *
  166. * @param string $moduleId
  167. * @return Zend_Service_DeveloperGarden_Response_BaseUserService_GetQuotaInformationResponse
  168. */
  169. protected function _getRequestModule($moduleId)
  170. {
  171. return new Zend_Service_DeveloperGarden_Request_BaseUserService_GetQuotaInformation(
  172. $moduleId
  173. );
  174. }
  175. /**
  176. * returns the request object with the specific moduleId and new quotaMax value
  177. *
  178. * @param string $moduleId
  179. * @param integer $quotaMax
  180. * @return Zend_Service_DeveloperGarden_Response_BaseUserService_GetQuotaInformationResponse
  181. */
  182. protected function _getChangeRequestModule($moduleId, $quotaMax)
  183. {
  184. return new Zend_Service_DeveloperGarden_Request_BaseUserService_ChangeQuotaPool(
  185. $moduleId,
  186. $quotaMax
  187. );
  188. }
  189. /**
  190. * returns the Quota Information for SMS Service
  191. *
  192. * @param int $environment
  193. * @return Zend_Service_DeveloperGarden_Response_BaseUserService_GetQuotaInformationResponse
  194. */
  195. public function getSmsQuotaInformation($environment = self::ENV_PRODUCTION)
  196. {
  197. self::checkEnvironment($environment);
  198. $moduleId = $this->_buildModuleString('Sms', $environment);
  199. $request = $this->_getRequestModule($moduleId);
  200. return $this->getQuotaInformation($request);
  201. }
  202. /**
  203. * returns the Quota Information for VoiceCall Service
  204. *
  205. * @param int $environment
  206. * @return Zend_Service_DeveloperGarden_Response_BaseUserService_GetQuotaInformationResponse
  207. */
  208. public function getVoiceCallQuotaInformation($environment = self::ENV_PRODUCTION)
  209. {
  210. self::checkEnvironment($environment);
  211. $moduleId = $this->_buildModuleString('VoiceButler', $environment);
  212. $request = $this->_getRequestModule($moduleId);
  213. return $this->getQuotaInformation($request);
  214. }
  215. /**
  216. * returns the Quota Information for SMS ConferenceCall
  217. *
  218. * @param int $environment
  219. * @return Zend_Service_DeveloperGarden_Response_BaseUserService_GetQuotaInformationResponse
  220. */
  221. public function getConfernceCallQuotaInformation($environment = self::ENV_PRODUCTION)
  222. {
  223. self::checkEnvironment($environment);
  224. $moduleId = $this->_buildModuleString('CCS', $environment);
  225. $request = $this->_getRequestModule($moduleId);
  226. return $this->getQuotaInformation($request);
  227. }
  228. /**
  229. * returns the Quota Information for LocaleSearch Service
  230. *
  231. * @param int $environment
  232. * @return Zend_Service_DeveloperGarden_Response_BaseUserService_GetQuotaInformationResponse
  233. */
  234. public function getLocalSearchQuotaInformation($environment = self::ENV_PRODUCTION)
  235. {
  236. self::checkEnvironment($environment);
  237. $moduleId = $this->_buildModuleString('localsearch', $environment);
  238. $request = $this->_getRequestModule($moduleId);
  239. return $this->getQuotaInformation($request);
  240. }
  241. /**
  242. * returns the Quota Information for IPLocation Service
  243. *
  244. * @param int $environment
  245. * @return Zend_Service_DeveloperGarden_Response_BaseUserService_GetQuotaInformationResponse
  246. */
  247. public function getIPLocationQuotaInformation($environment = self::ENV_PRODUCTION)
  248. {
  249. self::checkEnvironment($environment);
  250. $moduleId = $this->_buildModuleString('IPLocation', $environment);
  251. $request = $this->_getRequestModule($moduleId);
  252. return $this->getQuotaInformation($request);
  253. }
  254. /**
  255. * returns the quota information
  256. *
  257. * @param Zend_Service_DeveloperGarden_Request_BaseUserService $request
  258. * @return Zend_Service_DeveloperGarden_Response_BaseUserService_GetQuotaInformationResponse
  259. */
  260. public function getQuotaInformation(
  261. Zend_Service_DeveloperGarden_Request_BaseUserService_GetQuotaInformation $request
  262. ) {
  263. $this->_checkModuleId($request->getModuleId());
  264. return $this->getSoapClient()
  265. ->getQuotaInformation($request)
  266. ->parse();
  267. }
  268. /**
  269. * sets new user quota for the sms service
  270. *
  271. * @param integer $quotaMax
  272. * @param integer $environment
  273. * @return Zend_Service_DeveloperGarden_Response_BaseUserService_ChangeQuotaPoolResponse
  274. */
  275. public function changeSmsQuotaPool($quotaMax = 0, $environment = self::ENV_PRODUCTION)
  276. {
  277. self::checkEnvironment($environment);
  278. $moduleId = $this->_buildModuleString('Sms', $environment);
  279. $request = $this->_getChangeRequestModule($moduleId, $quotaMax);
  280. return $this->changeQuotaPool($request);
  281. }
  282. /**
  283. * sets new user quota for the voice call service
  284. *
  285. * @param integer $quotaMax
  286. * @param integer $environment
  287. * @return Zend_Service_DeveloperGarden_Response_BaseUserService_ChangeQuotaPoolResponse
  288. */
  289. public function changeVoiceCallQuotaPool($quotaMax = 0, $environment = self::ENV_PRODUCTION)
  290. {
  291. self::checkEnvironment($environment);
  292. $moduleId = $this->_buildModuleString('VoiceButler', $environment);
  293. $request = $this->_getChangeRequestModule($moduleId, $quotaMax);
  294. return $this->changeQuotaPool($request);
  295. }
  296. /**
  297. * sets new user quota for the IPLocation service
  298. *
  299. * @param integer $quotaMax
  300. * @param integer $environment
  301. * @return Zend_Service_DeveloperGarden_Response_BaseUserService_ChangeQuotaPoolResponse
  302. */
  303. public function changeIPLocationQuotaPool($quotaMax = 0, $environment = self::ENV_PRODUCTION)
  304. {
  305. self::checkEnvironment($environment);
  306. $moduleId = $this->_buildModuleString('IPLocation', $environment);
  307. $request = $this->_getChangeRequestModule($moduleId, $quotaMax);
  308. return $this->changeQuotaPool($request);
  309. }
  310. /**
  311. * sets new user quota for the Conference Call service
  312. *
  313. * @param integer $quotaMax
  314. * @param integer $environment
  315. * @return Zend_Service_DeveloperGarden_Response_BaseUserService_ChangeQuotaPoolResponse
  316. */
  317. public function changeConferenceCallQuotaPool($quotaMax = 0, $environment = self::ENV_PRODUCTION)
  318. {
  319. self::checkEnvironment($environment);
  320. $moduleId = $this->_buildModuleString('CCS', $environment);
  321. $request = $this->_getChangeRequestModule($moduleId, $quotaMax);
  322. return $this->changeQuotaPool($request);
  323. }
  324. /**
  325. * sets new user quota for the Local Search service
  326. *
  327. * @param integer $quotaMax
  328. * @param integer $environment
  329. * @return Zend_Service_DeveloperGarden_Response_BaseUserService_ChangeQuotaPoolResponse
  330. */
  331. public function changeLocalSearchQuotaPool($quotaMax = 0, $environment = self::ENV_PRODUCTION)
  332. {
  333. self::checkEnvironment($environment);
  334. $moduleId = $this->_buildModuleString('localsearch', $environment);
  335. $request = $this->_getChangeRequestModule($moduleId, $quotaMax);
  336. return $this->changeQuotaPool($request);
  337. }
  338. /**
  339. * set new quota values for the defined module
  340. *
  341. * @param Zend_Service_DeveloperGarden_Request_BaseUserService_ChangeQuotaPool $request
  342. * @return Zend_Service_DeveloperGarden_Response_BaseUserService_ChangeQuotaPoolResponse
  343. */
  344. public function changeQuotaPool(
  345. Zend_Service_DeveloperGarden_Request_BaseUserService_ChangeQuotaPool $request
  346. ) {
  347. $this->_checkModuleId($request->getModuleId());
  348. return $this->getSoapClient()
  349. ->changeQuotaPool($request)
  350. ->parse();
  351. }
  352. /**
  353. * get the result for a list of accounts
  354. *
  355. * @param array $accounts
  356. * @return Zend_Service_DeveloperGarden_Response_BaseUserService_GetAccountBalanceResponse
  357. */
  358. public function getAccountBalance(array $accounts = array())
  359. {
  360. $request = new Zend_Service_DeveloperGarden_Request_BaseUserService_GetAccountBalance(
  361. $accounts
  362. );
  363. return $this->getSoapClient()
  364. ->getAccountBalance($request)
  365. ->parse();
  366. }
  367. }