Class SortQueryBuilder
java.lang.Object
net.amcintosh.freshbooks.models.builders.SortQueryBuilder
- All Implemented Interfaces:
QueryBuilder
Builder for sorting
.list()
call responses by sortable fields.
FreshBooksClient freshBooksClient = new FreshBooksClient.FreshBooksClientBuilder("some_client_id")
.withAccessToken("some_token")
.build();
Clients clients = new Clients(freshBooksClient);
SortQueryBuilder sort = new SortQueryBuilder();
sort.ascending("invoice_date");
assertEquals("&sort=invoice_date_asc", sort.build(ResourceType.ACCOUNTING_LIKE));
ArrayList<QueryBuilder> builders = new ArrayList<QueryBuilder>();
builders.add(sort);
ClientList clientListResponse = clients.list(accountId, builders);
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a sort by the field in ascending order.build
(ResourceType resourceType) Build the query string parameters for the list call.void
descending
(String key) Add a sort by the field in descending order.toString()
-
Constructor Details
-
SortQueryBuilder
public SortQueryBuilder()
-
-
Method Details
-
ascending
Add a sort by the field in ascending order.- Parameters:
key
- The field for the resource list to be sorted by
-
descending
Add a sort by the field in descending order.- Parameters:
key
- The field for the resource list to be sorted by
-
toString
-
build
Build the query string parameters for the list call. As different FreshBooks resources use different structure for sort parameters, a resource type is required.- Specified by:
build
in interfaceQueryBuilder
- Parameters:
resourceType
- The resource type.- Returns:
- The composed query string parameters.
-