-
-
Notifications
You must be signed in to change notification settings - Fork 222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add attachments support for Slack::Web::Api::Endpoints::Chat.chat_update #69
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,8 +82,14 @@ def chat_postMessage(options = {}) | |
def chat_update(options = {}) | ||
throw ArgumentError.new('Required arguments :ts missing') if options[:ts].nil? | ||
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? | ||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think if we're going to do this we should do it in attachments = JSON.dump(options[:attachments]) if options.key?(:attachments) && ! options[:attachments].is_a?(String) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh we already do that in |
||
post('chat.update', options) | ||
end | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
diff --git a/lib/slack/web/api/endpoints/chat.rb b/lib/slack/web/api/endpoints/chat.rb | ||
index 0db7e67..1c3b2ee 100644 | ||
--- a/lib/slack/web/api/endpoints/chat.rb | ||
+++ b/lib/slack/web/api/endpoints/chat.rb | ||
@@ -82,8 +82,14 @@ module Slack | ||
def chat_update(options = {}) | ||
throw ArgumentError.new('Required arguments :ts missing') if options[:ts].nil? | ||
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? | ||
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put this back please?