Sha256: b5a055ecd44961c67eec87c8af0af50e67cd1879d835ed24d63851225f046c6d

Contents?: true

Size: 1.29 KB

Versions: 12

Compression:

Stored size: 1.29 KB

Contents

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[:text].nil?
+            throw ArgumentError.new('Required arguments :text or :attachments missing') if options[:text].nil? && options[:attachments].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]
+              attachments = JSON.dump(attachments) unless attachments.is_a?(String)
+              options = options.merge(attachments: attachments)
+            end
             post('chat.update', options)
           end
         end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
slack-ruby-client-0.14.6 lib/slack/web/api/patches/chat.3.update-attachments-support.patch
slack-ruby-client-0.14.5 lib/slack/web/api/patches/chat.3.update-attachments-support.patch
slack-ruby-client-0.14.4 lib/slack/web/api/patches/chat.3.update-attachments-support.patch
slack-ruby-client-0.14.3 lib/slack/web/api/patches/chat.3.update-attachments-support.patch
slack-ruby-client-0.14.2 lib/slack/web/api/patches/chat.3.update-attachments-support.patch
slack-ruby-client-0.14.1 lib/slack/web/api/patches/chat.3.update-attachments-support.patch
slack-ruby-client-0.14.0 lib/slack/web/api/patches/chat.3.update-attachments-support.patch
slack-ruby-client-0.13.1 lib/slack/web/api/patches/chat.3.update-attachments-support.patch
slack-ruby-client-0.13.0 lib/slack/web/api/patches/chat.3.update-attachments-support.patch
slack-ruby-client-0.12.0 lib/slack/web/api/patches/chat.3.update-attachments-support.patch
slack-ruby-client-0.11.1 lib/slack/web/api/patches/chat.3.update-attachments-support.patch
slack-ruby-client-0.11.0 lib/slack/web/api/patches/chat.3.update-attachments-support.patch