   Fetches the env atom for the config. Must be either `:dev` or `:prod`, or an
   exception will be thrown.
 
-      config :shippex, :env, :dev
-
-      Shippex.env #=> :dev
-  """
-  @spec env() :: atom
+      iex> Application.put_env(:shippex, :env, :dev)
+      iex> Shippex.env
+      :dev
+  """
+  @spec env() :: :dev | :prod | none()
   def env() do
     case Application.get_env(:shippex, :env, :dev) do
       e when e in [:dev, :prod] -> e

    defexception [:message]

    def exception(message) do
      %InvalidConfigError{message: "Invalid config: #{inspect(message)}"}
    end
  end



  @doc """
  Fetches the rate for `shipment` for a specific `Service`. The `service` module
  contains the `Carrier` and selected delivery speed. You can also pass in the
  ID of the service.

      Shippex.fetch_rate(shipment, service)
  """
  @spec fetch_rate(Shipment.t(), atom() | Service.t()) :: {atom, Rate.t()}
  def fetch_rate(%Shipment{} = shipment, service) when is_atom(service) do
    service = Service.get(service)
    fetch_rate(shipment, service)
  end

  def fetch_rate(%Shipment{} = shipment, %Service{carrier: carrier} = service) do
    case Carrier.module(carrier).fetch_rate(shipment, service) do
      [rate] -> rate
