diff options
author | Tom Needham <needham.thomas@gmail.com> | 2013-01-25 12:48:59 +0000 |
---|---|---|
committer | Tom Needham <needham.thomas@gmail.com> | 2013-01-25 12:48:59 +0000 |
commit | 934735043bd130db1dc854f444a076e6e8ef89d3 (patch) | |
tree | d737f55185358a97d98ccd3a38049f9d187b18e1 /lib/ocs | |
parent | 1dac2ba496a0054e9d5383a6babe7401dd2a260c (diff) | |
download | nextcloud-server-934735043bd130db1dc854f444a076e6e8ef89d3.tar.gz nextcloud-server-934735043bd130db1dc854f444a076e6e8ef89d3.zip |
API: Remove api response structure from OC_OCS_Result, handle multiple registered methods for api calls
Diffstat (limited to 'lib/ocs')
-rw-r--r-- | lib/ocs/result.php | 48 |
1 files changed, 35 insertions, 13 deletions
diff --git a/lib/ocs/result.php b/lib/ocs/result.php index 65b2067fc3f..8ab378d79c5 100644 --- a/lib/ocs/result.php +++ b/lib/ocs/result.php @@ -49,26 +49,48 @@ class OC_OCS_Result{ public function setItemsPerPage(int $items) { $this->perPage = $items; } - + + /** + * get the status code + * @return int + */ + public function getStatusCode() { + return $this->statusCode; + } + /** - * returns the data associated with the api result + * get the meta data for the result * @return array */ - public function getResult() { - $return = array(); - $return['meta'] = array(); - $return['meta']['status'] = ($this->statusCode === 100) ? 'ok' : 'failure'; - $return['meta']['statuscode'] = $this->statusCode; - $return['meta']['message'] = $this->message; + public function getMeta() { + $meta = array(); + $meta['status'] = ($this->statusCode === 100) ? 'ok' : 'failure'; + $meta['statuscode'] = $this->statusCode; + $meta['message'] = $this->message; if(isset($this->items)) { - $return['meta']['totalitems'] = $this->items; + $meta['totalitems'] = $this->items; } if(isset($this->perPage)) { - $return['meta']['itemsperpage'] = $this->perPage; + $meta['itemsperpage'] = $this->perPage; } - $return['data'] = $this->data; - // Return the result data. - return $return; + return $meta; + + } + + /** + * get the result data + * @return array|string|int + */ + public function getData() { + return $this->data; + } + + /** + * return bool if the method succedded + * @return bool + */ + public function succeeded() { + return (substr($this->statusCode, 0, 1) === '1'); } |