From ec7434f089258131bcb8674d93b27dcc30f739d5 Mon Sep 17 00:00:00 2001 From: Martz Date: Wed, 29 Mar 2023 02:30:28 +0200 Subject: [PATCH] add logic for get list --- src/Collection.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Collection.php b/src/Collection.php index d9d1894..85f92de 100644 --- a/src/Collection.php +++ b/src/Collection.php @@ -32,6 +32,20 @@ class Collection $this->collection = $collection; } + /** + * @param int $start + * @param int $end + * @param array $queryParams + * @return array + */ + public function getList(int $start = 1, int $end = 50, array $queryParams = []): array + { + $getParams = !empty($queryParams) ? http_build_query($queryParams) : ""; + $response = $this->doRequest($this->url . "/api/collections/" . $this->collection . "/records?" . $getParams, 'GET'); + + return json_decode($response, JSON_FORCE_OBJECT); + } + /** * @param int $batch * @param array $queryParams @@ -39,6 +53,7 @@ class Collection */ public function getFullList(int $batch = 200, array $queryParams = []): array { + $queryParams = [... $queryParams, ['perPage' => $batch]]; $getParams = !empty($queryParams) ? http_build_query($queryParams) : ""; $response = $this->doRequest($this->url . "/api/collections/" . $this->collection . "/records?" . $getParams, 'GET');