lib/slack/endpoint/chat.rb in slack-api-1.4.0 vs lib/slack/endpoint/chat.rb in slack-api-1.5.0
- old
+ new
@@ -16,11 +16,10 @@
# @see https://github.com/aki017/slack-api-docs/blob/master/methods/chat.delete.md
# @see https://github.com/aki017/slack-api-docs/blob/master/methods/chat.delete.json
def chat_delete(options={})
throw ArgumentError.new("Required arguments :ts missing") if options[:ts].nil?
throw ArgumentError.new("Required arguments :channel missing") if options[:channel].nil?
- options[:attachments] = options[:attachments].to_json if Hash === options[:attachments]
post("chat.delete", options)
end
#
# This method sends a me message to a channel from the calling user.
@@ -33,11 +32,10 @@
# @see https://github.com/aki017/slack-api-docs/blob/master/methods/chat.meMessage.md
# @see https://github.com/aki017/slack-api-docs/blob/master/methods/chat.meMessage.json
def chat_meMessage(options={})
throw ArgumentError.new("Required arguments :channel missing") if options[:channel].nil?
throw ArgumentError.new("Required arguments :text missing") if options[:text].nil?
- options[:attachments] = options[:attachments].to_json if Hash === options[:attachments]
post("chat.meMessage", options)
end
#
# This method posts a message to a public channel, private channel, or direct message/IM channel.
@@ -71,16 +69,37 @@
# @see https://api.slack.com/methods/chat.postMessage
# @see https://github.com/aki017/slack-api-docs/blob/master/methods/chat.postMessage.md
# @see https://github.com/aki017/slack-api-docs/blob/master/methods/chat.postMessage.json
def chat_postMessage(options={})
throw ArgumentError.new("Required arguments :channel missing") if options[:channel].nil?
- throw ArgumentError.new("Required arguments :text missing") if options[:text].nil?
- options[:attachments] = options[:attachments].to_json if Hash === options[:attachments]
+ throw ArgumentError.new("Required arguments :text or :attachments missing") if options[:text].nil? && options[:attachments].nil?
+ options[:attachments] = options[:attachments].to_json if options[:attachments].is_a?(Array) || options[:attachments].is_a?(Hash)
post("chat.postMessage", options)
end
#
+ # This method attaches Slack app unfurl behavior to a specified and relevant message. A user token is required as this method does not support bot user tokens.
+ #
+ # @option options [Object] :channel
+ # Channel ID of the message
+ # @option options [Object] :ts
+ # Timestamp of the message to add unfurl behavior to
+ # @option options [Object] :unfurls
+ # JSON mapping a set of URLs from the message to their unfurl attachments
+ # @option options [Object] :user_auth_required
+ # Set to true or 1 to indicate the user must install your Slack app to trigger unfurls for this domain
+ # @see https://api.slack.com/methods/chat.unfurl
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/chat.unfurl.md
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/chat.unfurl.json
+ def chat_unfurl(options={})
+ throw ArgumentError.new("Required arguments :channel missing") if options[:channel].nil?
+ throw ArgumentError.new("Required arguments :ts missing") if options[:ts].nil?
+ throw ArgumentError.new("Required arguments :unfurls missing") if options[:unfurls].nil?
+ post("chat.unfurl", options)
+ end
+
+ #
# This method updates a message in a channel. Though related to chat.postMessage, some parameters of chat.update are handled differently.
#
# @option options [Object] :ts
# Timestamp of the message to be updated.
# @option options [Object] :channel
@@ -100,10 +119,10 @@
# @see https://github.com/aki017/slack-api-docs/blob/master/methods/chat.update.json
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?
- options[:attachments] = options[:attachments].to_json if Hash === options[:attachments]
+ options[:attachments] = options[:attachments].to_json if options[:attachments].is_a?(Array) || options[:attachments].is_a?(Hash)
post("chat.update", options)
end
end
end