aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSteven Blowers <sblowers@findmypast.com>2016-11-01 14:19:53 +0000
committerSteven Blowers <sblowers@findmypast.com>2016-11-01 14:19:53 +0000
commitbf62e2d177726a5921b485988c89764dd34eae3f (patch)
tree0d544c3f9d6c713af3845b7ca73afa7d8b456d1c /lib
parentdc3eabba821ff4f80ca417123629ca9ceb92eb51 (diff)
downloadzendex-bf62e2d177726a5921b485988c89764dd34eae3f.tar.gz
zendex-bf62e2d177726a5921b485988c89764dd34eae3f.tar.xz
adding ability to get related info on a user
Diffstat (limited to 'lib')
-rw-r--r--lib/http_client/in_memory.ex14
-rw-r--r--lib/zendex/user.ex7
2 files changed, 21 insertions, 0 deletions
diff --git a/lib/http_client/in_memory.ex b/lib/http_client/in_memory.ex
index b74450e..4c43211 100644
--- a/lib/http_client/in_memory.ex
+++ b/lib/http_client/in_memory.ex
@@ -70,6 +70,20 @@ defmodule Zendex.HttpClient.InMemory do
%{id: 67, name: "Sarpedon Baumgartner"}]})
end
+ def get!("#{@base_url}/api/v2/users/649267/related.json",
+ [{"Authorization", _authentication}]) do
+ fake_response(%{"user_related" => %{"assigned_tickets" => 12,
+ "ccd_tickets" => 5,
+ "entry_subscriptions" => 1,
+ "forum_subscriptions" => 3,
+ "organization_subscriptions" => 1,
+ "requested_tickets" => 7,
+ "subscriptions" => 6,
+ "topic_comments" => 116,
+ "topics" => 5,
+ "votes" => 2001}})
+ end
+
def post!(@base_url <> "/api/v2/tickets.json",
"{\"ticket\":{}}",
[{"Authorization", _authentication}, {"Content-Type", "application/json"}]) do
diff --git a/lib/zendex/user.ex b/lib/zendex/user.ex
index 88487f3..3983432 100644
--- a/lib/zendex/user.ex
+++ b/lib/zendex/user.ex
@@ -81,6 +81,13 @@ defmodule Zendex.User do
|> CommonHelpers.decode_response
end
+ @spec related_information(Zendex.Connection.t, integer) :: map
+ def related_information(connection, id) do
+ "#{connection.base_url}#{@url}/#{id}/related.json"
+ |> @http_client.get!(CommonHelpers.get_headers(connection.authentication))
+ |> CommonHelpers.decode_response
+ end
+
@doc """
Create a new user.
"""