Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* [#176](https://github.com/slack-ruby/slack-ruby-client/issues/176): Drop dependency on `json` gem - [@seuros](https://github.com/seuros).
* [#177](https://github.com/slack-ruby/slack-ruby-client/pull/177): Fix api ref repo - [@manuelmeurer](https://github.com/manuelmeurer).
* [#180](https://github.com/slack-ruby/slack-ruby-client/pull/180): Upgraded RuboCop 0.51.0 - [@dblock](https://github.com/dblock).
* [#181](https://github.com/slack-ruby/slack-ruby-client/pull/181): Added `chat_getPermalink`, `migration_exchange`, `users_admin_invite`, `users_admin_setInactive` and `users_prefs_get` - [@dblock](https://github.com/dblock).
* Your contribution here.

### 0.10.0 (9/19/2017)
Expand Down
3 changes: 2 additions & 1 deletion bin/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
require 'commands/dialog'
require 'commands/dnd'
require 'commands/emoji'
require 'commands/files_comments'
require 'commands/files'
require 'commands/files_comments'
require 'commands/groups'
require 'commands/im'
require 'commands/migration'
require 'commands/mpim'
require 'commands/oauth'
require 'commands/pins'
Expand Down
18 changes: 9 additions & 9 deletions bin/commands/channels.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@
end
end

g.desc 'This method returns the ID of a team channel.'
g.long_desc %( This method returns the ID of a team channel. )
g.command 'id' do |c|
c.flag 'channel', desc: 'Channel to get ID for, prefixed with #.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.channels_id(options))
end
end

g.desc 'Gets information about a channel.'
g.long_desc %( Gets information about a channel. )
g.command 'info' do |c|
Expand Down Expand Up @@ -154,13 +163,4 @@
puts JSON.dump($client.channels_unarchive(options))
end
end

g.desc 'This method returns the ID of a team channel.'
g.long_desc %( This method returns the ID of a team channel. )
g.command 'id' do |c|
c.flag 'channel', desc: 'Channel to get ID for, prefixed with #.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.channels_id(options))
end
end
end
16 changes: 13 additions & 3 deletions bin/commands/chat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,22 @@
g.command 'delete' do |c|
c.flag 'channel', desc: 'Channel containing the message to be deleted.'
c.flag 'ts', desc: 'Timestamp of the message to be deleted.'
c.flag 'as_user', desc: 'Pass true to delete the message as the authed user. Bot users in this context are considered authed users.'
c.flag 'as_user', desc: 'Pass true to delete the message as the authed user with chat:write:user scope. Bot users in this context are considered authed users. If unused or false, the message will be deleted with chat:write:bot scope.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.chat_delete(options))
end
end

g.desc 'Retrieve a permalink URL for a specific extant message'
g.long_desc %( Retrieve a permalink URL for a specific extant message )
g.command 'getPermalink' do |c|
c.flag 'channel', desc: 'The ID of the conversation or channel containing the message.'
c.flag 'message_ts', desc: "A message's ts value, uniquely identifying it within a channel."
c.action do |_global_options, options, _args|
puts JSON.dump($client.chat_getPermalink(options))
end
end

g.desc 'Share a me message into a channel.'
g.long_desc %( Share a me message into a channel. )
g.command 'meMessage' do |c|
Expand Down Expand Up @@ -77,10 +87,10 @@
g.long_desc %( Updates a message. )
g.command 'update' do |c|
c.flag 'channel', desc: 'Channel containing the message to be updated.'
c.flag 'text', desc: 'New text for the message, using the default formatting rules.'
c.flag 'text', desc: "New text for the message, using the default formatting rules. It's not required when presenting attachments."
c.flag 'ts', desc: 'Timestamp of the message to be updated.'
c.flag 'as_user', desc: 'Pass true to update the message as the authed user. Bot users in this context are considered authed users.'
c.flag 'attachments', desc: 'A JSON-based array of structured attachments, presented as a URL-encoded string.'
c.flag 'attachments', desc: 'A JSON-based array of structured attachments, presented as a URL-encoded string. This field is required when not presenting text.'
c.flag 'link_names', desc: 'Find and link channel names and usernames. Defaults to none. This parameter should be used in conjunction with parse. To set link_names to 1, specify a parse mode of full.'
c.flag 'parse', desc: 'Change how messages are treated. Defaults to client, unlike chat.postMessage. See below.'
c.action do |_global_options, options, _args|
Expand Down
20 changes: 10 additions & 10 deletions bin/commands/groups.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@
end
end

g.desc 'This method returns the ID of a group.'
g.long_desc %( This method returns the ID of a group. )
g.command 'id' do |c|
c.flag 'channel', desc: 'Group channel to get ID for, prefixed with #.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.groups_id(options))
end
end

g.desc 'Gets information about a private channel.'
g.long_desc %( Gets information about a private channel. )
g.command 'info' do |c|
Expand Down Expand Up @@ -86,7 +95,7 @@
g.long_desc %( Lists private channels that the calling user has access to. )
g.command 'list' do |c|
c.flag 'exclude_archived', desc: "Don't return archived private channels."
c.flag 'exclude_members', desc: 'Exlude the members from each group.'
c.flag 'exclude_members', desc: 'Exclude the members from each group.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.groups_list(options))
end
Expand Down Expand Up @@ -160,13 +169,4 @@
puts JSON.dump($client.groups_unarchive(options))
end
end

g.desc 'This method returns the ID of a group.'
g.long_desc %( This method returns the ID of a group. )
g.command 'id' do |c|
c.flag 'channel', desc: 'Group channel to get ID for, prefixed with #.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.groups_id(options))
end
end
end
14 changes: 14 additions & 0 deletions bin/commands/migration.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This file was auto-generated by lib/tasks/web.rake

desc 'Migration methods.'
command 'migration' do |g|
g.desc 'For Enterprise Grid workspaces, map local user IDs to global user IDs'
g.long_desc %( For Enterprise Grid workspaces, map local user IDs to global user IDs )
g.command 'exchange' do |c|
c.flag 'users', desc: 'A comma-separated list of user ids, up to 400 per request.'
c.flag 'to_old', desc: 'Specify true to convert W global user IDs to workspace-specific U IDs. Defaults to false.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.migration_exchange(options))
end
end
end
6 changes: 2 additions & 4 deletions bin/commands/rtm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
g.desc 'Starts a Real Time Messaging session.'
g.long_desc %( Starts a Real Time Messaging session. )
g.command 'connect' do |c|
c.flag 'batch_presence_aware', desc: 'Group presence change notices as presence_change_batch events when possible. See batching.'
c.flag 'presence_sub', desc: 'Only deliver presence events when requested by subscription. See presence subscriptions.'
c.flag 'batch_presence_aware', desc: 'Only deliver presence events when requested by subscription. See presence subscriptions.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.rtm_connect(options))
end
Expand All @@ -15,12 +14,11 @@
g.desc 'Starts a Real Time Messaging session.'
g.long_desc %( Starts a Real Time Messaging session. )
g.command 'start' do |c|
c.flag 'batch_presence_aware', desc: 'Group presence change notices as presence_change_batch events when possible. See batching.'
c.flag 'batch_presence_aware', desc: 'Only deliver presence events when requested by subscription. See presence subscriptions.'
c.flag 'include_locale', desc: 'Set this to true to receive the locale for users and channels. Defaults to false.'
c.flag 'mpim_aware', desc: 'Returns MPIMs to the client in the API response.'
c.flag 'no_latest', desc: 'Exclude latest timestamps for channels, groups, mpims, and ims. Automatically sets no_unreads to 1.'
c.flag 'no_unreads', desc: 'Skip unread counts for each channel (improves performance).'
c.flag 'presence_sub', desc: 'Only deliver presence events when requested by subscription. See presence subscriptions.'
c.flag 'simple_latest', desc: 'Return timestamp only for latest message object of each channel (improves performance).'
c.action do |_global_options, options, _args|
puts JSON.dump($client.rtm_start(options))
Expand Down
36 changes: 18 additions & 18 deletions bin/commands/users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@
end
end

g.desc 'This method returns the ID of a team user.'
g.long_desc %( This method returns the ID of a team user. )
g.command 'id' do |c|
c.flag 'user', desc: 'User to get ID for, prefixed with @.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.users_id(options))
end
end

g.desc "Get a user's identity."
g.long_desc %( Get a user's identity. )
g.command 'identity' do |c|
Expand Down Expand Up @@ -49,6 +58,15 @@
end
end

g.desc 'This method searches for users.'
g.long_desc %( This method searches for users. )
g.command 'search' do |c|
c.flag 'user', desc: 'User to search for.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.users_search(options))
end
end

g.desc 'Marks a user as active.'
g.long_desc %( Marks a user as active. )
g.command 'setActive' do |c|
Expand Down Expand Up @@ -77,22 +95,4 @@
puts JSON.dump($client.users_setPresence(options))
end
end

g.desc 'This method returns the ID of a team user.'
g.long_desc %( This method returns the ID of a team user. )
g.command 'id' do |c|
c.flag 'user', desc: 'User to get ID for, prefixed with @.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.users_id(options))
end
end

g.desc 'This method searches for users.'
g.long_desc %( This method searches for users. )
g.command 'search' do |c|
c.flag 'user', desc: 'User to search for.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.users_search(options))
end
end
end
28 changes: 28 additions & 0 deletions bin/commands/users_admin.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This file was auto-generated by lib/tasks/web.rake

desc 'UsersAdmin methods.'
command 'users_admin' do |g|
g.desc 'Send an invitation to a new user by email'
g.long_desc %( Send an invitation to a new user by email )
g.command 'invite' do |c|
c.flag 'email', desc: 'Email address of the new user'
c.flag 'channels', desc: 'Comma-separated list of IDs (not names!) for channels, which the new user will auto-join. Both channel IDs for public channels and group IDs for private chanels work.'
c.flag 'first_name', desc: 'Prefilled input for the "First name" field on the "new user registration" page.'
c.flag 'last_name', desc: 'Prefilled input for the "Last name" field on the "new user registration" page.'
c.flag 'resend', desc: 'Resend the invitation email if the user has already been invited and the email was sent some time ago.'
c.flag 'restricted', desc: 'Invite a guest that can use multiple channels'
c.flag 'ultra_restricted', desc: 'Invite a guest that can use one channel only'
c.action do |_global_options, options, _args|
puts JSON.dump($client.users_admin_invite(options))
end
end

g.desc 'Disable a user'
g.long_desc %( Disable a user )
g.command 'setInactive' do |c|
c.flag 'user', desc: 'User to disable'
c.action do |_global_options, options, _args|
puts JSON.dump($client.users_admin_setInactive(options))
end
end
end
6 changes: 4 additions & 2 deletions lib/slack/web/api/endpoints.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
require_relative 'endpoints/dialog'
require_relative 'endpoints/dnd'
require_relative 'endpoints/emoji'
require_relative 'endpoints/files_comments'
require_relative 'endpoints/files'
require_relative 'endpoints/files_comments'
require_relative 'endpoints/groups'
require_relative 'endpoints/im'
require_relative 'endpoints/migration'
require_relative 'endpoints/mpim'
require_relative 'endpoints/oauth'
require_relative 'endpoints/pins'
Expand Down Expand Up @@ -47,10 +48,11 @@ module Endpoints
include Dialog
include Dnd
include Emoji
include FilesComments
include Files
include FilesComments
include Groups
include Im
include Migration
include Mpim
include Oauth
include Pins
Expand Down
22 changes: 19 additions & 3 deletions lib/slack/web/api/endpoints/chat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module Chat
# @option options [timestamp] :ts
# Timestamp of the message to be deleted.
# @option options [Object] :as_user
# Pass true to delete the message as the authed user. Bot users in this context are considered authed users.
# Pass true to delete the message as the authed user with chat:write:user scope. Bot users in this context are considered authed users. If unused or false, the message will be deleted with chat:write:bot scope.
# @see https://api.slack.com/methods/chat.delete
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/chat/chat.delete.json
def chat_delete(options = {})
Expand All @@ -23,6 +23,22 @@ def chat_delete(options = {})
post('chat.delete', options)
end

#
# Retrieve a permalink URL for a specific extant message
#
# @option options [channel] :channel
# The ID of the conversation or channel containing the message.
# @option options [Object] :message_ts
# A message's ts value, uniquely identifying it within a channel.
# @see https://api.slack.com/methods/chat.getPermalink
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/chat/chat.getPermalink.json
def chat_getPermalink(options = {})
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
throw ArgumentError.new('Required arguments :message_ts missing') if options[:message_ts].nil?
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
post('chat.getPermalink', options)
end

#
# Share a me message into a channel.
#
Expand Down Expand Up @@ -145,13 +161,13 @@ def chat_unfurl(options = {})
# @option options [channel] :channel
# Channel containing the message to be updated.
# @option options [Object] :text
# New text for the message, using the default formatting rules.
# New text for the message, using the default formatting rules. It's not required when presenting attachments.
# @option options [timestamp] :ts
# Timestamp of the message to be updated.
# @option options [Object] :as_user
# Pass true to update the message as the authed user. Bot users in this context are considered authed users.
# @option options [Object] :attachments
# A JSON-based array of structured attachments, presented as a URL-encoded string.
# A JSON-based array of structured attachments, presented as a URL-encoded string. This field is required when not presenting text.
# @option options [Object] :link_names
# Find and link channel names and usernames. Defaults to none. This parameter should be used in conjunction with parse. To set link_names to 1, specify a parse mode of full.
# @option options [Object] :parse
Expand Down
2 changes: 1 addition & 1 deletion lib/slack/web/api/endpoints/groups.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def groups_leave(options = {})
# @option options [Object] :exclude_archived
# Don't return archived private channels.
# @option options [Object] :exclude_members
# Exlude the members from each group.
# Exclude the members from each group.
# @see https://api.slack.com/methods/groups.list
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/groups/groups.list.json
def groups_list(options = {})
Expand Down
25 changes: 25 additions & 0 deletions lib/slack/web/api/endpoints/migration.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This file was auto-generated by lib/tasks/web.rake

module Slack
module Web
module Api
module Endpoints
module Migration
#
# For Enterprise Grid workspaces, map local user IDs to global user IDs
#
# @option options [Object] :users
# A comma-separated list of user ids, up to 400 per request.
# @option options [Object] :to_old
# Specify true to convert W global user IDs to workspace-specific U IDs. Defaults to false.
# @see https://api.slack.com/methods/migration.exchange
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/migration/migration.exchange.json
def migration_exchange(options = {})
throw ArgumentError.new('Required arguments :users missing') if options[:users].nil?
post('migration.exchange', options)
end
end
end
end
end
end
6 changes: 1 addition & 5 deletions lib/slack/web/api/endpoints/rtm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ module Rtm
# Starts a Real Time Messaging session.
#
# @option options [Object] :batch_presence_aware
# Group presence change notices as presence_change_batch events when possible. See batching.
# @option options [Object] :presence_sub
# Only deliver presence events when requested by subscription. See presence subscriptions.
# @see https://api.slack.com/methods/rtm.connect
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/rtm/rtm.connect.json
Expand All @@ -22,7 +20,7 @@ def rtm_connect(options = {})
# Starts a Real Time Messaging session.
#
# @option options [Object] :batch_presence_aware
# Group presence change notices as presence_change_batch events when possible. See batching.
# Only deliver presence events when requested by subscription. See presence subscriptions.
# @option options [Object] :include_locale
# Set this to true to receive the locale for users and channels. Defaults to false.
# @option options [Object] :mpim_aware
Expand All @@ -31,8 +29,6 @@ def rtm_connect(options = {})
# Exclude latest timestamps for channels, groups, mpims, and ims. Automatically sets no_unreads to 1.
# @option options [Object] :no_unreads
# Skip unread counts for each channel (improves performance).
# @option options [Object] :presence_sub
# Only deliver presence events when requested by subscription. See presence subscriptions.
# @option options [Object] :simple_latest
# Return timestamp only for latest message object of each channel (improves performance).
# @see https://api.slack.com/methods/rtm.start
Expand Down
Loading