   def format_data(data) when is_list(data) do
     Url.to_query_string(data)
   end
-  
   def format_data(data), do: data
 
 end

  handles master account case if :"Authorization"
  custom header isn't present

  Without header defined

    iex> ExTwilio.Api.auth_header([], {123, 123})
    ["Authorization": "Basic MTIzOjEyMw=="]

  With header defined

    iex> ExTwilio.Api.auth_header(["Authorization": "Basic BASE64=="], {123, 123})
    ["Authorization": "Basic BASE64=="]
  """
  @spec auth_header(headers :: list, auth :: tuple) :: list
  def auth_header(headers, {sid, token}) when not is_nil(sid) and not is_nil(token) do 
    case Keyword.has_key?(headers, :"Authorization") do
      true -> headers
      false -> 
        auth = Base.encode64("#{sid}:#{token}")
        
        headers  
        |> Keyword.put(:"Authorization", "Basic #{auth}")
    end
  end


  @doc """
  Builds custom auth header for subaccounts

  ## Examples
    iex> ExTwilio.Api.auth_header([account: 123, token: 123])
    ["Authorization": "Basic MTIzOjEyMw=="]

    iex> ExTwilio.Api.auth_header([], {nil, 2})
    []
