Class: Slk::Api::Threads
- Inherits:
-
Object
- Object
- Slk::Api::Threads
- Defined in:
- lib/slk/api/threads.rb
Overview
Wrapper for Slack thread subscription API endpoints
Instance Method Summary collapse
-
#get_view(limit: 20) ⇒ Hash
Get unread threads.
-
#initialize(api_client, workspace) ⇒ Threads
constructor
A new instance of Threads.
-
#mark(channel:, thread_ts:, timestamp:) ⇒ Object
Mark a thread as read.
-
#unread_count ⇒ Integer
Get unread thread count.
-
#unreads? ⇒ Boolean
Check if there are unread threads.
Constructor Details
#initialize(api_client, workspace) ⇒ Threads
Returns a new instance of Threads.
7 8 9 10 |
# File 'lib/slk/api/threads.rb', line 7 def initialize(api_client, workspace) @api = api_client @workspace = workspace end |
Instance Method Details
#get_view(limit: 20) ⇒ Hash
Get unread threads
15 16 17 |
# File 'lib/slk/api/threads.rb', line 15 def get_view(limit: 20) @api.post(@workspace, 'subscriptions.thread.getView', { limit: limit }) end |
#mark(channel:, thread_ts:, timestamp:) ⇒ Object
Mark a thread as read
23 24 25 26 27 28 29 |
# File 'lib/slk/api/threads.rb', line 23 def mark(channel:, thread_ts:, timestamp:) @api.post_form(@workspace, 'subscriptions.thread.mark', { channel: channel, thread_ts: thread_ts, ts: }) end |
#unread_count ⇒ Integer
Get unread thread count
33 34 35 36 |
# File 'lib/slk/api/threads.rb', line 33 def unread_count response = get_view(limit: 1) response['total_unread_replies'] || 0 end |
#unreads? ⇒ Boolean
Check if there are unread threads
40 41 42 |
# File 'lib/slk/api/threads.rb', line 40 def unreads? unread_count.positive? end |