@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | protected function request($method, $url, array $body = [], array $query = [], array $headers = []) { |
| 45 | 45 | try { |
| 46 | - $response = json_decode(parent::request($method, 'ocs/v2.php/' . $url, $body, $query, $headers), true); |
|
| 46 | + $response = json_decode(parent::request($method, 'ocs/v2.php/'.$url, $body, $query, $headers), true); |
|
| 47 | 47 | } catch (ClientException $e) { |
| 48 | 48 | if ($e->getResponse()->getStatusCode() === 404) { |
| 49 | 49 | throw new NotFoundException(); |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | throw new NotFoundException(); |
| 64 | 64 | } |
| 65 | 65 | if ($response['ocs']['meta']['status'] !== 'ok') { |
| 66 | - throw new \Exception('Unknown ocs error ' . $response['ocs']['meta']['message']); |
|
| 66 | + throw new \Exception('Unknown ocs error '.$response['ocs']['meta']['message']); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | return $response['ocs']['data']; |
@@ -78,13 +78,13 @@ discard block |
||
| 78 | 78 | private function checkResponseArray(array $data, $type, array $keys) { |
| 79 | 79 | foreach ($keys as $key) { |
| 80 | 80 | if (!array_key_exists($key, $data)) { |
| 81 | - throw new \Exception('Invalid ' . $type . ' response, expected field ' . $key . ' not found'); |
|
| 81 | + throw new \Exception('Invalid '.$type.' response, expected field '.$key.' not found'); |
|
| 82 | 82 | } |
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | public function getUser($userId) { |
| 87 | - $result = $this->request('get', 'cloud/users/' . $userId); |
|
| 87 | + $result = $this->request('get', 'cloud/users/'.$userId); |
|
| 88 | 88 | $this->checkResponseArray($result, 'user', User::EXPECTED_KEYS); |
| 89 | 89 | return new User($result); |
| 90 | 90 | } |
@@ -31,70 +31,70 @@ |
||
| 31 | 31 | use OCP\Remote\Api\IUserApi; |
| 32 | 32 | |
| 33 | 33 | class OCS extends ApiBase implements ICapabilitiesApi, IUserApi { |
| 34 | - /** |
|
| 35 | - * @param string $method |
|
| 36 | - * @param string $url |
|
| 37 | - * @param array $body |
|
| 38 | - * @param array $query |
|
| 39 | - * @param array $headers |
|
| 40 | - * @return array |
|
| 41 | - * @throws ForbiddenException |
|
| 42 | - * @throws NotFoundException |
|
| 43 | - * @throws \Exception |
|
| 44 | - */ |
|
| 45 | - protected function request($method, $url, array $body = [], array $query = [], array $headers = []) { |
|
| 46 | - try { |
|
| 47 | - $response = json_decode(parent::request($method, 'ocs/v2.php/' . $url, $body, $query, $headers), true); |
|
| 48 | - } catch (ClientException $e) { |
|
| 49 | - if ($e->getResponse()->getStatusCode() === 404) { |
|
| 50 | - throw new NotFoundException(); |
|
| 51 | - } elseif ($e->getResponse()->getStatusCode() === 403 || $e->getResponse()->getStatusCode() === 401) { |
|
| 52 | - throw new ForbiddenException(); |
|
| 53 | - } else { |
|
| 54 | - throw $e; |
|
| 55 | - } |
|
| 56 | - } |
|
| 57 | - if (!isset($response['ocs']) || !isset($response['ocs']['meta'])) { |
|
| 58 | - throw new \Exception('Invalid ocs response'); |
|
| 59 | - } |
|
| 60 | - if ($response['ocs']['meta']['statuscode'] === API::RESPOND_UNAUTHORISED) { |
|
| 61 | - throw new ForbiddenException(); |
|
| 62 | - } |
|
| 63 | - if ($response['ocs']['meta']['statuscode'] === API::RESPOND_NOT_FOUND) { |
|
| 64 | - throw new NotFoundException(); |
|
| 65 | - } |
|
| 66 | - if ($response['ocs']['meta']['status'] !== 'ok') { |
|
| 67 | - throw new \Exception('Unknown ocs error ' . $response['ocs']['meta']['message']); |
|
| 68 | - } |
|
| 34 | + /** |
|
| 35 | + * @param string $method |
|
| 36 | + * @param string $url |
|
| 37 | + * @param array $body |
|
| 38 | + * @param array $query |
|
| 39 | + * @param array $headers |
|
| 40 | + * @return array |
|
| 41 | + * @throws ForbiddenException |
|
| 42 | + * @throws NotFoundException |
|
| 43 | + * @throws \Exception |
|
| 44 | + */ |
|
| 45 | + protected function request($method, $url, array $body = [], array $query = [], array $headers = []) { |
|
| 46 | + try { |
|
| 47 | + $response = json_decode(parent::request($method, 'ocs/v2.php/' . $url, $body, $query, $headers), true); |
|
| 48 | + } catch (ClientException $e) { |
|
| 49 | + if ($e->getResponse()->getStatusCode() === 404) { |
|
| 50 | + throw new NotFoundException(); |
|
| 51 | + } elseif ($e->getResponse()->getStatusCode() === 403 || $e->getResponse()->getStatusCode() === 401) { |
|
| 52 | + throw new ForbiddenException(); |
|
| 53 | + } else { |
|
| 54 | + throw $e; |
|
| 55 | + } |
|
| 56 | + } |
|
| 57 | + if (!isset($response['ocs']) || !isset($response['ocs']['meta'])) { |
|
| 58 | + throw new \Exception('Invalid ocs response'); |
|
| 59 | + } |
|
| 60 | + if ($response['ocs']['meta']['statuscode'] === API::RESPOND_UNAUTHORISED) { |
|
| 61 | + throw new ForbiddenException(); |
|
| 62 | + } |
|
| 63 | + if ($response['ocs']['meta']['statuscode'] === API::RESPOND_NOT_FOUND) { |
|
| 64 | + throw new NotFoundException(); |
|
| 65 | + } |
|
| 66 | + if ($response['ocs']['meta']['status'] !== 'ok') { |
|
| 67 | + throw new \Exception('Unknown ocs error ' . $response['ocs']['meta']['message']); |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - return $response['ocs']['data']; |
|
| 71 | - } |
|
| 70 | + return $response['ocs']['data']; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * @param array $data |
|
| 75 | - * @param string $type |
|
| 76 | - * @param string[] $keys |
|
| 77 | - * @throws \Exception |
|
| 78 | - */ |
|
| 79 | - private function checkResponseArray(array $data, $type, array $keys) { |
|
| 80 | - foreach ($keys as $key) { |
|
| 81 | - if (!array_key_exists($key, $data)) { |
|
| 82 | - throw new \Exception('Invalid ' . $type . ' response, expected field ' . $key . ' not found'); |
|
| 83 | - } |
|
| 84 | - } |
|
| 85 | - } |
|
| 73 | + /** |
|
| 74 | + * @param array $data |
|
| 75 | + * @param string $type |
|
| 76 | + * @param string[] $keys |
|
| 77 | + * @throws \Exception |
|
| 78 | + */ |
|
| 79 | + private function checkResponseArray(array $data, $type, array $keys) { |
|
| 80 | + foreach ($keys as $key) { |
|
| 81 | + if (!array_key_exists($key, $data)) { |
|
| 82 | + throw new \Exception('Invalid ' . $type . ' response, expected field ' . $key . ' not found'); |
|
| 83 | + } |
|
| 84 | + } |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - public function getUser($userId) { |
|
| 88 | - $result = $this->request('get', 'cloud/users/' . $userId); |
|
| 89 | - $this->checkResponseArray($result, 'user', User::EXPECTED_KEYS); |
|
| 90 | - return new User($result); |
|
| 91 | - } |
|
| 87 | + public function getUser($userId) { |
|
| 88 | + $result = $this->request('get', 'cloud/users/' . $userId); |
|
| 89 | + $this->checkResponseArray($result, 'user', User::EXPECTED_KEYS); |
|
| 90 | + return new User($result); |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - /** |
|
| 94 | - * @return array The capabilities in the form of [$appId => [$capability => $value]] |
|
| 95 | - */ |
|
| 96 | - public function getCapabilities() { |
|
| 97 | - $result = $this->request('get', 'cloud/capabilities'); |
|
| 98 | - return $result['capabilities']; |
|
| 99 | - } |
|
| 93 | + /** |
|
| 94 | + * @return array The capabilities in the form of [$appId => [$capability => $value]] |
|
| 95 | + */ |
|
| 96 | + public function getCapabilities() { |
|
| 97 | + $result = $this->request('get', 'cloud/capabilities'); |
|
| 98 | + return $result['capabilities']; |
|
| 99 | + } |
|
| 100 | 100 | } |
@@ -2,6 +2,6 @@ |
||
| 2 | 2 | |
| 3 | 3 | // autoload.php @generated by Composer |
| 4 | 4 | |
| 5 | -require_once __DIR__ . '/composer/autoload_real.php'; |
|
| 5 | +require_once __DIR__.'/composer/autoload_real.php'; |
|
| 6 | 6 | |
| 7 | 7 | return ComposerAutoloaderInitAdminAudit::getLoader(); |
@@ -2,6 +2,6 @@ |
||
| 2 | 2 | |
| 3 | 3 | // autoload.php @generated by Composer |
| 4 | 4 | |
| 5 | -require_once __DIR__ . '/composer/autoload_real.php'; |
|
| 5 | +require_once __DIR__.'/composer/autoload_real.php'; |
|
| 6 | 6 | |
| 7 | 7 | return ComposerAutoloaderInitDAV::getLoader(); |
@@ -2,6 +2,6 @@ |
||
| 2 | 2 | |
| 3 | 3 | // autoload.php @generated by Composer |
| 4 | 4 | |
| 5 | -require_once __DIR__ . '/composer/autoload_real.php'; |
|
| 5 | +require_once __DIR__.'/composer/autoload_real.php'; |
|
| 6 | 6 | |
| 7 | 7 | return ComposerAutoloaderInitComments::getLoader(); |
@@ -6,5 +6,5 @@ |
||
| 6 | 6 | $baseDir = $vendorDir; |
| 7 | 7 | |
| 8 | 8 | return array( |
| 9 | - 'OCA\\Files\\' => array($baseDir . '/../lib'), |
|
| 9 | + 'OCA\\Files\\' => array($baseDir.'/../lib'), |
|
| 10 | 10 | ); |
@@ -2,6 +2,6 @@ |
||
| 2 | 2 | |
| 3 | 3 | // autoload.php @generated by Composer |
| 4 | 4 | |
| 5 | -require_once __DIR__ . '/composer/autoload_real.php'; |
|
| 5 | +require_once __DIR__.'/composer/autoload_real.php'; |
|
| 6 | 6 | |
| 7 | 7 | return ComposerAutoloaderInitFiles::getLoader(); |
@@ -6,5 +6,5 @@ |
||
| 6 | 6 | $baseDir = $vendorDir; |
| 7 | 7 | |
| 8 | 8 | return array( |
| 9 | - 'OCA\\Encryption\\' => array($baseDir . '/../lib'), |
|
| 9 | + 'OCA\\Encryption\\' => array($baseDir.'/../lib'), |
|
| 10 | 10 | ); |
@@ -2,6 +2,6 @@ |
||
| 2 | 2 | |
| 3 | 3 | // autoload.php @generated by Composer |
| 4 | 4 | |
| 5 | -require_once __DIR__ . '/composer/autoload_real.php'; |
|
| 5 | +require_once __DIR__.'/composer/autoload_real.php'; |
|
| 6 | 6 | |
| 7 | 7 | return ComposerAutoloaderInitEncryption::getLoader(); |
@@ -2,6 +2,6 @@ |
||
| 2 | 2 | |
| 3 | 3 | // autoload.php @generated by Composer |
| 4 | 4 | |
| 5 | -require_once __DIR__ . '/composer/autoload_real.php'; |
|
| 5 | +require_once __DIR__.'/composer/autoload_real.php'; |
|
| 6 | 6 | |
| 7 | 7 | return ComposerAutoloaderInitFiles_Sharing::getLoader(); |