コード例 #1
0
ファイル: Api.php プロジェクト: Rodrifer/candyclub
 /**
  * Executes an API request that have at least the following information:
  *
  * - method: string method if the SOAP function
  * - data: data container for the SOAP function
  *
  * @param Object $request
  * @return stdClass
  */
 public function execute(Bronto_Object $request)
 {
     $tries = 0;
     $maxTries = $this->_options->getRetries();
     $method = $request->getMethod();
     $data = $request->getData();
     if ($data instanceof Bronto_Object) {
         $data = $data->toArray();
     }
     do {
         try {
             if (!$this->isAuthenticated()) {
                 $this->login();
             }
             return $this->getSoapClient()->{$method}($data);
         } catch (Exception $e) {
             $tries++;
             $this->_lastRequest = $request;
             $this->_lastException = new Bronto_Api_Exception($e->getMessage(), $e->getCode(), $e, $tries, $request);
             $this->_options->safeError()->filter(array($this, 'handleRetry'))->orElse(array($this, 'handleFallThrough'));
         }
     } while ($tries < $maxTries);
     // It should never reach here, but we'll safely terminate
     throw new Bronto_Api_Exception("Max attempts have been reached.");
 }