This is an abstraction of Shiphawk API to Elixir applications. It comes with a nice and clean DSL that easily enable projects to integrate with ShipHawk. You can check the docs on https://hexdocs.pm/shiphawk.
Add shiphawk
to your list of dependencies in mix.exs
:
def deps do
[
{:shiphawk, "~> 0.1.0"}
]
end
Make sure you also add the necessary configuration:
config :shiphawk, api_key: "your_api_key"
These are the supported API groups currenlty supported:
Shiphawk.Rates.get/3
is used to get shipping rates
items
: List of Maps, items that are being shipped (Accepted parameters).from
: Map with the address where it's being shipped from (Accepted parameters).to
: Map with the address where it's being shipped to (Accepted parameters).
items = [%{
package_type: "box",
item_type: "handling_unit",
handling_unit_type: "pallet", # Must be "pallet", "carton", "box", "crate", or "bag"
length: "10",
width: "10",
height: "11",
weight: "10",
value: 100.00
}]
from = %{ "zip" => "93101"}
to = %{ "zip" => "60060"}
Shiphawk.Rates.get(items, from, to)
# {
# :ok,
# %{"rates" => [...]}
# }