slack-ruby-client 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +9 -9
  3. data/CHANGELOG.md +9 -1
  4. data/README.md +9 -1
  5. data/bin/commands/chat.rb +1 -0
  6. data/bin/commands/files.rb +3 -14
  7. data/bin/commands/files_comments.rb +35 -0
  8. data/bin/commands/reminders.rb +50 -0
  9. data/bin/commands/usergroups.rb +29 -40
  10. data/bin/commands/usergroups_users.rb +25 -0
  11. data/bin/commands.rb +3 -0
  12. data/bin/slack +3 -1
  13. data/examples/hi_real_time/hi.rb +5 -1
  14. data/lib/slack/real_time/client.rb +1 -0
  15. data/lib/slack/real_time/config.rb +1 -1
  16. data/lib/slack/version.rb +1 -1
  17. data/lib/slack/web/api/endpoints/chat.rb +9 -1
  18. data/lib/slack/web/api/endpoints/files.rb +3 -22
  19. data/lib/slack/web/api/endpoints/files_comments.rb +59 -0
  20. data/lib/slack/web/api/endpoints/reminders.rb +74 -0
  21. data/lib/slack/web/api/endpoints/usergroups.rb +23 -40
  22. data/lib/slack/web/api/endpoints/usergroups_users.rb +42 -0
  23. data/lib/slack/web/api/endpoints.rb +6 -0
  24. data/lib/slack/web/api/patches/chat.3.update-attachments-support.patch +20 -0
  25. data/lib/slack/web/api/templates/command.erb +3 -3
  26. data/lib/slack/web/api/templates/endpoints.erb +1 -1
  27. data/lib/slack/web/api/templates/method.erb +2 -2
  28. data/lib/slack/web/api/templates/method_spec.erb +2 -2
  29. data/lib/slack/web/config.rb +1 -1
  30. data/lib/tasks/real_time.rake +1 -1
  31. data/lib/tasks/web.rake +11 -7
  32. data/slack-ruby-client.gemspec +1 -1
  33. data/spec/integration/integration_spec.rb +20 -0
  34. data/spec/slack/web/api/endpoints/custom_specs/chat_spec.rb +36 -0
  35. data/spec/slack/web/api/endpoints/files_comments_spec.rb +34 -0
  36. data/spec/slack/web/api/endpoints/files_spec.rb +1 -15
  37. data/spec/slack/web/api/endpoints/reminders_spec.rb +30 -0
  38. data/spec/slack/web/api/endpoints/usergroups_spec.rb +0 -8
  39. data/spec/slack/web/api/endpoints/usergroups_users_spec.rb +20 -0
  40. data/spec/support/vcr.rb +1 -0
  41. metadata +19 -6
data/lib/slack/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Slack
2
- VERSION = '0.7.0'
2
+ VERSION = '0.7.1'.freeze
3
3
  end
@@ -12,6 +12,8 @@ module Slack
12
12
  # Timestamp of the message to be deleted.
13
13
  # @option options [channel] :channel
14
14
  # Channel containing the message to be deleted.
15
+ # @option options [Object] :as_user
16
+ # Pass true to delete the message as the authed user. Bot users in this context are considered authed users.
15
17
  # @see https://api.slack.com/methods/chat.delete
16
18
  # @see https://github.com/dblock/slack-api-ref/blob/master/methods/chat/chat.delete.json
17
19
  def chat_delete(options = {})
@@ -82,8 +84,14 @@ module Slack
82
84
  def chat_update(options = {})
83
85
  throw ArgumentError.new('Required arguments :ts missing') if options[:ts].nil?
84
86
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
85
- throw ArgumentError.new('Required arguments :text missing') if options[:text].nil?
87
+ throw ArgumentError.new('Required arguments :text or :attachments missing') if options[:text].nil? && options[:attachments].nil?
86
88
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
89
+ # attachments must be passed as an encoded JSON string
90
+ if options.key?(:attachments)
91
+ attachments = options[:attachments]
92
+ attachments = JSON.dump(attachments) unless attachments.is_a?(String)
93
+ options = options.merge(attachments: attachments)
94
+ end
87
95
  post('chat.update', options)
88
96
  end
89
97
  end
@@ -5,24 +5,6 @@ module Slack
5
5
  module Api
6
6
  module Endpoints
7
7
  module Files
8
- #
9
- # Edit an existing comment on a file. Only the user who created a comment may make edits. Teams may configure a limited time window during which file comment edits are allowed.
10
- #
11
- # @option options [file] :file
12
- # File containing the comment to edit.
13
- # @option options [Object] :id
14
- # The comment to edit.
15
- # @option options [Object] :comment
16
- # Text of the comment to edit.
17
- # @see https://api.slack.com/methods/files.comments
18
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/files/files.comments.json
19
- def files_comments(options = {})
20
- throw ArgumentError.new('Required arguments :file missing') if options[:file].nil?
21
- throw ArgumentError.new('Required arguments :id missing') if options[:id].nil?
22
- throw ArgumentError.new('Required arguments :comment missing') if options[:comment].nil?
23
- post('files.comments', options)
24
- end
25
-
26
8
  #
27
9
  # This method deletes a file from your team.
28
10
  #
@@ -108,11 +90,11 @@ module Slack
108
90
  # This method allows you to create or upload an existing file.
109
91
  #
110
92
  # @option options [file] :file
111
- # File contents via multipart/form-data.
93
+ # File contents via multipart/form-data. If omitting this parameter, you must submit content.
112
94
  # @option options [Object] :content
113
- # File contents via a POST var.
95
+ # File contents via a POST variable. If omitting this parameter, you must provide a file.
114
96
  # @option options [Object] :filetype
115
- # Slack-internal file type identifier.
97
+ # A file type identifier.
116
98
  # @option options [Object] :filename
117
99
  # Filename of file.
118
100
  # @option options [Object] :title
@@ -124,7 +106,6 @@ module Slack
124
106
  # @see https://api.slack.com/methods/files.upload
125
107
  # @see https://github.com/dblock/slack-api-ref/blob/master/methods/files/files.upload.json
126
108
  def files_upload(options = {})
127
- throw ArgumentError.new('Required arguments :file missing') if options[:file].nil?
128
109
  throw ArgumentError.new('Required arguments :filename missing') if options[:filename].nil?
129
110
  post('files.upload', options)
130
111
  end
@@ -0,0 +1,59 @@
1
+ # This file was auto-generated by lib/tasks/web.rake
2
+
3
+ module Slack
4
+ module Web
5
+ module Api
6
+ module Endpoints
7
+ module FilesComments
8
+ #
9
+ # Add a comment to an existing file.
10
+ #
11
+ # @option options [file] :file
12
+ # File to add a comment to.
13
+ # @option options [Object] :comment
14
+ # Text of the comment to add.
15
+ # @see https://api.slack.com/methods/files.comments.add
16
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/files.comments/files.comments.add.json
17
+ def files_comments_add(options = {})
18
+ throw ArgumentError.new('Required arguments :file missing') if options[:file].nil?
19
+ throw ArgumentError.new('Required arguments :comment missing') if options[:comment].nil?
20
+ post('files.comments.add', options)
21
+ end
22
+
23
+ #
24
+ # Delete an existing comment on a file. Only the original author of the comment or a Team Administrator may delete a file comment.
25
+ #
26
+ # @option options [file] :file
27
+ # File to delete a comment from.
28
+ # @option options [Object] :id
29
+ # The comment to delete.
30
+ # @see https://api.slack.com/methods/files.comments.delete
31
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/files.comments/files.comments.delete.json
32
+ def files_comments_delete(options = {})
33
+ throw ArgumentError.new('Required arguments :file missing') if options[:file].nil?
34
+ throw ArgumentError.new('Required arguments :id missing') if options[:id].nil?
35
+ post('files.comments.delete', options)
36
+ end
37
+
38
+ #
39
+ # Edit an existing comment on a file. Only the user who created a comment may make edits. Teams may configure a limited time window during which file comment edits are allowed.
40
+ #
41
+ # @option options [file] :file
42
+ # File containing the comment to edit.
43
+ # @option options [Object] :id
44
+ # The comment to edit.
45
+ # @option options [Object] :comment
46
+ # Text of the comment to edit.
47
+ # @see https://api.slack.com/methods/files.comments.edit
48
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/files.comments/files.comments.edit.json
49
+ def files_comments_edit(options = {})
50
+ throw ArgumentError.new('Required arguments :file missing') if options[:file].nil?
51
+ throw ArgumentError.new('Required arguments :id missing') if options[:id].nil?
52
+ throw ArgumentError.new('Required arguments :comment missing') if options[:comment].nil?
53
+ post('files.comments.edit', options)
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,74 @@
1
+ # This file was auto-generated by lib/tasks/web.rake
2
+
3
+ module Slack
4
+ module Web
5
+ module Api
6
+ module Endpoints
7
+ module Reminders
8
+ #
9
+ # This method creates a reminder.
10
+ #
11
+ # @option options [Object] :text
12
+ # The content of the reminder.
13
+ # @option options [Object] :time
14
+ # When this reminder should happen: the Unix timestamp (up to five years from now), the number of seconds until the reminder (if within 24 hours), or a natural language description (Ex. "in 15 minutes," or "every Thursday").
15
+ # @option options [user] :user
16
+ # The user who will receive the reminder. If no user is specified, the reminder will go to user who created it.
17
+ # @see https://api.slack.com/methods/reminders.add
18
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/reminders/reminders.add.json
19
+ def reminders_add(options = {})
20
+ throw ArgumentError.new('Required arguments :text missing') if options[:text].nil?
21
+ throw ArgumentError.new('Required arguments :time missing') if options[:time].nil?
22
+ options = options.merge(user: users_id(options)['user']['id']) if options[:user]
23
+ post('reminders.add', options)
24
+ end
25
+
26
+ #
27
+ # This method completes a reminder.
28
+ #
29
+ # @option options [Object] :reminder
30
+ # The ID of the reminder to be marked as complete.
31
+ # @see https://api.slack.com/methods/reminders.complete
32
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/reminders/reminders.complete.json
33
+ def reminders_complete(options = {})
34
+ throw ArgumentError.new('Required arguments :reminder missing') if options[:reminder].nil?
35
+ post('reminders.complete', options)
36
+ end
37
+
38
+ #
39
+ # This method deletes a reminder.
40
+ #
41
+ # @option options [Object] :reminder
42
+ # The ID of the reminder.
43
+ # @see https://api.slack.com/methods/reminders.delete
44
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/reminders/reminders.delete.json
45
+ def reminders_delete(options = {})
46
+ throw ArgumentError.new('Required arguments :reminder missing') if options[:reminder].nil?
47
+ post('reminders.delete', options)
48
+ end
49
+
50
+ #
51
+ # This method returns information about a reminder.
52
+ #
53
+ # @option options [Object] :reminder
54
+ # The ID of the reminder.
55
+ # @see https://api.slack.com/methods/reminders.info
56
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/reminders/reminders.info.json
57
+ def reminders_info(options = {})
58
+ throw ArgumentError.new('Required arguments :reminder missing') if options[:reminder].nil?
59
+ post('reminders.info', options)
60
+ end
61
+
62
+ #
63
+ # This method lists all reminders created by or for a given user.
64
+ #
65
+ # @see https://api.slack.com/methods/reminders.list
66
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/reminders/reminders.list.json
67
+ def reminders_list(options = {})
68
+ post('reminders.list', options)
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
@@ -6,18 +6,18 @@ module Slack
6
6
  module Endpoints
7
7
  module Usergroups
8
8
  #
9
- # This method is used to create a user group.
9
+ # This method is used to create a User Group.
10
10
  #
11
11
  # @option options [Object] :name
12
- # A name for the user group. Must be unique among user groups.
12
+ # A name for the User Group. Must be unique among User Groups.
13
13
  # @option options [Object] :handle
14
- # A mention handle. Must be unique among channels, users and user groups.
14
+ # A mention handle. Must be unique among channels, users and User Groups.
15
15
  # @option options [Object] :description
16
- # A short description of the user group.
16
+ # A short description of the User Group.
17
17
  # @option options [Object] :channels
18
- # A comma separated string of encoded channel IDs for which the user group uses as a default.
18
+ # A comma separated string of encoded channel IDs for which the User Group uses as a default.
19
19
  # @option options [Object] :include_count
20
- # Include the number of users in each user group.
20
+ # Include the number of users in each User Group.
21
21
  # @see https://api.slack.com/methods/usergroups.create
22
22
  # @see https://github.com/dblock/slack-api-ref/blob/master/methods/usergroups/usergroups.create.json
23
23
  def usergroups_create(options = {})
@@ -26,12 +26,12 @@ module Slack
26
26
  end
27
27
 
28
28
  #
29
- # This method disables an existing user group.
29
+ # This method disables an existing User Group.
30
30
  #
31
31
  # @option options [Object] :usergroup
32
- # The encoded ID of the user group to disable.
32
+ # The encoded ID of the User Group to disable.
33
33
  # @option options [Object] :include_count
34
- # Include the number of users in the user group.
34
+ # Include the number of users in the User Group.
35
35
  # @see https://api.slack.com/methods/usergroups.disable
36
36
  # @see https://github.com/dblock/slack-api-ref/blob/master/methods/usergroups/usergroups.disable.json
37
37
  def usergroups_disable(options = {})
@@ -40,12 +40,12 @@ module Slack
40
40
  end
41
41
 
42
42
  #
43
- # This method enables a user group which was previously disabled.
43
+ # This method enables a User Group which was previously disabled.
44
44
  #
45
45
  # @option options [Object] :usergroup
46
- # The encoded ID of the user group to enable.
46
+ # The encoded ID of the User Group to enable.
47
47
  # @option options [Object] :include_count
48
- # Include the number of users in the user group.
48
+ # Include the number of users in the User Group.
49
49
  # @see https://api.slack.com/methods/usergroups.enable
50
50
  # @see https://github.com/dblock/slack-api-ref/blob/master/methods/usergroups/usergroups.enable.json
51
51
  def usergroups_enable(options = {})
@@ -54,14 +54,14 @@ module Slack
54
54
  end
55
55
 
56
56
  #
57
- # This method returns a list of all user groups in the team. This can optionally include disabled user groups.
57
+ # This method returns a list of all User Groups in the team. This can optionally include disabled User Groups.
58
58
  #
59
59
  # @option options [Object] :include_disabled
60
- # Include disabled user groups.
60
+ # Include disabled User Groups.
61
61
  # @option options [Object] :include_count
62
- # Include the number of users in each user group.
62
+ # Include the number of users in each User Group.
63
63
  # @option options [Object] :include_users
64
- # Include the list of users for each user group.
64
+ # Include the list of users for each User Group.
65
65
  # @see https://api.slack.com/methods/usergroups.list
66
66
  # @see https://github.com/dblock/slack-api-ref/blob/master/methods/usergroups/usergroups.list.json
67
67
  def usergroups_list(options = {})
@@ -69,43 +69,26 @@ module Slack
69
69
  end
70
70
 
71
71
  #
72
- # This method updates the properties of an existing user group.
72
+ # This method updates the properties of an existing User Group.
73
73
  #
74
74
  # @option options [Object] :usergroup
75
- # The encoded ID of the user group to update.
75
+ # The encoded ID of the User Group to update.
76
76
  # @option options [Object] :name
77
- # A name for the user group. Must be unique among user groups.
77
+ # A name for the User Group. Must be unique among User Groups.
78
78
  # @option options [Object] :handle
79
- # A mention handle. Must be unique among channels, users and user groups.
79
+ # A mention handle. Must be unique among channels, users and User Groups.
80
80
  # @option options [Object] :description
81
- # A short description of the user group.
81
+ # A short description of the User Group.
82
82
  # @option options [Object] :channels
83
- # A comma separated string of encoded channel IDs for which the user group uses as a default.
83
+ # A comma separated string of encoded channel IDs for which the User Group uses as a default.
84
84
  # @option options [Object] :include_count
85
- # Include the number of users in the user group.
85
+ # Include the number of users in the User Group.
86
86
  # @see https://api.slack.com/methods/usergroups.update
87
87
  # @see https://github.com/dblock/slack-api-ref/blob/master/methods/usergroups/usergroups.update.json
88
88
  def usergroups_update(options = {})
89
89
  throw ArgumentError.new('Required arguments :usergroup missing') if options[:usergroup].nil?
90
90
  post('usergroups.update', options)
91
91
  end
92
-
93
- #
94
- # 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.
95
- #
96
- # @option options [Object] :usergroup
97
- # The encoded ID of the user group to update.
98
- # @option options [Object] :users
99
- # A comma separated string of encoded user IDs that represent the entire list of users for the user group.
100
- # @option options [Object] :include_count
101
- # Include the number of users in the user group.
102
- # @see https://api.slack.com/methods/usergroups.users
103
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/usergroups/usergroups.users.json
104
- def usergroups_users(options = {})
105
- throw ArgumentError.new('Required arguments :usergroup missing') if options[:usergroup].nil?
106
- throw ArgumentError.new('Required arguments :users missing') if options[:users].nil?
107
- post('usergroups.users', options)
108
- end
109
92
  end
110
93
  end
111
94
  end
@@ -0,0 +1,42 @@
1
+ # This file was auto-generated by lib/tasks/web.rake
2
+
3
+ module Slack
4
+ module Web
5
+ module Api
6
+ module Endpoints
7
+ module UsergroupsUsers
8
+ #
9
+ # This method returns a list of all users within a User Group.
10
+ #
11
+ # @option options [Object] :usergroup
12
+ # The encoded ID of the User Group to update.
13
+ # @option options [Object] :include_disabled
14
+ # Allow results that involve disabled User Groups.
15
+ # @see https://api.slack.com/methods/usergroups.users.list
16
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/usergroups.users/usergroups.users.list.json
17
+ def usergroups_users_list(options = {})
18
+ throw ArgumentError.new('Required arguments :usergroup missing') if options[:usergroup].nil?
19
+ post('usergroups.users.list', options)
20
+ end
21
+
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.
24
+ #
25
+ # @option options [Object] :usergroup
26
+ # The encoded ID of the User Group to update.
27
+ # @option options [Object] :users
28
+ # A comma separated string of encoded user IDs that represent the entire list of users for the User Group.
29
+ # @option options [Object] :include_count
30
+ # Include the number of users in the User Group.
31
+ # @see https://api.slack.com/methods/usergroups.users.update
32
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/usergroups.users/usergroups.users.update.json
33
+ def usergroups_users_update(options = {})
34
+ throw ArgumentError.new('Required arguments :usergroup missing') if options[:usergroup].nil?
35
+ throw ArgumentError.new('Required arguments :users missing') if options[:users].nil?
36
+ post('usergroups.users.update', options)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -6,6 +6,7 @@ require 'slack/web/api/endpoints/channels'
6
6
  require 'slack/web/api/endpoints/chat'
7
7
  require 'slack/web/api/endpoints/dnd'
8
8
  require 'slack/web/api/endpoints/emoji'
9
+ require 'slack/web/api/endpoints/files_comments'
9
10
  require 'slack/web/api/endpoints/files'
10
11
  require 'slack/web/api/endpoints/groups'
11
12
  require 'slack/web/api/endpoints/im'
@@ -13,11 +14,13 @@ require 'slack/web/api/endpoints/mpim'
13
14
  require 'slack/web/api/endpoints/oauth'
14
15
  require 'slack/web/api/endpoints/pins'
15
16
  require 'slack/web/api/endpoints/reactions'
17
+ require 'slack/web/api/endpoints/reminders'
16
18
  require 'slack/web/api/endpoints/rtm'
17
19
  require 'slack/web/api/endpoints/search'
18
20
  require 'slack/web/api/endpoints/stars'
19
21
  require 'slack/web/api/endpoints/team'
20
22
  require 'slack/web/api/endpoints/usergroups'
23
+ require 'slack/web/api/endpoints/usergroups_users'
21
24
  require 'slack/web/api/endpoints/users'
22
25
 
23
26
  module Slack
@@ -34,6 +37,7 @@ module Slack
34
37
  include Chat
35
38
  include Dnd
36
39
  include Emoji
40
+ include FilesComments
37
41
  include Files
38
42
  include Groups
39
43
  include Im
@@ -41,11 +45,13 @@ module Slack
41
45
  include Oauth
42
46
  include Pins
43
47
  include Reactions
48
+ include Reminders
44
49
  include Rtm
45
50
  include Search
46
51
  include Stars
47
52
  include Team
48
53
  include Usergroups
54
+ include UsergroupsUsers
49
55
  include Users
50
56
  end
51
57
  end
@@ -0,0 +1,20 @@
1
+ diff --git a/lib/slack/web/api/endpoints/chat.rb b/lib/slack/web/api/endpoints/chat.rb
2
+ index 0db7e67..1c3b2ee 100644
3
+ --- a/lib/slack/web/api/endpoints/chat.rb
4
+ +++ b/lib/slack/web/api/endpoints/chat.rb
5
+ @@ -82,8 +82,14 @@ module Slack
6
+ def chat_update(options = {})
7
+ throw ArgumentError.new('Required arguments :ts missing') if options[:ts].nil?
8
+ throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
9
+ - throw ArgumentError.new('Required arguments :text missing') if options[:text].nil?
10
+ + throw ArgumentError.new('Required arguments :text or :attachments missing') if options[:text].nil? && options[:attachments].nil?
11
+ options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
12
+ + # attachments must be passed as an encoded JSON string
13
+ + if options.key?(:attachments)
14
+ + attachments = options[:attachments]
15
+ + attachments = JSON.dump(attachments) unless attachments.is_a?(String)
16
+ + options = options.merge(attachments: attachments)
17
+ + end
18
+ post('chat.update', options)
19
+ end
20
+ end