Class PaginationQueryBuilder
java.lang.Object
net.amcintosh.freshbooks.models.builders.PaginationQueryBuilder
- All Implemented Interfaces:
QueryBuilder
Builder for making paginated list queries.
Has two attributes,
page and perPage. When a PaginationQueryBuilder is passed
to a .list() call, the call will fetch only the perPage number of results and will
fetch the results offset by page.
FreshBooksClient freshBooksClient = new FreshBooksClient.FreshBooksClientBuilder("some_client_id")
.withAccessToken("some_token")
.build();
Clients clients = new Clients(freshBooksClient);
PaginationQueryBuilder p = new PaginationQueryBuilder(2, 4);
assertEquals("&page=2&per_page=4", p.build(ResourceType.ACCOUNTING_LIKE));
ArrayList<QueryBuilder> builders = new ArrayList<QueryBuilder>();
builders.add(p);
ClientList clientListResponse = clients.list(accountId, builders);
-
Constructor Summary
ConstructorsConstructorDescriptionCreate an uninitialized pagination query builder (page=1, perPage=100).PaginationQueryBuilder(int page, int perPage) Create an pagination query builder. -
Method Summary
Modifier and TypeMethodDescriptionbuild(ResourceType resourceType) Build the query string parameters for the list call.page(int page) Set the page number to query.perPage(int perPage) Set the number of results per page.toString()
-
Constructor Details
-
PaginationQueryBuilder
public PaginationQueryBuilder()Create an uninitialized pagination query builder (page=1, perPage=100). -
PaginationQueryBuilder
public PaginationQueryBuilder(int page, int perPage) Create an pagination query builder.- Parameters:
page- Page of results to returnperPage- Number of results to return
-
-
Method Details
-
page
Set the page number to query.- Parameters:
page- Page of results to return- Returns:
- The PaginationQueryBuilder instance.
-
perPage
Set the number of results per page.- Parameters:
perPage- Number of results to return- Returns:
- The PaginationQueryBuilder instance.
-
toString
-
build
Build the query string parameters for the list call. While all FreshBooks resources use the same structure of page paramters, a resource type is still required for interface consistency.- Specified by:
buildin interfaceQueryBuilder- Parameters:
resourceType- The resource type.- Returns:
- The composed query string parameters.
-