Class: SlackMsgr::Conversations

Inherits:
SlackMethod show all
Defined in:
lib/slack_msgr/conversations.rb

Overview

Handles all conversations functionality and methods corresponding with Slack API

Constant Summary collapse

CONVERSATIONS_METHODS =
{ open: 'open' }.freeze
REQUIRED_ARGUMENTS =
%i[token users].freeze
PERMITTED_ARGUMENTS =
%i[token channel return_im users].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method, opts) ⇒ Conversations

Returns a new instance of Conversations.



23
24
25
26
27
28
29
30
# File 'lib/slack_msgr/conversations.rb', line 23

def initialize(method, opts)
  conversations_method = CONVERSATIONS_METHODS[method]
  ErrorHandling.raise(:unknown_method, method: method) unless conversations_method

  @method = "conversations.#{conversations_method}"
  @opts   = opts
  @body   = sanitize_body
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



19
20
21
# File 'lib/slack_msgr/conversations.rb', line 19

def body
  @body
end

#methodObject (readonly)

Returns the value of attribute method.



19
20
21
# File 'lib/slack_msgr/conversations.rb', line 19

def method
  @method
end

#optsObject (readonly)

Returns the value of attribute opts.



19
20
21
# File 'lib/slack_msgr/conversations.rb', line 19

def opts
  @opts
end

Class Method Details

.call(method, opts = {}) ⇒ Object



13
14
15
16
# File 'lib/slack_msgr/conversations.rb', line 13

def call(method, opts = {})
  chat = new(method, opts)
  send_post_request_to_slack(chat)
end