ExEasyPost
ExEasyPost is an Elixir client library for the EasyPost API.
Features
- Support for all EasyPost resources
- Minimal configuration. Choose your favorite HTTP client and JSON codec.
- Support for per-request configuration
Getting Started
ExEasyPost allows you to choose which HTTP client and JSON codec you would like
to use. ExEasyPost supports :httpoison (HTTP client) and :poison (JSON
codec) out of the box.
defp deps do
[
{:ex_easypost, "~> 1.0"},
{:httpoison, "~> 0.13"},
{:poison, "~> 3.1"}
]
endUsage
ExEasyPost.Address.find("adr_a6fd5dd822c94bdfa1e3f2d28a4dbf9c")
|> ExEasyPost.request()
ExEasyPost will return {:ok, response} on success and {:error, reason} on
failure.
Configuration
ExEasyPost allows you to provide configuration as part of your application config or on a per-request basis.
Application configuration
config :ex_easypost,
api_key: "xxx"Per-request configuration
config = %{api_key: "xxx"}
ExEasyPost.Address.find("adr_a6fd5dd822c94bdfa1e3f2d28a4dbf9c")
|> ExEasyPost.request(config)Configuration options
:api_key- your EasyPost API key:host- host to make requests to (default:api.easypost.com):http_client- HTTP client used to make requests (default::httpoison):http_opts- configuration options passed to the api client:json_parser- codec used to encode and decode JSON (default::poison):path- URI path to make requests to (default:v2):port- HTTP port to make requests to:protocol- HTTP protocol to use when making requests (default:https)