16 lines
427 B
Elixir

defmodule YandexTranslate.Auth do
alias YandexTranslate.Auth.{ApiKey, IAMToken}
def get_config() do
Application.get_all_env(:yandex_translate) |> Map.new()
end
def authorization_value(config \\ get_config())
def authorization_value(%{private_key: _, authorized_key_id: _, service_account_id: _}),
do: IAMToken.get_auth_value()
def authorization_value(%{api_key: _}),
do: ApiKey.get_auth_value()
end