aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSteven Blowers <sblowers@findmypast.com>2016-11-01 13:51:12 +0000
committerSteven Blowers <sblowers@findmypast.com>2016-11-01 13:51:12 +0000
commitbfee6d82bd6b5a259482d6398b913e68d680792a (patch)
tree9bd1dcc48bff684d83ffb34af752058689953316 /lib
parent96cf6093809b049dd55efd6c10593b95ec2e5d03 (diff)
downloadzendex-bfee6d82bd6b5a259482d6398b913e68d680792a.tar.gz
zendex-bfee6d82bd6b5a259482d6398b913e68d680792a.tar.xz
adding functionality to delete a user
Diffstat (limited to 'lib')
-rw-r--r--lib/http_client/in_memory.ex38
-rw-r--r--lib/zendex/user.ex10
2 files changed, 48 insertions, 0 deletions
diff --git a/lib/http_client/in_memory.ex b/lib/http_client/in_memory.ex
index 46a53f5..b74450e 100644
--- a/lib/http_client/in_memory.ex
+++ b/lib/http_client/in_memory.ex
@@ -82,5 +82,43 @@ defmodule Zendex.HttpClient.InMemory do
fake_response(%{user: %{id: 1234, name: "Roger", email: "roger@dodger.com"}})
end
+ def delete!("#{@base_url}/api/v2/users/49043.json",
+ [{"Authorization", _authentication}]) do
+ fake_response(%{"user" => %{"ticket_restriction" => nil,
+ "chat_only" => false,
+ "shared_phone_number" => nil,
+ "notes" => "",
+ "phone" => nil,
+ "organization_id" => 149043,
+ "last_login_at" => "2016-10-28T21:08:23Z",
+ "moderator" => true,
+ "shared" => false,
+ "id" => 49043,
+ "role" => "admin",
+ "external_id" => nil,
+ "shared_agent" => false,
+ "photo" => nil,
+ "verified" => true,
+ "active" => false,
+ "locale_id" => 1,
+ "suspended" => false,
+ "created_at" => "2015-05-28T09:12:45Z",
+ "name" => "Rian Hawkins",
+ "restricted_agent" => false,
+ "locale" => "en-US",
+ "details" => "",
+ "alias" => nil,
+ "url" => "https://test.zendesk.com/api/v2/users/49043.json",
+ "custom_role_id" => nil,
+ "email" => "rian.hawkins@test.com",
+ "signature" => nil,
+ "two_factor_auth_enabled" => nil,
+ "time_zone" => "London",
+ "only_private_comments" => false,
+ "user_fields" => %{"customer_complaint" => nil},
+ "tags" => [],
+ "updated_at" => "2016-10-28T21:08:23Z"}})
+ end
+
defp fake_response(body), do: %{body: Poison.encode!(body)}
end
diff --git a/lib/zendex/user.ex b/lib/zendex/user.ex
index 4cae662..6873fb3 100644
--- a/lib/zendex/user.ex
+++ b/lib/zendex/user.ex
@@ -75,4 +75,14 @@ defmodule Zendex.User do
|> CommonHelpers.decode_response
end
+ @doc """
+ Delete a user.
+ """
+ @spec show(Zendex.Connection.t, integer) :: map
+ def delete(connection, id) do
+ "#{connection.base_url}#{@url}/#{id}.json"
+ |> @http_client.delete!(CommonHelpers.get_headers(connection.authentication))
+ |> CommonHelpers.decode_response
+ end
+
end