diff –git a/lib/slack/web/api/endpoints/chat.rb b/lib/slack/web/api/endpoints/chat.rb index 5186416..490bc91 100644 — a/lib/slack/web/api/endpoints/chat.rb +++ b/lib/slack/web/api/endpoints/chat.rb @@ -154,9 +154,15 @@ module Slack
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/chat/chat.update.json def chat_update(options = {}) throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
-
throw ArgumentError.new('Required arguments :text missing') if options.nil?
+ throw ArgumentError.new('Required arguments :text or :attachments missing') if options.nil? && options.nil?
throw ArgumentError.new('Required arguments :ts missing') if options[:ts].nil? options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
+ # attachments must be passed as an encoded JSON string + if options.key?(:attachments) + attachments = options + attachments = JSON.dump(attachments) unless attachments.is_a?(String) + options = options.merge(attachments: attachments) + end
post('chat.update', options) end end