Skip to content

Commit

Permalink
update Slack Web API with new methods (#298)
Browse files Browse the repository at this point in the history
* update Web API

* convert view option to JSON

* add custom spec for views endpoint

* update changelog

* changes for rubocop
  • Loading branch information
jmanian authored and dblock committed Sep 27, 2019
1 parent 499c4ba commit 6b559c3
Show file tree
Hide file tree
Showing 88 changed files with 835 additions and 473 deletions.
1 change: 1 addition & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ RSpec/FilePath:
- 'spec/slack/web/api/endpoints/custom_specs/dialog_spec.rb'
- 'spec/slack/web/api/endpoints/custom_specs/groups_spec.rb'
- 'spec/slack/web/api/endpoints/custom_specs/users_spec.rb'
- 'spec/slack/web/api/endpoints/custom_specs/views_spec.rb'
- 'spec/slack/web/api/errors/service_unavailable_spec.rb'

# Offense count: 13
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

* [#293](https://github.com/slack-ruby/slack-ruby-client/pull/293): Rubocop auto-correct and comprehensive todo - [@jcraigk](https://github.com/jcraigk).
* [#297](https://github.com/slack-ruby/slack-ruby-client/pull/297): Various Rubocop fixes - [@jcraigk](https://github.com/jcraigk).

* [#298](https://github.com/slack-ruby/slack-ruby-client/pull/298): Add `admin.apps`, `admin.app.requests` and `views` endpoints - [@jmanian](https://github.com/jmanian).
* Your contribution here.

### 0.14.4 (2019/7/28)
Expand Down
3 changes: 3 additions & 0 deletions bin/commands.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true
# This file was auto-generated by lib/tasks/web.rake

require 'commands/admin_apps'
require 'commands/admin_apps_requests'
require 'commands/admin_users_session'
require 'commands/api'
require 'commands/apps'
Expand Down Expand Up @@ -39,3 +41,4 @@
require 'commands/users_admin'
require 'commands/users_prefs'
require 'commands/users_profile'
require 'commands/views'
27 changes: 27 additions & 0 deletions bin/commands/admin_apps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# frozen_string_literal: true
# This file was auto-generated by lib/tasks/web.rake

desc 'AdminApps methods.'
command 'admin_apps' do |g|
g.desc 'Approve an app for installation on a workspace.'
g.long_desc %( Approve an app for installation on a workspace. )
g.command 'approve' do |c|
c.flag 'app_id', desc: 'The id of the app to approve.'
c.flag 'request_id', desc: 'The id of the request to approve.'
c.flag 'team_id', desc: '.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_apps_approve(options))
end
end

g.desc 'Restrict an app for installation on a workspace.'
g.long_desc %( Restrict an app for installation on a workspace. )
g.command 'restrict' do |c|
c.flag 'app_id', desc: 'The id of the app to restrict.'
c.flag 'request_id', desc: 'The id of the request to restrict.'
c.flag 'team_id', desc: '.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_apps_restrict(options))
end
end
end
16 changes: 16 additions & 0 deletions bin/commands/admin_apps_requests.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true
# This file was auto-generated by lib/tasks/web.rake

desc 'AdminAppsRequests methods.'
command 'admin_apps_requests' do |g|
g.desc 'List app requests for a team/workspace.'
g.long_desc %( List app requests for a team/workspace. )
g.command 'list' do |c|
c.flag 'cursor', desc: 'Set cursor to next_cursor returned by the previous call to list items in the next page.'
c.flag 'limit', desc: 'The maximum number of items to return. Must be between 1 - 1000 both inclusive.'
c.flag 'team_id', desc: '.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_apps_requests_list(options))
end
end
end
4 changes: 2 additions & 2 deletions bin/commands/admin_users_session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

desc 'AdminUsersSession methods.'
command 'admin_users_session' do |g|
g.desc "This method wipes a user session, leaving the user unauthenticated. The user's Slack client will reset its local cache."
g.long_desc %( This method wipes a user session, leaving the user unauthenticated. The user's Slack client will reset its local cache. )
g.desc 'Wipes all valid sessions on all devices for a given user'
g.long_desc %( Wipes all valid sessions on all devices for a given user )
g.command 'reset' do |c|
c.flag 'user_id', desc: 'The ID of the user to wipe sessions for.'
c.flag 'mobile_only', desc: 'Only expire mobile sessions (default: false).'
Expand Down
4 changes: 2 additions & 2 deletions bin/commands/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

desc 'Api methods.'
command 'api' do |g|
g.desc 'This method helps you test your calling code.'
g.long_desc %( This method helps you test your calling code. )
g.desc 'Checks API calling code.'
g.long_desc %( Checks API calling code. )
g.command 'test' do |c|
c.flag 'error', desc: 'Error response to return.'
c.flag 'foo', desc: 'example property to return.'
Expand Down
4 changes: 2 additions & 2 deletions bin/commands/apps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

desc 'Apps methods.'
command 'apps' do |g|
g.desc 'This method uninstalls an app. Unlike auth.revoke, which revokes a single token, this method revokes all tokens associated with a single installation of an app.'
g.long_desc %( This method uninstalls an app. Unlike auth.revoke, which revokes a single token, this method revokes all tokens associated with a single installation of an app. )
g.desc 'Uninstalls your app from a workspace.'
g.long_desc %( Uninstalls your app from a workspace. )
g.command 'uninstall' do |c|
c.flag 'client_id', desc: 'Issued when you created your application.'
c.flag 'client_secret', desc: 'Issued when you created your application.'
Expand Down
8 changes: 4 additions & 4 deletions bin/commands/apps_permissions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@

desc 'AppsPermissions methods.'
command 'apps_permissions' do |g|
g.desc 'This feature was exclusive to our workspace apps developer preview. The preview has now ended, but fan-favorite features such as token rotation and the Conversations API will become available to classic Slack apps over the coming months.'
g.long_desc %( This feature was exclusive to our workspace apps developer preview. The preview has now ended, but fan-favorite features such as token rotation and the Conversations API will become available to classic Slack apps over the coming months. )
g.desc 'Returns list of permissions this app has on a team.'
g.long_desc %( Returns list of permissions this app has on a team. )
g.command 'info' do |c|
c.action do |_global_options, options, _args|
puts JSON.dump($client.apps_permissions_info(options))
end
end

g.desc 'This feature was exclusive to our workspace apps developer preview. The preview has now ended, but fan-favorite features such as token rotation and the Conversations API will become available to classic Slack apps over the coming months.'
g.long_desc %( This feature was exclusive to our workspace apps developer preview. The preview has now ended, but fan-favorite features such as token rotation and the Conversations API will become available to classic Slack apps over the coming months. )
g.desc 'Allows an app to request additional scopes'
g.long_desc %( Allows an app to request additional scopes )
g.command 'request' do |c|
c.flag 'scopes', desc: 'A comma separated list of scopes to request for.'
c.flag 'trigger_id', desc: 'Token used to trigger the permissions API.'
Expand Down
4 changes: 2 additions & 2 deletions bin/commands/apps_permissions_resources.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

desc 'AppsPermissionsResources methods.'
command 'apps_permissions_resources' do |g|
g.desc 'This feature was exclusive to our workspace apps developer preview. The preview has now ended, but fan-favorite features such as token rotation and the Conversations API will become available to classic Slack apps over the coming months.'
g.long_desc %( This feature was exclusive to our workspace apps developer preview. The preview has now ended, but fan-favorite features such as token rotation and the Conversations API will become available to classic Slack apps over the coming months. )
g.desc 'Returns list of resource grants this app has on a team.'
g.long_desc %( Returns list of resource grants this app has on a team. )
g.command 'list' do |c|
c.flag 'cursor', desc: "Paginate through collections of data by setting the cursor parameter to a next_cursor attribute returned by a previous request's response_metadata. Default value fetches the first 'page' of the collection. See pagination for more detail."
c.flag 'limit', desc: 'The maximum number of items to return.'
Expand Down
4 changes: 2 additions & 2 deletions bin/commands/apps_permissions_scopes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

desc 'AppsPermissionsScopes methods.'
command 'apps_permissions_scopes' do |g|
g.desc 'This feature was exclusive to our workspace apps developer preview. The preview has now ended, but fan-favorite features such as token rotation and the Conversations API will become available to classic Slack apps over the coming months.'
g.long_desc %( This feature was exclusive to our workspace apps developer preview. The preview has now ended, but fan-favorite features such as token rotation and the Conversations API will become available to classic Slack apps over the coming months. )
g.desc 'Returns list of scopes this app has on a team.'
g.long_desc %( Returns list of scopes this app has on a team. )
g.command 'list' do |c|
c.action do |_global_options, options, _args|
puts JSON.dump($client.apps_permissions_scopes_list(options))
Expand Down
8 changes: 4 additions & 4 deletions bin/commands/apps_permissions_users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

desc 'AppsPermissionsUsers methods.'
command 'apps_permissions_users' do |g|
g.desc 'This feature was exclusive to our workspace apps developer preview. The preview has now ended, but fan-favorite features such as token rotation and the Conversations API will become available to classic Slack apps over the coming months.'
g.long_desc %( This feature was exclusive to our workspace apps developer preview. The preview has now ended, but fan-favorite features such as token rotation and the Conversations API will become available to classic Slack apps over the coming months. )
g.desc 'Returns list of user grants and corresponding scopes this app has on a team.'
g.long_desc %( Returns list of user grants and corresponding scopes this app has on a team. )
g.command 'list' do |c|
c.flag 'cursor', desc: "Paginate through collections of data by setting the cursor parameter to a next_cursor attribute returned by a previous request's response_metadata. Default value fetches the first 'page' of the collection. See pagination for more detail."
c.flag 'limit', desc: 'The maximum number of items to return.'
Expand All @@ -13,8 +13,8 @@
end
end

g.desc 'This feature was exclusive to our workspace apps developer preview. The preview has now ended, but fan-favorite features such as token rotation and the Conversations API will become available to classic Slack apps over the coming months.'
g.long_desc %( This feature was exclusive to our workspace apps developer preview. The preview has now ended, but fan-favorite features such as token rotation and the Conversations API will become available to classic Slack apps over the coming months. )
g.desc 'Enables an app to trigger a permissions modal to grant an app access to a user access scope.'
g.long_desc %( Enables an app to trigger a permissions modal to grant an app access to a user access scope. )
g.command 'request' do |c|
c.flag 'scopes', desc: 'A comma separated list of user scopes to request for.'
c.flag 'trigger_id', desc: 'Token used to trigger the request.'
Expand Down
8 changes: 4 additions & 4 deletions bin/commands/auth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@

desc 'Auth methods.'
command 'auth' do |g|
g.desc 'This method revokes an access token. Use it when you no longer need a token. For example, with a Sign In With Slack app, call this to log a user out.'
g.long_desc %( This method revokes an access token. Use it when you no longer need a token. For example, with a Sign In With Slack app, call this to log a user out. )
g.desc 'Revokes a token.'
g.long_desc %( Revokes a token. )
g.command 'revoke' do |c|
c.flag 'test', desc: 'Setting this parameter to 1 triggers a testing mode where the specified token will not actually be revoked.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.auth_revoke(options))
end
end

g.desc 'This method checks authentication and tells "you" who you are, even if you might be a bot.'
g.long_desc %( This method checks authentication and tells "you" who you are, even if you might be a bot. )
g.desc 'Checks authentication & identity.'
g.long_desc %( Checks authentication & identity. )
g.command 'test' do |c|
c.action do |_global_options, options, _args|
puts JSON.dump($client.auth_test(options))
Expand Down
4 changes: 2 additions & 2 deletions bin/commands/bots.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

desc 'Bots methods.'
command 'bots' do |g|
g.desc 'This method returns extended information about a bot user.'
g.long_desc %( This method returns extended information about a bot user. )
g.desc 'Gets information about a bot user.'
g.long_desc %( Gets information about a bot user. )
g.command 'info' do |c|
c.flag 'bot', desc: 'Bot user to get info on.'
c.action do |_global_options, options, _args|
Expand Down
60 changes: 30 additions & 30 deletions bin/commands/channels.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@

desc 'Channels methods.'
command 'channels' do |g|
g.desc 'This method archives a channel.'
g.long_desc %( This method archives a channel. )
g.desc 'Archives a channel.'
g.long_desc %( Archives a channel. )
g.command 'archive' do |c|
c.flag 'channel', desc: 'Channel to archive.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.channels_archive(options))
end
end

g.desc 'This method is used to create a channel.'
g.long_desc %( This method is used to create a channel. )
g.desc 'Creates a channel.'
g.long_desc %( Creates 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.'
Expand All @@ -31,8 +31,8 @@
end
end

g.desc 'This method returns a portion of message events from the specified public channel.'
g.long_desc %( This method returns a portion of message events from the specified public channel. )
g.desc 'Fetches history of messages and events from a channel.'
g.long_desc %( Fetches history of messages and events from a channel. )
g.command 'history' do |c|
c.flag 'channel', desc: 'Channel to fetch history for.'
c.flag 'inclusive', desc: 'Include messages with latest or oldest timestamp in results.'
Expand All @@ -53,8 +53,8 @@
end
end

g.desc 'This method returns information about a team channel.'
g.long_desc %( This method returns information about a team channel. )
g.desc 'Gets information about a channel.'
g.long_desc %( Gets information about a channel. )
g.command 'info' do |c|
c.flag 'channel', desc: 'Channel to get info on.'
c.flag 'include_locale', desc: 'Set this to true to receive the locale for this channel. Defaults to false.'
Expand All @@ -63,8 +63,8 @@
end
end

g.desc 'This method is used to invite a user to a channel. The calling user must be a member of the channel.'
g.long_desc %( This method is used to invite a user to a channel. The calling user must be a member of the channel. )
g.desc 'Invites a user to a channel.'
g.long_desc %( Invites a user to a channel. )
g.command 'invite' do |c|
c.flag 'channel', desc: 'Channel to invite user to.'
c.flag 'user', desc: 'User to invite to channel.'
Expand All @@ -73,8 +73,8 @@
end
end

g.desc 'This method is used to join a channel. If the channel does not exist, it is'
g.long_desc %( This method is used to join a channel. If the channel does not exist, it is created. )
g.desc 'Joins a channel, creating it if needed.'
g.long_desc %( Joins a channel, creating it if needed. )
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.'
Expand All @@ -83,8 +83,8 @@
end
end

g.desc 'This method allows a user to remove another member from a team channel.'
g.long_desc %( This method allows a user to remove another member from a team channel. )
g.desc 'Removes a user from a channel.'
g.long_desc %( Removes a user from a channel. )
g.command 'kick' do |c|
c.flag 'channel', desc: 'Channel to remove user from.'
c.flag 'user', desc: 'User to remove from channel.'
Expand All @@ -93,17 +93,17 @@
end
end

g.desc 'This method is used to leave a channel.'
g.long_desc %( This method is used to leave a channel. )
g.desc 'Leaves a channel.'
g.long_desc %( Leaves a channel. )
g.command 'leave' do |c|
c.flag 'channel', desc: 'Channel to leave.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.channels_leave(options))
end
end

g.desc "Don't use this method. Use conversations.list instead."
g.long_desc %( Don't use this method. Use conversations.list instead. )
g.desc 'Lists all channels in a Slack team.'
g.long_desc %( Lists all channels in a Slack team. )
g.command 'list' do |c|
c.flag 'cursor', desc: "Paginate through collections of data by setting the cursor parameter to a next_cursor attribute returned by a previous request's response_metadata. Default value fetches the first 'page' of the collection. See pagination for more detail."
c.flag 'exclude_archived', desc: 'Exclude archived channels from the list.'
Expand All @@ -114,8 +114,8 @@
end
end

g.desc 'This method moves the read cursor in a channel.'
g.long_desc %( This method moves the read cursor in a channel. )
g.desc 'Sets the read cursor in a channel.'
g.long_desc %( Sets the read cursor in a channel. )
g.command 'mark' do |c|
c.flag 'channel', desc: 'Channel to set reading cursor in.'
c.flag 'ts', desc: 'Timestamp of the most recently seen message.'
Expand All @@ -124,8 +124,8 @@
end
end

g.desc 'This method renames a team channel.'
g.long_desc %( This method renames a team channel. )
g.desc 'Renames a channel.'
g.long_desc %( Renames a channel. )
g.command 'rename' do |c|
c.flag 'channel', desc: 'Channel to rename.'
c.flag 'name', desc: 'New name for channel.'
Expand All @@ -135,8 +135,8 @@
end
end

g.desc 'This method returns an entire thread (a message plus all the messages in reply to it).'
g.long_desc %( This method returns an entire thread (a message plus all the messages in reply to it). )
g.desc 'Retrieve a thread of messages posted to a channel'
g.long_desc %( Retrieve a thread of messages posted to a channel )
g.command 'replies' do |c|
c.flag 'channel', desc: 'Channel to fetch thread from.'
c.flag 'thread_ts', desc: "Unique identifier of a thread's parent message."
Expand All @@ -145,8 +145,8 @@
end
end

g.desc 'This method is used to change the purpose of a channel. The calling user must be a member of the channel.'
g.long_desc %( This method is used to change the purpose of a channel. The calling user must be a member of the channel. )
g.desc 'Sets the purpose for a channel.'
g.long_desc %( Sets the purpose for a channel. )
g.command 'setPurpose' do |c|
c.flag 'channel', desc: 'Channel to set the purpose of.'
c.flag 'purpose', desc: 'The new purpose.'
Expand All @@ -156,8 +156,8 @@
end
end

g.desc 'This method is used to change the topic of a channel. The calling user must be a member of the channel.'
g.long_desc %( This method is used to change the topic of a channel. The calling user must be a member of the channel. )
g.desc 'Sets the topic for a channel.'
g.long_desc %( Sets the topic for a channel. )
g.command 'setTopic' do |c|
c.flag 'channel', desc: 'Channel to set the topic of.'
c.flag 'topic', desc: 'The new topic.'
Expand All @@ -166,8 +166,8 @@
end
end

g.desc 'This method unarchives a channel. The calling user is added to the channel.'
g.long_desc %( This method unarchives a channel. The calling user is added to the channel. )
g.desc 'Unarchives a channel.'
g.long_desc %( Unarchives a channel. )
g.command 'unarchive' do |c|
c.flag 'channel', desc: 'Channel to unarchive.'
c.action do |_global_options, options, _args|
Expand Down
Loading

0 comments on commit 6b559c3

Please sign in to comment.