/** * @return mixed * @throws ilCloudException */ protected function request() { $exodCurl = new exodCurl(); $exodCurl->setUrl($this->getRessource()); $exodCurl->addHeader("Authorization: Bearer " . $this->getAccessToken()); switch ($this->getRequestType()) { case self::REQ_TYPE_GET: $exodCurl->get(); break; case self::REQ_TYPE_PUT: $exodCurl->setPutFilePath($this->getRequestFilePath()); $exodCurl->put(); break; case self::REQ_TYPE_DELETE: $exodCurl->addHeader('if-match: ' . $this->getRequestEtag()); $exodCurl->delete(); break; case self::REQ_TYPE_POST: $exodCurl->post(); break; } $this->setResponseBody($exodCurl->getResponseBody()); $this->setResponseMimeType($exodCurl->getResponseMimeType()); $this->setResponseContentSize($exodCurl->getResponseContentSize()); $this->setResponseStatus($exodCurl->getResponseStatus()); $resp = json_decode($exodCurl->getResponseBody()); if ($this->getResponseStatus() == 401) { if (self::DEBUG) { echo '<pre>' . print_r($this, 1) . '</pre>'; exit; // } throw new ilCloudException(ilCloudException::AUTHENTICATION_FAILED, 'token invalid'); } if ($resp->error) { if (self::DEBUG) { throw new ilCloudException(-1, print_r($resp, true)); } else { throw new ilCloudException(-1, $resp->error->message); } } }