public function apiCall($action, array $params) { if (null === $this->requestStrategy) { $this->setRequestStrategy(new \SentioneApi\Net\RequestStrategy\Curl()); } $metadata = array('host' => $this->apiUrl, 'authentication_username' => $this->username, 'authentication_password' => $this->password, 'authentication_strategy' => 'digest'); /* @var $response \SentioneApi\Net\Response */ $response = $this->requestStrategy->doApiRequest($action, $params, $metadata); if (200 == $response->getResponseCode()) { $metadata = array(); return ApiResponse::build($action, $params, $response->getResponseBody(), $metadata); } switch ($response->getResponseCode()) { case 401: throw new ApiException("Bad credentials", 401); default: throw new ApiException("Unknown error", $response->getResponseCode()); } }