public class Client
extends java.lang.Object
The Client class is the starting point for interaction with the Whitepages API, serving as the starting place for making requests and getting results.
The key steps for use of the Client are:
Query
, andFor example:
Client client = new Client("yourapikey");
PersonQuery personQuery = new PersonQuery("Rory", null, "Williams");
Response<Person> = client.findPeople(personQuery);
List<Person> results = Response.getResults();
for( Person p : results ) {
System.out.println(p.getBestName());
}
In production applications, it is typically preferable to instantiate a single Client instance per thread, repeatedly using it for sequential requests to the API.
Constructor and Description |
---|
Client(Config config)
Creates a Client instance with the given Config instance.
|
Client(java.lang.String apiKey)
Creates a Client instance configured with the given API Key.
|
Modifier and Type | Method and Description |
---|---|
Response<Business> |
findBusinesses(BusinessQuery query)
Executes the given query and returns the response.
|
Response<Location> |
findLocations(LocationQuery query)
Executes the given query and returns the response.
|
Response<Person> |
findPeople(PersonQuery query)
Executes the given query and returns the response.
|
Response<Phone> |
findPhones(PhoneQuery query)
Executes the given query and returns the response.
|
Config |
getConfig() |
public Client(java.lang.String apiKey)
apiKey
- Your Whitepages API key.Config
public Client(Config config)
Creates a Client instance with the given Config instance.
The Config instance is not duplicated, so alterations to it will affect all Client instances using it.
config
- The Config instance to use.public Config getConfig()
public Response<Person> findPeople(PersonQuery query) throws FindException
query
- The query to perform.FindException
- Thrown if an exception occurs before a Response object could be created.public Response<Business> findBusinesses(BusinessQuery query) throws FindException
query
- The query to perform.FindException
- Thrown if an exception occurs before a Response object could be created.public Response<Phone> findPhones(PhoneQuery query) throws FindException
query
- The query to perform.FindException
- Thrown if an exception occurs before a Response object could be created.public Response<Location> findLocations(LocationQuery query) throws FindException
query
- The query to perform.FindException
- Thrown if an exception occurs before a Response object could be created.