Packages

An elixir client for the Orchestre National d'Île-de-France public API

Retired package: Release invalid - The underlying public API does not exist anymore.

Current section

Files

Jump to
ondix lib client.ex
Raw

lib/client.ex

defmodule Ondix.Client do
use HTTPoison.Base
@url (case System.get_env("API_URL") do
nil -> "https://api.orchestre-ile.com/api/v1/"
a -> a
end)
def process_request_url(url) do
@url <> url
end
def process_response_body(body) do
d = body
|> Poison.decode!
Map.keys(d)
|> Enum.reduce(%{}, fn k, a -> Map.put(a, String.to_atom(k), Map.get(d, k)) end)
end
def get(url, token) do
HTTPoison.get(url, [{"X-API-TOKEN", token}])
end
end