slack-ruby-client 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -8
  3. data/CHANGELOG.md +4 -0
  4. data/README.md +1 -1
  5. data/bin/commands.rb +1 -0
  6. data/bin/commands/api.rb +2 -2
  7. data/bin/commands/apps_permissions.rb +22 -0
  8. data/bin/commands/auth.rb +4 -4
  9. data/bin/commands/bots.rb +2 -2
  10. data/bin/commands/channels.rb +31 -31
  11. data/bin/commands/chat.rb +40 -23
  12. data/bin/commands/dnd.rb +8 -8
  13. data/bin/commands/emoji.rb +2 -2
  14. data/bin/commands/files.rb +17 -17
  15. data/bin/commands/files_comments.rb +6 -6
  16. data/bin/commands/groups.rb +36 -35
  17. data/bin/commands/im.rb +13 -13
  18. data/bin/commands/mpim.rb +11 -11
  19. data/bin/commands/oauth.rb +15 -2
  20. data/bin/commands/pins.rb +6 -6
  21. data/bin/commands/reactions.rb +13 -13
  22. data/bin/commands/reminders.rb +10 -10
  23. data/bin/commands/rtm.rb +10 -6
  24. data/bin/commands/search.rb +9 -9
  25. data/bin/commands/stars.rb +8 -8
  26. data/bin/commands/team.rb +10 -10
  27. data/bin/commands/team_profile.rb +2 -2
  28. data/bin/commands/usergroups.rb +16 -16
  29. data/bin/commands/usergroups_users.rb +4 -4
  30. data/bin/commands/users.rb +20 -18
  31. data/bin/commands/users_profile.rb +7 -7
  32. data/lib/slack/real_time/stores/starter.rb +20 -0
  33. data/lib/slack/real_time/stores/store.rb +20 -0
  34. data/lib/slack/version.rb +1 -1
  35. data/lib/slack/web/api/endpoints.rb +2 -0
  36. data/lib/slack/web/api/endpoints/api.rb +1 -1
  37. data/lib/slack/web/api/endpoints/apps_permissions.rb +35 -0
  38. data/lib/slack/web/api/endpoints/auth.rb +2 -2
  39. data/lib/slack/web/api/endpoints/bots.rb +1 -1
  40. data/lib/slack/web/api/endpoints/channels.rb +17 -18
  41. data/lib/slack/web/api/endpoints/chat.rb +67 -30
  42. data/lib/slack/web/api/endpoints/dnd.rb +4 -4
  43. data/lib/slack/web/api/endpoints/emoji.rb +1 -1
  44. data/lib/slack/web/api/endpoints/files.rb +16 -17
  45. data/lib/slack/web/api/endpoints/files_comments.rb +8 -8
  46. data/lib/slack/web/api/endpoints/groups.rb +21 -22
  47. data/lib/slack/web/api/endpoints/im.rb +8 -10
  48. data/lib/slack/web/api/endpoints/mpim.rb +7 -9
  49. data/lib/slack/web/api/endpoints/oauth.rb +23 -2
  50. data/lib/slack/web/api/endpoints/pins.rb +3 -5
  51. data/lib/slack/web/api/endpoints/reactions.rb +14 -16
  52. data/lib/slack/web/api/endpoints/reminders.rb +5 -5
  53. data/lib/slack/web/api/endpoints/rtm.rb +14 -6
  54. data/lib/slack/web/api/endpoints/search.rb +9 -9
  55. data/lib/slack/web/api/endpoints/stars.rb +7 -9
  56. data/lib/slack/web/api/endpoints/team.rb +8 -9
  57. data/lib/slack/web/api/endpoints/team_profile.rb +1 -1
  58. data/lib/slack/web/api/endpoints/usergroups.rb +17 -17
  59. data/lib/slack/web/api/endpoints/usergroups_users.rb +2 -2
  60. data/lib/slack/web/api/endpoints/users.rb +15 -15
  61. data/lib/slack/web/api/endpoints/users_profile.rb +8 -8
  62. data/lib/slack/web/api/patches/chat.3.update-attachments-support.patch +4 -3
  63. data/lib/slack/web/api/patches/chat.4.postEphemeral-attachments-support.patch +17 -0
  64. data/spec/integration/integration_spec.rb +1 -1
  65. data/spec/slack/web/api/endpoints/apps_permissions_spec.rb +15 -0
  66. data/spec/slack/web/api/endpoints/custom_specs/chat_spec.rb +37 -1
  67. data/spec/slack/web/api/endpoints/files_comments_spec.rb +8 -8
  68. data/spec/slack/web/api/endpoints/files_spec.rb +0 -5
  69. data/spec/slack/web/api/endpoints/oauth_spec.rb +11 -0
  70. metadata +7 -2
@@ -6,7 +6,7 @@ module Slack
6
6
  module Endpoints
7
7
  module UsergroupsUsers
8
8
  #
9
- # This method returns a list of all users within a User Group.
9
+ # List all users in a User Group
10
10
  #
11
11
  # @option options [Object] :usergroup
12
12
  # The encoded ID of the User Group to update.
@@ -20,7 +20,7 @@ module Slack
20
20
  end
21
21
 
22
22
  #
23
- # This method updates the list of users that belong to a User Group. This method replaces all users in a User Group with the list of users provided in the users parameter.
23
+ # Update the list of users for a User Group
24
24
  #
25
25
  # @option options [Object] :usergroup
26
26
  # The encoded ID of the User Group to update.
@@ -6,7 +6,7 @@ module Slack
6
6
  module Endpoints
7
7
  module Users
8
8
  #
9
- # This method allows the user to delete their profile image. It will clear whatever image is currently set.
9
+ # Delete the user profile photo
10
10
  #
11
11
  # @see https://api.slack.com/methods/users.deletePhoto
12
12
  # @see https://github.com/dblock/slack-api-ref/blob/master/methods/users/users.deletePhoto.json
@@ -15,8 +15,7 @@ module Slack
15
15
  end
16
16
 
17
17
  #
18
- # This method lets you find out information about a user's presence.
19
- # Consult the presence documentation for more details.
18
+ # Gets user presence information.
20
19
  #
21
20
  # @option options [user] :user
22
21
  # User to get presence info on. Defaults to the authed user.
@@ -29,7 +28,7 @@ module Slack
29
28
  end
30
29
 
31
30
  #
32
- # After your Slack app is awarded an identity token through Sign in with Slack, use this method to retrieve a user's identity.
31
+ # Get a user's identity.
33
32
  #
34
33
  # @see https://api.slack.com/methods/users.identity
35
34
  # @see https://github.com/dblock/slack-api-ref/blob/master/methods/users/users.identity.json
@@ -38,7 +37,7 @@ module Slack
38
37
  end
39
38
 
40
39
  #
41
- # This method returns information about a team member.
40
+ # Gets information about a user.
42
41
  #
43
42
  # @option options [user] :user
44
43
  # User to get info on.
@@ -51,10 +50,14 @@ module Slack
51
50
  end
52
51
 
53
52
  #
54
- # This method returns a list of all users in the team. This includes deleted/deactivated users.
53
+ # Lists all users in a Slack team.
55
54
  #
55
+ # @option options [Object] :cursor
56
+ # 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.
57
+ # @option options [Object] :limit
58
+ # The maximum number of items to return. Fewer than the requested number of items may be returned, even if the end of the users list hasn't been reached.
56
59
  # @option options [Object] :presence
57
- # Whether to include presence data in the output.
60
+ # Whether to include presence data in the output. Setting this to false improves performance, especially with large teams.
58
61
  # @see https://api.slack.com/methods/users.list
59
62
  # @see https://github.com/dblock/slack-api-ref/blob/master/methods/users/users.list.json
60
63
  def users_list(options = {})
@@ -62,9 +65,7 @@ module Slack
62
65
  end
63
66
 
64
67
  #
65
- # This method lets the slack messaging server know that the authenticated user
66
- # is currently active. Consult the presence documentation for
67
- # more details.
68
+ # Marks a user as active.
68
69
  #
69
70
  # @see https://api.slack.com/methods/users.setActive
70
71
  # @see https://github.com/dblock/slack-api-ref/blob/master/methods/users/users.setActive.json
@@ -73,16 +74,16 @@ module Slack
73
74
  end
74
75
 
75
76
  #
76
- # This method allows the user to set their profile image. The caller can pass image data via image.
77
+ # Set the user profile photo
77
78
  #
78
79
  # @option options [Object] :image
79
80
  # File contents via multipart/form-data.
81
+ # @option options [Object] :crop_w
82
+ # Width/height of crop box (always square).
80
83
  # @option options [Object] :crop_x
81
84
  # X coordinate of top-left corner of crop box.
82
85
  # @option options [Object] :crop_y
83
86
  # Y coordinate of top-left corner of crop box.
84
- # @option options [Object] :crop_w
85
- # Width/height of crop box (always square).
86
87
  # @see https://api.slack.com/methods/users.setPhoto
87
88
  # @see https://github.com/dblock/slack-api-ref/blob/master/methods/users/users.setPhoto.json
88
89
  def users_setPhoto(options = {})
@@ -91,8 +92,7 @@ module Slack
91
92
  end
92
93
 
93
94
  #
94
- # This method lets you set the calling user's manual presence.
95
- # Consult the presence documentation for more details.
95
+ # Manually sets user presence.
96
96
  #
97
97
  # @option options [Object] :presence
98
98
  # Either auto or away.
@@ -6,12 +6,12 @@ module Slack
6
6
  module Endpoints
7
7
  module UsersProfile
8
8
  #
9
- # Use this method to retrieve a user's profile information.
9
+ # Retrieves a user's profile information.
10
10
  #
11
- # @option options [user] :user
12
- # User to retrieve profile info for.
13
11
  # @option options [Object] :include_labels
14
12
  # Include labels for each ID in custom profile fields.
13
+ # @option options [user] :user
14
+ # User to retrieve profile info for.
15
15
  # @see https://api.slack.com/methods/users.profile.get
16
16
  # @see https://github.com/dblock/slack-api-ref/blob/master/methods/users.profile/users.profile.get.json
17
17
  def users_profile_get(options = {})
@@ -20,14 +20,14 @@ module Slack
20
20
  end
21
21
 
22
22
  #
23
- # Use this method to set a user's profile information, including name, email, current status, and other attributes.
23
+ # Set the profile information for a user.
24
24
  #
25
- # @option options [user] :user
26
- # ID of user to change. This argument may only be specified by team admins on paid teams.
27
- # @option options [Object] :profile
28
- # Collection of key:value pairs presented as a URL-encoded JSON hash.
29
25
  # @option options [Object] :name
30
26
  # Name of a single key to set. Usable only if profile is not passed.
27
+ # @option options [Object] :profile
28
+ # Collection of key:value pairs presented as a URL-encoded JSON hash.
29
+ # @option options [user] :user
30
+ # ID of user to change. This argument may only be specified by team admins on paid teams.
31
31
  # @option options [Object] :value
32
32
  # Value to set a single key to. Usable only if profile is not passed.
33
33
  # @see https://api.slack.com/methods/users.profile.set
@@ -1,13 +1,14 @@
1
1
  diff --git a/lib/slack/web/api/endpoints/chat.rb b/lib/slack/web/api/endpoints/chat.rb
2
- index 0db7e67..1c3b2ee 100644
2
+ index 5186416..490bc91 100644
3
3
  --- a/lib/slack/web/api/endpoints/chat.rb
4
4
  +++ b/lib/slack/web/api/endpoints/chat.rb
5
- @@ -82,8 +82,14 @@ module Slack
5
+ @@ -154,9 +154,15 @@ module Slack
6
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/chat/chat.update.json
6
7
  def chat_update(options = {})
7
- throw ArgumentError.new('Required arguments :ts missing') if options[:ts].nil?
8
8
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
9
9
  - throw ArgumentError.new('Required arguments :text missing') if options[:text].nil?
10
10
  + throw ArgumentError.new('Required arguments :text or :attachments missing') if options[:text].nil? && options[:attachments].nil?
11
+ throw ArgumentError.new('Required arguments :ts missing') if options[:ts].nil?
11
12
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
12
13
  + # attachments must be passed as an encoded JSON string
13
14
  + if options.key?(:attachments)
@@ -0,0 +1,17 @@
1
+ diff --git a/lib/slack/web/api/endpoints/chat.rb b/lib/slack/web/api/endpoints/chat.rb
2
+ index 846126e..0c254c6 100644
3
+ --- a/lib/slack/web/api/endpoints/chat.rb
4
+ +++ b/lib/slack/web/api/endpoints/chat.rb
5
+ @@ -62,6 +62,12 @@ module Slack
6
+ throw ArgumentError.new('Required arguments :text missing') if options[:text].nil?
7
+ throw ArgumentError.new('Required arguments :user missing') if options[:user].nil?
8
+ options = options.merge(user: users_id(options)['user']['id']) if options[:user]
9
+ + # attachments must be passed as an encoded JSON string
10
+ + if options.key?(:attachments)
11
+ + attachments = options[:attachments]
12
+ + attachments = JSON.dump(attachments) unless attachments.is_a?(String)
13
+ + options = options.merge(attachments: attachments)
14
+ + end
15
+ post('chat.postEphemeral', options)
16
+ end
17
+
@@ -51,7 +51,7 @@ RSpec.describe 'integration test', skip: (!ENV['SLACK_API_TOKEN'] || !ENV['CONCU
51
51
  end
52
52
 
53
53
  def start_server
54
- dt = rand(5) + 1
54
+ dt = rand(5) + 2
55
55
  logger.debug "#start_server, waiting #{dt} second(s)"
56
56
  sleep dt # prevent Slack 429 rate limit errors
57
57
  # start server and wait for on :open
@@ -0,0 +1,15 @@
1
+ # This file was auto-generated by lib/tasks/web.rake
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Slack::Web::Api::Endpoints::AppsPermissions do
6
+ let(:client) { Slack::Web::Client.new }
7
+ context 'apps.permissions_request' do
8
+ it 'requires scopes' do
9
+ expect { client.apps_permissions_request(trigger_id: ' ') }.to raise_error ArgumentError, /Required arguments :scopes missing/
10
+ end
11
+ it 'requires trigger_id' do
12
+ expect { client.apps_permissions_request(scopes: ' ') }.to raise_error ArgumentError, /Required arguments :trigger_id missing/
13
+ end
14
+ end
15
+ end
@@ -2,6 +2,42 @@ require 'spec_helper'
2
2
 
3
3
  RSpec.describe Slack::Web::Api::Endpoints::Chat do
4
4
  let(:client) { Slack::Web::Client.new }
5
+ context 'chat_postEphemeral' do
6
+ let(:user) { OpenStruct.new(user: { id: '123' }) }
7
+ before(:each) do
8
+ allow(described_class).to receive(:users_id).and_return(user)
9
+ end
10
+
11
+ it 'automatically converts attachments into JSON' do
12
+ expect(client).to receive(:post).with(
13
+ 'chat.postEphemeral',
14
+ channel: 'channel',
15
+ text: 'text',
16
+ user: '123',
17
+ attachments: '[]'
18
+ )
19
+ client.chat_postEphemeral(channel: 'channel', text: 'text', user: '123', attachments: [])
20
+ end
21
+ context 'text and user arguments' do
22
+ it 'requires text' do
23
+ expect { client.chat_postEphemeral(channel: 'channel') }.to raise_error ArgumentError, /Required arguments :text missing/
24
+ end
25
+ it 'requires user' do
26
+ expect { client.chat_postEphemeral(channel: 'channel', text: 'text') }.to raise_error ArgumentError, /Required arguments :user missing/
27
+ end
28
+ it 'both text and user' do
29
+ expect(client).to receive(:post).with('chat.postEphemeral', hash_including(text: 'text', user: '123'))
30
+ expect { client.chat_postEphemeral(channel: 'channel', text: 'text', user: '123') }.to_not raise_error
31
+ end
32
+ end
33
+ context 'attachments argument' do
34
+ it 'optional attachments' do
35
+ expect(client).to receive(:post).with('chat.postEphemeral', hash_including(attachments: '[]'))
36
+ expect { client.chat_postEphemeral(channel: 'channel', text: 'text', user: '123', attachments: []) }.to_not raise_error
37
+ end
38
+ end
39
+ end
40
+
5
41
  context 'chat_postMessage' do
6
42
  it 'automatically converts attachments into JSON' do
7
43
  expect(client).to receive(:post).with(
@@ -45,7 +81,7 @@ RSpec.describe Slack::Web::Api::Endpoints::Chat do
45
81
  end
46
82
  context 'ts arguments' do
47
83
  it 'requires ts' do
48
- expect { client.chat_update(channel: 'channel') }.to raise_error ArgumentError, /Required arguments :ts missing>/
84
+ expect { client.chat_update(channel: 'channel', text: 'text') }.to raise_error ArgumentError, /Required arguments :ts missing>/
49
85
  end
50
86
  end
51
87
  context 'text and attachment arguments' do
@@ -5,12 +5,12 @@ require 'spec_helper'
5
5
  RSpec.describe Slack::Web::Api::Endpoints::FilesComments do
6
6
  let(:client) { Slack::Web::Client.new }
7
7
  context 'files.comments_add' do
8
- it 'requires file' do
9
- expect { client.files_comments_add(comment: 'Everyone should take a moment to read this file.') }.to raise_error ArgumentError, /Required arguments :file missing/
10
- end
11
8
  it 'requires comment' do
12
9
  expect { client.files_comments_add(file: 'F1234467890') }.to raise_error ArgumentError, /Required arguments :comment missing/
13
10
  end
11
+ it 'requires file' do
12
+ expect { client.files_comments_add(comment: 'Everyone should take a moment to read this file.') }.to raise_error ArgumentError, /Required arguments :file missing/
13
+ end
14
14
  end
15
15
  context 'files.comments_delete' do
16
16
  it 'requires file' do
@@ -21,14 +21,14 @@ RSpec.describe Slack::Web::Api::Endpoints::FilesComments do
21
21
  end
22
22
  end
23
23
  context 'files.comments_edit' do
24
+ it 'requires comment' do
25
+ expect { client.files_comments_edit(file: 'F1234567890', id: 'Fc1234567890') }.to raise_error ArgumentError, /Required arguments :comment missing/
26
+ end
24
27
  it 'requires file' do
25
- expect { client.files_comments_edit(id: 'Fc1234567890', comment: 'Everyone should take a moment to read this file, seriously.') }.to raise_error ArgumentError, /Required arguments :file missing/
28
+ expect { client.files_comments_edit(comment: 'Everyone should take a moment to read this file, seriously.', id: 'Fc1234567890') }.to raise_error ArgumentError, /Required arguments :file missing/
26
29
  end
27
30
  it 'requires id' do
28
- expect { client.files_comments_edit(file: 'F1234567890', comment: 'Everyone should take a moment to read this file, seriously.') }.to raise_error ArgumentError, /Required arguments :id missing/
29
- end
30
- it 'requires comment' do
31
- expect { client.files_comments_edit(file: 'F1234567890', id: 'Fc1234567890') }.to raise_error ArgumentError, /Required arguments :comment missing/
31
+ expect { client.files_comments_edit(comment: 'Everyone should take a moment to read this file, seriously.', file: 'F1234567890') }.to raise_error ArgumentError, /Required arguments :id missing/
32
32
  end
33
33
  end
34
34
  end
@@ -24,9 +24,4 @@ RSpec.describe Slack::Web::Api::Endpoints::Files do
24
24
  expect { client.files_sharedPublicURL }.to raise_error ArgumentError, /Required arguments :file missing/
25
25
  end
26
26
  end
27
- context 'files_upload' do
28
- it 'requires filename' do
29
- expect { client.files_upload }.to raise_error ArgumentError, /Required arguments :filename missing/
30
- end
31
- end
32
27
  end
@@ -15,4 +15,15 @@ RSpec.describe Slack::Web::Api::Endpoints::Oauth do
15
15
  expect { client.oauth_access(client_id: '4b39e9-752c4', client_secret: '33fea0113f5b1') }.to raise_error ArgumentError, /Required arguments :code missing/
16
16
  end
17
17
  end
18
+ context 'oauth_token' do
19
+ it 'requires client_id' do
20
+ expect { client.oauth_token(client_secret: '33fea0113f5b1', code: 'ccdaa72ad') }.to raise_error ArgumentError, /Required arguments :client_id missing/
21
+ end
22
+ it 'requires client_secret' do
23
+ expect { client.oauth_token(client_id: '4b39e9-752c4', code: 'ccdaa72ad') }.to raise_error ArgumentError, /Required arguments :client_secret missing/
24
+ end
25
+ it 'requires code' do
26
+ expect { client.oauth_token(client_id: '4b39e9-752c4', client_secret: '33fea0113f5b1') }.to raise_error ArgumentError, /Required arguments :code missing/
27
+ end
28
+ end
18
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slack-ruby-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Doubrovkine
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-06 00:00:00.000000000 Z
11
+ date: 2017-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -230,6 +230,7 @@ files:
230
230
  - UPGRADING.md
231
231
  - bin/commands.rb
232
232
  - bin/commands/api.rb
233
+ - bin/commands/apps_permissions.rb
233
234
  - bin/commands/auth.rb
234
235
  - bin/commands/bots.rb
235
236
  - bin/commands/channels.rb
@@ -305,6 +306,7 @@ files:
305
306
  - lib/slack/version.rb
306
307
  - lib/slack/web/api/endpoints.rb
307
308
  - lib/slack/web/api/endpoints/api.rb
309
+ - lib/slack/web/api/endpoints/apps_permissions.rb
308
310
  - lib/slack/web/api/endpoints/auth.rb
309
311
  - lib/slack/web/api/endpoints/bots.rb
310
312
  - lib/slack/web/api/endpoints/channels.rb
@@ -346,6 +348,7 @@ files:
346
348
  - lib/slack/web/api/patches/chat.1.text-attachments-required.patch
347
349
  - lib/slack/web/api/patches/chat.2.attachments-json.patch
348
350
  - lib/slack/web/api/patches/chat.3.update-attachments-support.patch
351
+ - lib/slack/web/api/patches/chat.4.postEphemeral-attachments-support.patch
349
352
  - lib/slack/web/api/schema/group.json
350
353
  - lib/slack/web/api/schema/method.json
351
354
  - lib/slack/web/api/templates/command.erb
@@ -398,6 +401,7 @@ files:
398
401
  - spec/slack/slack_spec.rb
399
402
  - spec/slack/version_spec.rb
400
403
  - spec/slack/web/api/endpoints/api_spec.rb
404
+ - spec/slack/web/api/endpoints/apps_permissions_spec.rb
401
405
  - spec/slack/web/api/endpoints/bots_spec.rb
402
406
  - spec/slack/web/api/endpoints/custom_specs/auth_spec.rb
403
407
  - spec/slack/web/api/endpoints/custom_specs/channels_spec.rb
@@ -492,6 +496,7 @@ test_files:
492
496
  - spec/slack/slack_spec.rb
493
497
  - spec/slack/version_spec.rb
494
498
  - spec/slack/web/api/endpoints/api_spec.rb
499
+ - spec/slack/web/api/endpoints/apps_permissions_spec.rb
495
500
  - spec/slack/web/api/endpoints/bots_spec.rb
496
501
  - spec/slack/web/api/endpoints/custom_specs/auth_spec.rb
497
502
  - spec/slack/web/api/endpoints/custom_specs/channels_spec.rb