Class: Slack::Surfaces::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/slack/surfaces/message.rb

Overview

App-published messages are dynamic yet transient spaces. They allow users to complete workflows among their Slack conversations.

api.slack.com/surfaces#messages api.slack.com/messaging/composing#complex_layouts

Constant Summary collapse

TYPE =
'message'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(blocks: nil, text: nil, channel: nil, thread_ts: nil, as_user: nil) ⇒ Message

Returns a new instance of Message.



13
14
15
16
17
18
19
# File 'lib/slack/surfaces/message.rb', line 13

def initialize(blocks: nil, text: nil, channel: nil, thread_ts: nil, as_user: nil)
  @blocks = blocks || Slack::BlockKit::Blocks.new
  @channel = channel
  @thread_ts = thread_ts
  @as_user = as_user
  @text = text
end

Instance Attribute Details

#blocksObject (readonly)

Returns the value of attribute blocks.



21
22
23
# File 'lib/slack/surfaces/message.rb', line 21

def blocks
  @blocks
end

Instance Method Details

#as_jsonObject



23
24
25
26
27
28
29
30
31
# File 'lib/slack/surfaces/message.rb', line 23

def as_json(*)
  {
    channel: @channel,
    thread_ts: @thread_ts,
    as_user: @as_user,
    text: @text,
    blocks: @blocks.as_json
  }.compact
end