Elixir Library for Lob API
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config
lib/lob
test
.credo.exs
.dialyzer_ignore
.gitignore
.travis.yml
CHANGELOG.md
CONTRIBUTING.md
LICENSE.txt
README.md
coveralls.json
mix.exs
mix.lock

README.md

lob_elixir

Build Status Hex.pm Coverage Status Libraries.io for releases

Elixir library for Lob API.

Installation

The package can be installed by adding lob_elixir to your list of dependencies in mix.exs:

def deps do
  [
    {:lob_elixir, "~> 1.0.0"}
  ]
end

Getting Started

This library implements the Lob API. Please read through the official API Documentation to get a complete sense of what to expect from each endpoint.

Registration

The library requires a valid Lob API key to work properly. To acquire an API key, first create an account at Lob.com. Once you have created an account, you can access your API Keys from the Settings Panel.

API Key Configuration

The library will by default refer to the :api_key config when making authenticated requests. If that is not present, it will look for the LOB_API_KEY environment variable.

# Configuring an API key with configs
config :lob_elixir,
  api_key: "your_api_key"

Similarly, the library allows users to optionally configure the API version through the :api_version config. If that is not present, it will look for the LOB_API_VERSION environment variable.

# Configuring an API key and API version with configs
config :lob_elixir,
  api_key: "your_api_key",
  api_version: "2014-12-18"

Usage

Requests return a 2-tuple or 3-tuple, depending on the response.

# Successful response
{:ok, postcards, _headers} = Postcard.list()

# Unsuccessful response
{:error, %{message: ":nxdomain"}} = Postcard.list()

# Unsuccessful response with status code
{:error, %{message: "postcard not found", status_code: 404}} = Postcard.retrieve('nonexistent_resource')

Contributing

To contribute, please see the CONTRIBUTING.md file.

Testing

Tests are written using ExUnit, Elixir's built-in test framework.

Here's how you can run the tests:

mix test

To run tests with a coverage report:

mix coveralls.html

Then view the report at cover/excoveralls.html.

=======================

Copyright © 2018 Lob.com

Released under the MIT License, which can be found in the repository in LICENSE.txt.