Module: Slack::Web::Im

Included in:
Slack::Web
Defined in:
lib/slack/web/im.rb

Overview

Module for the im methods. Get info on your direct messages.

Constant Summary collapse

SCOPE =

Endpoint scope

'im'

Instance Method Summary collapse

Instance Method Details

#im_close(params = {}) ⇒ Object

Close a direct message channel.

Parameters:

  • params (Hash) (defaults to: {})

    API call arguments

Options Hash (params):

  • 'channel' (im)

    Direct message channel to close.

See Also:



20
21
22
23
24
# File 'lib/slack/web/im.rb', line 20

def im_close(params = {})
  fail ArgumentError, "Required arguments 'channel' missing" if params['channel'].nil?
  response = @session.do_post "#{SCOPE}.close", params
  Slack.parse_response(response)
end

#im_history(params = {}) ⇒ Object

Fetches history of messages and events from direct message channel.

Parameters:

  • params (Hash) (defaults to: {})

    API call arguments

Options Hash (params):

  • 'channel' (im)

    Direct message channel to fetch history for.

  • 'latest' (timestamp)

    Latest message timestamp to include in results.

  • 'oldest' (timestamp)

    Oldest message timestamp to include in results.

  • 'inclusive' (Object)

    Include messages with latest or oldest timestamp in results.

  • 'count' (Object)

    Number of messages to return, between 1 and 1000.

See Also:



42
43
44
45
46
# File 'lib/slack/web/im.rb', line 42

def im_history(params = {})
  fail ArgumentError, "Required arguments 'channel' missing" if params['channel'].nil?
  response = @session.do_post "#{SCOPE}.history", params
  Slack.parse_response(response)
end

#im_list(params = {}) ⇒ Object

Lists direct message channels for the calling user.

Parameters:

  • params (Hash) (defaults to: {})

    API call arguments

See Also:



54
55
56
57
# File 'lib/slack/web/im.rb', line 54

def im_list(params = {})
  response = @session.do_post "#{SCOPE}.list", params
  Slack.parse_response(response)
end

#im_mark(params = {}) ⇒ Object

Sets the read cursor in a direct message channel.

Parameters:

  • params (Hash) (defaults to: {})

    API call arguments

Options Hash (params):

  • 'channel' (im)

    Direct message channel to set reading cursor in.

  • 'ts' (timestamp)

    Timestamp of the most recently seen message.

See Also:



69
70
71
72
73
74
# File 'lib/slack/web/im.rb', line 69

def im_mark(params = {})
  fail ArgumentError, "Required arguments 'channel' missing" if params['channel'].nil?
  fail ArgumentError, "Required arguments 'ts' missing" if params['ts'].nil?
  response = @session.do_post "#{SCOPE}.mark", params
  Slack.parse_response(response)
end

#im_open(params = {}) ⇒ Object

Opens a direct message channel.

Parameters:

  • params (Hash) (defaults to: {})

    API call arguments

Options Hash (params):

  • 'user' (user)

    User to open a direct message channel with.

See Also:



84
85
86
87
88
# File 'lib/slack/web/im.rb', line 84

def im_open(params = {})
  fail ArgumentError, "Required arguments 'user' missing" if params['user'].nil?
  response = @session.do_post "#{SCOPE}.open", params
  Slack.parse_response(response)
end