Class IncludesQueryBuilder

java.lang.Object
net.amcintosh.freshbooks.models.builders.IncludesQueryBuilder
All Implemented Interfaces:
QueryBuilder

public class IncludesQueryBuilder extends Object implements QueryBuilder
Builder for including relationships, sub-resources, or additional data in the response. Can be passed to a .get() call, or to a .list() call.

     FreshBooksClient freshBooksClient = new FreshBooksClient.FreshBooksClientBuilder("some_client_id")
         .withAccessToken("some_token")
         .build();
     Clients clients = new Clients(freshBooksClient);

     IncludesQueryBuilder inc = new IncludesQueryBuilder();
     inc.includes("last_activity").includes("late_reminders");
     assertEquals("&includes[]=last_activity&includes[]=late_reminders", inc.build(ResourceType.ACCOUNTING_LIKE));

     Client clientResponse = clients.get(accountId, clientId, inc);

     ArrayList<QueryBuilder> builders = new ArrayList<QueryBuilder>();
     builders.add(inc);
     ClientList clientListResponse = clients.list(accountId, builders);
 
  • Constructor Details

    • IncludesQueryBuilder

      public IncludesQueryBuilder()
  • Method Details

    • include

      public IncludesQueryBuilder include(String key)
      Add an include key to the builder.
      Parameters:
      key - The key for the included field, sub-resource, etc.
      Returns:
      The IncludesQueryBuilder instance.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • build

      public String build(ResourceType resourceType)
      Build the query string parameters for the list or get call. As different FreshBooks resources use different structure for includes parameters, a resource type is required.
      Specified by:
      build in interface QueryBuilder
      Parameters:
      resourceType - The resource type.
      Returns:
      The composed query string parameters.