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 ondix_stateful.ex
Raw

lib/ondix_stateful.ex

defmodule Ondix.StateAgent do
use Agent
def start_link(token) do
Agent.start_link(fn -> token end, name: __MODULE__)
end
def token() do
Agent.get(__MODULE__, &(&1))
end
end
defmodule Ondix.StatefulClient do
def with_token(token) do
Ondix.StateAgent.start_link(token)
Ondix.StatefulClient
end
def get(url) do
Ondix.Client.get(url, Ondix.StateAgent.token())
end
end