slack-ruby-client 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/integration_test.yml +1 -1
- data/.github/workflows/lint.yml +1 -1
- data/.github/workflows/pr_lint.yml +1 -1
- data/.github/workflows/test.yml +1 -1
- data/.github/workflows/update_api.yml +8 -3
- data/CHANGELOG.md +7 -0
- data/README.md +2 -2
- data/bin/commands/admin_apps_activities.rb +4 -4
- data/bin/commands/admin_apps_config.rb +2 -2
- data/bin/commands/admin_conversations.rb +2 -1
- data/bin/commands/admin_users.rb +2 -0
- data/bin/commands/chat.rb +9 -9
- data/bin/commands/conversations.rb +2 -1
- data/bin/commands/functions.rb +31 -0
- data/bin/commands/pins.rb +0 -1
- data/bin/commands/team.rb +2 -2
- data/bin/commands/usergroups.rb +10 -10
- data/bin/commands/usergroups_users.rb +8 -8
- data/lib/slack/events/request.rb +4 -2
- data/lib/slack/version.rb +1 -1
- data/lib/slack/web/api/endpoints/admin_apps_activities.rb +5 -5
- data/lib/slack/web/api/endpoints/admin_apps_config.rb +3 -3
- data/lib/slack/web/api/endpoints/admin_conversations.rb +3 -1
- data/lib/slack/web/api/endpoints/admin_functions_permissions.rb +1 -1
- data/lib/slack/web/api/endpoints/admin_users.rb +4 -0
- data/lib/slack/web/api/endpoints/admin_workflows.rb +3 -3
- data/lib/slack/web/api/endpoints/apps_activities.rb +1 -1
- data/lib/slack/web/api/endpoints/chat.rb +21 -21
- data/lib/slack/web/api/endpoints/conversations.rb +3 -1
- data/lib/slack/web/api/endpoints/functions.rb +43 -0
- data/lib/slack/web/api/endpoints/openid_connect.rb +1 -1
- data/lib/slack/web/api/endpoints/pins.rb +0 -2
- data/lib/slack/web/api/endpoints/search.rb +3 -3
- data/lib/slack/web/api/endpoints/team.rb +3 -3
- data/lib/slack/web/api/endpoints/team_profile.rb +1 -1
- data/lib/slack/web/api/endpoints/usergroups.rb +5 -5
- data/lib/slack/web/api/endpoints/usergroups_users.rb +6 -6
- data/lib/slack/web/api/endpoints/users.rb +1 -1
- data/lib/slack/web/api/endpoints.rb +2 -0
- data/lib/slack/web/api/errors.rb +14 -0
- data/lib/slack/web/api/patches/.gitkeep +0 -0
- data/spec/slack/events/request_spec.rb +11 -0
- data/spec/slack/web/api/endpoints/chat_spec.rb +76 -4
- data/spec/slack/web/api/endpoints/custom_specs/chat_spec.rb +2 -9
- data/spec/slack/web/api/endpoints/functions_spec.rb +28 -0
- metadata +7 -3
- data/lib/slack/web/api/patches/chat.attachments-blocks.patch +0 -21
@@ -96,16 +96,16 @@ module Slack
|
|
96
96
|
#
|
97
97
|
# @option options [channel] :channel
|
98
98
|
# Channel, private group, or IM channel to send message to. Can be an encoded ID, or a name.
|
99
|
-
# @option options [string] :text
|
100
|
-
# How this field works and whether it is required depends on other fields you use in your API call. See below for more detail.
|
101
99
|
# @option options [user] :user
|
102
100
|
# id of the user who will receive the ephemeral message. The user should be in the channel specified by the channel argument.
|
103
|
-
# @option options [boolean] :as_user
|
104
|
-
# (Legacy) Pass true to post the message as the authed user. Defaults to true if the chat:write:bot scope is not included. Otherwise, defaults to false.
|
105
101
|
# @option options [string] :attachments
|
106
102
|
# A JSON-based array of structured attachments, presented as a URL-encoded string.
|
107
103
|
# @option options [blocks[] as string] :blocks
|
108
104
|
# A JSON-based array of structured blocks, presented as a URL-encoded string.
|
105
|
+
# @option options [string] :text
|
106
|
+
# How this field works and whether it is required depends on other fields you use in your API call. See below for more detail.
|
107
|
+
# @option options [boolean] :as_user
|
108
|
+
# (Legacy) Pass true to post the message as the authed user. Defaults to true if the chat:write:bot scope is not included. Otherwise, defaults to false.
|
109
109
|
# @option options [string] :icon_emoji
|
110
110
|
# Emoji to use as the icon for this message. Overrides icon_url.
|
111
111
|
# @option options [string] :icon_url
|
@@ -122,8 +122,8 @@ module Slack
|
|
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, 'At least one of :attachments, :blocks, :text is required' if options[:attachments].nil? && options[:blocks].nil? && options[:text].nil?
|
126
125
|
raise ArgumentError, 'Required arguments :user missing' if options[:user].nil?
|
126
|
+
raise ArgumentError, 'At least one of :attachments, :blocks, :text is required' if options[:attachments].nil? && options[:blocks].nil? && options[:text].nil?
|
127
127
|
options = options.merge(user: users_id(options)['user']['id']) if options[:user]
|
128
128
|
options = encode_options_as_json(options, %i[attachments blocks])
|
129
129
|
post('chat.postEphemeral', options)
|
@@ -139,7 +139,7 @@ module Slack
|
|
139
139
|
# @option options [blocks[] as string] :blocks
|
140
140
|
# A JSON-based array of structured blocks, presented as a URL-encoded string.
|
141
141
|
# @option options [string] :text
|
142
|
-
#
|
142
|
+
# How this field works and whether it is required depends on other fields you use in your API call. See below for more detail.
|
143
143
|
# @option options [boolean] :as_user
|
144
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.
|
145
145
|
# @option options [string] :icon_emoji
|
@@ -179,20 +179,20 @@ module Slack
|
|
179
179
|
# @option options [channel] :channel
|
180
180
|
# Channel, private group, or DM channel to send message to. Can be an encoded ID, or a name. See below for more details.
|
181
181
|
# @option options [integer] :post_at
|
182
|
-
# Unix
|
183
|
-
# @option options [string] :text
|
184
|
-
# How this field works and whether it is required depends on other fields you use in your API call. See below for more detail.
|
185
|
-
# @option options [boolean] :as_user
|
186
|
-
# Set to true to post the message as the authed user, instead of as a bot. Defaults to false. Cannot be used by new Slack apps. See chat.postMessage.
|
182
|
+
# Unix timestamp representing the future time the message should post to Slack.
|
187
183
|
# @option options [string] :attachments
|
188
184
|
# A JSON-based array of structured attachments, presented as a URL-encoded string.
|
189
185
|
# @option options [blocks[] as string] :blocks
|
190
186
|
# A JSON-based array of structured blocks, presented as a URL-encoded string.
|
187
|
+
# @option options [string] :text
|
188
|
+
# How this field works and whether it is required depends on other fields you use in your API call. See below for more detail.
|
189
|
+
# @option options [boolean] :as_user
|
190
|
+
# Set to true to post the message as the authed user, instead of as a bot. Defaults to false. Cannot be used by new Slack apps. See chat.postMessage.
|
191
191
|
# @option options [boolean] :link_names
|
192
192
|
# Find and link user groups. No longer supports linking individual users; use syntax shown in Mentioning Users instead.
|
193
193
|
# @option options [string] :metadata
|
194
194
|
# JSON object with event_type and event_payload fields, presented as a URL-encoded string. Metadata you post to Slack is accessible to any app or user who is a member of that workspace.
|
195
|
-
# @option options [
|
195
|
+
# @option options [enum] :parse
|
196
196
|
# Change how messages are treated. See chat.postMessage.
|
197
197
|
# @option options [boolean] :reply_broadcast
|
198
198
|
# Used in conjunction with thread_ts and indicates whether reply should be made visible to everyone in the channel or conversation. Defaults to false.
|
@@ -207,7 +207,7 @@ module Slack
|
|
207
207
|
def chat_scheduleMessage(options = {})
|
208
208
|
raise ArgumentError, 'Required arguments :channel missing' if options[:channel].nil?
|
209
209
|
raise ArgumentError, 'Required arguments :post_at missing' if options[:post_at].nil?
|
210
|
-
raise ArgumentError, '
|
210
|
+
raise ArgumentError, 'At least one of :attachments, :blocks, :text is required' if options[:attachments].nil? && options[:blocks].nil? && options[:text].nil?
|
211
211
|
options = encode_options_as_json(options, %i[attachments blocks metadata])
|
212
212
|
post('chat.scheduleMessage', options)
|
213
213
|
end
|
@@ -221,7 +221,7 @@ module Slack
|
|
221
221
|
# Timestamp of the message to add unfurl behavior to.
|
222
222
|
# @option options [string] :unfurls
|
223
223
|
# URL-encoded JSON map with keys set to URLs featured in the the message, pointing to their unfurl blocks or message attachments.
|
224
|
-
# @option options [
|
224
|
+
# @option options [enum] :source
|
225
225
|
# The source of the link to unfurl. The source may either be composer, when the link is inside the message composer, or conversations_history, when the link has been posted to a conversation.
|
226
226
|
# @option options [string] :unfurl_id
|
227
227
|
# The ID of the link to unfurl. Both unfurl_id and source must be provided together, or channel and ts must be provided together.
|
@@ -251,12 +251,14 @@ module Slack
|
|
251
251
|
# Channel containing the message to be updated.
|
252
252
|
# @option options [timestamp] :ts
|
253
253
|
# Timestamp of the message to be updated.
|
254
|
-
# @option options [boolean] :as_user
|
255
|
-
# Pass true to update the message as the authed user. Bot users in this context are considered authed users.
|
256
254
|
# @option options [string] :attachments
|
257
|
-
# A JSON-based array of structured attachments, presented as a URL-encoded string.
|
255
|
+
# A JSON-based array of structured attachments, presented as a URL-encoded string.
|
258
256
|
# @option options [blocks[] as string] :blocks
|
259
|
-
# A JSON-based array of structured blocks, presented as a URL-encoded string.
|
257
|
+
# A JSON-based array of structured blocks, presented as a URL-encoded string.
|
258
|
+
# @option options [string] :text
|
259
|
+
# How this field works and whether it is required depends on other fields you use in your API call. See below for more detail.
|
260
|
+
# @option options [boolean] :as_user
|
261
|
+
# Pass true to update the message as the authed user. Bot users in this context are considered authed users.
|
260
262
|
# @option options [array] :file_ids
|
261
263
|
# Array of new file ids that will be sent with this message.
|
262
264
|
# @option options [boolean] :link_names
|
@@ -267,14 +269,12 @@ module Slack
|
|
267
269
|
# Change how messages are treated. Defaults to client, unlike chat.postMessage. Accepts either none or full. If you do not specify a value for this field, the original value set for the message will be overwritten with the default, client.
|
268
270
|
# @option options [boolean] :reply_broadcast
|
269
271
|
# Broadcast an existing thread reply to make it visible to everyone in the channel or conversation.
|
270
|
-
# @option options [string] :text
|
271
|
-
# New text for the message, using the default formatting rules. It's not required when presenting blocks or attachments.
|
272
272
|
# @see https://api.slack.com/methods/chat.update
|
273
273
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/chat/chat.update.json
|
274
274
|
def chat_update(options = {})
|
275
275
|
raise ArgumentError, 'Required arguments :channel missing' if options[:channel].nil?
|
276
276
|
raise ArgumentError, 'Required arguments :ts missing' if options[:ts].nil?
|
277
|
-
raise ArgumentError, 'At least one of :attachments, :blocks, :text
|
277
|
+
raise ArgumentError, 'At least one of :attachments, :blocks, :text is required' if options[:attachments].nil? && options[:blocks].nil? && options[:text].nil?
|
278
278
|
options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
|
279
279
|
options = encode_options_as_json(options, %i[attachments blocks metadata])
|
280
280
|
post('chat.update', options)
|
@@ -153,6 +153,8 @@ module Slack
|
|
153
153
|
# The ID of the public or private channel to invite user(s) to.
|
154
154
|
# @option options [string] :users
|
155
155
|
# A comma separated list of user IDs. Up to 1000 users may be listed.
|
156
|
+
# @option options [boolean] :force
|
157
|
+
# When set to true and multiple user IDs are provided, continue inviting the valid ones while disregarding invalid IDs. Defaults to false.
|
156
158
|
# @see https://api.slack.com/methods/conversations.invite
|
157
159
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/conversations/conversations.invite.json
|
158
160
|
def conversations_invite(options = {})
|
@@ -232,7 +234,7 @@ module Slack
|
|
232
234
|
# @option options [boolean] :exclude_archived
|
233
235
|
# Set to true to exclude archived channels from the list.
|
234
236
|
# @option options [number] :limit
|
235
|
-
# 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
|
237
|
+
# 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 under 1000.
|
236
238
|
# @option options [string] :team_id
|
237
239
|
# encoded team id to list channels in, required if token belongs to org-wide app.
|
238
240
|
# @option options [string] :types
|
@@ -0,0 +1,43 @@
|
|
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 Functions
|
9
|
+
#
|
10
|
+
# Signal that a function failed to complete
|
11
|
+
#
|
12
|
+
# @option options [string] :error
|
13
|
+
# A human-readable error message that contains information about why the function failed to complete.
|
14
|
+
# @option options [string] :function_execution_id
|
15
|
+
# Context identifier that maps to the executed function.
|
16
|
+
# @see https://api.slack.com/methods/functions.completeError
|
17
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/functions/functions.completeError.json
|
18
|
+
def functions_completeError(options = {})
|
19
|
+
raise ArgumentError, 'Required arguments :error missing' if options[:error].nil?
|
20
|
+
raise ArgumentError, 'Required arguments :function_execution_id missing' if options[:function_execution_id].nil?
|
21
|
+
post('functions.completeError', options)
|
22
|
+
end
|
23
|
+
|
24
|
+
#
|
25
|
+
# Signal the successful completion of a function
|
26
|
+
#
|
27
|
+
# @option options [string] :function_execution_id
|
28
|
+
# Context identifier that maps to the executed function.
|
29
|
+
# @option options [object] :outputs
|
30
|
+
# A JSON-based object that conforms to the output parameters schema for the custom function defined in the manifest.
|
31
|
+
# @see https://api.slack.com/methods/functions.completeSuccess
|
32
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/functions/functions.completeSuccess.json
|
33
|
+
def functions_completeSuccess(options = {})
|
34
|
+
raise ArgumentError, 'Required arguments :function_execution_id missing' if options[:function_execution_id].nil?
|
35
|
+
raise ArgumentError, 'Required arguments :outputs missing' if options[:outputs].nil?
|
36
|
+
options = encode_options_as_json(options, %i[outputs])
|
37
|
+
post('functions.completeSuccess', options)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -15,7 +15,7 @@ module Slack
|
|
15
15
|
# Issued when you created your application.
|
16
16
|
# @option options [string] :code
|
17
17
|
# The code param returned via the OAuth callback.
|
18
|
-
# @option options [
|
18
|
+
# @option options [enum] :grant_type
|
19
19
|
# The grant_type param as described in the OAuth spec.
|
20
20
|
# @option options [string] :redirect_uri
|
21
21
|
# This must match the originally submitted URI (if one was sent).
|
@@ -11,8 +11,6 @@ module Slack
|
|
11
11
|
#
|
12
12
|
# @option options [channel] :channel
|
13
13
|
# Channel to pin the messsage to. You must also include a timestamp when pinning messages.
|
14
|
-
# @option options [string] :quip_component_id
|
15
|
-
# Component ID for the pins component that was inserted into the channel canvas, if any.
|
16
14
|
# @option options [string] :timestamp
|
17
15
|
# Timestamp of the message to pin. You must also include the channel.
|
18
16
|
# @see https://api.slack.com/methods/pins.add
|
@@ -15,7 +15,7 @@ module Slack
|
|
15
15
|
# Pass a value of true to enable query highlight markers (see below).
|
16
16
|
# @option options [string] :sort
|
17
17
|
# Return matches sorted by either score or timestamp.
|
18
|
-
# @option options [
|
18
|
+
# @option options [enum] :sort_dir
|
19
19
|
# Change sort direction to ascending (asc) or descending (desc).
|
20
20
|
# @option options [string] :team_id
|
21
21
|
# encoded team id to search in, required if org token is used.
|
@@ -35,7 +35,7 @@ module Slack
|
|
35
35
|
# Pass a value of true to enable query highlight markers (see below).
|
36
36
|
# @option options [string] :sort
|
37
37
|
# Return matches sorted by either score or timestamp.
|
38
|
-
# @option options [
|
38
|
+
# @option options [enum] :sort_dir
|
39
39
|
# Change sort direction to ascending (asc) or descending (desc).
|
40
40
|
# @option options [string] :team_id
|
41
41
|
# encoded team id to search in, required if org token is used.
|
@@ -57,7 +57,7 @@ module Slack
|
|
57
57
|
# Pass a value of true to enable query highlight markers (see below).
|
58
58
|
# @option options [string] :sort
|
59
59
|
# Return matches sorted by either score or timestamp.
|
60
|
-
# @option options [
|
60
|
+
# @option options [enum] :sort_dir
|
61
61
|
# Change sort direction to ascending (asc) or descending (desc).
|
62
62
|
# @option options [string] :team_id
|
63
63
|
# encoded team id to search in, required if org token is used.
|
@@ -57,7 +57,7 @@ module Slack
|
|
57
57
|
# Gets information about the current team.
|
58
58
|
#
|
59
59
|
# @option options [string] :domain
|
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.
|
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. This is the value set up for the 'Joining This Workspace' workspace setting. If it contains more than one domain, the field will contain multiple comma-separated domain values. If no domain is set, the field is empty.
|
61
61
|
# @option options [string] :team
|
62
62
|
# Team to get info about; if omitted, will return information about the current team.
|
63
63
|
# @see https://api.slack.com/methods/team.info
|
@@ -71,8 +71,8 @@ module Slack
|
|
71
71
|
#
|
72
72
|
# @option options [string] :app_id
|
73
73
|
# Filter logs to this Slack app. Defaults to all logs.
|
74
|
-
# @option options [
|
75
|
-
# Filter logs with this change type. Defaults to all logs.
|
74
|
+
# @option options [enum] :change_type
|
75
|
+
# Filter logs with this change type. Possible values are added, removed, enabled, disabled, and updated. Defaults to all logs.
|
76
76
|
# @option options [string] :service_id
|
77
77
|
# Filter logs to this service. Defaults to all logs.
|
78
78
|
# @option options [string] :team_id
|
@@ -9,7 +9,7 @@ module Slack
|
|
9
9
|
#
|
10
10
|
# Retrieve a team's profile.
|
11
11
|
#
|
12
|
-
# @option options [
|
12
|
+
# @option options [enum] :visibility
|
13
13
|
# Filter by visibility.
|
14
14
|
# @see https://api.slack.com/methods/team.profile.get
|
15
15
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/team.profile/team.profile.get.json
|
@@ -7,7 +7,7 @@ module Slack
|
|
7
7
|
module Endpoints
|
8
8
|
module Usergroups
|
9
9
|
#
|
10
|
-
# Create a User Group
|
10
|
+
# Create a User Group.
|
11
11
|
#
|
12
12
|
# @option options [string] :name
|
13
13
|
# A name for the User Group. Must be unique among User Groups.
|
@@ -29,7 +29,7 @@ module Slack
|
|
29
29
|
end
|
30
30
|
|
31
31
|
#
|
32
|
-
# Disable an existing User Group
|
32
|
+
# Disable an existing User Group.
|
33
33
|
#
|
34
34
|
# @option options [Object] :usergroup
|
35
35
|
# The encoded ID of the User Group to disable.
|
@@ -45,7 +45,7 @@ module Slack
|
|
45
45
|
end
|
46
46
|
|
47
47
|
#
|
48
|
-
# Enable a User Group
|
48
|
+
# Enable a User Group.
|
49
49
|
#
|
50
50
|
# @option options [string] :usergroup
|
51
51
|
# The encoded ID of the User Group to enable.
|
@@ -61,7 +61,7 @@ module Slack
|
|
61
61
|
end
|
62
62
|
|
63
63
|
#
|
64
|
-
# List all User Groups for a team
|
64
|
+
# List all User Groups for a team.
|
65
65
|
#
|
66
66
|
# @option options [boolean] :include_count
|
67
67
|
# Include the number of users in each User Group.
|
@@ -78,7 +78,7 @@ module Slack
|
|
78
78
|
end
|
79
79
|
|
80
80
|
#
|
81
|
-
# Update an existing User Group
|
81
|
+
# Update an existing User Group.
|
82
82
|
#
|
83
83
|
# @option options [Object] :usergroup
|
84
84
|
# The encoded ID of the User Group to update.
|
@@ -7,10 +7,10 @@ module Slack
|
|
7
7
|
module Endpoints
|
8
8
|
module UsergroupsUsers
|
9
9
|
#
|
10
|
-
# List all users in a User Group
|
10
|
+
# List all users in a User Group.
|
11
11
|
#
|
12
12
|
# @option options [string] :usergroup
|
13
|
-
# The encoded ID of the User Group to
|
13
|
+
# The encoded ID of the User Group to list users for.
|
14
14
|
# @option options [boolean] :include_disabled
|
15
15
|
# Allow results that involve disabled User Groups.
|
16
16
|
# @option options [string] :team_id
|
@@ -23,14 +23,14 @@ module Slack
|
|
23
23
|
end
|
24
24
|
|
25
25
|
#
|
26
|
-
# Update the list of users for a
|
26
|
+
# Update the list of users for a user group.
|
27
27
|
#
|
28
28
|
# @option options [string] :usergroup
|
29
|
-
# The encoded ID of the
|
29
|
+
# The encoded ID of the user group to update.
|
30
30
|
# @option options [array] :users
|
31
|
-
# A comma separated string of encoded user IDs that represent the entire list of users for the
|
31
|
+
# A comma separated string of encoded user IDs that represent the entire list of users for the user group.
|
32
32
|
# @option options [boolean] :include_count
|
33
|
-
# Include the number of users in the
|
33
|
+
# Include the number of users in the user group.
|
34
34
|
# @option options [string] :team_id
|
35
35
|
# encoded team id where the user group exists, required if org token is used.
|
36
36
|
# @see https://api.slack.com/methods/usergroups.users.update
|
@@ -143,7 +143,7 @@ module Slack
|
|
143
143
|
#
|
144
144
|
# Manually sets user presence.
|
145
145
|
#
|
146
|
-
# @option options [
|
146
|
+
# @option options [enum] :presence
|
147
147
|
# Either auto or away.
|
148
148
|
# @see https://api.slack.com/methods/users.setPresence
|
149
149
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/users/users.setPresence.json
|
@@ -55,6 +55,7 @@ require_relative 'endpoints/emoji'
|
|
55
55
|
require_relative 'endpoints/files'
|
56
56
|
require_relative 'endpoints/files_comments'
|
57
57
|
require_relative 'endpoints/files_remote'
|
58
|
+
require_relative 'endpoints/functions'
|
58
59
|
require_relative 'endpoints/functions_workflows_steps'
|
59
60
|
require_relative 'endpoints/functions_workflows_steps_responses'
|
60
61
|
require_relative 'endpoints/migration'
|
@@ -142,6 +143,7 @@ module Slack
|
|
142
143
|
include Files
|
143
144
|
include FilesComments
|
144
145
|
include FilesRemote
|
146
|
+
include Functions
|
145
147
|
include FunctionsWorkflowsSteps
|
146
148
|
include FunctionsWorkflowsStepsResponses
|
147
149
|
include Migration
|
data/lib/slack/web/api/errors.rb
CHANGED
@@ -32,6 +32,7 @@ module Slack
|
|
32
32
|
class ApprovalNotFound < SlackError; end
|
33
33
|
class AsUserNotSupported < SlackError; end
|
34
34
|
class AtLeastOneSessionSettingRequired < SlackError; end
|
35
|
+
class AttachmentPayloadLimitExceeded < SlackError; end
|
35
36
|
class AuthMismatch < SlackError; end
|
36
37
|
class AuthorizationNotFound < SlackError; end
|
37
38
|
class AutoProvisionFailure < SlackError; end
|
@@ -174,6 +175,7 @@ module Slack
|
|
174
175
|
class ErrorTooBig < SlackError; end
|
175
176
|
class ErrorUnpublishingWorkflows < SlackError; end
|
176
177
|
class ExchangedTriggerId < SlackError; end
|
178
|
+
class ExecutionNotInRunningState < SlackError; end
|
177
179
|
class ExpiredTriggerId < SlackError; end
|
178
180
|
class ExternalChannelMigrating < SlackError; end
|
179
181
|
class ExternalLimitedRestriction < SlackError; end
|
@@ -231,6 +233,7 @@ module Slack
|
|
231
233
|
class ForbiddenHandle < SlackError; end
|
232
234
|
class ForbiddenTeam < SlackError; end
|
233
235
|
class FreeTeamNotAllowed < SlackError; end
|
236
|
+
class FunctionExecutionNotFound < SlackError; end
|
234
237
|
class FunctionNotFound < SlackError; end
|
235
238
|
class GroupAlreadyLinkedToChannel < SlackError; end
|
236
239
|
class GroupMustNotBeEmpty < SlackError; end
|
@@ -240,6 +243,7 @@ module Slack
|
|
240
243
|
class HashConflict < SlackError; end
|
241
244
|
class InactiveCall < SlackError; end
|
242
245
|
class InactiveInvite < SlackError; end
|
246
|
+
class IncludeDeactivatedUserWorkspacesInvalid < SlackError; end
|
243
247
|
class InsecureRequest < SlackError; end
|
244
248
|
class InternalError < SlackError; end
|
245
249
|
class InvalidAction < SlackError; end
|
@@ -384,11 +388,13 @@ module Slack
|
|
384
388
|
class MissingChannel < SlackError; end
|
385
389
|
class MissingDialog < SlackError; end
|
386
390
|
class MissingDuration < SlackError; end
|
391
|
+
class MissingFileData < SlackError; end
|
387
392
|
class MissingPostType < SlackError; end
|
388
393
|
class MissingProfileId < SlackError; end
|
389
394
|
class MissingResource < SlackError; end
|
390
395
|
class MissingScope < SlackError; end
|
391
396
|
class MissingSource < SlackError; end
|
397
|
+
class MissingStepIds < SlackError; end
|
392
398
|
class MissingSubteamName < SlackError; end
|
393
399
|
class MissingTargetTeam < SlackError; end
|
394
400
|
class MissingTeam < SlackError; end
|
@@ -472,6 +478,7 @@ module Slack
|
|
472
478
|
class PaginationNotAvailable < SlackError; end
|
473
479
|
class PaidOnly < SlackError; end
|
474
480
|
class PaidTeamsOnly < SlackError; end
|
481
|
+
class ParameterValidationFailed < SlackError; end
|
475
482
|
class ParentBookmarkDisabled < SlackError; end
|
476
483
|
class ParentWithLink < SlackError; end
|
477
484
|
class PartialProfileSetFailed < SlackError; end
|
@@ -647,6 +654,7 @@ module Slack
|
|
647
654
|
'approval_not_found' => ApprovalNotFound,
|
648
655
|
'as_user_not_supported' => AsUserNotSupported,
|
649
656
|
'at_least_one_session_setting_required' => AtLeastOneSessionSettingRequired,
|
657
|
+
'attachment_payload_limit_exceeded' => AttachmentPayloadLimitExceeded,
|
650
658
|
'auth_mismatch' => AuthMismatch,
|
651
659
|
'authorization_not_found' => AuthorizationNotFound,
|
652
660
|
'auto_provision_failure' => AutoProvisionFailure,
|
@@ -789,6 +797,7 @@ module Slack
|
|
789
797
|
'error_too_big' => ErrorTooBig,
|
790
798
|
'error_unpublishing_workflows' => ErrorUnpublishingWorkflows,
|
791
799
|
'exchanged_trigger_id' => ExchangedTriggerId,
|
800
|
+
'execution_not_in_running_state' => ExecutionNotInRunningState,
|
792
801
|
'expired_trigger_id' => ExpiredTriggerId,
|
793
802
|
'external_channel_migrating' => ExternalChannelMigrating,
|
794
803
|
'external_limited_restriction' => ExternalLimitedRestriction,
|
@@ -846,6 +855,7 @@ module Slack
|
|
846
855
|
'forbidden_handle' => ForbiddenHandle,
|
847
856
|
'forbidden_team' => ForbiddenTeam,
|
848
857
|
'free_team_not_allowed' => FreeTeamNotAllowed,
|
858
|
+
'function_execution_not_found' => FunctionExecutionNotFound,
|
849
859
|
'function_not_found' => FunctionNotFound,
|
850
860
|
'group_already_linked_to_channel' => GroupAlreadyLinkedToChannel,
|
851
861
|
'group_must_not_be_empty' => GroupMustNotBeEmpty,
|
@@ -855,6 +865,7 @@ module Slack
|
|
855
865
|
'hash_conflict' => HashConflict,
|
856
866
|
'inactive_call' => InactiveCall,
|
857
867
|
'inactive_invite' => InactiveInvite,
|
868
|
+
'include_deactivated_user_workspaces_invalid' => IncludeDeactivatedUserWorkspacesInvalid,
|
858
869
|
'insecure_request' => InsecureRequest,
|
859
870
|
'internal_error' => InternalError,
|
860
871
|
'invalid_action' => InvalidAction,
|
@@ -999,11 +1010,13 @@ module Slack
|
|
999
1010
|
'missing_channel' => MissingChannel,
|
1000
1011
|
'missing_dialog' => MissingDialog,
|
1001
1012
|
'missing_duration' => MissingDuration,
|
1013
|
+
'missing_file_data' => MissingFileData,
|
1002
1014
|
'missing_post_type' => MissingPostType,
|
1003
1015
|
'missing_profile_id' => MissingProfileId,
|
1004
1016
|
'missing_resource' => MissingResource,
|
1005
1017
|
'missing_scope' => MissingScope,
|
1006
1018
|
'missing_source' => MissingSource,
|
1019
|
+
'missing_step_ids' => MissingStepIds,
|
1007
1020
|
'missing_subteam_name' => MissingSubteamName,
|
1008
1021
|
'missing_target_team' => MissingTargetTeam,
|
1009
1022
|
'missing_team' => MissingTeam,
|
@@ -1087,6 +1100,7 @@ module Slack
|
|
1087
1100
|
'pagination_not_available' => PaginationNotAvailable,
|
1088
1101
|
'paid_only' => PaidOnly,
|
1089
1102
|
'paid_teams_only' => PaidTeamsOnly,
|
1103
|
+
'parameter_validation_failed' => ParameterValidationFailed,
|
1090
1104
|
'parent_bookmark_disabled' => ParentBookmarkDisabled,
|
1091
1105
|
'parent_with_link' => ParentWithLink,
|
1092
1106
|
'partial_profile_set_failed' => PartialProfileSetFailed,
|
File without changes
|
@@ -47,6 +47,17 @@ RSpec.describe Slack::Events::Request do
|
|
47
47
|
expect(http_request.body.read).to eq body
|
48
48
|
end
|
49
49
|
|
50
|
+
context 'with an already read body' do
|
51
|
+
before do
|
52
|
+
http_request.body.read
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'rewinds the request body before reading it' do
|
56
|
+
expect(request.body).to eq body
|
57
|
+
expect(http_request.body.read).to eq body
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
50
61
|
context 'time' do
|
51
62
|
after do
|
52
63
|
Timecop.return
|
@@ -6,9 +6,33 @@ require 'spec_helper'
|
|
6
6
|
RSpec.describe Slack::Web::Api::Endpoints::Chat do
|
7
7
|
let(:client) { Slack::Web::Client.new }
|
8
8
|
context 'chat_postEphemeral' do
|
9
|
+
it 'requires one of attachments, blocks, text' do
|
10
|
+
expect { client.chat_postEphemeral(channel: %q[C1234567890], user: %q[U0BPQUNTA]) }.to raise_error ArgumentError, /At least one of/
|
11
|
+
|
12
|
+
expect(client).to receive(:post).with('chat.postEphemeral', {attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[C1234567890], user: %q[U0BPQUNTA]})
|
13
|
+
client.chat_postEphemeral(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[C1234567890], user: %q[U0BPQUNTA])
|
14
|
+
|
15
|
+
expect(client).to receive(:post).with('chat.postEphemeral', {blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], channel: %q[C1234567890], user: %q[U0BPQUNTA]})
|
16
|
+
client.chat_postEphemeral(blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], channel: %q[C1234567890], user: %q[U0BPQUNTA])
|
17
|
+
|
18
|
+
expect(client).to receive(:post).with('chat.postEphemeral', {text: %q[Hello world], channel: %q[C1234567890], user: %q[U0BPQUNTA]})
|
19
|
+
client.chat_postEphemeral(text: %q[Hello world], channel: %q[C1234567890], user: %q[U0BPQUNTA])
|
20
|
+
|
21
|
+
expect(client).to receive(:post).with('chat.postEphemeral', {attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], channel: %q[C1234567890], user: %q[U0BPQUNTA]})
|
22
|
+
client.chat_postEphemeral(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], channel: %q[C1234567890], user: %q[U0BPQUNTA])
|
23
|
+
|
24
|
+
expect(client).to receive(:post).with('chat.postEphemeral', {attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], text: %q[Hello world], channel: %q[C1234567890], user: %q[U0BPQUNTA]})
|
25
|
+
client.chat_postEphemeral(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], text: %q[Hello world], channel: %q[C1234567890], user: %q[U0BPQUNTA])
|
26
|
+
|
27
|
+
expect(client).to receive(:post).with('chat.postEphemeral', {blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], text: %q[Hello world], channel: %q[C1234567890], user: %q[U0BPQUNTA]})
|
28
|
+
client.chat_postEphemeral(blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], text: %q[Hello world], channel: %q[C1234567890], user: %q[U0BPQUNTA])
|
29
|
+
|
30
|
+
expect(client).to receive(:post).with('chat.postEphemeral', {attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], text: %q[Hello world], channel: %q[C1234567890], user: %q[U0BPQUNTA]})
|
31
|
+
client.chat_postEphemeral(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], text: %q[Hello world], channel: %q[C1234567890], user: %q[U0BPQUNTA])
|
32
|
+
end
|
9
33
|
it 'encodes attachments, blocks as json' do
|
10
|
-
expect(client).to receive(:post).with('chat.postEphemeral', {channel: %q[C1234567890],
|
11
|
-
client.chat_postEphemeral(channel: %q[C1234567890],
|
34
|
+
expect(client).to receive(:post).with('chat.postEphemeral', {channel: %q[C1234567890], user: %q[U0BPQUNTA], attachments: %q[{"data":["data"]}], blocks: %q[{"data":["data"]}]})
|
35
|
+
client.chat_postEphemeral(channel: %q[C1234567890], user: %q[U0BPQUNTA], attachments: {:data=>["data"]}, blocks: {:data=>["data"]})
|
12
36
|
end
|
13
37
|
end
|
14
38
|
context 'chat_postMessage' do
|
@@ -42,9 +66,33 @@ RSpec.describe Slack::Web::Api::Endpoints::Chat do
|
|
42
66
|
end
|
43
67
|
end
|
44
68
|
context 'chat_scheduleMessage' do
|
69
|
+
it 'requires one of attachments, blocks, text' do
|
70
|
+
expect { client.chat_scheduleMessage(channel: %q[C1234567890], post_at: %q[299876400]) }.to raise_error ArgumentError, /At least one of/
|
71
|
+
|
72
|
+
expect(client).to receive(:post).with('chat.scheduleMessage', {attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[C1234567890], post_at: %q[299876400]})
|
73
|
+
client.chat_scheduleMessage(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[C1234567890], post_at: %q[299876400])
|
74
|
+
|
75
|
+
expect(client).to receive(:post).with('chat.scheduleMessage', {blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], channel: %q[C1234567890], post_at: %q[299876400]})
|
76
|
+
client.chat_scheduleMessage(blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], channel: %q[C1234567890], post_at: %q[299876400])
|
77
|
+
|
78
|
+
expect(client).to receive(:post).with('chat.scheduleMessage', {text: %q[Hello world], channel: %q[C1234567890], post_at: %q[299876400]})
|
79
|
+
client.chat_scheduleMessage(text: %q[Hello world], channel: %q[C1234567890], post_at: %q[299876400])
|
80
|
+
|
81
|
+
expect(client).to receive(:post).with('chat.scheduleMessage', {attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], channel: %q[C1234567890], post_at: %q[299876400]})
|
82
|
+
client.chat_scheduleMessage(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], channel: %q[C1234567890], post_at: %q[299876400])
|
83
|
+
|
84
|
+
expect(client).to receive(:post).with('chat.scheduleMessage', {attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], text: %q[Hello world], channel: %q[C1234567890], post_at: %q[299876400]})
|
85
|
+
client.chat_scheduleMessage(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], text: %q[Hello world], channel: %q[C1234567890], post_at: %q[299876400])
|
86
|
+
|
87
|
+
expect(client).to receive(:post).with('chat.scheduleMessage', {blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], text: %q[Hello world], channel: %q[C1234567890], post_at: %q[299876400]})
|
88
|
+
client.chat_scheduleMessage(blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], text: %q[Hello world], channel: %q[C1234567890], post_at: %q[299876400])
|
89
|
+
|
90
|
+
expect(client).to receive(:post).with('chat.scheduleMessage', {attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], text: %q[Hello world], channel: %q[C1234567890], post_at: %q[299876400]})
|
91
|
+
client.chat_scheduleMessage(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], text: %q[Hello world], channel: %q[C1234567890], post_at: %q[299876400])
|
92
|
+
end
|
45
93
|
it 'encodes attachments, blocks, metadata as json' do
|
46
|
-
expect(client).to receive(:post).with('chat.scheduleMessage', {channel: %q[C1234567890], post_at: %q[299876400],
|
47
|
-
client.chat_scheduleMessage(channel: %q[C1234567890], post_at: %q[299876400],
|
94
|
+
expect(client).to receive(:post).with('chat.scheduleMessage', {channel: %q[C1234567890], post_at: %q[299876400], attachments: %q[{"data":["data"]}], blocks: %q[{"data":["data"]}], metadata: %q[{"data":["data"]}]})
|
95
|
+
client.chat_scheduleMessage(channel: %q[C1234567890], post_at: %q[299876400], attachments: {:data=>["data"]}, blocks: {:data=>["data"]}, metadata: {:data=>["data"]})
|
48
96
|
end
|
49
97
|
end
|
50
98
|
context 'chat_unfurl' do
|
@@ -54,6 +102,30 @@ RSpec.describe Slack::Web::Api::Endpoints::Chat do
|
|
54
102
|
end
|
55
103
|
end
|
56
104
|
context 'chat_update' do
|
105
|
+
it 'requires one of attachments, blocks, text' do
|
106
|
+
expect { client.chat_update(channel: %q[C1234567890], ts: %q["1405894322.002768"]) }.to raise_error ArgumentError, /At least one of/
|
107
|
+
|
108
|
+
expect(client).to receive(:post).with('chat.update', {attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[C1234567890], ts: %q["1405894322.002768"]})
|
109
|
+
client.chat_update(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[C1234567890], ts: %q["1405894322.002768"])
|
110
|
+
|
111
|
+
expect(client).to receive(:post).with('chat.update', {blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], channel: %q[C1234567890], ts: %q["1405894322.002768"]})
|
112
|
+
client.chat_update(blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], channel: %q[C1234567890], ts: %q["1405894322.002768"])
|
113
|
+
|
114
|
+
expect(client).to receive(:post).with('chat.update', {text: %q[Hello world], channel: %q[C1234567890], ts: %q["1405894322.002768"]})
|
115
|
+
client.chat_update(text: %q[Hello world], channel: %q[C1234567890], ts: %q["1405894322.002768"])
|
116
|
+
|
117
|
+
expect(client).to receive(:post).with('chat.update', {attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], channel: %q[C1234567890], ts: %q["1405894322.002768"]})
|
118
|
+
client.chat_update(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], channel: %q[C1234567890], ts: %q["1405894322.002768"])
|
119
|
+
|
120
|
+
expect(client).to receive(:post).with('chat.update', {attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], text: %q[Hello world], channel: %q[C1234567890], ts: %q["1405894322.002768"]})
|
121
|
+
client.chat_update(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], text: %q[Hello world], channel: %q[C1234567890], ts: %q["1405894322.002768"])
|
122
|
+
|
123
|
+
expect(client).to receive(:post).with('chat.update', {blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], text: %q[Hello world], channel: %q[C1234567890], ts: %q["1405894322.002768"]})
|
124
|
+
client.chat_update(blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], text: %q[Hello world], channel: %q[C1234567890], ts: %q["1405894322.002768"])
|
125
|
+
|
126
|
+
expect(client).to receive(:post).with('chat.update', {attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], text: %q[Hello world], channel: %q[C1234567890], ts: %q["1405894322.002768"]})
|
127
|
+
client.chat_update(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], text: %q[Hello world], channel: %q[C1234567890], ts: %q["1405894322.002768"])
|
128
|
+
end
|
57
129
|
it 'encodes attachments, blocks, metadata as json' do
|
58
130
|
expect(client).to receive(:post).with('chat.update', {channel: %q[C1234567890], ts: %q["1405894322.002768"], attachments: %q[{"data":["data"]}], blocks: %q[{"data":["data"]}], metadata: %q[{"data":["data"]}]})
|
59
131
|
client.chat_update(channel: %q[C1234567890], ts: %q["1405894322.002768"], attachments: {:data=>["data"]}, blocks: {:data=>["data"]}, metadata: {:data=>["data"]})
|