diff --git a/classes/ilios.php b/classes/ilios.php index 77ead53..87021b1 100644 --- a/classes/ilios.php +++ b/classes/ilios.php @@ -45,6 +45,11 @@ class ilios { */ const API_BASE_PATH = '/api/v3/'; + /** + * @var int The maximum number of filtering request parameters in a given API request. + */ + const MAX_FILTER_PARAMS = 250; + /** * @var string The API access token. */ @@ -335,6 +340,16 @@ public function get( array $filterby = [], array $sortby = [], ): array { + // If needed, recursively call this function with smaller batch sizes of filtering parameters. + if (count($filterby) > self::MAX_FILTER_PARAMS) { + $batches = array_chunk($filterby, self::MAX_FILTER_PARAMS); + $results = []; + foreach ($batches as $batch) { + $result = $this->get($path, $key, $batch, $sortby); + $results = array_merge($results, $result); + } + return $results; + } $this->validate_access_token($this->accesstoken); $options = ['headers' => ['X-JWT-Authorization' => 'Token ' . $this->accesstoken]];