示例#1
0
 /**
  *
  * @throws Zend_Json_Exception
  * @param  string  $sResponse
  * @param  string  $format
  * @return Sitec_Rest_Response
  */
 public function doResponse($sResponse, $format)
 {
     if ('xml' == $format) {
         try {
             return DatatypeAbstractFerryXML::createObjectFromFerryXml($sResponse);
         } catch (\Zend_Json_Exception $e) {
             throw new \SitecRESA\Exception\IO("La réponse n'est pas au format attendu : {$sResponse}");
         }
     } else {
         try {
             $result = Zend_Json::decode($sResponse);
             if ($this->isAssociativeArray($result)) {
                 return DatatypeAbstract::createObjectFromArray($this, $result);
             } else {
                 $aoResults = array();
                 foreach ($result as $resultPiece) {
                     $aoResults[] = DatatypeAbstract::createObjectFromArray($this, $resultPiece);
                 }
                 return $aoResults;
             }
         } catch (\Zend_Json_Exception $e) {
             throw new \SitecRESA\Exception\IO("La réponse n'est pas au format attendu : {$sResponse}");
         }
     }
 }
示例#2
0
 /**
  *
  * @throws Zend_Json_Exception
  * @param  string  $sResponse
  * @return Sitec_Rest_Response
  */
 public function doResponse($sResponse)
 {
     $apiClient = new \SitecRESA\WS\Client(array("apiKey" => $this->sApiKey, "secretKey" => $this->sSecretKey, "url" => $this->client->getBaseUrl()));
     try {
         $result = Zend_Json::decode($sResponse);
         if ($this->isAssociativeArray($result)) {
             return DatatypeAbstract::createObjectFromArray($apiClient, $result);
         } else {
             $aoResults = array();
             foreach ($result as $resultPiece) {
                 $aoResults[] = DatatypeAbstract::createObjectFromArray($apiClient, $resultPiece);
             }
             return $aoResults;
         }
     } catch (\Zend_Json_Exception $e) {
         throw new \SitecRESA\Exception\IO("La réponse n'est pas au format attendu : {$sResponse}");
     }
 }