@@ 35,16 35,16 @@ defmodule Triglav.Autotrolej.Api do
variant: String.t()
}
- @spec fetch_stops() :: {:ok, [stop()]} | {:error, Tesla.Ent.t()}
+ @spec fetch_stops() :: {:ok, [stop()]} | {:error, Tesla.Env.t()}
def fetch_stops() do
- with {:ok, data} <- do_get("/ATstanice.json") do
+ with {:ok, data} <- fetch("/ATstanice.json") do
{:ok, Enum.map(data, &convert_stop/1)}
end
end
- # @spec fetch_routes() :: {:ok, [route()]} | {:error, Tesla.Ent.t()}
+ @spec fetch_routes() :: {:ok, [route()]} | {:error, Tesla.Env.t()}
def fetch_routes() do
- with {:ok, data} <- do_get("/ATlinije.json") do
+ with {:ok, data} <- fetch("/ATlinije.json") do
stops =
data
|> Stream.dedup_by(&Map.drop(&1, ["Id"]))
@@ 76,7 76,7 @@ defmodule Triglav.Autotrolej.Api do
}
end
- defp do_get(path) do
+ defp fetch(path) do
with {:ok, response} <- get(path) do
if response.status == 200, do: {:ok, response.body}, else: {:error, response}
end