aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSteven Blowers <shdblowers@gmail.com>2016-11-22 13:37:00 +0000
committerSteven Blowers <shdblowers@gmail.com>2016-11-22 13:37:00 +0000
commite08eb7c1f4f9b2ac56433a465a4b07bbfc7e8530 (patch)
treeccf29a646449ab9afd766433d50ec2b8e6666cc2 /lib
parentea7f4479f151f95d4f1c1b7df121b4ec0dc6e309 (diff)
downloadzendex-e08eb7c1f4f9b2ac56433a465a4b07bbfc7e8530.tar.gz
zendex-e08eb7c1f4f9b2ac56433a465a4b07bbfc7e8530.tar.xz
trying out using meck on tickets module
Diffstat (limited to 'lib')
-rw-r--r--lib/http_client/in_memory.ex11
-rw-r--r--lib/zendex/ticket.ex5
2 files changed, 2 insertions, 14 deletions
diff --git a/lib/http_client/in_memory.ex b/lib/http_client/in_memory.ex
index a448afd..eabe99f 100644
--- a/lib/http_client/in_memory.ex
+++ b/lib/http_client/in_memory.ex
@@ -6,11 +6,6 @@ defmodule Zendex.HttpClient.InMemory do
@base_url "http://test.zendesk.com"
- def get!(@base_url <> "/api/v2/tickets.json",
- [{"Authorization", _authentication}]) do
- fake_response("ticket")
- end
-
def get!(@base_url <> "/api/v2/search.json?query=requester%3AJimbob+type%3Aticket",
[{"Authorization", _authentication}]) do
fake_response(["Jimbob Ticket 1", "Jimbob Ticket 2"])
@@ -37,12 +32,6 @@ defmodule Zendex.HttpClient.InMemory do
%{id: 67, name: "Sarpedon Baumgartner"}]})
end
- def post!(@base_url <> "/api/v2/tickets.json",
- "{\"ticket\":{}}",
- [{"Authorization", _authentication}, {"Content-Type", "application/json"}]) do
- fake_response("Ticket created successfully!")
- end
-
def post!(@base_url <> "/api/v2/users.json",
"{\"user\":{\"name\":\"Roger\",\"email\":\"roger@dodger.com\"}}",
[{"Authorization", _authentication}, {"Content-Type", "application/json"}]) do
diff --git a/lib/zendex/ticket.ex b/lib/zendex/ticket.ex
index 9232d6e..2aaf7ae 100644
--- a/lib/zendex/ticket.ex
+++ b/lib/zendex/ticket.ex
@@ -7,7 +7,6 @@ defmodule Zendex.Ticket do
alias Zendex.CommonHelpers
@url "/api/v2/tickets.json"
- @http_client Application.get_env(:zendex, :http_client)
@doc """
List all tickets.
@@ -15,7 +14,7 @@ defmodule Zendex.Ticket do
@spec list(Zendex.Connection.t) :: map
def list(connection) do
"#{connection.base_url}#{@url}"
- |> @http_client.get!(CommonHelpers.get_headers(connection.authentication))
+ |> HTTPoison.get!(CommonHelpers.get_headers(connection.authentication))
|> CommonHelpers.decode_response
end
@@ -25,7 +24,7 @@ defmodule Zendex.Ticket do
@spec create(Zendex.Connection.t, map) :: map
def create(connection, ticket) do
"#{connection.base_url}#{@url}"
- |> @http_client.post!(Poison.encode!(ticket),
+ |> HTTPoison.post!(Poison.encode!(ticket),
CommonHelpers.get_headers(connection.authentication,
%{content_type: :json}))
|> CommonHelpers.decode_response