module Slack::Web::Api::Endpoints::Chat
def chat_postMessage(options = {})
- See: https://github.com/slack-ruby/slack-api-ref/blob/master/methods/chat/chat.postMessage.json -
See: https://api.slack.com/methods/chat.postMessage -
Options Hash:
(**options)-
:username(Object) -- -
:unfurl_media(Object) -- -
:unfurl_links(Object) -- -
:thread_ts(Object) -- -
:reply_broadcast(Object) -- -
:parse(Object) -- -
:mrkdwn(Object) -- -
:link_names(Object) -- -
:icon_url(Object) -- -
:icon_emoji(Object) -- -
:blocks(Object) -- -
:attachments(Object) -- -
:as_user(Object) -- -
:text(Object) -- -
:channel(channel) --
def chat_postMessage(options = {}) throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil? throw ArgumentError.new('Required arguments :text, :attachments or :blocks missing') if options[:text].nil? && options[:attachments].nil? && options[:blocks].nil? # attachments must be passed as an encoded JSON string if options.key?(:attachments) attachments = options[:attachments] attachments = JSON.dump(attachments) unless attachments.is_a?(String) options = options.merge(attachments: attachments) end # blocks must be passed as an encoded JSON string if options.key?(:blocks) blocks = options[:blocks] blocks = JSON.dump(blocks) unless blocks.is_a?(String) options = options.merge(blocks: blocks) end post('chat.postMessage', options) end