Below we have several examples that demonstrate how to use the USA Spending Client.
The following example executes a request for ALL the information available for the given search criteria for sub-award data — note that all requests to the USA Spending web services follow the same pattern.
The QueryBuilder takes an instance of the Spring Framework’s RestTemplate and the URL to the USA Spending endpoint and returns an instance of the class that pertains to that web service.
The QueryBuilder allows the developer to take advantage of method chaining so as to create a single query that includes all of the request parameters; the developer then executes the query by invoking the execute method.
QueryBuilder builder = new QueryBuilder( restTemplate, "https://www.usaspending.gov/"); Complete complete = builder .fsrs() .setFiscalYear("2009") .setStateCode("TX") .setDetail(Detail.complete) .setMaxRecords(1000) .doGet(Complete.class);
The integration tests provide a comprehensive set of examples to assist the developer — see here.
An advanced example is available at Bitbucket here.