From bfb94ea7ae98bd34ad864092caaff18df880b35b Mon Sep 17 00:00:00 2001 From: Andrew McIntosh Date: Sun, 1 Oct 2023 09:15:54 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Add=20sort=20documentation=20to?= =?UTF-8?q?=20README?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 514c972..9b914e1 100644 --- a/README.md +++ b/README.md @@ -437,7 +437,30 @@ echo $client->outstanding_balance->amount; // null, new client has no balance ##### Sorting -TODO: +To sort the results of a list call by supported fields (see the documentation for that resource) a +`SortBuilder` can be used. + +```php +use amcintosh\FreshBooks\Builder\SortBuilder; + +$sort = new SortBuilder(); +$sort->ascending("invoice_date"); + +$invoices = $freshBooksClient->invoices()->list($accountId, builders: [$sort]); +``` + +to sort by the invoice date in ascending order, or: + +```php +use amcintosh\FreshBooks\Builder\SortBuilder; + +$sort = new SortBuilder(); +$sort->descending("invoice_date"); + +$invoices = $freshBooksClient->invoices()->list($accountId, builders: [$sort]); +``` + +for descending order. ## Development