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