defmodule HubIdentityElixir.Server do @moduledoc """ Documentation for `HubIdentityElixir`. """ @doc """ Get the list of Open Authentication Providers from HubIdentity ## Examples iex> HubIdentityElixir.get_providers() [ { "logo_url": "https://stage-identity.hubsynch.com/images/facebook.png", "name": "facebook", "request_url": request_url } ] """ def get_providers do HTTPoison.get("#{hub_identity_url()}/api/v1/providers", headers()) |> parse_response() end def hub_identity_url do case Application.get_env(:hub_identity_elixir, :url) do url when is_binary(url) -> url _ -> "https://stage-identity.hubsynch.com" end end defp headers do auth_key = Application.get_env(:hub_identity_elixir, :public_key) [{"x-api-key", auth_key}] end defp parse_response({:ok, %HTTPoison.Response{status_code: 200, body: body}}) do body |> Jason.decode() end end