From 0edee8bcd985be4ff1294ad7f25bba5fcab7c19e Mon Sep 17 00:00:00 2001 From: dblock Date: Wed, 8 Mar 2017 19:21:17 -0500 Subject: [PATCH] Updated Slack API, 3/8/2017. --- CHANGELOG.md | 2 ++ bin/commands/channels.rb | 3 +++ bin/commands/files_comments.rb | 1 - bin/commands/groups.rb | 2 ++ bin/commands/search.rb | 6 +++--- lib/slack/web/api/endpoints/channels.rb | 6 ++++++ lib/slack/web/api/endpoints/files_comments.rb | 3 --- lib/slack/web/api/endpoints/groups.rb | 4 ++++ lib/slack/web/api/endpoints/search.rb | 6 +++--- lib/slack/web/api/slack-api-ref | 2 +- 10 files changed, 24 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 928ea1ea..6b9d7b0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ * [#134](https://github.com/slack-ruby/slack-ruby-client/issues/134): Set `start_options[:request][:timeout]`, used with `rtm.start` in `Slack::RealTime::Client`, to 180 seconds - [@dblock](https://github.com/dblock). * [#136](https://github.com/slack-ruby/slack-ruby-client/pull/136): Pass request options in web client calls - [@dblock](https://github.com/dblock). * [#121](https://github.com/slack-ruby/slack-ruby-client/pull/121): Fix: check that the current Celluloid actor is running before calling `terminate` - [@newdark](https://github.com/newdark). +* [#138](https://github.com/slack-ruby/slack-ruby-client/pull/138): Added `validate` option to `channels_create`, `channels_join`, `channels_rename`, `groups_create` and `groups_rename` Web APIs - [@dblock](https://github.com/dblock). +* [#138](https://github.com/slack-ruby/slack-ruby-client/pull/138): Removed `channel` option from `files_comments_add` Web API - [@dblock](https://github.com/dblock). * Your contribution here. ### 0.7.9 (2/9/2017) diff --git a/bin/commands/channels.rb b/bin/commands/channels.rb index 0b286952..8041fc61 100644 --- a/bin/commands/channels.rb +++ b/bin/commands/channels.rb @@ -15,6 +15,7 @@ g.long_desc %( This method is used to create a channel. ) g.command 'create' do |c| c.flag 'name', desc: 'Name of channel to create.' + c.flag 'validate', desc: 'Whether to return errors on invalid channel name instead of modifying it to meet the specified criteria.' c.action do |_global_options, options, _args| puts JSON.dump($client.channels_create(options)) end @@ -56,6 +57,7 @@ g.long_desc %( This method is used to join a channel. If the channel does not exist, it is created. ) g.command 'join' do |c| c.flag 'name', desc: 'Name of channel to join.' + c.flag 'validate', desc: 'Whether to return errors on invalid channel name instead of modifying it to meet the specified criteria.' c.action do |_global_options, options, _args| puts JSON.dump($client.channels_join(options)) end @@ -104,6 +106,7 @@ g.command 'rename' do |c| c.flag 'channel', desc: 'Channel to rename.' c.flag 'name', desc: 'New name for channel.' + c.flag 'validate', desc: 'Whether to return errors on invalid channel name instead of modifying it to meet the specified criteria.' c.action do |_global_options, options, _args| puts JSON.dump($client.channels_rename(options)) end diff --git a/bin/commands/files_comments.rb b/bin/commands/files_comments.rb index ccb63693..a30e3116 100644 --- a/bin/commands/files_comments.rb +++ b/bin/commands/files_comments.rb @@ -7,7 +7,6 @@ g.command 'add' do |c| c.flag 'file', desc: 'File to add a comment to.' c.flag 'comment', desc: 'Text of the comment to add.' - c.flag 'channel', desc: 'Channel id (encoded) of which location to associate with the new comment.' c.action do |_global_options, options, _args| puts JSON.dump($client.files_comments_add(options)) end diff --git a/bin/commands/groups.rb b/bin/commands/groups.rb index ffef14dc..59002a4a 100644 --- a/bin/commands/groups.rb +++ b/bin/commands/groups.rb @@ -24,6 +24,7 @@ g.long_desc %( This method creates a private channel. ) g.command 'create' do |c| c.flag 'name', desc: 'Name of private channel to create.' + c.flag 'validate', desc: 'Whether to return errors on invalid channel name instead of modifying it to meet the specified criteria.' c.action do |_global_options, options, _args| puts JSON.dump($client.groups_create(options)) end @@ -122,6 +123,7 @@ g.command 'rename' do |c| c.flag 'channel', desc: 'Private channel to rename.' c.flag 'name', desc: 'New name for private channel.' + c.flag 'validate', desc: 'Whether to return errors on invalid channel name instead of modifying it to meet the specified criteria.' c.action do |_global_options, options, _args| puts JSON.dump($client.groups_rename(options)) end diff --git a/bin/commands/search.rb b/bin/commands/search.rb index 99039654..89fb9441 100644 --- a/bin/commands/search.rb +++ b/bin/commands/search.rb @@ -8,7 +8,7 @@ c.flag 'query', desc: 'Search query. May contains booleans, etc.' c.flag 'sort', desc: 'Return matches sorted by either score or timestamp.' c.flag 'sort_dir', desc: 'Change sort direction to ascending (asc) or descending (desc).' - c.flag 'highlight', desc: 'Pass a value of 1 to enable query highlight markers (see below).' + c.flag 'highlight', desc: 'Pass a value of true to enable query highlight markers (see below).' c.action do |_global_options, options, _args| puts JSON.dump($client.search_all(options)) end @@ -20,7 +20,7 @@ c.flag 'query', desc: 'Search query. May contain booleans, etc.' c.flag 'sort', desc: 'Return matches sorted by either score or timestamp.' c.flag 'sort_dir', desc: 'Change sort direction to ascending (asc) or descending (desc).' - c.flag 'highlight', desc: 'Pass a value of 1 to enable query highlight markers (see below).' + c.flag 'highlight', desc: 'Pass a value of true to enable query highlight markers (see below).' c.action do |_global_options, options, _args| puts JSON.dump($client.search_files(options)) end @@ -32,7 +32,7 @@ c.flag 'query', desc: 'Search query. May contains booleans, etc.' c.flag 'sort', desc: 'Return matches sorted by either score or timestamp.' c.flag 'sort_dir', desc: 'Change sort direction to ascending (asc) or descending (desc).' - c.flag 'highlight', desc: 'Pass a value of 1 to enable query highlight markers (see below).' + c.flag 'highlight', desc: 'Pass a value of true to enable query highlight markers (see below).' c.action do |_global_options, options, _args| puts JSON.dump($client.search_messages(options)) end diff --git a/lib/slack/web/api/endpoints/channels.rb b/lib/slack/web/api/endpoints/channels.rb index 3794ff8e..e6b25453 100644 --- a/lib/slack/web/api/endpoints/channels.rb +++ b/lib/slack/web/api/endpoints/channels.rb @@ -23,6 +23,8 @@ def channels_archive(options = {}) # # @option options [Object] :name # Name of channel to create. + # @option options [Object] :validate + # Whether to return errors on invalid channel name instead of modifying it to meet the specified criteria. # @see https://api.slack.com/methods/channels.create # @see https://github.com/dblock/slack-api-ref/blob/master/methods/channels/channels.create.json def channels_create(options = {}) @@ -87,6 +89,8 @@ def channels_invite(options = {}) # # @option options [Object] :name # Name of channel to join. + # @option options [Object] :validate + # Whether to return errors on invalid channel name instead of modifying it to meet the specified criteria. # @see https://api.slack.com/methods/channels.join # @see https://github.com/dblock/slack-api-ref/blob/master/methods/channels/channels.join.json def channels_join(options = {}) @@ -158,6 +162,8 @@ def channels_mark(options = {}) # Channel to rename. # @option options [Object] :name # New name for channel. + # @option options [Object] :validate + # Whether to return errors on invalid channel name instead of modifying it to meet the specified criteria. # @see https://api.slack.com/methods/channels.rename # @see https://github.com/dblock/slack-api-ref/blob/master/methods/channels/channels.rename.json def channels_rename(options = {}) diff --git a/lib/slack/web/api/endpoints/files_comments.rb b/lib/slack/web/api/endpoints/files_comments.rb index 7c908b12..6085168e 100644 --- a/lib/slack/web/api/endpoints/files_comments.rb +++ b/lib/slack/web/api/endpoints/files_comments.rb @@ -12,14 +12,11 @@ module FilesComments # File to add a comment to. # @option options [Object] :comment # Text of the comment to add. - # @option options [channel] :channel - # Channel id (encoded) of which location to associate with the new comment. # @see https://api.slack.com/methods/files.comments.add # @see https://github.com/dblock/slack-api-ref/blob/master/methods/files.comments/files.comments.add.json def files_comments_add(options = {}) throw ArgumentError.new('Required arguments :file missing') if options[:file].nil? throw ArgumentError.new('Required arguments :comment missing') if options[:comment].nil? - options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel] post('files.comments.add', options) end diff --git a/lib/slack/web/api/endpoints/groups.rb b/lib/slack/web/api/endpoints/groups.rb index 0107f50e..ed40e8aa 100644 --- a/lib/slack/web/api/endpoints/groups.rb +++ b/lib/slack/web/api/endpoints/groups.rb @@ -36,6 +36,8 @@ def groups_close(options = {}) # # @option options [Object] :name # Name of private channel to create. + # @option options [Object] :validate + # Whether to return errors on invalid channel name instead of modifying it to meet the specified criteria. # @see https://api.slack.com/methods/groups.create # @see https://github.com/dblock/slack-api-ref/blob/master/methods/groups/groups.create.json def groups_create(options = {}) @@ -187,6 +189,8 @@ def groups_open(options = {}) # Private channel to rename. # @option options [Object] :name # New name for private channel. + # @option options [Object] :validate + # Whether to return errors on invalid channel name instead of modifying it to meet the specified criteria. # @see https://api.slack.com/methods/groups.rename # @see https://github.com/dblock/slack-api-ref/blob/master/methods/groups/groups.rename.json def groups_rename(options = {}) diff --git a/lib/slack/web/api/endpoints/search.rb b/lib/slack/web/api/endpoints/search.rb index 771525f6..d923b4ec 100644 --- a/lib/slack/web/api/endpoints/search.rb +++ b/lib/slack/web/api/endpoints/search.rb @@ -15,7 +15,7 @@ module Search # @option options [Object] :sort_dir # Change sort direction to ascending (asc) or descending (desc). # @option options [Object] :highlight - # Pass a value of 1 to enable query highlight markers (see below). + # Pass a value of true to enable query highlight markers (see below). # @see https://api.slack.com/methods/search.all # @see https://github.com/dblock/slack-api-ref/blob/master/methods/search/search.all.json def search_all(options = {}) @@ -33,7 +33,7 @@ def search_all(options = {}) # @option options [Object] :sort_dir # Change sort direction to ascending (asc) or descending (desc). # @option options [Object] :highlight - # Pass a value of 1 to enable query highlight markers (see below). + # Pass a value of true to enable query highlight markers (see below). # @see https://api.slack.com/methods/search.files # @see https://github.com/dblock/slack-api-ref/blob/master/methods/search/search.files.json def search_files(options = {}) @@ -51,7 +51,7 @@ def search_files(options = {}) # @option options [Object] :sort_dir # Change sort direction to ascending (asc) or descending (desc). # @option options [Object] :highlight - # Pass a value of 1 to enable query highlight markers (see below). + # Pass a value of true to enable query highlight markers (see below). # @see https://api.slack.com/methods/search.messages # @see https://github.com/dblock/slack-api-ref/blob/master/methods/search/search.messages.json def search_messages(options = {}) diff --git a/lib/slack/web/api/slack-api-ref b/lib/slack/web/api/slack-api-ref index 58ffde63..9e94f94d 160000 --- a/lib/slack/web/api/slack-api-ref +++ b/lib/slack/web/api/slack-api-ref @@ -1 +1 @@ -Subproject commit 58ffde63cd6940c1b49aff50ad494e042692588b +Subproject commit 9e94f94dcfe02e04de23cab1f5fc47107936491a