Example #1
0
 /**
  * Validate Api resource name and Api response code
  *
  * @param string $resource
  * @param Client $client
  * @param string $method
  * @throws ApiCriticalException
  */
 private function validateResponseCode($resource, Client $client, $method)
 {
     $error_key = $method == Client::METHOD_POST ? 'P/' : 'G/';
     $error_key .= $resource;
     if (!isset($this->error_codes[$error_key])) {
         throw new ApiCriticalException('Unknown api method: "' . $resource . '"');
     }
     $http_code = $client->getHttpCode();
     if (!array_key_exists($http_code, $this->http_codes)) {
         throw new ApiCriticalException('Unexpected api http code (' . $http_code . ') for resource "' . $method . '/' . $resource . '"');
     }
 }