Skip to content

Commit ca12820

Browse files
authored
Merge pull request #303 from holtkamp/patch-paged-filter
Patch paged filter
2 parents 942f676 + e75f864 commit ca12820

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Picqer/Financials/Moneybird/Actions/Filterable.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,24 @@ trait Filterable
1111

1212
/**
1313
* @param array $filters
14+
* @param int|null $perPage Number of results per page
15+
* @param int|null $page Page to load, typically starts at 1
1416
* @return mixed
1517
*
1618
* @throws \Picqer\Financials\Moneybird\Exceptions\ApiException
1719
*/
18-
public function filter(array $filters)
20+
public function filter(array $filters, $perPage = null, $page = null)
1921
{
2022
$filterList = [];
2123
foreach ($filters as $key => $value) {
2224
$filterList[] = $key . ':' . $value;
2325
}
2426

25-
$result = $this->connection()->get($this->getFilterEndpoint(), ['filter' => implode(',', $filterList)]);
27+
$result = $this->connection()->get($this->getFilterEndpoint(), [
28+
'filter' => implode(',', $filterList),
29+
'per_page' => $perPage,
30+
'page' => $page,
31+
], false);
2632

2733
return $this->collectionFromResult($result);
2834
}

0 commit comments

Comments
 (0)