   Deletes a recipient from an email list.
 
       :ok = delete_recipient(123, "recipient_id")
+
   """
   @spec delete_recipient(integer, String.t) :: :ok | :error
   def delete_recipient(list_id, recipient_id) do
-    SendGrid.delete(@base_api_url <> "/#{list_id}/recipients/#{recipient_id}", %{})
-    |> case do
-      { :ok, %{ status_code: 204 } } -> :ok
+    url = @base_api_url <> "/#{list_id}/recipients/#{recipient_id}"
+    case SendGrid.delete(url, %{}) do
+      {:ok, %{status_code: 204}} -> :ok
       _ -> :error
     end
   end

  Creates an email list.

      {:ok, 2} = add("marketing")
  """
  @spec add(String.t) :: {:ok, integer} | :error
  def add(list_name) do
    SendGrid.post(@base_api_url, %{name: list_name})
    |> case do
      { :ok, %{ status_code: 201, body: body } } -> {:ok, body["id"]}
      _ -> :error
    end
  end

  """
  @spec all_recipients(integer, integer, integer) :: list(%{}) | :error
  def all_recipients(list_id, page \\ 1, page_size \\ 100) do
    url = @base_api_url <> "/#{list_id}/recipients?page_size=#{page_size}&page=#{page}"
    case SendGrid.get(url) do
      {:ok, %{status_code: 200, body: body}} -> body["recipients"]
      _ -> :error
    end
  end
