Class: Slack::Messages::Payload

Inherits:
Object
  • Object
show all
Defined in:
lib/slack/messages/payload.rb

Constant Summary collapse

PAYLOAD_PARAMS =
i[
  channel
  text
  parse
  link_names
  attachments
  unfurl_links
  unfurl_media
  username
  as_user
  icon_url
  icon_emoji
  thread_ts
  reply_broadcast
].freeze

Instance Method Summary collapse

Instance Method Details

#to_paramsObject



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/slack/messages/payload.rb', line 22

def to_params
  params = {}
  PAYLOAD_PARAMS.each { |p|
    if "#{p}" == 'attachments'
      attachments = []
      @attachments.each { |a| attachments.push(a.to_params) } unless @attachments.nil?
      params['attachments'] = attachments unless attachments.empty?
      next
    end
    params["#{p}"] = send(p) unless send(p).nil?
  }
  params
end