   @moduledoc """
   Client protocol used by `ApiClient` and `OauthClient`.
   """
+  @fallback_to_any true
 
   @type t :: Hipchat.ApiClient.t | Hipchat.OauthClient.t
   @type query_params_t :: [{String.t, String.t}]

  """
  @spec options(t, query_params_t) :: Hipchat.Httpc.options_t
  def options(client, query_params)
end

defmodule Hipchat.ApiClient do

      httpc_opts:    httpc_opts,
    }
  end

  alias __MODULE__, as: OC
  defimpl Hipchat.Client do
    def headers(%OC{client_id: ci, client_secret: cs}) do
      encoded = Base.encode64("#{ci}:#{cs}")
      [{"authorization", "Basic #{encoded}"}]
    end

    def options(%OC{httpc_opts: ho}, query_params), do: [{:params, query_params} | ho]
  end
end
