Class: Slk::Api::Conversations
- Inherits:
-
Object
- Object
- Slk::Api::Conversations
- Defined in:
- lib/slk/api/conversations.rb
Overview
Wrapper for Slack conversations.* API endpoints
Instance Method Summary collapse
- #history(channel:, limit: 20, cursor: nil, oldest: nil, latest: nil) ⇒ Object
- #info(channel:) ⇒ Object
-
#initialize(api_client, workspace) ⇒ Conversations
constructor
A new instance of Conversations.
- #list(cursor: nil, limit: 1000, types: 'public_channel,private_channel') ⇒ Object
- #mark(channel:, timestamp:) ⇒ Object
- #members(channel:, cursor: nil, limit: 100) ⇒ Object
- #open(users:) ⇒ Object
- #replies(channel:, timestamp:, limit: 100, cursor: nil) ⇒ Object
Constructor Details
#initialize(api_client, workspace) ⇒ Conversations
Returns a new instance of Conversations.
7 8 9 10 |
# File 'lib/slk/api/conversations.rb', line 7 def initialize(api_client, workspace) @api = api_client @workspace = workspace end |
Instance Method Details
#history(channel:, limit: 20, cursor: nil, oldest: nil, latest: nil) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/slk/api/conversations.rb', line 18 def history(channel:, limit: 20, cursor: nil, oldest: nil, latest: nil) params = { channel: channel, limit: limit } params[:cursor] = cursor if cursor params[:oldest] = oldest if oldest params[:latest] = latest if latest @api.post(@workspace, 'conversations.history', params) end |
#info(channel:) ⇒ Object
42 43 44 |
# File 'lib/slk/api/conversations.rb', line 42 def info(channel:) @api.post_form(@workspace, 'conversations.info', { channel: channel }) end |
#list(cursor: nil, limit: 1000, types: 'public_channel,private_channel') ⇒ Object
12 13 14 15 16 |
# File 'lib/slk/api/conversations.rb', line 12 def list(cursor: nil, limit: 1000, types: 'public_channel,private_channel') params = { limit: limit, types: types } params[:cursor] = cursor if cursor @api.post(@workspace, 'conversations.list', params) end |
#mark(channel:, timestamp:) ⇒ Object
38 39 40 |
# File 'lib/slk/api/conversations.rb', line 38 def mark(channel:, timestamp:) @api.post(@workspace, 'conversations.mark', { channel: channel, ts: }) end |
#members(channel:, cursor: nil, limit: 100) ⇒ Object
46 47 48 49 50 |
# File 'lib/slk/api/conversations.rb', line 46 def members(channel:, cursor: nil, limit: 100) params = { channel: channel, limit: limit } params[:cursor] = cursor if cursor @api.post(@workspace, 'conversations.members', params) end |
#open(users:) ⇒ Object
33 34 35 36 |
# File 'lib/slk/api/conversations.rb', line 33 def open(users:) user_list = Array(users).join(',') @api.post(@workspace, 'conversations.open', { users: user_list }) end |
#replies(channel:, timestamp:, limit: 100, cursor: nil) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/slk/api/conversations.rb', line 26 def replies(channel:, timestamp:, limit: 100, cursor: nil) params = { channel: channel, ts: , limit: limit } params[:cursor] = cursor if cursor # Use form encoding - some workspaces (Enterprise Grid) require it @api.post_form(@workspace, 'conversations.replies', params) end |