diff options
author | Steven Blowers <sblowers@findmypast.com> | 2016-09-13 13:58:26 +0100 |
---|---|---|
committer | Steven Blowers <sblowers@findmypast.com> | 2016-09-13 13:58:26 +0100 |
commit | b036ecfc34bc283b143aca540253918e6d8eda5c (patch) | |
tree | 856ee4960538447d1b9376e04c52a84773bb49d4 /lib | |
parent | 3b3846695d484033fa0b661cc416447bafed37eb (diff) | |
download | zendex-b036ecfc34bc283b143aca540253918e6d8eda5c.tar.gz zendex-b036ecfc34bc283b143aca540253918e6d8eda5c.tar.xz |
Refactoring tickets code.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/zendex/ticket.ex | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/zendex/ticket.ex b/lib/zendex/ticket.ex index 5e2b66e..b6ccad9 100644 --- a/lib/zendex/ticket.ex +++ b/lib/zendex/ticket.ex @@ -10,16 +10,20 @@ defmodule Zendex.Ticket do @spec list(Zendex.Connection.t) :: HTTPoison.Response.t def list(connection) do - @http_client.get!(connection.base_url <> @url, [{"Authorization", - "Basic #{connection.authentication}"}]) + full_url = connection.base_url <> @url + + @http_client.get!(full_url, headers(connection.authentication)) end @spec create(Zendex.Connection.t, map) :: HTTPoison.Response.t def create(connection, ticket) do @http_client.post!(connection.base_url <> @url, - Poison.encode!(ticket), - [{"Authorization", "Basic #{connection.authentication}"}, - {"Content-Type", "application/json"}]) + Poison.encode!(ticket), + headers(connection.authentication) ++ + [{"Content-Type", "application/json"}]) end + defp headers(authentication) do + [{"Authorization", "Basic #{authentication}"}] + end end |