slack-ruby-client 0.9.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +3 -0
  4. data/.rubocop_todo.yml +40 -39
  5. data/.travis.yml +1 -9
  6. data/CHANGELOG.md +24 -0
  7. data/CONTRIBUTING.md +2 -2
  8. data/Gemfile +3 -1
  9. data/README.md +40 -12
  10. data/Rakefile +1 -1
  11. data/UPGRADING.md +1 -1
  12. data/bin/commands/api.rb +2 -2
  13. data/bin/commands/apps_permissions.rb +22 -0
  14. data/bin/commands/auth.rb +4 -4
  15. data/bin/commands/bots.rb +2 -2
  16. data/bin/commands/channels.rb +52 -40
  17. data/bin/commands/chat.rb +63 -25
  18. data/bin/commands/conversations.rb +178 -0
  19. data/bin/commands/dialog.rb +14 -0
  20. data/bin/commands/dnd.rb +8 -8
  21. data/bin/commands/emoji.rb +2 -2
  22. data/bin/commands/files.rb +38 -17
  23. data/bin/commands/files_comments.rb +6 -6
  24. data/bin/commands/groups.rb +44 -51
  25. data/bin/commands/im.rb +16 -13
  26. data/bin/commands/migration.rb +14 -0
  27. data/bin/commands/mpim.rb +11 -11
  28. data/bin/commands/oauth.rb +15 -2
  29. data/bin/commands/pins.rb +6 -6
  30. data/bin/commands/reactions.rb +13 -13
  31. data/bin/commands/reminders.rb +10 -10
  32. data/bin/commands/rtm.rb +9 -6
  33. data/bin/commands/search.rb +9 -9
  34. data/bin/commands/stars.rb +8 -8
  35. data/bin/commands/team.rb +10 -10
  36. data/bin/commands/team_profile.rb +2 -2
  37. data/bin/commands/usergroups.rb +16 -16
  38. data/bin/commands/usergroups_users.rb +4 -4
  39. data/bin/commands/users.rb +40 -36
  40. data/bin/commands/users_admin.rb +28 -0
  41. data/bin/commands/users_prefs.rb +12 -0
  42. data/bin/commands/users_profile.rb +7 -7
  43. data/bin/commands.rb +7 -1
  44. data/bin/slack +1 -1
  45. data/examples/hi_real_time/hi.rb +1 -1
  46. data/examples/hi_real_time_and_web/hi.rb +1 -1
  47. data/examples/hi_real_time_async_celluloid/hi.rb +1 -1
  48. data/examples/hi_real_time_async_eventmachine/hi.rb +1 -1
  49. data/examples/hi_web/hi.rb +1 -1
  50. data/examples/new_ticket/new_ticket.rb +1 -1
  51. data/lib/slack/messages/formatting.rb +4 -4
  52. data/lib/slack/messages/message.rb +1 -2
  53. data/lib/slack/real_time/api/templates/event_handler.erb +1 -1
  54. data/lib/slack/real_time/client.rb +11 -10
  55. data/lib/slack/real_time/concurrency/celluloid.rb +6 -2
  56. data/lib/slack/real_time/config.rb +11 -11
  57. data/lib/slack/real_time/models/base.rb +1 -2
  58. data/lib/slack/real_time/socket.rb +2 -2
  59. data/lib/slack/real_time/stores/base.rb +1 -2
  60. data/lib/slack/real_time/stores/starter.rb +92 -72
  61. data/lib/slack/real_time/stores/store.rb +120 -90
  62. data/lib/slack/version.rb +1 -1
  63. data/lib/slack/web/api/endpoints/api.rb +2 -2
  64. data/lib/slack/web/api/endpoints/apps_permissions.rb +35 -0
  65. data/lib/slack/web/api/endpoints/auth.rb +4 -4
  66. data/lib/slack/web/api/endpoints/bots.rb +2 -2
  67. data/lib/slack/web/api/endpoints/channels.rb +57 -34
  68. data/lib/slack/web/api/endpoints/chat.rb +107 -37
  69. data/lib/slack/web/api/endpoints/conversations.rb +301 -0
  70. data/lib/slack/web/api/endpoints/dialog.rb +32 -0
  71. data/lib/slack/web/api/endpoints/dnd.rb +9 -9
  72. data/lib/slack/web/api/endpoints/emoji.rb +2 -2
  73. data/lib/slack/web/api/endpoints/files.rb +53 -23
  74. data/lib/slack/web/api/endpoints/files_comments.rb +11 -11
  75. data/lib/slack/web/api/endpoints/groups.rb +38 -50
  76. data/lib/slack/web/api/endpoints/im.rb +27 -17
  77. data/lib/slack/web/api/endpoints/migration.rb +25 -0
  78. data/lib/slack/web/api/endpoints/mpim.rb +13 -15
  79. data/lib/slack/web/api/endpoints/oauth.rb +24 -3
  80. data/lib/slack/web/api/endpoints/pins.rb +6 -8
  81. data/lib/slack/web/api/endpoints/presence.rb +1 -1
  82. data/lib/slack/web/api/endpoints/reactions.rb +18 -20
  83. data/lib/slack/web/api/endpoints/reminders.rb +10 -10
  84. data/lib/slack/web/api/endpoints/rtm.rb +14 -8
  85. data/lib/slack/web/api/endpoints/search.rb +12 -12
  86. data/lib/slack/web/api/endpoints/stars.rb +10 -12
  87. data/lib/slack/web/api/endpoints/team.rb +12 -13
  88. data/lib/slack/web/api/endpoints/team_profile.rb +2 -2
  89. data/lib/slack/web/api/endpoints/usergroups.rb +22 -22
  90. data/lib/slack/web/api/endpoints/usergroups_users.rb +4 -4
  91. data/lib/slack/web/api/endpoints/users.rb +34 -24
  92. data/lib/slack/web/api/endpoints/users_admin.rb +46 -0
  93. data/lib/slack/web/api/endpoints/users_prefs.rb +19 -0
  94. data/lib/slack/web/api/endpoints/users_profile.rb +10 -10
  95. data/lib/slack/web/api/endpoints.rb +14 -2
  96. data/lib/slack/web/api/mixins/ids.id.rb +1 -1
  97. data/lib/slack/web/api/mixins/users.search.rb +38 -36
  98. data/lib/slack/web/api/patches/chat.1.text-attachments-required.patch +1 -1
  99. data/lib/slack/web/api/patches/chat.3.update-attachments-support.patch +4 -3
  100. data/lib/slack/web/api/patches/chat.4.postEphemeral-attachments-support.patch +17 -0
  101. data/lib/slack/web/api/patches/dialog.1.open-json-support.patch +17 -0
  102. data/lib/slack/web/api/templates/command.erb +4 -3
  103. data/lib/slack/web/api/templates/commands.erb +1 -1
  104. data/lib/slack/web/api/templates/endpoints.erb +2 -2
  105. data/lib/slack/web/api/templates/method.erb +18 -3
  106. data/lib/slack/web/api/templates/method_spec.erb +1 -1
  107. data/lib/slack/web/config.rb +16 -12
  108. data/lib/slack/web/faraday/connection.rb +1 -1
  109. data/lib/slack/web/faraday/response/raise_error.rb +3 -3
  110. data/lib/slack/web/pagination/cursor.rb +48 -0
  111. data/lib/slack-ruby-client.rb +6 -0
  112. data/lib/tasks/git.rake +1 -1
  113. data/lib/tasks/real_time.rake +1 -1
  114. data/lib/tasks/web.rake +4 -1
  115. data/slack-ruby-client.gemspec +2 -3
  116. data/spec/fixtures/slack/web/paginated_users_list.yml +181 -0
  117. data/spec/integration/integration_spec.rb +1 -1
  118. data/spec/slack/messages/formatting_spec.rb +1 -1
  119. data/spec/slack/real_time/client_spec.rb +62 -63
  120. data/spec/slack/real_time/concurrency/celluloid_spec.rb +41 -31
  121. data/spec/slack/real_time/concurrency/it_behaves_like_a_realtime_socket.rb +1 -1
  122. data/spec/slack/real_time/event_handlers/bot_spec.rb +4 -2
  123. data/spec/slack/real_time/event_handlers/event_handlers_spec.rb +1 -1
  124. data/spec/slack/real_time/event_handlers/user_spec.rb +4 -2
  125. data/spec/slack/web/api/endpoints/apps_permissions_spec.rb +15 -0
  126. data/spec/slack/web/api/endpoints/conversations_spec.rb +100 -0
  127. data/spec/slack/web/api/endpoints/custom_specs/chat_spec.rb +37 -1
  128. data/spec/slack/web/api/endpoints/custom_specs/dialog_spec.rb +28 -0
  129. data/spec/slack/web/api/endpoints/custom_specs/users_spec.rb +16 -6
  130. data/spec/slack/web/api/endpoints/files_comments_spec.rb +8 -8
  131. data/spec/slack/web/api/endpoints/files_spec.rb +16 -5
  132. data/spec/slack/web/api/endpoints/migration_spec.rb +12 -0
  133. data/spec/slack/web/api/endpoints/oauth_spec.rb +11 -0
  134. data/spec/slack/web/api/endpoints/users_admin_spec.rb +17 -0
  135. data/spec/slack/web/api/endpoints/users_prefs_spec.rb +7 -0
  136. data/spec/slack/web/api/error_spec.rb +1 -1
  137. data/spec/slack/web/api/errors/slack_error_spec.rb +1 -1
  138. data/spec/slack/web/api/mixins/users_spec.rb +6 -4
  139. data/spec/slack/web/api/pagination/cursor_spec.rb +70 -0
  140. data/spec/support/queue_with_timeout.rb +1 -1
  141. data/spec/support/real_time/concurrency/mock.rb +1 -2
  142. metadata +47 -30
@@ -6,12 +6,12 @@ module Slack
6
6
  module Endpoints
7
7
  module Groups
8
8
  #
9
- # This method archives a private channel.
9
+ # Archives a private channel.
10
10
  #
11
11
  # @option options [group] :channel
12
12
  # Private channel to archive.
13
13
  # @see https://api.slack.com/methods/groups.archive
14
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/groups/groups.archive.json
14
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/groups/groups.archive.json
15
15
  def groups_archive(options = {})
16
16
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
17
17
  options = options.merge(channel: groups_id(options)['group']['id']) if options[:channel]
@@ -19,39 +19,26 @@ module Slack
19
19
  end
20
20
 
21
21
  #
22
- # This method closes a private channel.
23
- #
24
- # @option options [group] :channel
25
- # Private channel to close.
26
- # @see https://api.slack.com/methods/groups.close
27
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/groups/groups.close.json
28
- def groups_close(options = {})
29
- throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
30
- options = options.merge(channel: groups_id(options)['group']['id']) if options[:channel]
31
- post('groups.close', options)
32
- end
33
-
34
- #
35
- # This method creates a private channel.
22
+ # Creates a private channel.
36
23
  #
37
24
  # @option options [Object] :name
38
25
  # Name of private channel to create.
39
26
  # @option options [Object] :validate
40
27
  # Whether to return errors on invalid channel name instead of modifying it to meet the specified criteria.
41
28
  # @see https://api.slack.com/methods/groups.create
42
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/groups/groups.create.json
29
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/groups/groups.create.json
43
30
  def groups_create(options = {})
44
31
  throw ArgumentError.new('Required arguments :name missing') if options[:name].nil?
45
32
  post('groups.create', options)
46
33
  end
47
34
 
48
35
  #
49
- # This method takes an existing private channel and performs the following steps:
36
+ # Clones and archives a private channel.
50
37
  #
51
38
  # @option options [group] :channel
52
39
  # Private channel to clone and archive.
53
40
  # @see https://api.slack.com/methods/groups.createChild
54
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/groups/groups.createChild.json
41
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/groups/groups.createChild.json
55
42
  def groups_createChild(options = {})
56
43
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
57
44
  options = options.merge(channel: groups_id(options)['group']['id']) if options[:channel]
@@ -59,22 +46,20 @@ module Slack
59
46
  end
60
47
 
61
48
  #
62
- # This method returns a portion of messages/events from the specified private channel.
63
- # To read the entire history for a private channel, call the method with no latest or
64
- # oldest arguments, and then continue paging using the instructions below.
49
+ # Fetches history of messages and events from a private channel.
65
50
  #
66
51
  # @option options [group] :channel
67
52
  # Private channel to fetch history for.
53
+ # @option options [Object] :inclusive
54
+ # Include messages with latest or oldest timestamp in results.
68
55
  # @option options [timestamp] :latest
69
56
  # End of time range of messages to include in results.
70
57
  # @option options [timestamp] :oldest
71
58
  # Start of time range of messages to include in results.
72
- # @option options [Object] :inclusive
73
- # Include messages with latest or oldest timestamp in results.
74
59
  # @option options [Object] :unreads
75
60
  # Include unread_count_display in the output?.
76
61
  # @see https://api.slack.com/methods/groups.history
77
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/groups/groups.history.json
62
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/groups/groups.history.json
78
63
  def groups_history(options = {})
79
64
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
80
65
  options = options.merge(channel: groups_id(options)['group']['id']) if options[:channel]
@@ -82,12 +67,14 @@ module Slack
82
67
  end
83
68
 
84
69
  #
85
- # This method returns information about a private channel.
70
+ # Gets information about a private channel.
86
71
  #
87
72
  # @option options [group] :channel
88
73
  # Private channel to get info on.
74
+ # @option options [Object] :include_locale
75
+ # Set this to true to receive the locale for this group. Defaults to false.
89
76
  # @see https://api.slack.com/methods/groups.info
90
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/groups/groups.info.json
77
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/groups/groups.info.json
91
78
  def groups_info(options = {})
92
79
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
93
80
  options = options.merge(channel: groups_id(options)['group']['id']) if options[:channel]
@@ -95,14 +82,14 @@ module Slack
95
82
  end
96
83
 
97
84
  #
98
- # This method is used to invite a user to a private channel. The calling user must be a member of the private channel.
85
+ # Invites a user to a private channel.
99
86
  #
100
87
  # @option options [group] :channel
101
88
  # Private channel to invite user to.
102
89
  # @option options [user] :user
103
90
  # User to invite.
104
91
  # @see https://api.slack.com/methods/groups.invite
105
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/groups/groups.invite.json
92
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/groups/groups.invite.json
106
93
  def groups_invite(options = {})
107
94
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
108
95
  throw ArgumentError.new('Required arguments :user missing') if options[:user].nil?
@@ -112,14 +99,14 @@ module Slack
112
99
  end
113
100
 
114
101
  #
115
- # This method allows a user to remove another member from a private channel.
102
+ # Removes a user from a private channel.
116
103
  #
117
104
  # @option options [group] :channel
118
105
  # Private channel to remove user from.
119
106
  # @option options [user] :user
120
107
  # User to remove from private channel.
121
108
  # @see https://api.slack.com/methods/groups.kick
122
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/groups/groups.kick.json
109
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/groups/groups.kick.json
123
110
  def groups_kick(options = {})
124
111
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
125
112
  throw ArgumentError.new('Required arguments :user missing') if options[:user].nil?
@@ -129,12 +116,12 @@ module Slack
129
116
  end
130
117
 
131
118
  #
132
- # This method is used to leave a private channel.
119
+ # Leaves a private channel.
133
120
  #
134
121
  # @option options [group] :channel
135
122
  # Private channel to leave.
136
123
  # @see https://api.slack.com/methods/groups.leave
137
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/groups/groups.leave.json
124
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/groups/groups.leave.json
138
125
  def groups_leave(options = {})
139
126
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
140
127
  options = options.merge(channel: groups_id(options)['group']['id']) if options[:channel]
@@ -142,26 +129,27 @@ module Slack
142
129
  end
143
130
 
144
131
  #
145
- # This method returns a list of private channels in the team that the caller is in and archived groups that the caller was in.
146
- # The list of (non-deactivated) members in each private channel is also returned.
132
+ # Lists private channels that the calling user has access to.
147
133
  #
148
134
  # @option options [Object] :exclude_archived
149
135
  # Don't return archived private channels.
136
+ # @option options [Object] :exclude_members
137
+ # Exclude the members from each group.
150
138
  # @see https://api.slack.com/methods/groups.list
151
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/groups/groups.list.json
139
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/groups/groups.list.json
152
140
  def groups_list(options = {})
153
141
  post('groups.list', options)
154
142
  end
155
143
 
156
144
  #
157
- # This method moves the read cursor in a private channel.
145
+ # Sets the read cursor in a private channel.
158
146
  #
159
147
  # @option options [group] :channel
160
148
  # Private channel to set reading cursor in.
161
149
  # @option options [timestamp] :ts
162
150
  # Timestamp of the most recently seen message.
163
151
  # @see https://api.slack.com/methods/groups.mark
164
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/groups/groups.mark.json
152
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/groups/groups.mark.json
165
153
  def groups_mark(options = {})
166
154
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
167
155
  throw ArgumentError.new('Required arguments :ts missing') if options[:ts].nil?
@@ -170,12 +158,12 @@ module Slack
170
158
  end
171
159
 
172
160
  #
173
- # This method opens a private channel.
161
+ # Opens a private channel.
174
162
  #
175
163
  # @option options [group] :channel
176
164
  # Private channel to open.
177
165
  # @see https://api.slack.com/methods/groups.open
178
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/groups/groups.open.json
166
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/groups/groups.open.json
179
167
  def groups_open(options = {})
180
168
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
181
169
  options = options.merge(channel: groups_id(options)['group']['id']) if options[:channel]
@@ -183,7 +171,7 @@ module Slack
183
171
  end
184
172
 
185
173
  #
186
- # This method renames a private channel.
174
+ # Renames a private channel.
187
175
  #
188
176
  # @option options [group] :channel
189
177
  # Private channel to rename.
@@ -192,7 +180,7 @@ module Slack
192
180
  # @option options [Object] :validate
193
181
  # Whether to return errors on invalid channel name instead of modifying it to meet the specified criteria.
194
182
  # @see https://api.slack.com/methods/groups.rename
195
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/groups/groups.rename.json
183
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/groups/groups.rename.json
196
184
  def groups_rename(options = {})
197
185
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
198
186
  throw ArgumentError.new('Required arguments :name missing') if options[:name].nil?
@@ -201,14 +189,14 @@ module Slack
201
189
  end
202
190
 
203
191
  #
204
- # This method returns an entire thread (a message plus all the messages in reply to it).
192
+ # Retrieve a thread of messages posted to a private channel
205
193
  #
206
194
  # @option options [group] :channel
207
195
  # Private channel to fetch thread from.
208
196
  # @option options [Object] :thread_ts
209
197
  # Unique identifier of a thread's parent message.
210
198
  # @see https://api.slack.com/methods/groups.replies
211
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/groups/groups.replies.json
199
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/groups/groups.replies.json
212
200
  def groups_replies(options = {})
213
201
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
214
202
  throw ArgumentError.new('Required arguments :thread_ts missing') if options[:thread_ts].nil?
@@ -217,14 +205,14 @@ module Slack
217
205
  end
218
206
 
219
207
  #
220
- # This method is used to change the purpose of a private channel. The calling user must be a member of the private channel.
208
+ # Sets the purpose for a private channel.
221
209
  #
222
210
  # @option options [group] :channel
223
211
  # Private channel to set the purpose of.
224
212
  # @option options [Object] :purpose
225
213
  # The new purpose.
226
214
  # @see https://api.slack.com/methods/groups.setPurpose
227
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/groups/groups.setPurpose.json
215
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/groups/groups.setPurpose.json
228
216
  def groups_setPurpose(options = {})
229
217
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
230
218
  throw ArgumentError.new('Required arguments :purpose missing') if options[:purpose].nil?
@@ -233,14 +221,14 @@ module Slack
233
221
  end
234
222
 
235
223
  #
236
- # This method is used to change the topic of a private channel. The calling user must be a member of the private channel.
224
+ # Sets the topic for a private channel.
237
225
  #
238
226
  # @option options [group] :channel
239
227
  # Private channel to set the topic of.
240
228
  # @option options [Object] :topic
241
229
  # The new topic.
242
230
  # @see https://api.slack.com/methods/groups.setTopic
243
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/groups/groups.setTopic.json
231
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/groups/groups.setTopic.json
244
232
  def groups_setTopic(options = {})
245
233
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
246
234
  throw ArgumentError.new('Required arguments :topic missing') if options[:topic].nil?
@@ -249,12 +237,12 @@ module Slack
249
237
  end
250
238
 
251
239
  #
252
- # This method unarchives a private channel.
240
+ # Unarchives a private channel.
253
241
  #
254
242
  # @option options [group] :channel
255
243
  # Private channel to unarchive.
256
244
  # @see https://api.slack.com/methods/groups.unarchive
257
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/groups/groups.unarchive.json
245
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/groups/groups.unarchive.json
258
246
  def groups_unarchive(options = {})
259
247
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
260
248
  options = options.merge(channel: groups_id(options)['group']['id']) if options[:channel]
@@ -6,12 +6,12 @@ module Slack
6
6
  module Endpoints
7
7
  module Im
8
8
  #
9
- # This method closes a direct message channel.
9
+ # Close a direct message channel.
10
10
  #
11
11
  # @option options [im] :channel
12
12
  # Direct message channel to close.
13
13
  # @see https://api.slack.com/methods/im.close
14
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/im/im.close.json
14
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/im/im.close.json
15
15
  def im_close(options = {})
16
16
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
17
17
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
@@ -19,22 +19,20 @@ module Slack
19
19
  end
20
20
 
21
21
  #
22
- # This method returns a portion of messages/events from the specified direct message channel.
23
- # To read the entire history for a direct message channel, call the method with no latest or
24
- # oldest arguments, and then continue paging using the instructions below.
22
+ # Fetches history of messages and events from direct message channel.
25
23
  #
26
24
  # @option options [im] :channel
27
25
  # Direct message channel to fetch history for.
26
+ # @option options [Object] :inclusive
27
+ # Include messages with latest or oldest timestamp in results.
28
28
  # @option options [timestamp] :latest
29
29
  # End of time range of messages to include in results.
30
30
  # @option options [timestamp] :oldest
31
31
  # Start of time range of messages to include in results.
32
- # @option options [Object] :inclusive
33
- # Include messages with latest or oldest timestamp in results.
34
32
  # @option options [Object] :unreads
35
33
  # Include unread_count_display in the output?.
36
34
  # @see https://api.slack.com/methods/im.history
37
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/im/im.history.json
35
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/im/im.history.json
38
36
  def im_history(options = {})
39
37
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
40
38
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
@@ -42,23 +40,33 @@ module Slack
42
40
  end
43
41
 
44
42
  #
45
- # This method returns a list of all im channels that the user has.
43
+ # Lists direct message channels for the calling user.
46
44
  #
45
+ # @option options [Object] :cursor
46
+ # 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.
47
+ # @option options [Object] :limit
48
+ # 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.
47
49
  # @see https://api.slack.com/methods/im.list
48
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/im/im.list.json
50
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/im/im.list.json
49
51
  def im_list(options = {})
50
- post('im.list', options)
52
+ if block_given?
53
+ Pagination::Cursor.new(self, :im_list, options).each do |page|
54
+ yield page
55
+ end
56
+ else
57
+ post('im.list', options)
58
+ end
51
59
  end
52
60
 
53
61
  #
54
- # This method moves the read cursor in a direct message channel.
62
+ # Sets the read cursor in a direct message channel.
55
63
  #
56
64
  # @option options [im] :channel
57
65
  # Direct message channel to set reading cursor in.
58
66
  # @option options [timestamp] :ts
59
67
  # Timestamp of the most recently seen message.
60
68
  # @see https://api.slack.com/methods/im.mark
61
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/im/im.mark.json
69
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/im/im.mark.json
62
70
  def im_mark(options = {})
63
71
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
64
72
  throw ArgumentError.new('Required arguments :ts missing') if options[:ts].nil?
@@ -67,14 +75,16 @@ module Slack
67
75
  end
68
76
 
69
77
  #
70
- # This method opens a direct message channel with another member of your Slack team.
78
+ # Opens a direct message channel.
71
79
  #
72
80
  # @option options [user] :user
73
81
  # User to open a direct message channel with.
82
+ # @option options [Object] :include_locale
83
+ # Set this to true to receive the locale for this im. Defaults to false.
74
84
  # @option options [Object] :return_im
75
85
  # Boolean, indicates you want the full IM channel definition in the response.
76
86
  # @see https://api.slack.com/methods/im.open
77
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/im/im.open.json
87
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/im/im.open.json
78
88
  def im_open(options = {})
79
89
  throw ArgumentError.new('Required arguments :user missing') if options[:user].nil?
80
90
  options = options.merge(user: users_id(options)['user']['id']) if options[:user]
@@ -82,14 +92,14 @@ module Slack
82
92
  end
83
93
 
84
94
  #
85
- # This method returns an entire thread (a message plus all the messages in reply to it).
95
+ # Retrieve a thread of messages posted to a direct message conversation
86
96
  #
87
97
  # @option options [im] :channel
88
98
  # Direct message channel to fetch thread from.
89
99
  # @option options [Object] :thread_ts
90
100
  # Unique identifier of a thread's parent message.
91
101
  # @see https://api.slack.com/methods/im.replies
92
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/im/im.replies.json
102
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/im/im.replies.json
93
103
  def im_replies(options = {})
94
104
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
95
105
  throw ArgumentError.new('Required arguments :thread_ts missing') if options[:thread_ts].nil?
@@ -0,0 +1,25 @@
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 Migration
8
+ #
9
+ # For Enterprise Grid workspaces, map local user IDs to global user IDs
10
+ #
11
+ # @option options [Object] :users
12
+ # A comma-separated list of user ids, up to 400 per request.
13
+ # @option options [Object] :to_old
14
+ # Specify true to convert W global user IDs to workspace-specific U IDs. Defaults to false.
15
+ # @see https://api.slack.com/methods/migration.exchange
16
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/migration/migration.exchange.json
17
+ def migration_exchange(options = {})
18
+ throw ArgumentError.new('Required arguments :users missing') if options[:users].nil?
19
+ post('migration.exchange', options)
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -6,12 +6,12 @@ module Slack
6
6
  module Endpoints
7
7
  module Mpim
8
8
  #
9
- # This method closes a multiparty direct message channel.
9
+ # Closes a multiparty direct message channel.
10
10
  #
11
11
  # @option options [channel] :channel
12
12
  # MPIM to close.
13
13
  # @see https://api.slack.com/methods/mpim.close
14
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/mpim/mpim.close.json
14
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/mpim/mpim.close.json
15
15
  def mpim_close(options = {})
16
16
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
17
17
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
@@ -19,22 +19,20 @@ module Slack
19
19
  end
20
20
 
21
21
  #
22
- # This method returns a portion of messages/events from the specified multiparty direct message channel.
23
- # To read the entire history for a multiparty direct message, call the method with no latest or
24
- # oldest arguments, and then continue paging using the instructions below.
22
+ # Fetches history of messages and events from a multiparty direct message.
25
23
  #
26
24
  # @option options [channel] :channel
27
25
  # Multiparty direct message to fetch history for.
26
+ # @option options [Object] :inclusive
27
+ # Include messages with latest or oldest timestamp in results.
28
28
  # @option options [timestamp] :latest
29
29
  # End of time range of messages to include in results.
30
30
  # @option options [timestamp] :oldest
31
31
  # Start of time range of messages to include in results.
32
- # @option options [Object] :inclusive
33
- # Include messages with latest or oldest timestamp in results.
34
32
  # @option options [Object] :unreads
35
33
  # Include unread_count_display in the output?.
36
34
  # @see https://api.slack.com/methods/mpim.history
37
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/mpim/mpim.history.json
35
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/mpim/mpim.history.json
38
36
  def mpim_history(options = {})
39
37
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
40
38
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
@@ -42,23 +40,23 @@ module Slack
42
40
  end
43
41
 
44
42
  #
45
- # This method returns a list of all multiparty direct message channels that the user has.
43
+ # Lists multiparty direct message channels for the calling user.
46
44
  #
47
45
  # @see https://api.slack.com/methods/mpim.list
48
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/mpim/mpim.list.json
46
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/mpim/mpim.list.json
49
47
  def mpim_list(options = {})
50
48
  post('mpim.list', options)
51
49
  end
52
50
 
53
51
  #
54
- # This method moves the read cursor in a multiparty direct message channel.
52
+ # Sets the read cursor in a multiparty direct message channel.
55
53
  #
56
54
  # @option options [channel] :channel
57
55
  # multiparty direct message channel to set reading cursor in.
58
56
  # @option options [timestamp] :ts
59
57
  # Timestamp of the most recently seen message.
60
58
  # @see https://api.slack.com/methods/mpim.mark
61
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/mpim/mpim.mark.json
59
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/mpim/mpim.mark.json
62
60
  def mpim_mark(options = {})
63
61
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
64
62
  throw ArgumentError.new('Required arguments :ts missing') if options[:ts].nil?
@@ -72,21 +70,21 @@ module Slack
72
70
  # @option options [Object] :users
73
71
  # Comma separated lists of users. The ordering of the users is preserved whenever a MPIM group is returned.
74
72
  # @see https://api.slack.com/methods/mpim.open
75
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/mpim/mpim.open.json
73
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/mpim/mpim.open.json
76
74
  def mpim_open(options = {})
77
75
  throw ArgumentError.new('Required arguments :users missing') if options[:users].nil?
78
76
  post('mpim.open', options)
79
77
  end
80
78
 
81
79
  #
82
- # This method returns an entire thread (a message plus all the messages in reply to it).
80
+ # Retrieve a thread of messages posted to a direct message conversation from a multiparty direct message.
83
81
  #
84
82
  # @option options [channel] :channel
85
83
  # Multiparty direct message channel to fetch thread from.
86
84
  # @option options [Object] :thread_ts
87
85
  # Unique identifier of a thread's parent message.
88
86
  # @see https://api.slack.com/methods/mpim.replies
89
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/mpim/mpim.replies.json
87
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/mpim/mpim.replies.json
90
88
  def mpim_replies(options = {})
91
89
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
92
90
  throw ArgumentError.new('Required arguments :thread_ts missing') if options[:thread_ts].nil?
@@ -6,8 +6,7 @@ module Slack
6
6
  module Endpoints
7
7
  module Oauth
8
8
  #
9
- # This method allows you to exchange a temporary OAuth code for an API access token.
10
- # This is used as part of the OAuth authentication flow.
9
+ # Exchanges a temporary OAuth code for an API token.
11
10
  #
12
11
  # @option options [Object] :client_id
13
12
  # Issued when you created your application.
@@ -18,13 +17,35 @@ module Slack
18
17
  # @option options [Object] :redirect_uri
19
18
  # This must match the originally submitted URI (if one was sent).
20
19
  # @see https://api.slack.com/methods/oauth.access
21
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/oauth/oauth.access.json
20
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/oauth/oauth.access.json
22
21
  def oauth_access(options = {})
23
22
  throw ArgumentError.new('Required arguments :client_id missing') if options[:client_id].nil?
24
23
  throw ArgumentError.new('Required arguments :client_secret missing') if options[:client_secret].nil?
25
24
  throw ArgumentError.new('Required arguments :code missing') if options[:code].nil?
26
25
  post('oauth.access', options)
27
26
  end
27
+
28
+ #
29
+ # Exchanges a temporary OAuth verifier code for a workspace token.
30
+ #
31
+ # @option options [Object] :client_id
32
+ # Issued when you created your application.
33
+ # @option options [Object] :client_secret
34
+ # Issued when you created your application.
35
+ # @option options [Object] :code
36
+ # The code param returned via the OAuth callback.
37
+ # @option options [Object] :redirect_uri
38
+ # This must match the originally submitted URI (if one was sent).
39
+ # @option options [Object] :single_channel
40
+ # Request the user to add your app only to a single channel.
41
+ # @see https://api.slack.com/methods/oauth.token
42
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/oauth/oauth.token.json
43
+ def oauth_token(options = {})
44
+ throw ArgumentError.new('Required arguments :client_id missing') if options[:client_id].nil?
45
+ throw ArgumentError.new('Required arguments :client_secret missing') if options[:client_secret].nil?
46
+ throw ArgumentError.new('Required arguments :code missing') if options[:code].nil?
47
+ post('oauth.token', options)
48
+ end
28
49
  end
29
50
  end
30
51
  end
@@ -6,8 +6,7 @@ module Slack
6
6
  module Endpoints
7
7
  module Pins
8
8
  #
9
- # This method pins an item (file, file comment, channel message, or group message) to a particular channel.
10
- # The channel argument is required and one of file, file_comment, or timestamp must also be specified.
9
+ # Pins an item to a channel.
11
10
  #
12
11
  # @option options [channel] :channel
13
12
  # Channel to pin the item in.
@@ -18,7 +17,7 @@ module Slack
18
17
  # @option options [Object] :timestamp
19
18
  # Timestamp of the message to pin.
20
19
  # @see https://api.slack.com/methods/pins.add
21
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/pins/pins.add.json
20
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/pins/pins.add.json
22
21
  def pins_add(options = {})
23
22
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
24
23
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
@@ -26,12 +25,12 @@ module Slack
26
25
  end
27
26
 
28
27
  #
29
- # This method lists the items pinned to a channel.
28
+ # Lists items pinned to a channel.
30
29
  #
31
30
  # @option options [channel] :channel
32
31
  # Channel to get pinned items for.
33
32
  # @see https://api.slack.com/methods/pins.list
34
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/pins/pins.list.json
33
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/pins/pins.list.json
35
34
  def pins_list(options = {})
36
35
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
37
36
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
@@ -39,8 +38,7 @@ module Slack
39
38
  end
40
39
 
41
40
  #
42
- # This method un-pins an item (file, file comment, channel message, or group message) from a channel.
43
- # The channel argument is required and one of file, file_comment, or timestamp must also be specified.
41
+ # Un-pins an item from a channel.
44
42
  #
45
43
  # @option options [channel] :channel
46
44
  # Channel where the item is pinned to.
@@ -51,7 +49,7 @@ module Slack
51
49
  # @option options [Object] :timestamp
52
50
  # Timestamp of the message to un-pin.
53
51
  # @see https://api.slack.com/methods/pins.remove
54
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/pins/pins.remove.json
52
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/pins/pins.remove.json
55
53
  def pins_remove(options = {})
56
54
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
57
55
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
@@ -11,7 +11,7 @@ module Slack
11
11
  # @option options [Object] :presence
12
12
  # Either `active` or `away`.
13
13
  # @see https://api.slack.com/methods/presence.set
14
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/presence.set.json
14
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/presence.set.json
15
15
  def presence_set(options = {})
16
16
  throw ArgumentError.new('Required arguments :presence missing') if options[:presence].nil?
17
17
  post('presence.set', options)