summaryrefslogtreecommitdiffstats
path: root/lib/ocs/result.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ocs/result.php')
-rw-r--r--lib/ocs/result.php48
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');
}