diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b1dc81f..43b3f017 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ### 3.1.1 (Next) * [#581](https://github.com/slack-ruby/slack-ruby-client/pull/581): Migrate Danger to use danger-pr-comment workflow - [@dblock](https://github.com/dblock). +* [#578](https://github.com/slack-ruby/slack-ruby-client/pull/578): Update API from [slack-api-ref@3275786](https://github.com/slack-ruby/slack-api-ref/commit/3275786) - [@slack-ruby-ci-bot](https://github.com/apps/slack-ruby-ci-bot). * Your contribution here. ### 3.1.0 (2025/11/15) diff --git a/bin/commands/admin_conversations.rb b/bin/commands/admin_conversations.rb index 06cb39ad..678f255d 100644 --- a/bin/commands/admin_conversations.rb +++ b/bin/commands/admin_conversations.rb @@ -43,6 +43,16 @@ class App end end + g.desc 'Exclude channels from Slack AI in bulk' + g.long_desc %( Exclude channels from Slack AI in bulk ) + g.command 'bulkSetExcludeFromSlackAi' do |c| + c.flag 'channel_ids', desc: 'An array of channel IDs to exclude from Slack AI.' + c.flag 'exclude', desc: 'Whether the channels should be excluded from Slack AI.' + c.action do |_global_options, options, _args| + puts JSON.dump(@client.admin_conversations_bulkSetExcludeFromSlackAi(options)) + end + end + g.desc 'Convert a public channel to a private channel.' g.long_desc %( Convert a public channel to a private channel. ) g.command 'convertToPrivate' do |c| diff --git a/bin/commands/admin_functions_permissions.rb b/bin/commands/admin_functions_permissions.rb index b363daac..7e246a46 100644 --- a/bin/commands/admin_functions_permissions.rb +++ b/bin/commands/admin_functions_permissions.rb @@ -21,6 +21,7 @@ class App c.flag 'function_id', desc: 'The function ID to set permissions for.' c.flag 'visibility', desc: 'The function visibility.' c.flag 'user_ids', desc: 'List of user IDs to allow for named_entities visibility.' + c.flag 'permissions', desc: 'Array of permissions for the function.' c.action do |_global_options, options, _args| puts JSON.dump(@client.admin_functions_permissions_set(options)) end diff --git a/bin/commands/admin_users.rb b/bin/commands/admin_users.rb index 28857d0f..62ab78d3 100644 --- a/bin/commands/admin_users.rb +++ b/bin/commands/admin_users.rb @@ -71,10 +71,10 @@ class App end end - g.desc 'Set an existing regular user or owner to be a workspace admin.' - g.long_desc %( Set an existing regular user or owner to be a workspace admin. ) + g.desc 'Set an existing regular user or owner to be a workspace or org admin.' + g.long_desc %( Set an existing regular user or owner to be a workspace or org admin. ) g.command 'setAdmin' do |c| - c.flag 'team_id', desc: 'The ID (T1234) of the workspace.' + c.flag 'team_id', desc: 'The ID of the workspace or organization.' c.flag 'user_id', desc: 'The ID of the user to designate as an admin.' c.action do |_global_options, options, _args| puts JSON.dump(@client.admin_users_setAdmin(options)) @@ -92,11 +92,11 @@ class App end end - g.desc 'Set an existing regular user or admin to be a workspace owner.' - g.long_desc %( Set an existing regular user or admin to be a workspace owner. ) + g.desc 'Set an existing regular user or admin to be a workspace or org owner.' + g.long_desc %( Set an existing regular user or admin to be a workspace or org owner. ) g.command 'setOwner' do |c| - c.flag 'team_id', desc: 'The ID (T1234) of the workspace.' - c.flag 'user_id', desc: 'Id of the user to promote to owner.' + c.flag 'team_id', desc: 'The ID of the workspace or organization.' + c.flag 'user_id', desc: 'ID of the user to promote to owner.' c.action do |_global_options, options, _args| puts JSON.dump(@client.admin_users_setOwner(options)) end @@ -105,7 +105,7 @@ class App g.desc 'Set an existing guest user, admin user, or owner to be a regular user.' g.long_desc %( Set an existing guest user, admin user, or owner to be a regular user. ) g.command 'setRegular' do |c| - c.flag 'team_id', desc: 'The ID (T1234) of the workspace.' + c.flag 'team_id', desc: 'The ID of the workspace or organization.' c.flag 'user_id', desc: 'The ID of the user to designate as a regular user.' c.action do |_global_options, options, _args| puts JSON.dump(@client.admin_users_setRegular(options)) diff --git a/bin/commands/admin_workflows_triggers_types_permissions.rb b/bin/commands/admin_workflows_triggers_types_permissions.rb index 9c0a56da..4dc3ee86 100644 --- a/bin/commands/admin_workflows_triggers_types_permissions.rb +++ b/bin/commands/admin_workflows_triggers_types_permissions.rb @@ -6,10 +6,10 @@ module Cli class App desc 'AdminWorkflowsTriggersTypesPermissions methods.' command 'admin_workflows_triggers_types_permissions' do |g| - g.desc 'list the permissions for using each trigger type' - g.long_desc %( list the permissions for using each trigger type ) + g.desc 'List the permissions for using each trigger type.' + g.long_desc %( List the permissions for using each trigger type. ) g.command 'lookup' do |c| - c.flag 'trigger_type_ids', desc: 'The trigger types IDs for which to get the permissions.' + c.flag 'trigger_type_ids', desc: 'The trigger type IDs for which to get the permissions.' c.action do |_global_options, options, _args| puts JSON.dump(@client.admin_workflows_triggers_types_permissions_lookup(options)) end @@ -21,6 +21,7 @@ class App c.flag 'id', desc: 'The trigger type ID for which to set the permissions.' c.flag 'visibility', desc: 'The function visibility.' c.flag 'user_ids', desc: 'List of user IDs to allow for named_entities visibility.' + c.flag 'permissions', desc: '' c.action do |_global_options, options, _args| puts JSON.dump(@client.admin_workflows_triggers_types_permissions_set(options)) end diff --git a/bin/commands/apps_user_connection.rb b/bin/commands/apps_user_connection.rb new file mode 100644 index 00000000..4ecdfb5e --- /dev/null +++ b/bin/commands/apps_user_connection.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true +# This file was auto-generated by lib/tasks/web.rake + +module Slack + module Cli + class App + desc 'AppsUserConnection methods.' + command 'apps_user_connection' do |g| + g.desc 'Updates the connection status between a user and an app.' + g.long_desc %( Updates the connection status between a user and an app. ) + g.command 'update' do |c| + c.flag 'user_id', desc: 'The ID of the user for the status update.' + c.flag 'status', desc: 'The status that should be set for the user.' + c.action do |_global_options, options, _args| + puts JSON.dump(@client.apps_user_connection_update(options)) + end + end + end + end + end +end diff --git a/bin/commands/assistant_threads.rb b/bin/commands/assistant_threads.rb index 128d5c4b..b1d8d9c6 100644 --- a/bin/commands/assistant_threads.rb +++ b/bin/commands/assistant_threads.rb @@ -11,8 +11,8 @@ class App g.command 'setStatus' do |c| c.flag 'channel_id', desc: 'Channel ID containing the assistant thread.' c.flag 'thread_ts', desc: 'Message timestamp of the thread of where to set the status.' - c.flag 'status', desc: "Status of the specified bot user, e.g. 'is thinking...'." - c.flag 'loading_messages', desc: 'The list of messages to rotate through as a loading indicator.' + c.flag 'status', desc: "Status of the specified bot user, e.g., 'is thinking...'. A two minute timeout applies, which will cause the status to be removed if no message has been sent." + c.flag 'loading_messages', desc: 'The list of messages to rotate through as a loading indicator. Maximum of 10 messages.' c.action do |_global_options, options, _args| puts JSON.dump(@client.assistant_threads_setStatus(options)) end diff --git a/bin/commands/chat.rb b/bin/commands/chat.rb index 90f8d58d..89909e3d 100644 --- a/bin/commands/chat.rb +++ b/bin/commands/chat.rb @@ -103,7 +103,7 @@ class App 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.' c.flag 'markdown_text', desc: 'Accepts message text formatted in markdown. This argument should not be used in conjunction with blocks or text. Limit this field to 12,000 characters.' - c.flag 'metadata', desc: '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.' + c.flag 'metadata', desc: 'JSON object with event_type and event_payload fields, presented as a URL-encoded string. You can also provide Work Object entity metadata using this parameter. Metadata you post to Slack is accessible to any app or user who is a member of that workspace.' c.flag 'mrkdwn', desc: 'Disable Slack markup parsing by setting to false. Enabled by default.' c.flag 'parse', desc: 'Change how messages are treated. See below.' c.flag 'reply_broadcast', desc: 'Used in conjunction with thread_ts and indicates whether reply should be made visible to everyone in the channel or conversation. Defaults to false.' @@ -142,7 +142,7 @@ class App g.desc 'Starts a new streaming conversation.' g.long_desc %( Starts a new streaming conversation. ) g.command 'startStream' do |c| - c.flag 'channel', desc: 'An encoded ID that represents a channel, private group, or DM.' + c.flag 'channel', desc: 'An encoded ID that represents a channel thread or DM.' c.flag 'markdown_text', desc: 'Accepts message text formatted in markdown. Limit this field to 12,000 characters.' c.flag 'thread_ts', desc: "Provide another message's ts value to reply to. Streamed messages should always be replies to a user request." c.flag 'recipient_user_id', desc: 'The encoded ID of the user to receive the streaming text. Required when streaming to channels.' @@ -177,7 +177,7 @@ class App c.flag 'user_auth_blocks', desc: 'Provide a JSON based array of structured blocks presented as URL-encoded string to send as an ephemeral message to the user as invitation to authenticate further and enable full unfurling behavior.' c.flag 'unfurl_id', desc: 'The ID of the link to unfurl. Both unfurl_id and source must be provided together, or channel and ts must be provided together.' c.flag 'source', desc: '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.' - c.flag 'metadata', desc: 'JSON object with entity_type and entity_payload fields, presented as a URL-encoded string. Either unfurls or metadata must be provided.' + c.flag 'metadata', desc: 'JSON object with an entities field providing an array of Work Object entities. Either unfurls or metadata must be provided.' c.action do |_global_options, options, _args| puts JSON.dump(@client.chat_unfurl(options)) end @@ -188,6 +188,7 @@ class App g.command 'update' do |c| c.flag 'as_user', desc: 'Pass true to update the message as the authed user. Bot users in this context are considered authed users.' c.flag 'attachments', desc: 'A JSON-based array of structured attachments, presented as a URL-encoded string.' + c.flag 'unfurled_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 'markdown_text', desc: 'Accepts message text formatted in markdown. This argument should not be used in conjunction with blocks or text. Limit this field to 12,000 characters.' c.flag 'metadata', desc: "JSON object with event_type and event_payload fields, presented as a URL-encoded string. If you don't include this field, the message's previous metadata will be retained. To remove previous metadata, include an empty object for this field. Metadata you post to Slack is accessible to any app or user who is a member of that workspace." diff --git a/bin/commands/users.rb b/bin/commands/users.rb index 176c1576..d6623b64 100644 --- a/bin/commands/users.rb +++ b/bin/commands/users.rb @@ -6,8 +6,8 @@ module Cli class App desc 'Users methods.' command 'users' do |g| - g.desc 'List conversations the calling user may access.' - g.long_desc %( List conversations the calling user may access. ) + g.desc 'List conversations the calling user is a member of.' + g.long_desc %( List conversations the calling user is a member of. ) g.command 'conversations' do |c| c.flag 'cursor', desc: "Paginate through collections of data by setting the cursor parameter to a next_cursor attribute returned by a previous request's response_metadata. Default value fetches the first 'page' of the collection. See pagination for more detail." c.flag 'exclude_archived', desc: 'Set to true to exclude archived channels from the list.' diff --git a/lib/slack/web/api/endpoints.rb b/lib/slack/web/api/endpoints.rb index 622e80ea..32749e08 100644 --- a/lib/slack/web/api/endpoints.rb +++ b/lib/slack/web/api/endpoints.rb @@ -41,6 +41,7 @@ require_relative 'endpoints/apps_datastore' require_relative 'endpoints/apps_event_authorizations' require_relative 'endpoints/apps_manifest' +require_relative 'endpoints/apps_user_connection' require_relative 'endpoints/assistant_search' require_relative 'endpoints/assistant_threads' require_relative 'endpoints/auth' @@ -147,6 +148,7 @@ module Endpoints include AppsDatastore include AppsEventAuthorizations include AppsManifest + include AppsUserConnection include AssistantSearch include AssistantThreads include Auth diff --git a/lib/slack/web/api/endpoints/admin_conversations.rb b/lib/slack/web/api/endpoints/admin_conversations.rb index cad81a17..bf021300 100644 --- a/lib/slack/web/api/endpoints/admin_conversations.rb +++ b/lib/slack/web/api/endpoints/admin_conversations.rb @@ -57,6 +57,21 @@ def admin_conversations_bulkMove(options = {}) post('admin.conversations.bulkMove', options) end + # + # Exclude channels from Slack AI in bulk + # + # @option options [array] :channel_ids + # An array of channel IDs to exclude from Slack AI. + # @option options [boolean] :exclude + # Whether the channels should be excluded from Slack AI. + # @see https://api.slack.com/methods/admin.conversations.bulkSetExcludeFromSlackAi + # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/admin.conversations/admin.conversations.bulkSetExcludeFromSlackAi.json + def admin_conversations_bulkSetExcludeFromSlackAi(options = {}) + raise ArgumentError, 'Required arguments :channel_ids missing' if options[:channel_ids].nil? + raise ArgumentError, 'Required arguments :exclude missing' if options[:exclude].nil? + post('admin.conversations.bulkSetExcludeFromSlackAi', options) + end + # # Convert a public channel to a private channel. # diff --git a/lib/slack/web/api/endpoints/admin_functions_permissions.rb b/lib/slack/web/api/endpoints/admin_functions_permissions.rb index acb2a674..06f8f414 100644 --- a/lib/slack/web/api/endpoints/admin_functions_permissions.rb +++ b/lib/slack/web/api/endpoints/admin_functions_permissions.rb @@ -27,11 +27,12 @@ def admin_functions_permissions_lookup(options = {}) # The function visibility. # @option options [array] :user_ids # List of user IDs to allow for named_entities visibility. + # @option options [array] :permissions + # Array of permissions for the function. # @see https://api.slack.com/methods/admin.functions.permissions.set # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/admin.functions.permissions/admin.functions.permissions.set.json def admin_functions_permissions_set(options = {}) raise ArgumentError, 'Required arguments :function_id missing' if options[:function_id].nil? - raise ArgumentError, 'Required arguments :visibility missing' if options[:visibility].nil? post('admin.functions.permissions.set', options) end end diff --git a/lib/slack/web/api/endpoints/admin_users.rb b/lib/slack/web/api/endpoints/admin_users.rb index 1825990e..34dd07de 100644 --- a/lib/slack/web/api/endpoints/admin_users.rb +++ b/lib/slack/web/api/endpoints/admin_users.rb @@ -115,10 +115,10 @@ def admin_users_remove(options = {}) end # - # Set an existing regular user or owner to be a workspace admin. + # Set an existing regular user or owner to be a workspace or org admin. # # @option options [Object] :team_id - # The ID (T1234) of the workspace. + # The ID of the workspace or organization. # @option options [string] :user_id # The ID of the user to designate as an admin. # @see https://api.slack.com/methods/admin.users.setAdmin @@ -147,12 +147,12 @@ def admin_users_setExpiration(options = {}) end # - # Set an existing regular user or admin to be a workspace owner. + # Set an existing regular user or admin to be a workspace or org owner. # # @option options [Object] :team_id - # The ID (T1234) of the workspace. + # The ID of the workspace or organization. # @option options [Object] :user_id - # Id of the user to promote to owner. + # ID of the user to promote to owner. # @see https://api.slack.com/methods/admin.users.setOwner # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/admin.users/admin.users.setOwner.json def admin_users_setOwner(options = {}) @@ -165,7 +165,7 @@ def admin_users_setOwner(options = {}) # Set an existing guest user, admin user, or owner to be a regular user. # # @option options [Object] :team_id - # The ID (T1234) of the workspace. + # The ID of the workspace or organization. # @option options [string] :user_id # The ID of the user to designate as a regular user. # @see https://api.slack.com/methods/admin.users.setRegular diff --git a/lib/slack/web/api/endpoints/admin_workflows_triggers_types_permissions.rb b/lib/slack/web/api/endpoints/admin_workflows_triggers_types_permissions.rb index 5bf8cd80..ebf17218 100644 --- a/lib/slack/web/api/endpoints/admin_workflows_triggers_types_permissions.rb +++ b/lib/slack/web/api/endpoints/admin_workflows_triggers_types_permissions.rb @@ -7,10 +7,10 @@ module Api module Endpoints module AdminWorkflowsTriggersTypesPermissions # - # list the permissions for using each trigger type + # List the permissions for using each trigger type. # # @option options [array] :trigger_type_ids - # The trigger types IDs for which to get the permissions. + # The trigger type IDs for which to get the permissions. # @see https://api.slack.com/methods/admin.workflows.triggers.types.permissions.lookup # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/admin.workflows.triggers.types.permissions/admin.workflows.triggers.types.permissions.lookup.json def admin_workflows_triggers_types_permissions_lookup(options = {}) @@ -27,11 +27,11 @@ def admin_workflows_triggers_types_permissions_lookup(options = {}) # The function visibility. # @option options [array] :user_ids # List of user IDs to allow for named_entities visibility. + # @option options [object] :permissions # @see https://api.slack.com/methods/admin.workflows.triggers.types.permissions.set # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/admin.workflows.triggers.types.permissions/admin.workflows.triggers.types.permissions.set.json def admin_workflows_triggers_types_permissions_set(options = {}) raise ArgumentError, 'Required arguments :id missing' if options[:id].nil? - raise ArgumentError, 'Required arguments :visibility missing' if options[:visibility].nil? post('admin.workflows.triggers.types.permissions.set', options) end end diff --git a/lib/slack/web/api/endpoints/apps_user_connection.rb b/lib/slack/web/api/endpoints/apps_user_connection.rb new file mode 100644 index 00000000..a9782bd8 --- /dev/null +++ b/lib/slack/web/api/endpoints/apps_user_connection.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true +# This file was auto-generated by lib/tasks/web.rake + +module Slack + module Web + module Api + module Endpoints + module AppsUserConnection + # + # Updates the connection status between a user and an app. + # + # @option options [string] :user_id + # The ID of the user for the status update. + # @option options [enum] :status + # The status that should be set for the user. + # @see https://api.slack.com/methods/apps.user.connection.update + # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/apps.user.connection/apps.user.connection.update.json + def apps_user_connection_update(options = {}) + raise ArgumentError, 'Required arguments :user_id missing' if options[:user_id].nil? + raise ArgumentError, 'Required arguments :status missing' if options[:status].nil? + post('apps.user.connection.update', options) + end + end + end + end + end +end diff --git a/lib/slack/web/api/endpoints/assistant_threads.rb b/lib/slack/web/api/endpoints/assistant_threads.rb index e45d0825..2f44c823 100644 --- a/lib/slack/web/api/endpoints/assistant_threads.rb +++ b/lib/slack/web/api/endpoints/assistant_threads.rb @@ -14,9 +14,9 @@ module AssistantThreads # @option options [string] :thread_ts # Message timestamp of the thread of where to set the status. # @option options [string] :status - # Status of the specified bot user, e.g. 'is thinking...'. + # Status of the specified bot user, e.g., 'is thinking...'. A two minute timeout applies, which will cause the status to be removed if no message has been sent. # @option options [array] :loading_messages - # The list of messages to rotate through as a loading indicator. + # The list of messages to rotate through as a loading indicator. Maximum of 10 messages. # @see https://api.slack.com/methods/assistant.threads.setStatus # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/assistant.threads/assistant.threads.setStatus.json def assistant_threads_setStatus(options = {}) diff --git a/lib/slack/web/api/endpoints/chat.rb b/lib/slack/web/api/endpoints/chat.rb index 2a75caf1..71b57ee2 100644 --- a/lib/slack/web/api/endpoints/chat.rb +++ b/lib/slack/web/api/endpoints/chat.rb @@ -144,7 +144,8 @@ def chat_meMessage(options = {}) def chat_postEphemeral(options = {}) raise ArgumentError, 'Required arguments :channel missing' if options[:channel].nil? raise ArgumentError, 'Required arguments :user missing' if options[:user].nil? - raise ArgumentError, 'At least one of :attachments, :blocks, :text is required' if options[:attachments].nil? && options[:blocks].nil? && options[:text].nil? + raise ArgumentError, 'At least one of :attachments, :blocks, :text, :markdown_text is required' if options[:attachments].nil? && options[:blocks].nil? && options[:text].nil? && options[:markdown_text].nil? + raise ArgumentError, 'Exactly one of :text, :markdown_text is required' unless options[:text].nil? ^ options[:markdown_text].nil? options = options.merge(user: users_id(options)['user']['id']) if options[:user] options = encode_options_as_json(options, %i[attachments blocks]) post('chat.postEphemeral', options) @@ -172,7 +173,7 @@ def chat_postEphemeral(options = {}) # @option options [string] :markdown_text # Accepts message text formatted in markdown. This argument should not be used in conjunction with blocks or text. Limit this field to 12,000 characters. # @option options [string] :metadata - # 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. + # JSON object with event_type and event_payload fields, presented as a URL-encoded string. You can also provide Work Object entity metadata using this parameter. Metadata you post to Slack is accessible to any app or user who is a member of that workspace. # @option options [boolean] :mrkdwn # Disable Slack markup parsing by setting to false. Enabled by default. # @option options [string] :parse @@ -193,7 +194,8 @@ def chat_postEphemeral(options = {}) # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/chat/chat.postMessage.json def chat_postMessage(options = {}) raise ArgumentError, 'Required arguments :channel missing' if options[:channel].nil? - raise ArgumentError, 'At least one of :attachments, :blocks, :text is required' if options[:attachments].nil? && options[:blocks].nil? && options[:text].nil? + raise ArgumentError, 'At least one of :attachments, :blocks, :text, :markdown_text is required' if options[:attachments].nil? && options[:blocks].nil? && options[:text].nil? && options[:markdown_text].nil? + raise ArgumentError, 'Exactly one of :text, :markdown_text is required' unless options[:text].nil? ^ options[:markdown_text].nil? options = encode_options_as_json(options, %i[attachments blocks metadata]) post('chat.postMessage', options) end @@ -234,7 +236,8 @@ def chat_postMessage(options = {}) def chat_scheduleMessage(options = {}) raise ArgumentError, 'Required arguments :channel missing' if options[:channel].nil? raise ArgumentError, 'Required arguments :post_at missing' if options[:post_at].nil? - raise ArgumentError, 'At least one of :attachments, :blocks, :text is required' if options[:attachments].nil? && options[:blocks].nil? && options[:text].nil? + raise ArgumentError, 'At least one of :attachments, :blocks, :text, :markdown_text is required' if options[:attachments].nil? && options[:blocks].nil? && options[:text].nil? && options[:markdown_text].nil? + raise ArgumentError, 'Exactly one of :text, :markdown_text is required' unless options[:text].nil? ^ options[:markdown_text].nil? options = encode_options_as_json(options, %i[attachments blocks metadata]) post('chat.scheduleMessage', options) end @@ -243,7 +246,7 @@ def chat_scheduleMessage(options = {}) # Starts a new streaming conversation. # # @option options [channel] :channel - # An encoded ID that represents a channel, private group, or DM. + # An encoded ID that represents a channel thread or DM. # @option options [string] :markdown_text # Accepts message text formatted in markdown. Limit this field to 12,000 characters. # @option options [string] :thread_ts @@ -306,7 +309,7 @@ def chat_stopStream(options = {}) # @option options [enum] :source # 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. # @option options [string] :metadata - # JSON object with entity_type and entity_payload fields, presented as a URL-encoded string. Either unfurls or metadata must be provided. + # JSON object with an entities field providing an array of Work Object entities. Either unfurls or metadata must be provided. # @see https://api.slack.com/methods/chat.unfurl # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/chat/chat.unfurl.json def chat_unfurl(options = {}) @@ -322,6 +325,8 @@ def chat_unfurl(options = {}) # Pass true to update the message as the authed user. Bot users in this context are considered authed users. # @option options [string] :attachments # A JSON-based array of structured attachments, presented as a URL-encoded string. + # @option options [string] :unfurled_attachments + # A JSON-based array of structured attachments, presented as a URL-encoded string. # @option options [string] :blocks # A JSON-based array of structured blocks, presented as a URL-encoded string. # @option options [string] :markdown_text @@ -347,9 +352,10 @@ def chat_unfurl(options = {}) def chat_update(options = {}) raise ArgumentError, 'Required arguments :channel missing' if options[:channel].nil? raise ArgumentError, 'Required arguments :ts missing' if options[:ts].nil? - raise ArgumentError, 'At least one of :attachments, :blocks, :text is required' if options[:attachments].nil? && options[:blocks].nil? && options[:text].nil? + raise ArgumentError, 'At least one of :attachments, :blocks, :text, :markdown_text is required' if options[:attachments].nil? && options[:blocks].nil? && options[:text].nil? && options[:markdown_text].nil? + raise ArgumentError, 'Exactly one of :text, :markdown_text is required' unless options[:text].nil? ^ options[:markdown_text].nil? options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel] - options = encode_options_as_json(options, %i[attachments blocks metadata]) + options = encode_options_as_json(options, %i[attachments unfurled_attachments blocks metadata]) post('chat.update', options) end end diff --git a/lib/slack/web/api/endpoints/users.rb b/lib/slack/web/api/endpoints/users.rb index 33709010..58e79f7f 100644 --- a/lib/slack/web/api/endpoints/users.rb +++ b/lib/slack/web/api/endpoints/users.rb @@ -7,7 +7,7 @@ module Api module Endpoints module Users # - # List conversations the calling user may access. + # List conversations the calling user is a member of. # # @option options [string] :cursor # Paginate through collections of data by setting the cursor parameter to a next_cursor attribute returned by a previous request's response_metadata. Default value fetches the first "page" of the collection. See pagination for more detail. diff --git a/lib/slack/web/api/errors.rb b/lib/slack/web/api/errors.rb index 7b7ce336..5dbc1376 100644 --- a/lib/slack/web/api/errors.rb +++ b/lib/slack/web/api/errors.rb @@ -27,6 +27,7 @@ class AppMissingActionUrl < SlackError; end class AppNotEligible < SlackError; end class AppNotFound < SlackError; end class AppNotHosted < SlackError; end + class AppNotSubscribed < SlackError; end class AppRestrictedOrgWide < SlackError; end class ApprovalInactive < SlackError; end class ApprovalNotFound < SlackError; end @@ -89,6 +90,7 @@ class CannotReplyToMessage < SlackError; end class CannotResetBot < SlackError; end class CannotResetPrimaryOwner < SlackError; end class CannotResolveAlias < SlackError; end + class CannotSetOrgAdminToRegularAtWorkspaceLevel < SlackError; end class CannotSetThisGuestToRegularAtTeamLevel < SlackError; end class CannotShareCrossWorkspaceChannel < SlackError; end class CannotShareMandatoryChannel < SlackError; end @@ -237,12 +239,14 @@ class FailedToRemoveGroupUsers < SlackError; end class FailedToRemoveUserFromWorkspace < SlackError; end class FailedToRenameEmoji < SlackError; end class FailedToSendInvite < SlackError; end + class FailedToSetAdminOnWorkspaces < SlackError; end class FailedToSetDefaultChannels < SlackError; end class FailedToSetDescription < SlackError; end class FailedToSetDiscoverability < SlackError; end class FailedToSetExpiration < SlackError; end class FailedToSetIcon < SlackError; end class FailedToSetName < SlackError; end + class FailedToSetOwnerOnWorkspaces < SlackError; end class FailedToSetUserToAdmin < SlackError; end class FailedToSetUserToOwner < SlackError; end class FailedToSetUserToRegular < SlackError; end @@ -265,9 +269,11 @@ class FileChannelRenameError < SlackError; end class FileCommentNotFound < SlackError; end class FileDeleted < SlackError; end class FileDeletingDisabled < SlackError; end + class FileIsDeleted < SlackError; end class FileNotFound < SlackError; end class FileNotShared < SlackError; end class FileNotYetAvailable < SlackError; end + class FileShareLimitReached < SlackError; end class FileUnderReview < SlackError; end class FileUpdateFailed < SlackError; end class FileUploadSizeRestricted < SlackError; end @@ -359,6 +365,8 @@ class InvalidOptionId < SlackError; end class InvalidOrgId < SlackError; end class InvalidParameters < SlackError; end class InvalidParentType < SlackError; end + class InvalidPermission < SlackError; end + class InvalidPermissionSet < SlackError; end class InvalidPermissionType < SlackError; end class InvalidPermissions < SlackError; end class InvalidPhoneNumber < SlackError; end @@ -446,11 +454,13 @@ class ListsDisabledUserTeam < SlackError; end class MalwareDetected < SlackError; end class ManagedChannelNotSupported < SlackError; end class MarkdownTextConflict < SlackError; end + class MaxFileSharingExceeded < SlackError; end class MemberAnalyticsDisabled < SlackError; end class MemberLimitExceeded < SlackError; end class MessageLimitExceeded < SlackError; end class MessageNotFound < SlackError; end class MessageNotInStreamingState < SlackError; end + class MessageNotOwnedByApp < SlackError; end class MessageTooLong < SlackError; end class MessagesTabDisabled < SlackError; end class MessagingProcessingFailed < SlackError; end @@ -612,7 +622,9 @@ class RequestAlreadyResolved < SlackError; end class RequestIdOrAppIdIsRequired < SlackError; end class RequestIdRequiredForCustomIntegrations < SlackError; end class RequestTimeout < SlackError; end + class RequiredVisibility < SlackError; end class ReservedName < SlackError; end + class ReservedUsername < SlackError; end class ResizedButStillTooLarge < SlackError; end class RestrictedAction < SlackError; end class RestrictedActionNonThreadableChannel < SlackError; end @@ -651,6 +663,7 @@ class TargetTeamNotOnOrg < SlackError; end class TeamAddedToOrg < SlackError; end class TeamIdOrOrgRequired < SlackError; end class TeamIdRequiredForEnterprise < SlackError; end + class TeamLimitExceeded < SlackError; end class TeamNotConnected < SlackError; end class TeamNotFound < SlackError; end class TeamNotOnEnterprise < SlackError; end @@ -698,6 +711,7 @@ class UnableToDelete < SlackError; end class UnableToFetchCustomEmojis < SlackError; end class UnableToLinkIdpGroupAndChannel < SlackError; end class UnableToProcessPostRequest < SlackError; end + class UnableToShareFiles < SlackError; end class UnableToUnlinkIdpGroupAndChannel < SlackError; end class UnableToUpdateExistingSessions < SlackError; end class UneditableColumn < SlackError; end @@ -775,6 +789,7 @@ class WorkflowsExportCsvNotEnabled < SlackError; end 'app_not_eligible' => AppNotEligible, 'app_not_found' => AppNotFound, 'app_not_hosted' => AppNotHosted, + 'app_not_subscribed' => AppNotSubscribed, 'app_restricted_org_wide' => AppRestrictedOrgWide, 'approval_inactive' => ApprovalInactive, 'approval_not_found' => ApprovalNotFound, @@ -837,6 +852,7 @@ class WorkflowsExportCsvNotEnabled < SlackError; end 'cannot_reset_bot' => CannotResetBot, 'cannot_reset_primary_owner' => CannotResetPrimaryOwner, 'cannot_resolve_alias' => CannotResolveAlias, + 'cannot_set_org_admin_to_regular_at_workspace_level' => CannotSetOrgAdminToRegularAtWorkspaceLevel, 'cannot_set_this_guest_to_regular_at_team_level' => CannotSetThisGuestToRegularAtTeamLevel, 'cannot_share_cross_workspace_channel' => CannotShareCrossWorkspaceChannel, 'cannot_share_mandatory_channel' => CannotShareMandatoryChannel, @@ -985,12 +1001,14 @@ class WorkflowsExportCsvNotEnabled < SlackError; end 'failed_to_remove_user_from_workspace' => FailedToRemoveUserFromWorkspace, 'failed_to_rename_emoji' => FailedToRenameEmoji, 'failed_to_send_invite' => FailedToSendInvite, + 'failed_to_set_admin_on_workspaces' => FailedToSetAdminOnWorkspaces, 'failed_to_set_default_channels' => FailedToSetDefaultChannels, 'failed_to_set_description' => FailedToSetDescription, 'failed_to_set_discoverability' => FailedToSetDiscoverability, 'failed_to_set_expiration' => FailedToSetExpiration, 'failed_to_set_icon' => FailedToSetIcon, 'failed_to_set_name' => FailedToSetName, + 'failed_to_set_owner_on_workspaces' => FailedToSetOwnerOnWorkspaces, 'failed_to_set_user_to_admin' => FailedToSetUserToAdmin, 'failed_to_set_user_to_owner' => FailedToSetUserToOwner, 'failed_to_set_user_to_regular' => FailedToSetUserToRegular, @@ -1013,9 +1031,11 @@ class WorkflowsExportCsvNotEnabled < SlackError; end 'file_comment_not_found' => FileCommentNotFound, 'file_deleted' => FileDeleted, 'file_deleting_disabled' => FileDeletingDisabled, + 'file_is_deleted' => FileIsDeleted, 'file_not_found' => FileNotFound, 'file_not_shared' => FileNotShared, 'file_not_yet_available' => FileNotYetAvailable, + 'file_share_limit_reached' => FileShareLimitReached, 'file_under_review' => FileUnderReview, 'file_update_failed' => FileUpdateFailed, 'file_upload_size_restricted' => FileUploadSizeRestricted, @@ -1107,6 +1127,8 @@ class WorkflowsExportCsvNotEnabled < SlackError; end 'invalid_org_id' => InvalidOrgId, 'invalid_parameters' => InvalidParameters, 'invalid_parent_type' => InvalidParentType, + 'invalid_permission' => InvalidPermission, + 'invalid_permission_set' => InvalidPermissionSet, 'invalid_permission_type' => InvalidPermissionType, 'invalid_permissions' => InvalidPermissions, 'invalid_phone_number' => InvalidPhoneNumber, @@ -1194,11 +1216,13 @@ class WorkflowsExportCsvNotEnabled < SlackError; end 'malware_detected' => MalwareDetected, 'managed_channel_not_supported' => ManagedChannelNotSupported, 'markdown_text_conflict' => MarkdownTextConflict, + 'max_file_sharing_exceeded' => MaxFileSharingExceeded, 'member_analytics_disabled' => MemberAnalyticsDisabled, 'member_limit_exceeded' => MemberLimitExceeded, 'message_limit_exceeded' => MessageLimitExceeded, 'message_not_found' => MessageNotFound, 'message_not_in_streaming_state' => MessageNotInStreamingState, + 'message_not_owned_by_app' => MessageNotOwnedByApp, 'message_too_long' => MessageTooLong, 'messages_tab_disabled' => MessagesTabDisabled, 'messaging_processing_failed' => MessagingProcessingFailed, @@ -1360,7 +1384,9 @@ class WorkflowsExportCsvNotEnabled < SlackError; end 'request_id_or_app_id_is_required' => RequestIdOrAppIdIsRequired, 'request_id_required_for_custom_integrations' => RequestIdRequiredForCustomIntegrations, 'request_timeout' => RequestTimeout, + 'required_visibility' => RequiredVisibility, 'reserved_name' => ReservedName, + 'reserved_username' => ReservedUsername, 'resized_but_still_too_large' => ResizedButStillTooLarge, 'restricted_action' => RestrictedAction, 'restricted_action_non_threadable_channel' => RestrictedActionNonThreadableChannel, @@ -1399,6 +1425,7 @@ class WorkflowsExportCsvNotEnabled < SlackError; end 'team_added_to_org' => TeamAddedToOrg, 'team_id_or_org_required' => TeamIdOrOrgRequired, 'team_id_required_for_enterprise' => TeamIdRequiredForEnterprise, + 'team_limit_exceeded' => TeamLimitExceeded, 'team_not_connected' => TeamNotConnected, 'team_not_found' => TeamNotFound, 'team_not_on_enterprise' => TeamNotOnEnterprise, @@ -1446,6 +1473,7 @@ class WorkflowsExportCsvNotEnabled < SlackError; end 'unable_to_fetch_custom_emojis' => UnableToFetchCustomEmojis, 'unable_to_link_idp_group_and_channel' => UnableToLinkIdpGroupAndChannel, 'unable_to_process_post_request' => UnableToProcessPostRequest, + 'unable_to_share_files' => UnableToShareFiles, 'unable_to_unlink_idp_group_and_channel' => UnableToUnlinkIdpGroupAndChannel, 'unable_to_update_existing_sessions' => UnableToUpdateExistingSessions, 'uneditable_column' => UneditableColumn, diff --git a/lib/slack/web/api/slack-api-ref b/lib/slack/web/api/slack-api-ref index 32757867..171609f7 160000 --- a/lib/slack/web/api/slack-api-ref +++ b/lib/slack/web/api/slack-api-ref @@ -1 +1 @@ -Subproject commit 32757867a5d54838b71403fbf45bc4c081abdf23 +Subproject commit 171609f75039241987e0940217d101a3c1122e47 diff --git a/spec/slack/web/api/endpoints/admin_conversations_spec.rb b/spec/slack/web/api/endpoints/admin_conversations_spec.rb index c976da99..c9325959 100644 --- a/spec/slack/web/api/endpoints/admin_conversations_spec.rb +++ b/spec/slack/web/api/endpoints/admin_conversations_spec.rb @@ -28,6 +28,14 @@ expect { client.admin_conversations_bulkMove(target_team_id: %q[]) }.to raise_error ArgumentError, /Required arguments :channel_ids missing/ end end + context 'admin.conversations_bulkSetExcludeFromSlackAi' do + it 'requires channel_ids' do + expect { client.admin_conversations_bulkSetExcludeFromSlackAi(exclude: %q[true]) }.to raise_error ArgumentError, /Required arguments :channel_ids missing/ + end + it 'requires exclude' do + expect { client.admin_conversations_bulkSetExcludeFromSlackAi(channel_ids: %q[["C12345", "C98765"]]) }.to raise_error ArgumentError, /Required arguments :exclude missing/ + end + end context 'admin.conversations_convertToPrivate' do it 'requires channel_id' do expect { client.admin_conversations_convertToPrivate }.to raise_error ArgumentError, /Required arguments :channel_id missing/ diff --git a/spec/slack/web/api/endpoints/admin_functions_permissions_spec.rb b/spec/slack/web/api/endpoints/admin_functions_permissions_spec.rb index 0209eda4..85773ec2 100644 --- a/spec/slack/web/api/endpoints/admin_functions_permissions_spec.rb +++ b/spec/slack/web/api/endpoints/admin_functions_permissions_spec.rb @@ -12,10 +12,7 @@ end context 'admin.functions.permissions_set' do it 'requires function_id' do - expect { client.admin_functions_permissions_set(visibility: %q[]) }.to raise_error ArgumentError, /Required arguments :function_id missing/ - end - it 'requires visibility' do - expect { client.admin_functions_permissions_set(function_id: %q[]) }.to raise_error ArgumentError, /Required arguments :visibility missing/ + expect { client.admin_functions_permissions_set }.to raise_error ArgumentError, /Required arguments :function_id missing/ end end end diff --git a/spec/slack/web/api/endpoints/admin_users_spec.rb b/spec/slack/web/api/endpoints/admin_users_spec.rb index 89c66dd8..96747ff4 100644 --- a/spec/slack/web/api/endpoints/admin_users_spec.rb +++ b/spec/slack/web/api/endpoints/admin_users_spec.rb @@ -37,7 +37,7 @@ expect { client.admin_users_setAdmin(user_id: %q[W12345678]) }.to raise_error ArgumentError, /Required arguments :team_id missing/ end it 'requires user_id' do - expect { client.admin_users_setAdmin(team_id: %q[]) }.to raise_error ArgumentError, /Required arguments :user_id missing/ + expect { client.admin_users_setAdmin(team_id: %q[T12345678]) }.to raise_error ArgumentError, /Required arguments :user_id missing/ end end context 'admin.users_setExpiration' do @@ -50,10 +50,10 @@ end context 'admin.users_setOwner' do it 'requires team_id' do - expect { client.admin_users_setOwner(user_id: %q[]) }.to raise_error ArgumentError, /Required arguments :team_id missing/ + expect { client.admin_users_setOwner(user_id: %q[W12345678]) }.to raise_error ArgumentError, /Required arguments :team_id missing/ end it 'requires user_id' do - expect { client.admin_users_setOwner(team_id: %q[]) }.to raise_error ArgumentError, /Required arguments :user_id missing/ + expect { client.admin_users_setOwner(team_id: %q[T12345678]) }.to raise_error ArgumentError, /Required arguments :user_id missing/ end end context 'admin.users_setRegular' do @@ -61,7 +61,7 @@ expect { client.admin_users_setRegular(user_id: %q[W12345678]) }.to raise_error ArgumentError, /Required arguments :team_id missing/ end it 'requires user_id' do - expect { client.admin_users_setRegular(team_id: %q[]) }.to raise_error ArgumentError, /Required arguments :user_id missing/ + expect { client.admin_users_setRegular(team_id: %q[T12345678]) }.to raise_error ArgumentError, /Required arguments :user_id missing/ end end end diff --git a/spec/slack/web/api/endpoints/admin_workflows_triggers_types_permissions_spec.rb b/spec/slack/web/api/endpoints/admin_workflows_triggers_types_permissions_spec.rb index 4dd119a6..9a2ffe3f 100644 --- a/spec/slack/web/api/endpoints/admin_workflows_triggers_types_permissions_spec.rb +++ b/spec/slack/web/api/endpoints/admin_workflows_triggers_types_permissions_spec.rb @@ -12,10 +12,7 @@ end context 'admin.workflows.triggers.types.permissions_set' do it 'requires id' do - expect { client.admin_workflows_triggers_types_permissions_set(visibility: %q[]) }.to raise_error ArgumentError, /Required arguments :id missing/ - end - it 'requires visibility' do - expect { client.admin_workflows_triggers_types_permissions_set(id: %q[['FTT01', 'FTT02', 'FTT03']]) }.to raise_error ArgumentError, /Required arguments :visibility missing/ + expect { client.admin_workflows_triggers_types_permissions_set }.to raise_error ArgumentError, /Required arguments :id missing/ end end end diff --git a/spec/slack/web/api/endpoints/apps_user_connection_spec.rb b/spec/slack/web/api/endpoints/apps_user_connection_spec.rb new file mode 100644 index 00000000..01684ac1 --- /dev/null +++ b/spec/slack/web/api/endpoints/apps_user_connection_spec.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true +# This file was auto-generated by lib/tasks/web.rake + +require 'spec_helper' + +RSpec.describe Slack::Web::Api::Endpoints::AppsUserConnection do + let(:client) { Slack::Web::Client.new } + context 'apps.user.connection_update' do + it 'requires user_id' do + expect { client.apps_user_connection_update(status: %q[connected]) }.to raise_error ArgumentError, /Required arguments :user_id missing/ + end + it 'requires status' do + expect { client.apps_user_connection_update(user_id: %q[U12345678]) }.to raise_error ArgumentError, /Required arguments :status missing/ + end + end +end diff --git a/spec/slack/web/api/endpoints/chat_spec.rb b/spec/slack/web/api/endpoints/chat_spec.rb index 81b4c7d7..ee6bedf9 100644 --- a/spec/slack/web/api/endpoints/chat_spec.rb +++ b/spec/slack/web/api/endpoints/chat_spec.rb @@ -58,12 +58,12 @@ end context 'chat_postEphemeral' do it 'requires channel' do - expect { client.chat_postEphemeral(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], user: %q[U0BPQUNTA]) }.to raise_error ArgumentError, /Required arguments :channel missing/ + expect { client.chat_postEphemeral(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], text: %q[Hello world], user: %q[U0BPQUNTA]) }.to raise_error ArgumentError, /Required arguments :channel missing/ end it 'requires user' do - expect { client.chat_postEphemeral(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[]) }.to raise_error ArgumentError, /Required arguments :user missing/ + expect { client.chat_postEphemeral(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[], text: %q[Hello world]) }.to raise_error ArgumentError, /Required arguments :user missing/ end - it 'requires one of attachments, blocks, text' do + it 'requires one of attachments, blocks, text, markdown_text' do expect { client.chat_postEphemeral(channel: %q[], user: %q[U0BPQUNTA]) }.to raise_error ArgumentError, /At least one of/ expect(client).to receive(:post).with('chat.postEphemeral', {attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[], user: %q[U0BPQUNTA]}) @@ -75,28 +75,63 @@ expect(client).to receive(:post).with('chat.postEphemeral', {text: %q[Hello world], channel: %q[], user: %q[U0BPQUNTA]}) client.chat_postEphemeral(text: %q[Hello world], channel: %q[], user: %q[U0BPQUNTA]) + expect(client).to receive(:post).with('chat.postEphemeral', {markdown_text: %q[**This is bold text**], channel: %q[], user: %q[U0BPQUNTA]}) + client.chat_postEphemeral(markdown_text: %q[**This is bold text**], channel: %q[], user: %q[U0BPQUNTA]) + 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[], user: %q[U0BPQUNTA]}) client.chat_postEphemeral(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], channel: %q[], user: %q[U0BPQUNTA]) expect(client).to receive(:post).with('chat.postEphemeral', {attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], text: %q[Hello world], channel: %q[], user: %q[U0BPQUNTA]}) client.chat_postEphemeral(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], text: %q[Hello world], channel: %q[], user: %q[U0BPQUNTA]) + expect(client).to receive(:post).with('chat.postEphemeral', {attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], markdown_text: %q[**This is bold text**], channel: %q[], user: %q[U0BPQUNTA]}) + client.chat_postEphemeral(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], markdown_text: %q[**This is bold text**], channel: %q[], user: %q[U0BPQUNTA]) + 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[], user: %q[U0BPQUNTA]}) client.chat_postEphemeral(blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], text: %q[Hello world], channel: %q[], user: %q[U0BPQUNTA]) + expect(client).to receive(:post).with('chat.postEphemeral', {blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], markdown_text: %q[**This is bold text**], channel: %q[], user: %q[U0BPQUNTA]}) + client.chat_postEphemeral(blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], markdown_text: %q[**This is bold text**], channel: %q[], user: %q[U0BPQUNTA]) + + expect(client).to receive(:post).with('chat.postEphemeral', {text: %q[Hello world], markdown_text: %q[**This is bold text**], channel: %q[], user: %q[U0BPQUNTA]}) + client.chat_postEphemeral(text: %q[Hello world], markdown_text: %q[**This is bold text**], channel: %q[], user: %q[U0BPQUNTA]) + 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[], user: %q[U0BPQUNTA]}) 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[], user: %q[U0BPQUNTA]) + + 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"}}]], markdown_text: %q[**This is bold text**], channel: %q[], user: %q[U0BPQUNTA]}) + client.chat_postEphemeral(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], markdown_text: %q[**This is bold text**], channel: %q[], user: %q[U0BPQUNTA]) + + expect(client).to receive(:post).with('chat.postEphemeral', {attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], text: %q[Hello world], markdown_text: %q[**This is bold text**], channel: %q[], user: %q[U0BPQUNTA]}) + client.chat_postEphemeral(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], text: %q[Hello world], markdown_text: %q[**This is bold text**], channel: %q[], user: %q[U0BPQUNTA]) + + expect(client).to receive(:post).with('chat.postEphemeral', {blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], text: %q[Hello world], markdown_text: %q[**This is bold text**], channel: %q[], user: %q[U0BPQUNTA]}) + client.chat_postEphemeral(blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], text: %q[Hello world], markdown_text: %q[**This is bold text**], channel: %q[], user: %q[U0BPQUNTA]) + + 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], markdown_text: %q[**This is bold text**], channel: %q[], user: %q[U0BPQUNTA]}) + 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], markdown_text: %q[**This is bold text**], channel: %q[], user: %q[U0BPQUNTA]) + end + it 'requires one of text, markdown_text' do + expect { client.chat_postEphemeral(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[], user: %q[U0BPQUNTA]) }.to raise_error ArgumentError, /Exactly one of/ + + expect(client).to receive(:post).with('chat.postEphemeral', {text: %q[Hello world], attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[], user: %q[U0BPQUNTA]}) + client.chat_postEphemeral(text: %q[Hello world], attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[], user: %q[U0BPQUNTA]) + + expect(client).to receive(:post).with('chat.postEphemeral', {markdown_text: %q[**This is bold text**], attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[], user: %q[U0BPQUNTA]}) + client.chat_postEphemeral(markdown_text: %q[**This is bold text**], attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[], user: %q[U0BPQUNTA]) + + expect { client.chat_postEphemeral(text: %q[Hello world], markdown_text: %q[**This is bold text**], attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[], user: %q[U0BPQUNTA]) }.to raise_error ArgumentError, /Exactly one of/ end it 'encodes attachments, blocks as json' do - expect(client).to receive(:post).with('chat.postEphemeral', {attachments: %q[{"data":["data"]}], channel: %q[], user: %q[U0BPQUNTA], blocks: %q[{"data":["data"]}]}) - client.chat_postEphemeral(attachments: {:data=>["data"]}, channel: %q[], user: %q[U0BPQUNTA], blocks: {:data=>["data"]}) + expect(client).to receive(:post).with('chat.postEphemeral', {attachments: %q[{"data":["data"]}], channel: %q[], text: %q[Hello world], user: %q[U0BPQUNTA], blocks: %q[{"data":["data"]}]}) + client.chat_postEphemeral(attachments: {:data=>["data"]}, channel: %q[], text: %q[Hello world], user: %q[U0BPQUNTA], blocks: {:data=>["data"]}) end end context 'chat_postMessage' do it 'requires channel' do - expect { client.chat_postMessage(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]]) }.to raise_error ArgumentError, /Required arguments :channel missing/ + expect { client.chat_postMessage(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], text: %q[Hello world]) }.to raise_error ArgumentError, /Required arguments :channel missing/ end - it 'requires one of attachments, blocks, text' do + it 'requires one of attachments, blocks, text, markdown_text' do expect { client.chat_postMessage(channel: %q[]) }.to raise_error ArgumentError, /At least one of/ expect(client).to receive(:post).with('chat.postMessage', {attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[]}) @@ -108,31 +143,66 @@ expect(client).to receive(:post).with('chat.postMessage', {text: %q[Hello world], channel: %q[]}) client.chat_postMessage(text: %q[Hello world], channel: %q[]) + expect(client).to receive(:post).with('chat.postMessage', {markdown_text: %q[**This is bold text**], channel: %q[]}) + client.chat_postMessage(markdown_text: %q[**This is bold text**], channel: %q[]) + expect(client).to receive(:post).with('chat.postMessage', {attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], channel: %q[]}) client.chat_postMessage(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], channel: %q[]) expect(client).to receive(:post).with('chat.postMessage', {attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], text: %q[Hello world], channel: %q[]}) client.chat_postMessage(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], text: %q[Hello world], channel: %q[]) + expect(client).to receive(:post).with('chat.postMessage', {attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], markdown_text: %q[**This is bold text**], channel: %q[]}) + client.chat_postMessage(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], markdown_text: %q[**This is bold text**], channel: %q[]) + expect(client).to receive(:post).with('chat.postMessage', {blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], text: %q[Hello world], channel: %q[]}) client.chat_postMessage(blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], text: %q[Hello world], channel: %q[]) + expect(client).to receive(:post).with('chat.postMessage', {blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], markdown_text: %q[**This is bold text**], channel: %q[]}) + client.chat_postMessage(blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], markdown_text: %q[**This is bold text**], channel: %q[]) + + expect(client).to receive(:post).with('chat.postMessage', {text: %q[Hello world], markdown_text: %q[**This is bold text**], channel: %q[]}) + client.chat_postMessage(text: %q[Hello world], markdown_text: %q[**This is bold text**], channel: %q[]) + expect(client).to receive(:post).with('chat.postMessage', {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[]}) client.chat_postMessage(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[]) + + expect(client).to receive(:post).with('chat.postMessage', {attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], markdown_text: %q[**This is bold text**], channel: %q[]}) + client.chat_postMessage(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], markdown_text: %q[**This is bold text**], channel: %q[]) + + expect(client).to receive(:post).with('chat.postMessage', {attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], text: %q[Hello world], markdown_text: %q[**This is bold text**], channel: %q[]}) + client.chat_postMessage(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], text: %q[Hello world], markdown_text: %q[**This is bold text**], channel: %q[]) + + expect(client).to receive(:post).with('chat.postMessage', {blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], text: %q[Hello world], markdown_text: %q[**This is bold text**], channel: %q[]}) + client.chat_postMessage(blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], text: %q[Hello world], markdown_text: %q[**This is bold text**], channel: %q[]) + + expect(client).to receive(:post).with('chat.postMessage', {attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], text: %q[Hello world], markdown_text: %q[**This is bold text**], channel: %q[]}) + client.chat_postMessage(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], text: %q[Hello world], markdown_text: %q[**This is bold text**], channel: %q[]) + end + it 'requires one of text, markdown_text' do + expect { client.chat_postMessage(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[]) }.to raise_error ArgumentError, /Exactly one of/ + + expect(client).to receive(:post).with('chat.postMessage', {text: %q[Hello world], attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[]}) + client.chat_postMessage(text: %q[Hello world], attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[]) + + expect(client).to receive(:post).with('chat.postMessage', {markdown_text: %q[**This is bold text**], attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[]}) + client.chat_postMessage(markdown_text: %q[**This is bold text**], attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[]) + + expect { client.chat_postMessage(text: %q[Hello world], markdown_text: %q[**This is bold text**], attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[]) }.to raise_error ArgumentError, /Exactly one of/ end it 'encodes attachments, blocks, metadata as json' do - expect(client).to receive(:post).with('chat.postMessage', {attachments: %q[{"data":["data"]}], channel: %q[], blocks: %q[{"data":["data"]}], metadata: %q[{"data":["data"]}]}) - client.chat_postMessage(attachments: {:data=>["data"]}, channel: %q[], blocks: {:data=>["data"]}, metadata: {:data=>["data"]}) + expect(client).to receive(:post).with('chat.postMessage', {attachments: %q[{"data":["data"]}], channel: %q[], text: %q[Hello world], blocks: %q[{"data":["data"]}], metadata: %q[{"data":["data"]}]}) + client.chat_postMessage(attachments: {:data=>["data"]}, channel: %q[], text: %q[Hello world], blocks: {:data=>["data"]}, metadata: {:data=>["data"]}) end end context 'chat_scheduleMessage' do it 'requires channel' do - expect { client.chat_scheduleMessage(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], post_at: %q[299876400]) }.to raise_error ArgumentError, /Required arguments :channel missing/ + expect { client.chat_scheduleMessage(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], post_at: %q[299876400], text: %q[Hello world]) }.to raise_error ArgumentError, /Required arguments :channel missing/ end it 'requires post_at' do - expect { client.chat_scheduleMessage(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[]) }.to raise_error ArgumentError, /Required arguments :post_at missing/ + expect { client.chat_scheduleMessage(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[], text: %q[Hello world]) }.to raise_error ArgumentError, /Required arguments :post_at missing/ end - it 'requires one of attachments, blocks, text' do + it 'requires one of attachments, blocks, text, markdown_text' do expect { client.chat_scheduleMessage(channel: %q[], post_at: %q[299876400]) }.to raise_error ArgumentError, /At least one of/ expect(client).to receive(:post).with('chat.scheduleMessage', {attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[], post_at: %q[299876400]}) @@ -144,26 +214,61 @@ expect(client).to receive(:post).with('chat.scheduleMessage', {text: %q[Hello world], channel: %q[], post_at: %q[299876400]}) client.chat_scheduleMessage(text: %q[Hello world], channel: %q[], post_at: %q[299876400]) + expect(client).to receive(:post).with('chat.scheduleMessage', {markdown_text: %q[**This is bold text**], channel: %q[], post_at: %q[299876400]}) + client.chat_scheduleMessage(markdown_text: %q[**This is bold text**], channel: %q[], post_at: %q[299876400]) + 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[], post_at: %q[299876400]}) client.chat_scheduleMessage(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], channel: %q[], post_at: %q[299876400]) expect(client).to receive(:post).with('chat.scheduleMessage', {attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], text: %q[Hello world], channel: %q[], post_at: %q[299876400]}) client.chat_scheduleMessage(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], text: %q[Hello world], channel: %q[], post_at: %q[299876400]) + expect(client).to receive(:post).with('chat.scheduleMessage', {attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], markdown_text: %q[**This is bold text**], channel: %q[], post_at: %q[299876400]}) + client.chat_scheduleMessage(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], markdown_text: %q[**This is bold text**], channel: %q[], post_at: %q[299876400]) + 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[], post_at: %q[299876400]}) client.chat_scheduleMessage(blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], text: %q[Hello world], channel: %q[], post_at: %q[299876400]) + expect(client).to receive(:post).with('chat.scheduleMessage', {blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], markdown_text: %q[**This is bold text**], channel: %q[], post_at: %q[299876400]}) + client.chat_scheduleMessage(blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], markdown_text: %q[**This is bold text**], channel: %q[], post_at: %q[299876400]) + + expect(client).to receive(:post).with('chat.scheduleMessage', {text: %q[Hello world], markdown_text: %q[**This is bold text**], channel: %q[], post_at: %q[299876400]}) + client.chat_scheduleMessage(text: %q[Hello world], markdown_text: %q[**This is bold text**], channel: %q[], post_at: %q[299876400]) + 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[], post_at: %q[299876400]}) 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[], post_at: %q[299876400]) + + 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"}}]], markdown_text: %q[**This is bold text**], channel: %q[], post_at: %q[299876400]}) + client.chat_scheduleMessage(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], markdown_text: %q[**This is bold text**], channel: %q[], post_at: %q[299876400]) + + expect(client).to receive(:post).with('chat.scheduleMessage', {attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], text: %q[Hello world], markdown_text: %q[**This is bold text**], channel: %q[], post_at: %q[299876400]}) + client.chat_scheduleMessage(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], text: %q[Hello world], markdown_text: %q[**This is bold text**], channel: %q[], post_at: %q[299876400]) + + expect(client).to receive(:post).with('chat.scheduleMessage', {blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], text: %q[Hello world], markdown_text: %q[**This is bold text**], channel: %q[], post_at: %q[299876400]}) + client.chat_scheduleMessage(blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], text: %q[Hello world], markdown_text: %q[**This is bold text**], channel: %q[], post_at: %q[299876400]) + + 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], markdown_text: %q[**This is bold text**], channel: %q[], post_at: %q[299876400]}) + 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], markdown_text: %q[**This is bold text**], channel: %q[], post_at: %q[299876400]) + end + it 'requires one of text, markdown_text' do + expect { client.chat_scheduleMessage(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[], post_at: %q[299876400]) }.to raise_error ArgumentError, /Exactly one of/ + + expect(client).to receive(:post).with('chat.scheduleMessage', {text: %q[Hello world], attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[], post_at: %q[299876400]}) + client.chat_scheduleMessage(text: %q[Hello world], attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[], post_at: %q[299876400]) + + expect(client).to receive(:post).with('chat.scheduleMessage', {markdown_text: %q[**This is bold text**], attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[], post_at: %q[299876400]}) + client.chat_scheduleMessage(markdown_text: %q[**This is bold text**], attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[], post_at: %q[299876400]) + + expect { client.chat_scheduleMessage(text: %q[Hello world], markdown_text: %q[**This is bold text**], attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[], post_at: %q[299876400]) }.to raise_error ArgumentError, /Exactly one of/ end it 'encodes attachments, blocks, metadata as json' do - expect(client).to receive(:post).with('chat.scheduleMessage', {attachments: %q[{"data":["data"]}], channel: %q[], post_at: %q[299876400], blocks: %q[{"data":["data"]}], metadata: %q[{"data":["data"]}]}) - client.chat_scheduleMessage(attachments: {:data=>["data"]}, channel: %q[], post_at: %q[299876400], blocks: {:data=>["data"]}, metadata: {:data=>["data"]}) + expect(client).to receive(:post).with('chat.scheduleMessage', {attachments: %q[{"data":["data"]}], channel: %q[], post_at: %q[299876400], text: %q[Hello world], blocks: %q[{"data":["data"]}], metadata: %q[{"data":["data"]}]}) + client.chat_scheduleMessage(attachments: {:data=>["data"]}, channel: %q[], post_at: %q[299876400], text: %q[Hello world], blocks: {:data=>["data"]}, metadata: {:data=>["data"]}) end end context 'chat_startStream' do it 'requires channel' do - expect { client.chat_startStream(thread_ts: %q[1721609600]) }.to raise_error ArgumentError, /Required arguments :channel missing/ + expect { client.chat_startStream(thread_ts: %q[1721609600.123456]) }.to raise_error ArgumentError, /Required arguments :channel missing/ end it 'requires thread_ts' do expect { client.chat_startStream(channel: %q[]) }.to raise_error ArgumentError, /Required arguments :thread_ts missing/ @@ -189,12 +294,12 @@ end context 'chat_update' do it 'requires channel' do - expect { client.chat_update(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], ts: %q["1405894322.002768"]) }.to raise_error ArgumentError, /Required arguments :channel missing/ + expect { client.chat_update(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], text: %q[Hello world], ts: %q["1405894322.002768"]) }.to raise_error ArgumentError, /Required arguments :channel missing/ end it 'requires ts' do - expect { client.chat_update(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[]) }.to raise_error ArgumentError, /Required arguments :ts missing/ + expect { client.chat_update(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[], text: %q[Hello world]) }.to raise_error ArgumentError, /Required arguments :ts missing/ end - it 'requires one of attachments, blocks, text' do + it 'requires one of attachments, blocks, text, markdown_text' do expect { client.chat_update(channel: %q[], ts: %q["1405894322.002768"]) }.to raise_error ArgumentError, /At least one of/ expect(client).to receive(:post).with('chat.update', {attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[], ts: %q["1405894322.002768"]}) @@ -206,21 +311,56 @@ expect(client).to receive(:post).with('chat.update', {text: %q[Hello world], channel: %q[], ts: %q["1405894322.002768"]}) client.chat_update(text: %q[Hello world], channel: %q[], ts: %q["1405894322.002768"]) + expect(client).to receive(:post).with('chat.update', {markdown_text: %q[**This is bold text**], channel: %q[], ts: %q["1405894322.002768"]}) + client.chat_update(markdown_text: %q[**This is bold text**], channel: %q[], ts: %q["1405894322.002768"]) + 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[], ts: %q["1405894322.002768"]}) client.chat_update(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], channel: %q[], ts: %q["1405894322.002768"]) expect(client).to receive(:post).with('chat.update', {attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], text: %q[Hello world], channel: %q[], ts: %q["1405894322.002768"]}) client.chat_update(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], text: %q[Hello world], channel: %q[], ts: %q["1405894322.002768"]) + expect(client).to receive(:post).with('chat.update', {attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], markdown_text: %q[**This is bold text**], channel: %q[], ts: %q["1405894322.002768"]}) + client.chat_update(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], markdown_text: %q[**This is bold text**], channel: %q[], ts: %q["1405894322.002768"]) + 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[], ts: %q["1405894322.002768"]}) client.chat_update(blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], text: %q[Hello world], channel: %q[], ts: %q["1405894322.002768"]) + expect(client).to receive(:post).with('chat.update', {blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], markdown_text: %q[**This is bold text**], channel: %q[], ts: %q["1405894322.002768"]}) + client.chat_update(blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], markdown_text: %q[**This is bold text**], channel: %q[], ts: %q["1405894322.002768"]) + + expect(client).to receive(:post).with('chat.update', {text: %q[Hello world], markdown_text: %q[**This is bold text**], channel: %q[], ts: %q["1405894322.002768"]}) + client.chat_update(text: %q[Hello world], markdown_text: %q[**This is bold text**], channel: %q[], ts: %q["1405894322.002768"]) + 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[], ts: %q["1405894322.002768"]}) 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[], ts: %q["1405894322.002768"]) + + 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"}}]], markdown_text: %q[**This is bold text**], channel: %q[], ts: %q["1405894322.002768"]}) + client.chat_update(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], markdown_text: %q[**This is bold text**], channel: %q[], ts: %q["1405894322.002768"]) + + expect(client).to receive(:post).with('chat.update', {attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], text: %q[Hello world], markdown_text: %q[**This is bold text**], channel: %q[], ts: %q["1405894322.002768"]}) + client.chat_update(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], text: %q[Hello world], markdown_text: %q[**This is bold text**], channel: %q[], ts: %q["1405894322.002768"]) + + expect(client).to receive(:post).with('chat.update', {blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], text: %q[Hello world], markdown_text: %q[**This is bold text**], channel: %q[], ts: %q["1405894322.002768"]}) + client.chat_update(blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], text: %q[Hello world], markdown_text: %q[**This is bold text**], channel: %q[], ts: %q["1405894322.002768"]) + + 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], markdown_text: %q[**This is bold text**], channel: %q[], ts: %q["1405894322.002768"]}) + 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], markdown_text: %q[**This is bold text**], channel: %q[], ts: %q["1405894322.002768"]) end - it 'encodes attachments, blocks, metadata as json' do - expect(client).to receive(:post).with('chat.update', {attachments: %q[{"data":["data"]}], channel: %q[], ts: %q["1405894322.002768"], blocks: %q[{"data":["data"]}], metadata: %q[{"data":["data"]}]}) - client.chat_update(attachments: {:data=>["data"]}, channel: %q[], ts: %q["1405894322.002768"], blocks: {:data=>["data"]}, metadata: {:data=>["data"]}) + it 'requires one of text, markdown_text' do + expect { client.chat_update(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[], ts: %q["1405894322.002768"]) }.to raise_error ArgumentError, /Exactly one of/ + + expect(client).to receive(:post).with('chat.update', {text: %q[Hello world], attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[], ts: %q["1405894322.002768"]}) + client.chat_update(text: %q[Hello world], attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[], ts: %q["1405894322.002768"]) + + expect(client).to receive(:post).with('chat.update', {markdown_text: %q[**This is bold text**], attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[], ts: %q["1405894322.002768"]}) + client.chat_update(markdown_text: %q[**This is bold text**], attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[], ts: %q["1405894322.002768"]) + + expect { client.chat_update(text: %q[Hello world], markdown_text: %q[**This is bold text**], attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[], ts: %q["1405894322.002768"]) }.to raise_error ArgumentError, /Exactly one of/ + end + it 'encodes attachments, unfurled_attachments, blocks, metadata as json' do + expect(client).to receive(:post).with('chat.update', {attachments: %q[{"data":["data"]}], channel: %q[], text: %q[Hello world], ts: %q["1405894322.002768"], unfurled_attachments: %q[{"data":["data"]}], blocks: %q[{"data":["data"]}], metadata: %q[{"data":["data"]}]}) + client.chat_update(attachments: {:data=>["data"]}, channel: %q[], text: %q[Hello world], ts: %q["1405894322.002768"], unfurled_attachments: {:data=>["data"]}, blocks: {:data=>["data"]}, metadata: {:data=>["data"]}) end end end