Java wrapper for the Lob.com API. See the full Lob.com API Documentation. For best results, be sure that you're using the latest version of the Lob API and the latest version of the java wrapper.
lob-java uses Guava's ListenableFuture, the Ning AsyncHttpClient, and the Jackson serialization library to make robust, asynchronous integration with Lob's API easy.
Here's a general overview of the Lob services available, click through to read more.
First, you will need to first create an account at Lob.com and obtain your Test and Live API Keys.
Once you have created an account, you can access your API Keys from the Settings Panel.
Include the following in your pom.xml
for Maven:
<dependencies>
<dependency>
<groupId>com.lob</groupId>
<artifactId>lob-java</artifactId>
<version>3.2.0</version>
</dependency>
...
</dependencies>
We've provided examples in the lob-java-examples/
package that has examples of how to use the lob-java wrapper with some of our core endpoints.
- lob-java contains the actual client for interacting with Lob's API. It depends on:
- guava
- asynchttpclient
- netty
- joda-money
- joda-time
- jackson-annotations
- two jackson-databind packages
- lob-java-examples contains usage examples and is not intended to be consumed by your code.
To initialize the wrapper, create an instance of AsyncLobClient
as follows:
import com.lob.client.AsyncLobClient;
import com.lob.client.LobClient;
final LobClient client = AsyncLobClient.createDefault("yourApiKey");
You can customize your http client configuration by passing in an AsyncHttpClientConfiguration
:
import com.lob.client.AsyncLobClient;
import com.lob.client.LobClient;
final AsyncHttpClientConfiguration.Builder configBuilder = new AsyncHttpClientConfiguration.Builder();
// configuration...
final LobClient client = AsyncLobClient.create("yourApiKey", configBuilder.build());
You may optionally set an API version. This is useful for testing your code against new API versions before you upgrade.
Note that setting the API version only affects future instances of LobClient
s, so be sure to set it before creating your client.
import com.lob.client.AsyncLobClient;
import com.lob.client.LobClient;
Lob.setApiVersion("apiVersion");
final LobClient client = AsyncLobClient.createDefault("yourApiKey");
Please ensure any callbacks attached to the ListenableFuture
s returned from the LobClient
have a dedicated Executor
for their execution. Otherwise, the callbacks will be executed on internal I/O threads, adversely affecting performance.
We've provided various examples for you to try out here.
There are simple scripts to demonstrate how to create all the core Lob objects (checks, letters, postcards, etc.) As well as more complex examples that utilize other libraries and external files:
- Introduction
- Versioning
- Errors
- Rate Limiting
- Metadata
- Addresses
- Postcards API
- Letters API
- Checks API
- Area Mail API
- Resources
- Appendix
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Make sure the tests pass
- Open up coverage/index.html in your browser and add tests if required
- Create new Pull Request
You can run all tests with the command mvn test
in the main directory.
=======================
Copyright © 2013 Lob.com
Released under the MIT License, which can be found in the repository in LICENSE.txt
.