Skip to content

Commit

Permalink
Update API from slack-api-ref@3ec3c10 (2024-08-29)
Browse files Browse the repository at this point in the history
  • Loading branch information
web-flow committed Aug 29, 2024
1 parent 56995cc commit 7f515c9
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
### 2.4.1 (Next)

* [#525](https://github.com/slack-ruby/slack-ruby-client/pull/525): Exclude spec files from gem package - [@amatsuda](https://github.com/amatsuda).
* [#524](https://github.com/slack-ruby-client/pulls/524): Update API from [slack-api-ref@3ec3c10](https://github.com/slack-ruby/slack-api-ref/commit/3ec3c10) - [@slack-ruby-ci-bot](https://github.com/apps/slack-ruby-ci-bot).
* Your contribution here.

### 2.4.0 (2024/07/14)
Expand Down
1 change: 1 addition & 0 deletions bin/commands/admin_users_session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class App
g.long_desc %( Revoke a single session for a user. The user will be forced to login to Slack. )
g.command 'invalidate' do |c|
c.flag 'session_id', desc: 'ID of the session to invalidate.'
c.flag 'user_id', desc: 'ID of the user that the session belongs to.'
c.flag 'team_id', desc: 'ID of the workspace that the session belongs to.'
c.action do |_global_options, options, _args|
puts JSON.dump(@client.admin_users_session_invalidate(options))
Expand Down
2 changes: 1 addition & 1 deletion bin/commands/chat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class App
c.flag 'attachments', desc: 'A JSON-based array of structured attachments, presented as a URL-encoded string.'
c.flag 'blocks', desc: 'A JSON-based array of structured blocks, presented as a URL-encoded string.'
c.flag 'text', desc: 'How this field works and whether it is required depends on other fields you use in your API call. See below for more detail.'
c.flag 'as_user', desc: '(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.'
c.flag 'as_user', desc: '(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 legacy as_user parameter below.'
c.flag 'icon_emoji', desc: 'Emoji to use as the icon for this message. Overrides icon_url.'
c.flag 'icon_url', desc: 'URL to an image to use as the icon for this message.'
c.flag 'link_names', desc: 'Find and link user groups. No longer supports linking individual users; use syntax shown in Mentioning Users instead.'
Expand Down
2 changes: 2 additions & 0 deletions bin/commands/usergroups.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class App
c.flag 'name', desc: 'A name for the User Group. Must be unique among User Groups.'
c.flag 'channels', desc: 'A comma separated string of encoded channel IDs for which the User Group uses as a default.'
c.flag 'description', desc: 'A short description of the User Group.'
c.flag 'enable_section', desc: 'Configure this user group to show as a sidebar section for all group members. Note: Only relevant if group has 1 or more default channels added.'
c.flag 'handle', desc: 'A mention handle. Must be unique among channels, users and User Groups.'
c.flag 'include_count', desc: 'Include the number of users in each User Group.'
c.flag 'team_id', desc: 'Encoded team id where the user group has to be created, required if org token is used.'
Expand Down Expand Up @@ -60,6 +61,7 @@ class App
c.flag 'usergroup', desc: 'The encoded ID of the User Group to update.'
c.flag 'channels', desc: 'A comma separated string of encoded channel IDs for which the User Group uses as a default.'
c.flag 'description', desc: 'A short description of the User Group.'
c.flag 'enable_section', desc: 'Configure this user group to show as a sidebar section for all group members. Note: Only relevant if group has 1 or more default channels added.'
c.flag 'handle', desc: 'A mention handle. Must be unique among channels, users and User Groups.'
c.flag 'include_count', desc: 'Include the number of users in the User Group.'
c.flag 'name', desc: 'A name for the User Group. Must be unique among User Groups.'
Expand Down
6 changes: 4 additions & 2 deletions lib/slack/web/api/endpoints/admin_users_session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ def admin_users_session_getSettings(options = {})
#
# @option options [integer] :session_id
# ID of the session to invalidate.
# @option options [string] :team_id
# @option options [Object] :user_id
# ID of the user that the session belongs to.
# @option options [Object] :team_id
# ID of the workspace that the session belongs to.
# @see https://api.slack.com/methods/admin.users.session.invalidate
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/admin.users.session/admin.users.session.invalidate.json
def admin_users_session_invalidate(options = {})
raise ArgumentError, 'Required arguments :session_id missing' if options[:session_id].nil?
raise ArgumentError, 'Required arguments :team_id missing' if options[:team_id].nil?
raise ArgumentError, 'Exactly one of :user_id, :team_id is required' unless options[:user_id].nil? ^ options[:team_id].nil?
post('admin.users.session.invalidate', options)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/slack/web/api/endpoints/chat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def chat_postEphemeral(options = {})
# @option options [string] :text
# How this field works and whether it is required depends on other fields you use in your API call. See below for more detail.
# @option options [boolean] :as_user
# (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.
# (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 legacy as_user parameter below.
# @option options [string] :icon_emoji
# Emoji to use as the icon for this message. Overrides icon_url.
# @option options [string] :icon_url
Expand Down
4 changes: 4 additions & 0 deletions lib/slack/web/api/endpoints/usergroups.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ module Usergroups
# A comma separated string of encoded channel IDs for which the User Group uses as a default.
# @option options [string] :description
# A short description of the User Group.
# @option options [boolean] :enable_section
# Configure this user group to show as a sidebar section for all group members. Note: Only relevant if group has 1 or more default channels added.
# @option options [string] :handle
# A mention handle. Must be unique among channels, users and User Groups.
# @option options [boolean] :include_count
Expand Down Expand Up @@ -86,6 +88,8 @@ def usergroups_list(options = {})
# A comma separated string of encoded channel IDs for which the User Group uses as a default.
# @option options [string] :description
# A short description of the User Group.
# @option options [boolean] :enable_section
# Configure this user group to show as a sidebar section for all group members. Note: Only relevant if group has 1 or more default channels added.
# @option options [string] :handle
# A mention handle. Must be unique among channels, users and User Groups.
# @option options [boolean] :include_count
Expand Down
8 changes: 6 additions & 2 deletions lib/slack/web/api/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ class ErrorBadUpload < SlackError; end
class ErrorBadWide < SlackError; end
class ErrorInvalidAlias < SlackError; end
class ErrorInvalidEmojiToRename < SlackError; end
class ErrorLowerCaseNamesOnly < SlackError; end
class ErrorMissingName < SlackError; end
class ErrorNameTaken < SlackError; end
class ErrorNameTakenI18n < SlackError; end
Expand Down Expand Up @@ -336,6 +337,7 @@ class InvalidScheduledMessageId < SlackError; end
class InvalidScopes < SlackError; end
class InvalidSearchChannelType < SlackError; end
class InvalidSetting < SlackError; end
class InvalidShortcutType < SlackError; end
class InvalidSort < SlackError; end
class InvalidSortDir < SlackError; end
class InvalidSource < SlackError; end
Expand Down Expand Up @@ -541,7 +543,6 @@ class RestrictedTooMany < SlackError; end
class RetentionOverrideNotAllowed < SlackError; end
class SentRecently < SlackError; end
class ServiceUnavailable < SlackError; end
class SessionExpired < SlackError; end
class SessionInvalidationFailed < SlackError; end
class SessionNotFound < SlackError; end
class SessionResetNotAllowed < SlackError; end
Expand Down Expand Up @@ -570,6 +571,7 @@ class TeamNotConnected < SlackError; end
class TeamNotFound < SlackError; end
class TeamNotOnEnterprise < SlackError; end
class TeamQuotaExceeded < SlackError; end
class TeamTierCannotCreateChannelCanvases < SlackError; end
class TeamsNotFound < SlackError; end
class TemplateNotVisible < SlackError; end
class ThreadLocked < SlackError; end
Expand Down Expand Up @@ -833,6 +835,7 @@ class WorkflowsExportCsvNotEnabled < SlackError; end
'error_bad_wide' => ErrorBadWide,
'error_invalid_alias' => ErrorInvalidAlias,
'error_invalid_emoji_to_rename' => ErrorInvalidEmojiToRename,
'error_lower_case_names_only' => ErrorLowerCaseNamesOnly,
'error_missing_name' => ErrorMissingName,
'error_name_taken' => ErrorNameTaken,
'error_name_taken_i18n' => ErrorNameTakenI18n,
Expand Down Expand Up @@ -991,6 +994,7 @@ class WorkflowsExportCsvNotEnabled < SlackError; end
'invalid_scopes' => InvalidScopes,
'invalid_search_channel_type' => InvalidSearchChannelType,
'invalid_setting' => InvalidSetting,
'invalid_shortcut_type' => InvalidShortcutType,
'invalid_sort' => InvalidSort,
'invalid_sort_dir' => InvalidSortDir,
'invalid_source' => InvalidSource,
Expand Down Expand Up @@ -1196,7 +1200,6 @@ class WorkflowsExportCsvNotEnabled < SlackError; end
'retention_override_not_allowed' => RetentionOverrideNotAllowed,
'sent_recently' => SentRecently,
'service_unavailable' => ServiceUnavailable,
'session_expired' => SessionExpired,
'session_invalidation_failed' => SessionInvalidationFailed,
'session_not_found' => SessionNotFound,
'session_reset_not_allowed' => SessionResetNotAllowed,
Expand Down Expand Up @@ -1225,6 +1228,7 @@ class WorkflowsExportCsvNotEnabled < SlackError; end
'team_not_found' => TeamNotFound,
'team_not_on_enterprise' => TeamNotOnEnterprise,
'team_quota_exceeded' => TeamQuotaExceeded,
'team_tier_cannot_create_channel_canvases' => TeamTierCannotCreateChannelCanvases,
'teams_not_found' => TeamsNotFound,
'template_not_visible' => TemplateNotVisible,
'thread_locked' => ThreadLocked,
Expand Down
17 changes: 14 additions & 3 deletions spec/slack/web/api/endpoints/admin_users_session_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,21 @@
end
context 'admin.users.session_invalidate' do
it 'requires session_id' do
expect { client.admin_users_session_invalidate(team_id: %q[T1234]) }.to raise_error ArgumentError, /Required arguments :session_id missing/
expect { client.admin_users_session_invalidate(user_id: %q[U12345]) }.to raise_error ArgumentError, /Required arguments :session_id missing/
end
it 'requires team_id' do
expect { client.admin_users_session_invalidate(session_id: %q[12345]) }.to raise_error ArgumentError, /Required arguments :team_id missing/
it 'requires user_id' do
expect { client.admin_users_session_invalidate(session_id: %q[12345]) }.to raise_error ArgumentError, /Required arguments :user_id missing/
end
it 'requires one of user_id, team_id' do
expect { client.admin_users_session_invalidate(session_id: %q[12345]) }.to raise_error ArgumentError, /Exactly one of/

expect(client).to receive(:post).with('admin.users.session.invalidate', {user_id: %q[U12345], session_id: %q[12345]})
client.admin_users_session_invalidate(user_id: %q[U12345], session_id: %q[12345])

expect(client).to receive(:post).with('admin.users.session.invalidate', {team_id: %q[T1234], session_id: %q[12345]})
client.admin_users_session_invalidate(team_id: %q[T1234], session_id: %q[12345])

expect { client.admin_users_session_invalidate(user_id: %q[U12345], team_id: %q[T1234], session_id: %q[12345]) }.to raise_error ArgumentError, /Exactly one of/
end
end
context 'admin.users.session_reset' do
Expand Down

0 comments on commit 7f515c9

Please sign in to comment.