diff options
author | Steven Blowers <shdblowers@gmail.com> | 2016-10-30 20:12:28 +0000 |
---|---|---|
committer | Steven Blowers <shdblowers@gmail.com> | 2016-10-30 20:12:28 +0000 |
commit | ea7f4479f151f95d4f1c1b7df121b4ec0dc6e309 (patch) | |
tree | 072e364d62bfa08b08753d3729623fc9dc7229c6 /lib | |
parent | f7d7d8f441840962ed7d1809b808462d4a7ad9a8 (diff) | |
download | zendex-ea7f4479f151f95d4f1c1b7df121b4ec0dc6e309.tar.gz zendex-ea7f4479f151f95d4f1c1b7df121b4ec0dc6e309.tar.xz |
adding functionality to show many users
Diffstat (limited to 'lib')
-rw-r--r-- | lib/http_client/in_memory.ex | 6 | ||||
-rw-r--r-- | lib/zendex/user.ex | 12 |
2 files changed, 18 insertions, 0 deletions
diff --git a/lib/http_client/in_memory.ex b/lib/http_client/in_memory.ex index d05bcea..a448afd 100644 --- a/lib/http_client/in_memory.ex +++ b/lib/http_client/in_memory.ex @@ -31,6 +31,12 @@ defmodule Zendex.HttpClient.InMemory do fake_response(%{"user": %{"id": 87, "name": "Quim Stroud"}}) end + def get!("#{@base_url}/api/v2/users/show_many.json?ids=6,67", + [{"Authorization", _authentication}]) do + fake_response(%{users: [%{id: 6, name: "Kiki Segal"}, + %{id: 67, name: "Sarpedon Baumgartner"}]}) + 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 8479735..31c3a06 100644 --- a/lib/zendex/user.ex +++ b/lib/zendex/user.ex @@ -29,6 +29,18 @@ defmodule Zendex.User do end @doc """ + Show many user, given their ids. + """ + @spec show_many(Zendex.Connection.t, [integer]) :: map + def show_many(connection, ids) do + ids = Enum.join(ids, ",") + + "#{connection.base_url}#{@url}/show_many.json?ids=#{ids}" + |> @http_client.get!(CommonHelpers.get_headers(connection.authentication)) + |> CommonHelpers.decode_response + end + + @doc """ Create a new user. """ @spec create(Zendex.Connection.t, map) :: map |