slack-ruby-client 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. checksums.yaml +4 -4
  2. data/.coveralls.yml +2 -0
  3. data/.github/workflows/test.yml +6 -0
  4. data/.github/workflows/update_api.yml +76 -0
  5. data/.gitignore +1 -0
  6. data/.rubocop_todo.yml +17 -29
  7. data/CHANGELOG.md +23 -1
  8. data/CONTRIBUTING.md +35 -32
  9. data/Gemfile +2 -0
  10. data/README.md +123 -14
  11. data/bin/commands/admin_apps_activities.rb +32 -0
  12. data/bin/commands/admin_apps_approved.rb +1 -0
  13. data/bin/commands/admin_apps_config.rb +31 -0
  14. data/bin/commands/admin_apps_requests.rb +1 -0
  15. data/bin/commands/admin_apps_restricted.rb +1 -0
  16. data/bin/commands/admin_functions.rb +23 -0
  17. data/bin/commands/admin_functions_permissions.rb +31 -0
  18. data/bin/commands/admin_roles.rb +1 -1
  19. data/bin/commands/admin_teams.rb +1 -1
  20. data/bin/commands/admin_users.rb +2 -2
  21. data/bin/commands/admin_workflows.rb +38 -0
  22. data/bin/commands/admin_workflows_collaborators.rb +31 -0
  23. data/bin/commands/admin_workflows_permissions.rb +21 -0
  24. data/bin/commands/apps_activities.rb +32 -0
  25. data/bin/commands/apps_auth_external.rb +32 -0
  26. data/bin/commands/apps_datastore.rb +70 -0
  27. data/bin/commands/auth_teams.rb +2 -2
  28. data/bin/commands/calls.rb +1 -1
  29. data/bin/commands/chat.rb +6 -6
  30. data/bin/commands/chat_scheduledMessages.rb +2 -2
  31. data/bin/commands/conversations.rb +3 -3
  32. data/bin/commands/dnd.rb +1 -1
  33. data/bin/commands/functions_workflows_steps.rb +2 -1
  34. data/bin/commands/functions_workflows_steps_responses.rb +2 -1
  35. data/bin/commands/reminders.rb +1 -1
  36. data/bin/commands/stars.rb +4 -4
  37. data/bin/commands/team.rb +3 -1
  38. data/bin/commands/users.rb +1 -1
  39. data/lib/slack/messages/formatting.rb +44 -0
  40. data/lib/slack/real_time/client.rb +14 -2
  41. data/lib/slack/real_time/concurrency/async.rb +4 -0
  42. data/lib/slack/real_time/config.rb +3 -0
  43. data/lib/slack/real_time/socket.rb +4 -0
  44. data/lib/slack/real_time/stores/starter.rb +2 -2
  45. data/lib/slack/real_time/stores/store.rb +2 -2
  46. data/lib/slack/version.rb +1 -1
  47. data/lib/slack/web/api/endpoints/admin_apps_activities.rb +53 -0
  48. data/lib/slack/web/api/endpoints/admin_apps_approved.rb +2 -0
  49. data/lib/slack/web/api/endpoints/admin_apps_config.rb +40 -0
  50. data/lib/slack/web/api/endpoints/admin_apps_requests.rb +2 -0
  51. data/lib/slack/web/api/endpoints/admin_apps_restricted.rb +2 -0
  52. data/lib/slack/web/api/endpoints/admin_conversations.rb +1 -0
  53. data/lib/slack/web/api/endpoints/admin_functions.rb +36 -0
  54. data/lib/slack/web/api/endpoints/admin_functions_permissions.rb +41 -0
  55. data/lib/slack/web/api/endpoints/admin_roles.rb +1 -1
  56. data/lib/slack/web/api/endpoints/admin_teams.rb +1 -1
  57. data/lib/slack/web/api/endpoints/admin_users.rb +2 -2
  58. data/lib/slack/web/api/endpoints/admin_workflows.rb +59 -0
  59. data/lib/slack/web/api/endpoints/admin_workflows_collaborators.rb +42 -0
  60. data/lib/slack/web/api/endpoints/admin_workflows_permissions.rb +26 -0
  61. data/lib/slack/web/api/endpoints/apps_activities.rb +54 -0
  62. data/lib/slack/web/api/endpoints/apps_auth_external.rb +41 -0
  63. data/lib/slack/web/api/endpoints/apps_datastore.rb +110 -0
  64. data/lib/slack/web/api/endpoints/apps_manifest.rb +2 -0
  65. data/lib/slack/web/api/endpoints/auth_teams.rb +1 -1
  66. data/lib/slack/web/api/endpoints/calls.rb +1 -1
  67. data/lib/slack/web/api/endpoints/chat.rb +14 -45
  68. data/lib/slack/web/api/endpoints/chat_scheduledMessages.rb +2 -2
  69. data/lib/slack/web/api/endpoints/conversations.rb +3 -3
  70. data/lib/slack/web/api/endpoints/dialog.rb +1 -6
  71. data/lib/slack/web/api/endpoints/dnd.rb +1 -1
  72. data/lib/slack/web/api/endpoints/functions_workflows_steps.rb +3 -1
  73. data/lib/slack/web/api/endpoints/functions_workflows_steps_responses.rb +3 -1
  74. data/lib/slack/web/api/endpoints/reminders.rb +1 -1
  75. data/lib/slack/web/api/endpoints/stars.rb +2 -2
  76. data/lib/slack/web/api/endpoints/team.rb +12 -2
  77. data/lib/slack/web/api/endpoints/users.rb +1 -1
  78. data/lib/slack/web/api/endpoints/users_profile.rb +1 -0
  79. data/lib/slack/web/api/endpoints/views.rb +7 -23
  80. data/lib/slack/web/api/endpoints/workflows.rb +2 -0
  81. data/lib/slack/web/api/endpoints.rb +20 -0
  82. data/lib/slack/web/api/errors.rb +66 -4
  83. data/lib/slack/web/api/options.rb +26 -0
  84. data/lib/slack/web/api/patches/chat.attachments-blocks.patch +7 -55
  85. data/lib/slack/web/api/templates/method.erb +12 -0
  86. data/lib/slack/web/api/templates/method_spec.erb +40 -4
  87. data/lib/slack/web/client.rb +1 -0
  88. data/lib/slack-ruby-client.rb +1 -0
  89. data/lib/tasks/web.rake +2 -4
  90. data/slack-ruby-client.gemspec +1 -0
  91. data/spec/slack/messages/formatting_spec.rb +60 -0
  92. data/spec/slack/real_time/client_spec.rb +25 -7
  93. data/spec/slack/real_time/concurrency/clients/async_spec.rb +16 -0
  94. data/spec/slack/web/api/endpoints/admin_apps_activities_spec.rb +8 -0
  95. data/spec/slack/web/api/endpoints/admin_apps_config_spec.rb +18 -0
  96. data/spec/slack/web/api/endpoints/admin_auth_policy_spec.rb +6 -6
  97. data/spec/slack/web/api/endpoints/admin_conversations_spec.rb +14 -10
  98. data/spec/slack/web/api/endpoints/admin_functions_permissions_spec.rb +21 -0
  99. data/spec/slack/web/api/endpoints/admin_functions_spec.rb +13 -0
  100. data/spec/slack/web/api/endpoints/admin_roles_spec.rb +6 -6
  101. data/spec/slack/web/api/endpoints/admin_teams_settings_spec.rb +1 -1
  102. data/spec/slack/web/api/endpoints/admin_usergroups_spec.rb +6 -6
  103. data/spec/slack/web/api/endpoints/admin_users_session_spec.rb +2 -2
  104. data/spec/slack/web/api/endpoints/admin_users_spec.rb +8 -8
  105. data/spec/slack/web/api/endpoints/admin_workflows_collaborators_spec.rb +24 -0
  106. data/spec/slack/web/api/endpoints/admin_workflows_permissions_spec.rb +13 -0
  107. data/spec/slack/web/api/endpoints/admin_workflows_spec.rb +13 -0
  108. data/spec/slack/web/api/endpoints/apps_activities_spec.rb +13 -0
  109. data/spec/slack/web/api/endpoints/apps_auth_external_spec.rb +13 -0
  110. data/spec/slack/web/api/endpoints/apps_datastore_spec.rb +45 -0
  111. data/spec/slack/web/api/endpoints/apps_manifest_spec.rb +8 -0
  112. data/spec/slack/web/api/endpoints/apps_spec.rb +2 -2
  113. data/spec/slack/web/api/endpoints/auth_spec.rb +8 -0
  114. data/spec/slack/web/api/endpoints/bookmarks_spec.rb +4 -4
  115. data/spec/slack/web/api/endpoints/calls_participants_spec.rb +4 -4
  116. data/spec/slack/web/api/endpoints/calls_spec.rb +2 -2
  117. data/spec/slack/web/api/endpoints/chat_spec.rb +62 -0
  118. data/spec/slack/web/api/endpoints/conversations_spec.rb +8 -0
  119. data/spec/slack/web/api/endpoints/custom_specs/chat_spec.rb +3 -3
  120. data/spec/slack/web/api/endpoints/custom_specs/views_spec.rb +1 -1
  121. data/spec/slack/web/api/endpoints/dialog_spec.rb +14 -0
  122. data/spec/slack/web/api/endpoints/files_comments_spec.rb +2 -2
  123. data/spec/slack/web/api/endpoints/files_remote_spec.rb +3 -3
  124. data/spec/slack/web/api/endpoints/files_spec.rb +2 -2
  125. data/spec/slack/web/api/endpoints/oauth_v2_spec.rb +2 -2
  126. data/spec/slack/web/api/endpoints/reactions_spec.rb +3 -3
  127. data/spec/slack/web/api/endpoints/reminders_spec.rb +2 -2
  128. data/spec/slack/web/api/endpoints/usergroups_users_spec.rb +2 -2
  129. data/spec/slack/web/api/endpoints/users_profile_spec.rb +6 -0
  130. data/spec/slack/web/api/endpoints/users_spec.rb +8 -0
  131. data/spec/slack/web/api/endpoints/views_spec.rb +65 -0
  132. data/spec/slack/web/api/endpoints/workflows_spec.rb +8 -0
  133. data/spec/slack/web/api/options_spec.rb +69 -0
  134. data/spec/spec_helper.rb +9 -0
  135. metadata +45 -5
  136. data/lib/slack/web/api/patches/dialog.encoded-json.patch +0 -17
  137. data/lib/slack/web/api/patches/views.view-json.patch +0 -55
@@ -0,0 +1,110 @@
1
+ # frozen_string_literal: true
2
+ # This file was auto-generated by lib/tasks/web.rake
3
+
4
+ module Slack
5
+ module Web
6
+ module Api
7
+ module Endpoints
8
+ module AppsDatastore
9
+ #
10
+ # Delete an item from a datastore
11
+ #
12
+ # @option options [string] :datastore
13
+ # name of the datastore.
14
+ # @option options [string] :id
15
+ # item id.
16
+ # @option options [Object] :app_id
17
+ # .
18
+ # @see https://api.slack.com/methods/apps.datastore.delete
19
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/apps.datastore/apps.datastore.delete.json
20
+ def apps_datastore_delete(options = {})
21
+ raise ArgumentError, 'Required arguments :datastore missing' if options[:datastore].nil?
22
+ raise ArgumentError, 'Required arguments :id missing' if options[:id].nil?
23
+ post('apps.datastore.delete', options)
24
+ end
25
+
26
+ #
27
+ # Get an item from a datastore
28
+ #
29
+ # @option options [string] :datastore
30
+ # name of the datastore.
31
+ # @option options [string] :id
32
+ # item id.
33
+ # @option options [Object] :app_id
34
+ # .
35
+ # @see https://api.slack.com/methods/apps.datastore.get
36
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/apps.datastore/apps.datastore.get.json
37
+ def apps_datastore_get(options = {})
38
+ raise ArgumentError, 'Required arguments :datastore missing' if options[:datastore].nil?
39
+ raise ArgumentError, 'Required arguments :id missing' if options[:id].nil?
40
+ post('apps.datastore.get', options)
41
+ end
42
+
43
+ #
44
+ # Creates a new item, or replaces an old item with a new item.
45
+ #
46
+ # @option options [string] :datastore
47
+ # name of the datastore.
48
+ # @option options [object] :item
49
+ # attribute names and values of the item.
50
+ # @option options [Object] :app_id
51
+ # .
52
+ # @see https://api.slack.com/methods/apps.datastore.put
53
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/apps.datastore/apps.datastore.put.json
54
+ def apps_datastore_put(options = {})
55
+ raise ArgumentError, 'Required arguments :datastore missing' if options[:datastore].nil?
56
+ raise ArgumentError, 'Required arguments :item missing' if options[:item].nil?
57
+ post('apps.datastore.put', options)
58
+ end
59
+
60
+ #
61
+ # Query a datastore for items
62
+ #
63
+ # @option options [string] :datastore
64
+ # Name of the datastore.
65
+ # @option options [Object] :app_id
66
+ # Required if calling with user token.
67
+ # @option options [string] :cursor
68
+ # Set cursor to next_cursor returned by the previous call to list items in the next page.
69
+ # @option options [string] :expression
70
+ # A query filter expression https://api.slack.com/future/datastores.
71
+ # @option options [object] :expression_attributes
72
+ # A map of attributes referenced in expression.
73
+ # @option options [object] :expression_values
74
+ # A map of values referenced in expression.
75
+ # @option options [integer] :limit
76
+ # The maximum number of items to evaluate for a given request (not necessarily the number of matching items). If the given request dataset size exceeds 1 MB before reaching the limit, the returned item count will likely be less than the limit. In any case where there are more items available beyond an imposed limit, a next_cursor value will be provided for use in subsequent requests.
77
+ # @see https://api.slack.com/methods/apps.datastore.query
78
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/apps.datastore/apps.datastore.query.json
79
+ def apps_datastore_query(options = {})
80
+ raise ArgumentError, 'Required arguments :datastore missing' if options[:datastore].nil?
81
+ if block_given?
82
+ Pagination::Cursor.new(self, :apps_datastore_query, options).each do |page|
83
+ yield page
84
+ end
85
+ else
86
+ post('apps.datastore.query', options)
87
+ end
88
+ end
89
+
90
+ #
91
+ # Edits an existing item's attributes, or adds a new item if it does not already exist.
92
+ #
93
+ # @option options [string] :datastore
94
+ # name of the datastore.
95
+ # @option options [object] :item
96
+ # attribute names and values to be updated.
97
+ # @option options [Object] :app_id
98
+ # .
99
+ # @see https://api.slack.com/methods/apps.datastore.update
100
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/apps.datastore/apps.datastore.update.json
101
+ def apps_datastore_update(options = {})
102
+ raise ArgumentError, 'Required arguments :datastore missing' if options[:datastore].nil?
103
+ raise ArgumentError, 'Required arguments :item missing' if options[:item].nil?
104
+ post('apps.datastore.update', options)
105
+ end
106
+ end
107
+ end
108
+ end
109
+ end
110
+ end
@@ -15,6 +15,7 @@ module Slack
15
15
  # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/apps.manifest/apps.manifest.create.json
16
16
  def apps_manifest_create(options = {})
17
17
  raise ArgumentError, 'Required arguments :manifest missing' if options[:manifest].nil?
18
+ options = encode_options_as_json(options, %i[manifest])
18
19
  post('apps.manifest.create', options)
19
20
  end
20
21
 
@@ -54,6 +55,7 @@ module Slack
54
55
  def apps_manifest_update(options = {})
55
56
  raise ArgumentError, 'Required arguments :app_id missing' if options[:app_id].nil?
56
57
  raise ArgumentError, 'Required arguments :manifest missing' if options[:manifest].nil?
58
+ options = encode_options_as_json(options, %i[manifest])
57
59
  post('apps.manifest.update', options)
58
60
  end
59
61
 
@@ -7,7 +7,7 @@ module Slack
7
7
  module Endpoints
8
8
  module AuthTeams
9
9
  #
10
- # List the workspaces a token can access.
10
+ # Obtain a full list of workspaces your org-wide app has been approved for.
11
11
  #
12
12
  # @option options [string] :cursor
13
13
  # Set cursor to next_cursor returned by the previous call to list items in the next page.
@@ -16,7 +16,7 @@ module Slack
16
16
  # @option options [string] :created_by
17
17
  # The valid Slack user ID of the user who created this Call. When this method is called with a user token, the created_by field is optional and defaults to the authed user of the token. Otherwise, the field is required.
18
18
  # @option options [integer] :date_start
19
- # Call start time in UTC UNIX timestamp format.
19
+ # Unix timestamp of the call start time.
20
20
  # @option options [string] :desktop_app_join_url
21
21
  # When supplied, available Slack clients will attempt to directly launch the 3rd-party Call with this URL.
22
22
  # @option options [string] :external_display_id
@@ -107,9 +107,9 @@ module Slack
107
107
  # @option options [blocks[] as string] :blocks
108
108
  # A JSON-based array of structured blocks, presented as a URL-encoded string.
109
109
  # @option options [string] :icon_emoji
110
- # Emoji to use as the icon for this message. Overrides icon_url. Must be used in conjunction with as_user set to false, otherwise ignored. See authorship below.
110
+ # Emoji to use as the icon for this message. Overrides icon_url.
111
111
  # @option options [string] :icon_url
112
- # URL to an image to use as the icon for this message. Must be used in conjunction with as_user set to false, otherwise ignored. See authorship below.
112
+ # URL to an image to use as the icon for this message.
113
113
  # @option options [boolean] :link_names
114
114
  # Find and link channel names and usernames.
115
115
  # @option options [string] :parse
@@ -117,26 +117,15 @@ module Slack
117
117
  # @option options [string] :thread_ts
118
118
  # Provide another message's ts value to post this message in a thread. Avoid using a reply's ts value; use its parent's value instead. Ephemeral messages in threads are only shown if there is already an active thread.
119
119
  # @option options [string] :username
120
- # Set your bot's user name. Must be used in conjunction with as_user set to false, otherwise ignored. See authorship below.
120
+ # Set your bot's user name.
121
121
  # @see https://api.slack.com/methods/chat.postEphemeral
122
122
  # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/chat/chat.postEphemeral.json
123
123
  def chat_postEphemeral(options = {})
124
124
  raise ArgumentError, 'Required arguments :channel missing' if options[:channel].nil?
125
- raise ArgumentError, 'Required arguments :text, :attachments or :blocks missing' if options[:text].nil? && options[:attachments].nil? && options[:blocks].nil?
125
+ raise ArgumentError, 'At least one of :attachments, :blocks, :text is required' if options[:attachments].nil? && options[:blocks].nil? && options[:text].nil?
126
126
  raise ArgumentError, 'Required arguments :user missing' if options[:user].nil?
127
127
  options = options.merge(user: users_id(options)['user']['id']) if options[:user]
128
- # attachments must be passed as an encoded JSON string
129
- if options.key?(:attachments)
130
- attachments = options[:attachments]
131
- attachments = JSON.dump(attachments) unless attachments.is_a?(String)
132
- options = options.merge(attachments: attachments)
133
- end
134
- # blocks must be passed as an encoded JSON string
135
- if options.key?(:blocks)
136
- blocks = options[:blocks]
137
- blocks = JSON.dump(blocks) unless blocks.is_a?(String)
138
- options = options.merge(blocks: blocks)
139
- end
128
+ options = encode_options_as_json(options, %i[attachments blocks])
140
129
  post('chat.postEphemeral', options)
141
130
  end
142
131
 
@@ -154,9 +143,9 @@ module Slack
154
143
  # @option options [boolean] :as_user
155
144
  # (Legacy) Pass true to post the message as the authed user instead of as a bot. Defaults to false. Can only be used by classic Slack apps. See authorship below.
156
145
  # @option options [string] :icon_emoji
157
- # Emoji to use as the icon for this message. Overrides icon_url. Must be used in conjunction with as_user set to false, otherwise ignored. See authorship below.
146
+ # Emoji to use as the icon for this message. Overrides icon_url.
158
147
  # @option options [string] :icon_url
159
- # URL to an image to use as the icon for this message. Must be used in conjunction with as_user set to false, otherwise ignored. See authorship below.
148
+ # URL to an image to use as the icon for this message.
160
149
  # @option options [boolean] :link_names
161
150
  # Find and link user groups. No longer supports linking individual users; use syntax shown in Mentioning Users instead.
162
151
  # @option options [string] :metadata
@@ -174,24 +163,13 @@ module Slack
174
163
  # @option options [boolean] :unfurl_media
175
164
  # Pass false to disable unfurling of media content.
176
165
  # @option options [string] :username
177
- # Set your bot's user name. Must be used in conjunction with as_user set to false, otherwise ignored. See authorship below.
166
+ # Set your bot's user name.
178
167
  # @see https://api.slack.com/methods/chat.postMessage
179
168
  # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/chat/chat.postMessage.json
180
169
  def chat_postMessage(options = {})
181
170
  raise ArgumentError, 'Required arguments :channel missing' if options[:channel].nil?
182
- raise ArgumentError, 'Required arguments :text, :attachments or :blocks missing' if options[:text].nil? && options[:attachments].nil? && options[:blocks].nil?
183
- # attachments must be passed as an encoded JSON string
184
- if options.key?(:attachments)
185
- attachments = options[:attachments]
186
- attachments = JSON.dump(attachments) unless attachments.is_a?(String)
187
- options = options.merge(attachments: attachments)
188
- end
189
- # blocks must be passed as an encoded JSON string
190
- if options.key?(:blocks)
191
- blocks = options[:blocks]
192
- blocks = JSON.dump(blocks) unless blocks.is_a?(String)
193
- options = options.merge(blocks: blocks)
194
- end
171
+ raise ArgumentError, 'At least one of :attachments, :blocks, :text is required' if options[:attachments].nil? && options[:blocks].nil? && options[:text].nil?
172
+ options = encode_options_as_json(options, %i[attachments blocks metadata])
195
173
  post('chat.postMessage', options)
196
174
  end
197
175
 
@@ -230,6 +208,7 @@ module Slack
230
208
  raise ArgumentError, 'Required arguments :channel missing' if options[:channel].nil?
231
209
  raise ArgumentError, 'Required arguments :post_at missing' if options[:post_at].nil?
232
210
  raise ArgumentError, 'Required arguments :text missing' if options[:text].nil?
211
+ options = encode_options_as_json(options, %i[attachments blocks metadata])
233
212
  post('chat.scheduleMessage', options)
234
213
  end
235
214
 
@@ -261,6 +240,7 @@ module Slack
261
240
  raise ArgumentError, 'Required arguments :ts missing' if options[:ts].nil?
262
241
  raise ArgumentError, 'Required arguments :unfurls missing' if options[:unfurls].nil?
263
242
  options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
243
+ options = encode_options_as_json(options, %i[unfurls user_auth_blocks])
264
244
  post('chat.unfurl', options)
265
245
  end
266
246
 
@@ -293,21 +273,10 @@ module Slack
293
273
  # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/chat/chat.update.json
294
274
  def chat_update(options = {})
295
275
  raise ArgumentError, 'Required arguments :channel missing' if options[:channel].nil?
296
- raise ArgumentError, 'Required arguments :text, :attachments, :blocks or :reply_broadcast missing' if options[:text].nil? && options[:attachments].nil? && options[:blocks].nil? && options[:reply_broadcast].nil?
297
276
  raise ArgumentError, 'Required arguments :ts missing' if options[:ts].nil?
277
+ raise ArgumentError, 'At least one of :attachments, :blocks, :text, :reply_broadcast is required' if options[:attachments].nil? && options[:blocks].nil? && options[:text].nil? && options[:reply_broadcast].nil?
298
278
  options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
299
- # attachments must be passed as an encoded JSON string
300
- if options.key?(:attachments)
301
- attachments = options[:attachments]
302
- attachments = JSON.dump(attachments) unless attachments.is_a?(String)
303
- options = options.merge(attachments: attachments)
304
- end
305
- # blocks must be passed as an encoded JSON string
306
- if options.key?(:blocks)
307
- blocks = options[:blocks]
308
- blocks = JSON.dump(blocks) unless blocks.is_a?(String)
309
- options = options.merge(blocks: blocks)
310
- end
279
+ options = encode_options_as_json(options, %i[attachments blocks metadata])
311
280
  post('chat.update', options)
312
281
  end
313
282
  end
@@ -14,11 +14,11 @@ module Slack
14
14
  # @option options [string] :cursor
15
15
  # For pagination purposes, this is the cursor value returned from a previous call to chat.scheduledmessages.list indicating where you want to start this call from.
16
16
  # @option options [timestamp] :latest
17
- # A UNIX timestamp of the latest value in the time range.
17
+ # A Unix timestamp of the latest value in the time range.
18
18
  # @option options [integer] :limit
19
19
  # Maximum number of original entries to return.
20
20
  # @option options [timestamp] :oldest
21
- # A UNIX timestamp of the oldest value in the time range.
21
+ # A Unix timestamp of the oldest value in the time range.
22
22
  # @option options [string] :team_id
23
23
  # encoded team id to list channels in, required if org token is used.
24
24
  # @see https://api.slack.com/methods/chat.scheduledMessages.list
@@ -16,7 +16,7 @@ module Slack
16
16
  # @option options [boolean] :free_trial_accepted
17
17
  # Whether you'd like to use your workspace's free trial to begin using Slack Connect.
18
18
  # @option options [Object] :invite_id
19
- # See the shared_channel_invite_received event payload for more details on how to retrieve the ID of the invitation.
19
+ # ID of the invite that you'd like to accept. Must provide either invite_id or channel_id. See the shared_channel_invite_received event payload for more details on how to retrieve the ID of the invitation.
20
20
  # @option options [boolean] :is_private
21
21
  # Whether the channel should be private.
22
22
  # @option options [Object] :team_id
@@ -168,11 +168,11 @@ module Slack
168
168
  # @option options [channel] :channel
169
169
  # ID of the channel on your team that you'd like to share.
170
170
  # @option options [array] :emails
171
- # Optional email to receive this invite. Either emails or user_ids must be provided.
171
+ # Optional email to receive this invite. Either emails or user_ids must be provided. Only one email or one user ID may be invited at a time.
172
172
  # @option options [boolean] :external_limited
173
173
  # Optional boolean on whether invite is to a external limited member. Defaults to true.
174
174
  # @option options [array] :user_ids
175
- # Optional user_id to receive this invite. Either emails or user_ids must be provided.
175
+ # Optional user_id to receive this invite. Either emails or user_ids must be provided. Only one email or one user ID may be invited at a time.
176
176
  # @see https://api.slack.com/methods/conversations.inviteShared
177
177
  # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/conversations/conversations.inviteShared.json
178
178
  def conversations_inviteShared(options = {})
@@ -18,12 +18,7 @@ module Slack
18
18
  def dialog_open(options = {})
19
19
  raise ArgumentError, 'Required arguments :dialog missing' if options[:dialog].nil?
20
20
  raise ArgumentError, 'Required arguments :trigger_id missing' if options[:trigger_id].nil?
21
- # dialog must be passed as an encoded JSON string
22
- if options.key?(:dialog)
23
- dialog = options[:dialog]
24
- dialog = JSON.dump(dialog) unless dialog.is_a?(String)
25
- options = options.merge(dialog: dialog)
26
- end
21
+ options = encode_options_as_json(options, %i[dialog])
27
22
  post('dialog.open', options)
28
23
  end
29
24
  end
@@ -42,7 +42,7 @@ module Slack
42
42
  # Turns on Do Not Disturb mode for the current user, or changes its duration.
43
43
  #
44
44
  # @option options [string] :num_minutes
45
- # Number of minutes, from now, to snooze until.
45
+ # This argument is required. Number of minutes, from now, to snooze until.
46
46
  # @see https://api.slack.com/methods/dnd.setSnooze
47
47
  # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/dnd/dnd.setSnooze.json
48
48
  def dnd_setSnooze(options = {})
@@ -10,9 +10,11 @@ module Slack
10
10
  # List the steps of a specific function of a workflow's versions
11
11
  #
12
12
  # @option options [string] :function_id
13
- # .
13
+ # The ID of the function to query.
14
14
  # @option options [string] :workflow
15
15
  # The workflow encoded ID or workflow reference.
16
+ # @option options [string] :workflow_app_id
17
+ # The app tied to the workflow reference.
16
18
  # @option options [string] :workflow_id
17
19
  # The workflow ID, starts with Wf*.
18
20
  # @see https://api.slack.com/methods/functions.workflows.steps.list
@@ -10,9 +10,11 @@ module Slack
10
10
  # Download form responses of a workflow
11
11
  #
12
12
  # @option options [string] :step_id
13
- # .
13
+ # The ID of the OpenForm step to export.
14
14
  # @option options [string] :workflow
15
15
  # The workflow encoded ID or workflow reference.
16
+ # @option options [string] :workflow_app_id
17
+ # The app tied to the workflow reference.
16
18
  # @option options [string] :workflow_id
17
19
  # The workflow ID, starts with Wf*.
18
20
  # @see https://api.slack.com/methods/functions.workflows.steps.responses.export
@@ -18,7 +18,7 @@ module Slack
18
18
  # @option options [string] :team_id
19
19
  # Encoded team id, required if org token is used.
20
20
  # @option options [user] :user
21
- # The user who will receive the reminder. If no user is specified, the reminder will go to user who created it.
21
+ # No longer supported - reminders cannot be set for other users. Previously, was the user who would receive the reminder.
22
22
  # @see https://api.slack.com/methods/reminders.add
23
23
  # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/reminders/reminders.add.json
24
24
  def reminders_add(options = {})
@@ -7,7 +7,7 @@ module Slack
7
7
  module Endpoints
8
8
  module Stars
9
9
  #
10
- # Save an item for later. Formerly known as _adding a star_.
10
+ # Save an item for later. Formerly known as adding a star.
11
11
  #
12
12
  # @option options [channel] :channel
13
13
  # Channel to add star to, or channel where the message to add star to was posted (used with timestamp).
@@ -25,7 +25,7 @@ module Slack
25
25
  end
26
26
 
27
27
  #
28
- # List a user's saved items, formerly known as _stars_.
28
+ # Listed a user's saved items, formerly known as stars.
29
29
  #
30
30
  # @option options [string] :cursor
31
31
  # Parameter for pagination. Set cursor equal to the next_cursor attribute returned by the previous request's response_metadata. This parameter is optional, but pagination is mandatory: the default value simply fetches the first "page" of the collection. See pagination for more details.
@@ -11,12 +11,22 @@ module Slack
11
11
  #
12
12
  # @option options [string] :before
13
13
  # End of time range of logs to include in results (inclusive).
14
+ # @option options [string] :cursor
15
+ # Parameter for pagination. Set cursor equal to the next_cursor attribute returned by the previous request's response_metadata. This parameter is optional, but pagination is mandatory: the default value simply fetches the first "page" of the collection. See pagination for more details.
16
+ # @option options [integer] :limit
17
+ # The maximum number of items to return. Fewer than the requested number of items may be returned, even if the end of the list hasn't been reached. If specified, result is returned using a cursor-based approach instead of a classic one.
14
18
  # @option options [string] :team_id
15
19
  # encoded team id to get logs from, required if org token is used.
16
20
  # @see https://api.slack.com/methods/team.accessLogs
17
21
  # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/team/team.accessLogs.json
18
22
  def team_accessLogs(options = {})
19
- post('team.accessLogs', options)
23
+ if block_given?
24
+ Pagination::Cursor.new(self, :team_accessLogs, options).each do |page|
25
+ yield page
26
+ end
27
+ else
28
+ post('team.accessLogs', options)
29
+ end
20
30
  end
21
31
 
22
32
  #
@@ -49,7 +59,7 @@ module Slack
49
59
  # @option options [string] :domain
50
60
  # Query by domain instead of team (only when team is null). This only works for domains in the same enterprise as the querying team token. This also expects the domain to belong to a team and not the enterprise itself.
51
61
  # @option options [string] :team
52
- # Team to get info on, if omitted, will return information about the current team. Will only return team that the authenticated token is allowed to see through external shared channels.
62
+ # Team to get info about; if omitted, will return information about the current team.
53
63
  # @see https://api.slack.com/methods/team.info
54
64
  # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/team/team.info.json
55
65
  def team_info(options = {})
@@ -14,7 +14,7 @@ module Slack
14
14
  # @option options [boolean] :exclude_archived
15
15
  # Set to true to exclude archived channels from the list.
16
16
  # @option options [number] :limit
17
- # The maximum number of items to return. Fewer than the requested number of items may be returned, even if the end of the list hasn't been reached. Must be an integer no larger than 1000.
17
+ # The maximum number of items to return. Fewer than the requested number of items may be returned, even if the end of the list hasn't been reached. Must be an integer with a max value of 999.
18
18
  # @option options [string] :team_id
19
19
  # encoded team id to list conversations in, required if org token is used.
20
20
  # @option options [string] :types
@@ -35,6 +35,7 @@ module Slack
35
35
  # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/users.profile/users.profile.set.json
36
36
  def users_profile_set(options = {})
37
37
  options = options.merge(user: users_id(options)['user']['id']) if options[:user]
38
+ options = encode_options_as_json(options, %i[profile])
38
39
  post('users.profile.set', options)
39
40
  end
40
41
  end
@@ -19,12 +19,8 @@ module Slack
19
19
  # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/views/views.open.json
20
20
  def views_open(options = {})
21
21
  raise ArgumentError, 'Required arguments :view missing' if options[:view].nil?
22
- raise ArgumentError, 'One of :trigger_id, :interactivity_pointer is required' unless options[:trigger_id].nil? ^ options[:interactivity_pointer].nil?
23
- if options.key?(:view)
24
- view = options[:view]
25
- view = JSON.dump(view) unless view.is_a?(String)
26
- options = options.merge(view: view)
27
- end
22
+ raise ArgumentError, 'Exactly one of :trigger_id, :interactivity_pointer is required' unless options[:trigger_id].nil? ^ options[:interactivity_pointer].nil?
23
+ options = encode_options_as_json(options, %i[view])
28
24
  post('views.open', options)
29
25
  end
30
26
 
@@ -42,11 +38,7 @@ module Slack
42
38
  def views_publish(options = {})
43
39
  raise ArgumentError, 'Required arguments :user_id missing' if options[:user_id].nil?
44
40
  raise ArgumentError, 'Required arguments :view missing' if options[:view].nil?
45
- if options.key?(:view)
46
- view = options[:view]
47
- view = JSON.dump(view) unless view.is_a?(String)
48
- options = options.merge(view: view)
49
- end
41
+ options = encode_options_as_json(options, %i[view])
50
42
  post('views.publish', options)
51
43
  end
52
44
 
@@ -63,12 +55,8 @@ module Slack
63
55
  # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/views/views.push.json
64
56
  def views_push(options = {})
65
57
  raise ArgumentError, 'Required arguments :view missing' if options[:view].nil?
66
- raise ArgumentError, 'One of :trigger_id, :interactivity_pointer is required' unless options[:trigger_id].nil? ^ options[:interactivity_pointer].nil?
67
- if options.key?(:view)
68
- view = options[:view]
69
- view = JSON.dump(view) unless view.is_a?(String)
70
- options = options.merge(view: view)
71
- end
58
+ raise ArgumentError, 'Exactly one of :trigger_id, :interactivity_pointer is required' unless options[:trigger_id].nil? ^ options[:interactivity_pointer].nil?
59
+ options = encode_options_as_json(options, %i[view])
72
60
  post('views.push', options)
73
61
  end
74
62
 
@@ -87,12 +75,8 @@ module Slack
87
75
  # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/views/views.update.json
88
76
  def views_update(options = {})
89
77
  raise ArgumentError, 'Required arguments :view missing' if options[:view].nil?
90
- raise ArgumentError, 'One of :external_id, :view_id is required' unless options[:external_id].nil? ^ options[:view_id].nil?
91
- if options.key?(:view)
92
- view = options[:view]
93
- view = JSON.dump(view) unless view.is_a?(String)
94
- options = options.merge(view: view)
95
- end
78
+ raise ArgumentError, 'Exactly one of :external_id, :view_id is required' unless options[:external_id].nil? ^ options[:view_id].nil?
79
+ options = encode_options_as_json(options, %i[view])
96
80
  post('views.update', options)
97
81
  end
98
82
  end
@@ -32,6 +32,7 @@ module Slack
32
32
  def workflows_stepFailed(options = {})
33
33
  raise ArgumentError, 'Required arguments :error missing' if options[:error].nil?
34
34
  raise ArgumentError, 'Required arguments :workflow_step_execute_id missing' if options[:workflow_step_execute_id].nil?
35
+ options = encode_options_as_json(options, %i[error])
35
36
  post('workflows.stepFailed', options)
36
37
  end
37
38
 
@@ -52,6 +53,7 @@ module Slack
52
53
  # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/workflows/workflows.updateStep.json
53
54
  def workflows_updateStep(options = {})
54
55
  raise ArgumentError, 'Required arguments :workflow_step_edit_id missing' if options[:workflow_step_edit_id].nil?
56
+ options = encode_options_as_json(options, %i[inputs outputs])
55
57
  post('workflows.updateStep', options)
56
58
  end
57
59
  end
@@ -3,7 +3,9 @@
3
3
 
4
4
  require_relative 'endpoints/admin_analytics'
5
5
  require_relative 'endpoints/admin_apps'
6
+ require_relative 'endpoints/admin_apps_activities'
6
7
  require_relative 'endpoints/admin_apps_approved'
8
+ require_relative 'endpoints/admin_apps_config'
7
9
  require_relative 'endpoints/admin_apps_requests'
8
10
  require_relative 'endpoints/admin_apps_restricted'
9
11
  require_relative 'endpoints/admin_audit_anomaly_allow'
@@ -13,6 +15,8 @@ require_relative 'endpoints/admin_conversations'
13
15
  require_relative 'endpoints/admin_conversations_ekm'
14
16
  require_relative 'endpoints/admin_conversations_restrictAccess'
15
17
  require_relative 'endpoints/admin_emoji'
18
+ require_relative 'endpoints/admin_functions'
19
+ require_relative 'endpoints/admin_functions_permissions'
16
20
  require_relative 'endpoints/admin_inviteRequests'
17
21
  require_relative 'endpoints/admin_inviteRequests_approved'
18
22
  require_relative 'endpoints/admin_inviteRequests_denied'
@@ -25,9 +29,15 @@ require_relative 'endpoints/admin_usergroups'
25
29
  require_relative 'endpoints/admin_users'
26
30
  require_relative 'endpoints/admin_users_session'
27
31
  require_relative 'endpoints/admin_users_unsupportedVersions'
32
+ require_relative 'endpoints/admin_workflows'
33
+ require_relative 'endpoints/admin_workflows_collaborators'
34
+ require_relative 'endpoints/admin_workflows_permissions'
28
35
  require_relative 'endpoints/api'
29
36
  require_relative 'endpoints/apps'
37
+ require_relative 'endpoints/apps_activities'
38
+ require_relative 'endpoints/apps_auth_external'
30
39
  require_relative 'endpoints/apps_connections'
40
+ require_relative 'endpoints/apps_datastore'
31
41
  require_relative 'endpoints/apps_event_authorizations'
32
42
  require_relative 'endpoints/apps_manifest'
33
43
  require_relative 'endpoints/auth'
@@ -80,7 +90,9 @@ module Slack
80
90
 
81
91
  include AdminAnalytics
82
92
  include AdminApps
93
+ include AdminAppsActivities
83
94
  include AdminAppsApproved
95
+ include AdminAppsConfig
84
96
  include AdminAppsRequests
85
97
  include AdminAppsRestricted
86
98
  include AdminAuditAnomalyAllow
@@ -90,6 +102,8 @@ module Slack
90
102
  include AdminConversationsEkm
91
103
  include AdminConversationsRestrictaccess
92
104
  include AdminEmoji
105
+ include AdminFunctions
106
+ include AdminFunctionsPermissions
93
107
  include AdminInviterequests
94
108
  include AdminInviterequestsApproved
95
109
  include AdminInviterequestsDenied
@@ -102,9 +116,15 @@ module Slack
102
116
  include AdminUsers
103
117
  include AdminUsersSession
104
118
  include AdminUsersUnsupportedversions
119
+ include AdminWorkflows
120
+ include AdminWorkflowsCollaborators
121
+ include AdminWorkflowsPermissions
105
122
  include Api
106
123
  include Apps
124
+ include AppsActivities
125
+ include AppsAuthExternal
107
126
  include AppsConnections
127
+ include AppsDatastore
108
128
  include AppsEventAuthorizations
109
129
  include AppsManifest
110
130
  include Auth