Current section
Files
Jump to
Current section
Files
lib/tvdb/auth.ex~
defmodule Tvdb.Auth do
@doc """
Creates the bucket to hold the key value pair
"""
def start_link do
Agent.start_link(&Map.New, name: :auth)
end
@doc """
Gets the value corresponding with `key`
"""
def get(key) do
Agent.get(:auth, &Map.get(&1, key))
end
@doc """
Puts a new value / replaces an existing value at `key` with `value
"""
def put(key,value) do
Agent.update(:auth, &Map.put(&1,key,value))
end
@doc """
Creates the body based on environment variables for the authorisation
request.
"""
defp auth_body do
{:ok, body} = %{apikey: Application.get_env(:tvdb, :api_key),
username: Application.get_env(:tvdb, :user_name),
userkey: Application.get_env(:tvdb, :user_key)}
|> Poison.encode
body
end
end