From ea7f4479f151f95d4f1c1b7df121b4ec0dc6e309 Mon Sep 17 00:00:00 2001 From: Steven Blowers Date: Sun, 30 Oct 2016 20:12:28 +0000 Subject: adding functionality to show many users --- lib/http_client/in_memory.ex | 6 ++++++ lib/zendex/user.ex | 12 ++++++++++++ 2 files changed, 18 insertions(+) (limited to 'lib') 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 @@ -28,6 +28,18 @@ defmodule Zendex.User do |> CommonHelpers.decode_response 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. """ -- cgit v1.2.1