Skip to content

theshrewedshrew/lob-java

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lob-java

Maven Central Build Status Coverage Status

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.

Table of Contents

Getting Started

Here's a general overview of the Lob services available, click through to read more.

Registration

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.

Installation

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>

Usage

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.

Project Structure

  • 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.

Initialization and Configuration

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 LobClients, 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");

Callbacks

Please ensure any callbacks attached to the ListenableFutures 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.

Examples

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:

API Documentation

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Make sure the tests pass
  6. Open up coverage/index.html in your browser and add tests if required
  7. Create new Pull Request

Testing

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.

About

Java Wrapper for Lob API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%