Class: SlackMsgr::Chat
- Inherits:
-
SlackMethod
- Object
- SlackMethod
- SlackMsgr::Chat
- Defined in:
- lib/slack_msgr/chat.rb
Overview
Handles all chat functionality and methods corresponding with Slack API
Constant Summary collapse
- CHAT_METHODS =
{ post_message: 'postMessage' }.freeze
- REQUIRED_ARGUMENTS =
%i[channel text].freeze
- PERMITTED_ARGUMENTS =
%i[ token channel text as_user attachments blocks icon_emoji icon_url link_names mrkdwn parse reply_broadcast thread_ts unfurl_links unfurl_media username ].freeze
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(method, opts) ⇒ Chat
constructor
A new instance of Chat.
Constructor Details
#initialize(method, opts) ⇒ Chat
Returns a new instance of Chat.
40 41 42 43 44 45 46 47 |
# File 'lib/slack_msgr/chat.rb', line 40 def initialize(method, opts) chat_method = CHAT_METHODS[method] ErrorHandling.raise(:unknown_method, method: method) unless chat_method @method = "chat.#{chat_method}" @opts = opts @body = sanitize_body end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
36 37 38 |
# File 'lib/slack_msgr/chat.rb', line 36 def body @body end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
36 37 38 |
# File 'lib/slack_msgr/chat.rb', line 36 def method @method end |
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
36 37 38 |
# File 'lib/slack_msgr/chat.rb', line 36 def opts @opts end |
Class Method Details
.call(method, opts = {}) ⇒ Object
30 31 32 33 |
# File 'lib/slack_msgr/chat.rb', line 30 def call(method, opts = {}) chat = new(method, opts) send_post_request_to_slack(chat) end |