EasyPost for Elixir

Installation

ex_easypost is publbished on Hex. Add it to your list of dependencies in mix.exs:

defp deps do
  [
    { :ex_easypost, "~> 3.0" }
  ]
end

ex_easypost requires you to provide an HTTP client and a JSON codec. hackney and jason are used by default. If you wish to use these defaults you will need add hackney and jason as dependencies as well.

Usage

You can send a request to the EasyPost API by building an EasyPost.Operation struct and passing it as the first argument to EasyPost.request/2 and passing a configuration map as the second argument.

Example

iex> params
...> |> EasyPost.Shipment.create()
...> |> EasyPost.request(%{ api_key: "xxx" })
{ :ok, %EasyPost.Response{} }

An EasyPost.Operation struct can be built using either a resource module (e.g. EasyPost.Shipment) or by building the struct manually. EasyPost.Operation contains fields :method, :params and :path.

Configuration