From f80a10acae6e8f7de1235480572d728d4e1d4c29 Mon Sep 17 00:00:00 2001 From: Delon Newman Date: Mon, 9 Aug 2021 15:12:13 -0600 Subject: [PATCH] Add Client#user_presence --- lib/wonder_llama/client.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/wonder_llama/client.rb b/lib/wonder_llama/client.rb index af7c47c..d06e604 100644 --- a/lib/wonder_llama/client.rb +++ b/lib/wonder_llama/client.rb @@ -73,6 +73,17 @@ def users(client_gravatar: false, include_custom_profile_fields: false) end end + def user_presence(user_id) + response = get(path: "/api/v1/users/#{user_id}/presence") + + response['presence'].each_with_object({}) do |(client, details), hash| + hash[client.to_sym] = { + status: details['status'].to_sym, + timestamp: Time.at(details['timestamp']) + } + end + end + private def get(path:, params: nil, connection_options: {})