Skip to content

Commit 40db424

Browse files
author
Cerlin
committed
Added functionality to query fields, limit, offset
1 parent b2cbf4b commit 40db424

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/Box/Services/Folders/FolderService.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,33 @@ public function create($folder_name, $parent_folder_id = 0)
7575
/**
7676
* Method to get items inside a folder. Same info can be found inside `getFolderInfo` method as well.
7777
* @param $folder_id integer Id of the folder for which the items has to be listed.
78+
* @param $fields array of fields which has to be included in response
79+
* @param $limit integer Variable to limit the response items
80+
* @param $offset integer Variable to offset the response items
7881
* @throws \InvalidArgumentException
7982
* @return \GuzzleHttp\Psr7\Response
8083
*/
81-
public function getFolderItems($folder_id = 0)
84+
public function getFolderItems($folder_id = 0, $fields = [], $limit = 100, $offset = 0)
8285
{
8386
Assert::integerish($folder_id, "The folder id must be an integer. Got: %s");
87+
Assert::integerish($limit, "The limit must be an integer. Got: %s");
88+
Assert::integerish($offset, "The offset must be an integer. Got: %s");
89+
90+
$query_fields = "?fields=";
91+
92+
foreach ($fields as $field) {
93+
if (trim($field)) {
94+
$query_fields = $query_fields . $field . ",";
95+
}
96+
}
97+
98+
$query_fields .= rtrim($query_fields, ',');
99+
$query_fields .= "&limit=" . $limit;
100+
$query_fields .= "&offset=" . $offset;
84101

85102
return $this->guzzle_client->request(
86103
'GET',
87-
BAP::BASE_FOLDER_URL . BAP::URL_SEPARATOR . $folder_id . BAP::URL_SEPARATOR . "items",
104+
BAP::BASE_FOLDER_URL . BAP::URL_SEPARATOR . $folder_id . BAP::URL_SEPARATOR . "items" . $query_fields,
88105
[
89106
'headers' => [
90107
"Authorization" => "Bearer " . $this->app_auth->getTokenInfo()->access_token

0 commit comments

Comments
 (0)