From 8897dd6eab0b16ff73d12295bc77d617c1117964 Mon Sep 17 00:00:00 2001 From: slack-ruby-ci-bot Date: Mon, 9 Sep 2024 23:22:35 +0000 Subject: [PATCH] Update API from slack-api-ref@3ec3c10 (2024-09-09) --- CHANGELOG.md | 1 + bin/commands/admin_users_session.rb | 1 + bin/commands/chat.rb | 2 +- .../conversations_requestSharedInvite.rb | 33 ++++++++++++++ bin/commands/usergroups.rb | 2 + lib/slack/web/api/endpoints.rb | 2 + .../web/api/endpoints/admin_users_session.rb | 6 ++- lib/slack/web/api/endpoints/chat.rb | 2 +- .../conversations_requestSharedInvite.rb | 44 +++++++++++++++++++ lib/slack/web/api/endpoints/usergroups.rb | 4 ++ lib/slack/web/api/errors.rb | 16 ++++++- lib/slack/web/api/slack-api-ref | 2 +- .../api/endpoints/admin_users_session_spec.rb | 17 +++++-- .../conversations_requestSharedInvite_spec.rb | 18 ++++++++ 14 files changed, 140 insertions(+), 10 deletions(-) create mode 100644 bin/commands/conversations_requestSharedInvite.rb create mode 100644 lib/slack/web/api/endpoints/conversations_requestSharedInvite.rb create mode 100644 spec/slack/web/api/endpoints/conversations_requestSharedInvite_spec.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 72f30ccc..9fb58180 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/bin/commands/admin_users_session.rb b/bin/commands/admin_users_session.rb index c31641c0..494b6855 100644 --- a/bin/commands/admin_users_session.rb +++ b/bin/commands/admin_users_session.rb @@ -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)) diff --git a/bin/commands/chat.rb b/bin/commands/chat.rb index 6ab0daa0..4eb95f01 100644 --- a/bin/commands/chat.rb +++ b/bin/commands/chat.rb @@ -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.' diff --git a/bin/commands/conversations_requestSharedInvite.rb b/bin/commands/conversations_requestSharedInvite.rb new file mode 100644 index 00000000..c919bbc7 --- /dev/null +++ b/bin/commands/conversations_requestSharedInvite.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true +# This file was auto-generated by lib/tasks/web.rake + +module Slack + module Cli + class App + desc 'ConversationsRequestsharedinvite methods.' + command 'conversations_requestSharedInvite' do |g| + g.desc 'Approves a request to add an external user to a channel and sends them a Slack Connect invite' + g.long_desc %( Approves a request to add an external user to a channel and sends them a Slack Connect invite ) + g.command 'approve' do |c| + c.flag 'invite_id', desc: 'ID of the requested shared channel invite to approve.' + c.flag 'channel_id', desc: 'Optional channel_id to which external user will be invited to. Will override the value on the requested invite.' + c.flag 'is_external_limited', desc: 'Optional boolean on whether the invited team will have post-only permissions in the channel. Will override the value on the requested invite.' + c.flag 'message', desc: 'Object describing the text to send along with the invite. If this object is specified, both text and is_override are required properties. If is_override is set to true, text will override the original invitation message. Otherwise, text will be appended to the original invitation message. The total length of the message cannot exceed 560 characters. If is_override is set to false, the length of text and the user specified message on the invite request in total must be less than 560 characters.' + c.action do |_global_options, options, _args| + puts JSON.dump(@client.conversations_requestSharedInvite_approve(options)) + end + end + + g.desc 'Denies a request to invite an external user to a channel' + g.long_desc %( Denies a request to invite an external user to a channel ) + g.command 'deny' do |c| + c.flag 'invite_id', desc: 'ID of the requested shared channel invite to deny.' + c.flag 'message', desc: 'Optional message explaining why the request to invite was denied.' + c.action do |_global_options, options, _args| + puts JSON.dump(@client.conversations_requestSharedInvite_deny(options)) + end + end + end + end + end +end diff --git a/bin/commands/usergroups.rb b/bin/commands/usergroups.rb index 7391c026..4b29cd83 100644 --- a/bin/commands/usergroups.rb +++ b/bin/commands/usergroups.rb @@ -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.' @@ -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.' diff --git a/lib/slack/web/api/endpoints.rb b/lib/slack/web/api/endpoints.rb index f0ca655b..023ddd02 100644 --- a/lib/slack/web/api/endpoints.rb +++ b/lib/slack/web/api/endpoints.rb @@ -55,6 +55,7 @@ require_relative 'endpoints/conversations' require_relative 'endpoints/conversations_canvases' require_relative 'endpoints/conversations_externalInvitePermissions' +require_relative 'endpoints/conversations_requestSharedInvite' require_relative 'endpoints/dialog' require_relative 'endpoints/dnd' require_relative 'endpoints/emoji' @@ -153,6 +154,7 @@ module Endpoints include Conversations include ConversationsCanvases include ConversationsExternalinvitepermissions + include ConversationsRequestsharedinvite include Dialog include Dnd include Emoji diff --git a/lib/slack/web/api/endpoints/admin_users_session.rb b/lib/slack/web/api/endpoints/admin_users_session.rb index 7dff9b28..3213c1e8 100644 --- a/lib/slack/web/api/endpoints/admin_users_session.rb +++ b/lib/slack/web/api/endpoints/admin_users_session.rb @@ -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 diff --git a/lib/slack/web/api/endpoints/chat.rb b/lib/slack/web/api/endpoints/chat.rb index 34e041dc..f3d771b9 100644 --- a/lib/slack/web/api/endpoints/chat.rb +++ b/lib/slack/web/api/endpoints/chat.rb @@ -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 diff --git a/lib/slack/web/api/endpoints/conversations_requestSharedInvite.rb b/lib/slack/web/api/endpoints/conversations_requestSharedInvite.rb new file mode 100644 index 00000000..ac790223 --- /dev/null +++ b/lib/slack/web/api/endpoints/conversations_requestSharedInvite.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true +# This file was auto-generated by lib/tasks/web.rake + +module Slack + module Web + module Api + module Endpoints + module ConversationsRequestsharedinvite + # + # Approves a request to add an external user to a channel and sends them a Slack Connect invite + # + # @option options [Object] :invite_id + # ID of the requested shared channel invite to approve. + # @option options [string] :channel_id + # Optional channel_id to which external user will be invited to. Will override the value on the requested invite. + # @option options [boolean] :is_external_limited + # Optional boolean on whether the invited team will have post-only permissions in the channel. Will override the value on the requested invite. + # @option options [object] :message + # Object describing the text to send along with the invite. If this object is specified, both text and is_override are required properties. If is_override is set to true, text will override the original invitation message. Otherwise, text will be appended to the original invitation message. The total length of the message cannot exceed 560 characters. If is_override is set to false, the length of text and the user specified message on the invite request in total must be less than 560 characters. + # @see https://api.slack.com/methods/conversations.requestSharedInvite.approve + # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/conversations.requestSharedInvite/conversations.requestSharedInvite.approve.json + def conversations_requestSharedInvite_approve(options = {}) + raise ArgumentError, 'Required arguments :invite_id missing' if options[:invite_id].nil? + post('conversations.requestSharedInvite.approve', options) + end + + # + # Denies a request to invite an external user to a channel + # + # @option options [Object] :invite_id + # ID of the requested shared channel invite to deny. + # @option options [string] :message + # Optional message explaining why the request to invite was denied. + # @see https://api.slack.com/methods/conversations.requestSharedInvite.deny + # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/conversations.requestSharedInvite/conversations.requestSharedInvite.deny.json + def conversations_requestSharedInvite_deny(options = {}) + raise ArgumentError, 'Required arguments :invite_id missing' if options[:invite_id].nil? + post('conversations.requestSharedInvite.deny', options) + end + end + end + end + end +end diff --git a/lib/slack/web/api/endpoints/usergroups.rb b/lib/slack/web/api/endpoints/usergroups.rb index 600a00e7..aa11987f 100644 --- a/lib/slack/web/api/endpoints/usergroups.rb +++ b/lib/slack/web/api/endpoints/usergroups.rb @@ -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 @@ -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 diff --git a/lib/slack/web/api/errors.rb b/lib/slack/web/api/errors.rb index aa5325db..ceb30003 100644 --- a/lib/slack/web/api/errors.rb +++ b/lib/slack/web/api/errors.rb @@ -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 @@ -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 @@ -367,6 +369,9 @@ class InvalidValue < SlackError; end class InvalidVisibility < SlackError; end class InvalidWorkflowAuthStrategy < SlackError; end class InvalidWorkspaceFilter < SlackError; end + class InviteAlreadyApproved < SlackError; end + class InviteAlreadyDenied < SlackError; end + class InviteExpired < SlackError; end class InviteFromSameOrg < SlackError; end class InviteLookupError < SlackError; end class InviteNotFound < SlackError; end @@ -541,7 +546,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 @@ -570,6 +574,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 @@ -634,6 +639,7 @@ class UrlRestrictionNotSupported < SlackError; end class UserAlreadyDeleted < SlackError; end class UserAlreadyTeamMember < SlackError; end class UserCannotCreateChannel < SlackError; end + class UserCannotManagePublicChannels < SlackError; end class UserCannotManageWorkspace < SlackError; end class UserDisabled < SlackError; end class UserDoesNotOwnChannel < SlackError; end @@ -833,6 +839,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, @@ -991,6 +998,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, @@ -1022,6 +1030,9 @@ class WorkflowsExportCsvNotEnabled < SlackError; end 'invalid_visibility' => InvalidVisibility, 'invalid_workflow_auth_strategy' => InvalidWorkflowAuthStrategy, 'invalid_workspace_filter' => InvalidWorkspaceFilter, + 'invite_already_approved' => InviteAlreadyApproved, + 'invite_already_denied' => InviteAlreadyDenied, + 'invite_expired' => InviteExpired, 'invite_from_same_org' => InviteFromSameOrg, 'invite_lookup_error' => InviteLookupError, 'invite_not_found' => InviteNotFound, @@ -1196,7 +1207,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, @@ -1225,6 +1235,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, @@ -1289,6 +1300,7 @@ class WorkflowsExportCsvNotEnabled < SlackError; end 'user_already_deleted' => UserAlreadyDeleted, 'user_already_team_member' => UserAlreadyTeamMember, 'user_cannot_create_channel' => UserCannotCreateChannel, + 'user_cannot_manage_public_channels' => UserCannotManagePublicChannels, 'user_cannot_manage_workspace' => UserCannotManageWorkspace, 'user_disabled' => UserDisabled, 'user_does_not_own_channel' => UserDoesNotOwnChannel, diff --git a/lib/slack/web/api/slack-api-ref b/lib/slack/web/api/slack-api-ref index 3ec3c101..fd069b16 160000 --- a/lib/slack/web/api/slack-api-ref +++ b/lib/slack/web/api/slack-api-ref @@ -1 +1 @@ -Subproject commit 3ec3c101d99cb5ab8af3694e57d883f04cfd5e2f +Subproject commit fd069b1616ca70d31f6b2bd2206006b3b86a9efa diff --git a/spec/slack/web/api/endpoints/admin_users_session_spec.rb b/spec/slack/web/api/endpoints/admin_users_session_spec.rb index 035c6e1e..eb5295d0 100644 --- a/spec/slack/web/api/endpoints/admin_users_session_spec.rb +++ b/spec/slack/web/api/endpoints/admin_users_session_spec.rb @@ -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 diff --git a/spec/slack/web/api/endpoints/conversations_requestSharedInvite_spec.rb b/spec/slack/web/api/endpoints/conversations_requestSharedInvite_spec.rb new file mode 100644 index 00000000..e0e69214 --- /dev/null +++ b/spec/slack/web/api/endpoints/conversations_requestSharedInvite_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true +# This file was auto-generated by lib/tasks/web.rake + +require 'spec_helper' + +RSpec.describe Slack::Web::Api::Endpoints::ConversationsRequestsharedinvite do + let(:client) { Slack::Web::Client.new } + context 'conversations.requestSharedInvite_approve' do + it 'requires invite_id' do + expect { client.conversations_requestSharedInvite_approve }.to raise_error ArgumentError, /Required arguments :invite_id missing/ + end + end + context 'conversations.requestSharedInvite_deny' do + it 'requires invite_id' do + expect { client.conversations_requestSharedInvite_deny }.to raise_error ArgumentError, /Required arguments :invite_id missing/ + end + end +end