From 23389b1bf44c8e9c707d734fde4aaa43a7547cc2 Mon Sep 17 00:00:00 2001 From: "Daniel (dB.) Doubrovkine" Date: Wed, 1 Nov 2023 23:26:54 -0400 Subject: [PATCH 1/3] Fix: remove unnecessary patch. --- lib/slack/web/api/patches/.gitkeep | 0 .../api/patches/chat.attachments-blocks.patch | 21 ------------------- .../api/endpoints/custom_specs/chat_spec.rb | 11 ++-------- 3 files changed, 2 insertions(+), 30 deletions(-) create mode 100644 lib/slack/web/api/patches/.gitkeep delete mode 100644 lib/slack/web/api/patches/chat.attachments-blocks.patch diff --git a/lib/slack/web/api/patches/.gitkeep b/lib/slack/web/api/patches/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/lib/slack/web/api/patches/chat.attachments-blocks.patch b/lib/slack/web/api/patches/chat.attachments-blocks.patch deleted file mode 100644 index aba01649..00000000 --- a/lib/slack/web/api/patches/chat.attachments-blocks.patch +++ /dev/null @@ -1,21 +0,0 @@ -diff --git a/lib/slack/web/api/endpoints/chat.rb b/lib/slack/web/api/endpoints/chat.rb -index b49065a..bf202f1 100644 ---- a/lib/slack/web/api/endpoints/chat.rb -+++ b/lib/slack/web/api/endpoints/chat.rb -@@ -122,7 +122,7 @@ module Slack - # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/chat/chat.postEphemeral.json - def chat_postEphemeral(options = {}) - raise ArgumentError, 'Required arguments :channel missing' if options[:channel].nil? -- raise ArgumentError, 'Required arguments :text missing' if options[:text].nil? -+ raise ArgumentError, 'At least one of :attachments, :blocks, :text is required' if options[:attachments].nil? && options[:blocks].nil? && options[:text].nil? - raise ArgumentError, 'Required arguments :user missing' if options[:user].nil? - options = options.merge(user: users_id(options)['user']['id']) if options[:user] - options = encode_options_as_json(options, %i[attachments blocks]) -@@ -274,6 +274,7 @@ module Slack - 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, :reply_broadcast is required' if options[:attachments].nil? && options[:blocks].nil? && options[:text].nil? && options[:reply_broadcast].nil? - options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel] - options = encode_options_as_json(options, %i[attachments blocks metadata]) - post('chat.update', options) diff --git a/spec/slack/web/api/endpoints/custom_specs/chat_spec.rb b/spec/slack/web/api/endpoints/custom_specs/chat_spec.rb index 6df7d34f..09fe43d8 100644 --- a/spec/slack/web/api/endpoints/custom_specs/chat_spec.rb +++ b/spec/slack/web/api/endpoints/custom_specs/chat_spec.rb @@ -33,7 +33,7 @@ context 'text and user arguments' do it 'requires text or attachments' do - expect { client.chat_postEphemeral(channel: 'channel') }.to( + expect { client.chat_postEphemeral(channel: 'channel', user: '123') }.to( raise_error(ArgumentError, /At least one of :attachments, :blocks, :text is required/) ) end @@ -167,7 +167,7 @@ context 'text, attachment and blocks arguments' do it 'requires text, attachments, blocks or reply_broadcast' do expect { client.chat_update(channel: 'channel', ts: ts) }.to( - raise_error(ArgumentError, /At least one of :attachments, :blocks, :text, :reply_broadcast is required/) + raise_error(ArgumentError, /At least one of :attachments, :blocks, :text is required/) ) end @@ -192,13 +192,6 @@ end.not_to raise_error end - it 'only reply_broadcast' do - expect(client).to receive(:post).with('chat.update', hash_including(reply_broadcast: true)) - expect do - client.chat_update(channel: 'channel', ts: ts, reply_broadcast: true) - end.not_to raise_error - end - it 'all text, attachments and blocks' do expect(client).to( receive(:post) From 847c1d2572fbf8fed96334e0aa513a051b24c8e7 Mon Sep 17 00:00:00 2001 From: "Daniel (dB.) Doubrovkine" Date: Wed, 1 Nov 2023 23:30:04 -0400 Subject: [PATCH 2/3] Update API from slack-api-ref@bc545649. --- bin/commands/admin_apps_activities.rb | 8 +- bin/commands/admin_apps_config.rb | 4 +- bin/commands/admin_conversations.rb | 1 + bin/commands/admin_users.rb | 2 + bin/commands/chat.rb | 17 ++-- bin/commands/conversations.rb | 2 +- bin/commands/team.rb | 2 +- bin/commands/usergroups.rb | 20 ++--- bin/commands/usergroups_users.rb | 10 +-- .../api/endpoints/admin_apps_activities.rb | 8 +- .../web/api/endpoints/admin_apps_config.rb | 4 +- .../web/api/endpoints/admin_conversations.rb | 2 + lib/slack/web/api/endpoints/admin_users.rb | 4 + lib/slack/web/api/endpoints/chat.rb | 38 ++++----- lib/slack/web/api/endpoints/conversations.rb | 2 +- lib/slack/web/api/endpoints/team.rb | 2 +- lib/slack/web/api/endpoints/usergroups.rb | 10 +-- .../web/api/endpoints/usergroups_users.rb | 6 +- lib/slack/web/api/errors.rb | 4 + lib/slack/web/api/slack-api-ref | 2 +- spec/slack/web/api/endpoints/chat_spec.rb | 80 ++++++++++++++++++- 21 files changed, 158 insertions(+), 70 deletions(-) diff --git a/bin/commands/admin_apps_activities.rb b/bin/commands/admin_apps_activities.rb index 4a4da63a..b52d513d 100644 --- a/bin/commands/admin_apps_activities.rb +++ b/bin/commands/admin_apps_activities.rb @@ -10,16 +10,16 @@ class App g.long_desc %( Get logs for a specified team/org ) g.command 'list' do |c| c.flag 'app_id', desc: 'The ID of the app to get activities from.' - c.flag 'component_id', desc: "The component ID of log events to be returned. Will be 'FnXXXXXX' for functions, and 'WfXXXXXX' for worflows." - c.flag 'component_type', desc: "The component type of log events to be returned. Acceptable values are ('events_api', 'workflows', 'functions', 'tables')." + c.flag 'component_id', desc: 'The component ID of log events to be returned. Will be FnXXXXXX for functions, and WfXXXXXX for worflows.' + c.flag 'component_type', desc: 'The component type of log events to be returned. Acceptable values are events_api, workflows, functions and tables.' 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. See pagination for more detail." c.flag 'limit', desc: 'The maximum number of items to return.' c.flag 'log_event_type', desc: 'The event type of log events to be returned.' c.flag 'max_date_created', desc: 'The latest timestamp of the log to retrieve (epoch microseconds).' c.flag 'min_date_created', desc: 'The earliest timestamp of the log to retrieve (epoch microseconds).' - c.flag 'min_log_level', desc: "The minimum log level of the log events to be returned. Defaults to 'info'. Acceptable values (in order of relative importance from smallest to largest) are ('trace', 'debug', 'info', 'warn', 'error', 'fatal')." + c.flag 'min_log_level', desc: 'The minimum log level of the log events to be returned. Defaults to info. Acceptable values (in order of relative importance from smallest to largest) are trace, debug, info, warn, error and fatal.' c.flag 'sort_direction', desc: 'The direction you want the data sorted by (always by timestamp).' - c.flag 'source', desc: "The source of log events to be returned. Acceptable values are ('slack', 'developer')." + c.flag 'source', desc: 'The source of log events to be returned. Acceptable values are slack and developer.' c.flag 'team_id', desc: 'The team who owns this log.' c.flag 'trace_id', desc: 'The trace ID of log events to be returned.' c.action do |_global_options, options, _args| diff --git a/bin/commands/admin_apps_config.rb b/bin/commands/admin_apps_config.rb index dd6b912f..8ac4cf8f 100644 --- a/bin/commands/admin_apps_config.rb +++ b/bin/commands/admin_apps_config.rb @@ -19,8 +19,8 @@ class App g.long_desc %( Set the app config for a connector ) g.command 'set' do |c| c.flag 'app_id', desc: 'The encoded app ID to set the app config for.' - c.flag 'domain_restrictions', desc: 'Domain restrictions for the app.' - c.flag 'workflow_auth_strategy', desc: 'The workflow auth permission.' + c.flag 'domain_restrictions', desc: 'Domain restrictions for the app. Should be an object with two properties: urls and emails. Each is an array of strings, and each sets the allowed URLs and emails for connector authorization, respectively.' + c.flag 'workflow_auth_strategy', desc: 'The workflow auth permission. Can be one of builder_choice or end_user_only.' c.action do |_global_options, options, _args| puts JSON.dump(@client.admin_apps_config_set(options)) end diff --git a/bin/commands/admin_conversations.rb b/bin/commands/admin_conversations.rb index 71ff12f6..a2a27ba0 100644 --- a/bin/commands/admin_conversations.rb +++ b/bin/commands/admin_conversations.rb @@ -176,6 +176,7 @@ class App c.flag 'sort', desc: 'Possible values are relevant (search ranking based on what we think is closest), name (alphabetical), member_count (number of users in the channel), and created (date channel was created). You can optionally pair this with the sort_dir arg to change how it is sorted.' c.flag 'sort_dir', desc: 'Sort direction. Possible values are asc for ascending order like (1, 2, 3) or (a, b, c), and desc for descending order like (3, 2, 1) or (c, b, a).' c.flag 'team_ids', desc: 'Comma separated string of team IDs, signifying the internal workspaces to search through.' + c.flag 'total_count_only', desc: 'Only return the total_count of channels. Omits channel data and allows access for admins without channel manager permissions.' c.action do |_global_options, options, _args| puts JSON.dump(@client.admin_conversations_search(options)) end diff --git a/bin/commands/admin_users.rb b/bin/commands/admin_users.rb index a3a50ec1..1a9fa45b 100644 --- a/bin/commands/admin_users.rb +++ b/bin/commands/admin_users.rb @@ -41,6 +41,8 @@ class App g.long_desc %( List users on a workspace ) g.command 'list' do |c| c.flag 'cursor', desc: 'Set cursor to next_cursor returned by the previous call to list items in the next page.' + c.flag 'include_deactivated_user_workspaces', desc: 'Only applies with org token and no team_id. If true, return workspaces for a user even if they may be deactivated on them. If false, return workspaces for a user only when user is active on them. Default is false.' + c.flag 'is_active', desc: 'If true, only active users will be returned. If false, only deactivated users will be returned. Default is true.' c.flag 'limit', desc: 'Limit for how many users to be retrieved per page.' c.flag 'team_id', desc: 'The ID (T1234) of the workspace. The team_id is required if you use an org-level token.' c.action do |_global_options, options, _args| diff --git a/bin/commands/chat.rb b/bin/commands/chat.rb index 33936f24..8d50405f 100644 --- a/bin/commands/chat.rb +++ b/bin/commands/chat.rb @@ -63,11 +63,11 @@ class App g.long_desc %( Sends an ephemeral message to a user in a channel. ) g.command 'postEphemeral' do |c| c.flag 'channel', desc: 'Channel, private group, or IM channel to send message to. Can be an encoded ID, or a name.' - 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 'user', desc: 'id of the user who will receive the ephemeral message. The user should be in the channel specified by the channel argument.' - c.flag 'as_user', desc: '(Legacy) Pass true to post the message as the authed user. Defaults to true if the chat:write:bot scope is not included. Otherwise, defaults to false.' 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. Defaults to true if the chat:write:bot scope is not included. Otherwise, defaults to false.' 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 channel names and usernames.' @@ -85,7 +85,7 @@ class App c.flag 'channel', desc: 'Channel, private group, or IM channel to send message to. Can be an encoded ID, or a name. See below for more details.' 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: 'The formatted text of the message to be published. If blocks are included, this will become the fallback text used in notifications.' + 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 '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.' @@ -94,6 +94,7 @@ class App 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.' + c.flag 'service_team_id', desc: 'For a message posted in App Home, Team ID corresponding to the selected app installation.' c.flag 'thread_ts', desc: "Provide another message's ts value to make this message a reply. Avoid using a reply's ts value; use its parent instead." c.flag 'unfurl_links', desc: 'Pass true to enable unfurling of primarily text-based content.' c.flag 'unfurl_media', desc: 'Pass false to disable unfurling of media content.' @@ -108,10 +109,10 @@ class App g.command 'scheduleMessage' do |c| c.flag 'channel', desc: 'Channel, private group, or DM channel to send message to. Can be an encoded ID, or a name. See below for more details.' c.flag 'post_at', desc: 'Unix EPOCH timestamp of time in future to send the message.' - 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: 'Set to true to post the message as the authed user, instead of as a bot. Defaults to false. Cannot be used by new Slack apps. See chat.postMessage.' 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: 'Set to true to post the message as the authed user, instead of as a bot. Defaults to false. Cannot be used by new Slack apps. See chat.postMessage.' 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 '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 'parse', desc: 'Change how messages are treated. See chat.postMessage.' @@ -146,15 +147,15 @@ class App g.command 'update' do |c| c.flag 'channel', desc: 'Channel containing the message to be updated.' c.flag 'ts', desc: 'Timestamp of the message to be updated.' + 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: '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. This field is required when not presenting text. If you don't include this field, the message's previous attachments will be retained. To remove previous attachments, include an empty array for this field." - c.flag 'blocks', desc: "A JSON-based array of structured blocks, presented as a URL-encoded string. If you don't include this field, the message's previous blocks will be retained. To remove previous blocks, include an empty array for this field." c.flag 'file_ids', desc: 'Array of new file ids that will be sent with this message.' c.flag 'link_names', desc: 'Find and link channel names and usernames. Defaults to none. If you do not specify a value for this field, the original value set for the message will be overwritten with the default, none.' 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." c.flag 'parse', desc: 'Change how messages are treated. Defaults to client, unlike chat.postMessage. Accepts either none or full. If you do not specify a value for this field, the original value set for the message will be overwritten with the default, client.' c.flag 'reply_broadcast', desc: 'Broadcast an existing thread reply to make it visible to everyone in the channel or conversation.' - c.flag 'text', desc: "New text for the message, using the default formatting rules. It's not required when presenting blocks or attachments." c.action do |_global_options, options, _args| puts JSON.dump(@client.chat_update(options)) end diff --git a/bin/commands/conversations.rb b/bin/commands/conversations.rb index 59ee34c0..e38a6e97 100644 --- a/bin/commands/conversations.rb +++ b/bin/commands/conversations.rb @@ -150,7 +150,7 @@ class App g.command 'list' 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.' - c.flag 'limit', desc: "The maximum number of items to return. Fewer than the requested number of items may be returned, even if the end of the list hasn't been reached. Must be an integer no larger than 1000." + c.flag 'limit', desc: "The maximum number of items to return. Fewer than the requested number of items may be returned, even if the end of the list hasn't been reached. Must be an integer under 1000." c.flag 'team_id', desc: 'encoded team id to list channels in, required if token belongs to org-wide app.' c.flag 'types', desc: 'Mix and match channel types by providing a comma-separated list of any combination of public_channel, private_channel, mpim, im.' c.action do |_global_options, options, _args| diff --git a/bin/commands/team.rb b/bin/commands/team.rb index 902ade74..6359dce5 100644 --- a/bin/commands/team.rb +++ b/bin/commands/team.rb @@ -44,7 +44,7 @@ class App g.long_desc %( Gets the integration logs for the current team. ) g.command 'integrationLogs' do |c| c.flag 'app_id', desc: 'Filter logs to this Slack app. Defaults to all logs.' - c.flag 'change_type', desc: 'Filter logs with this change type. Defaults to all logs.' + c.flag 'change_type', desc: 'Filter logs with this change type. Possible values are added, removed, enabled, disabled, and updated. Defaults to all logs.' c.flag 'service_id', desc: 'Filter logs to this service. Defaults to all logs.' c.flag 'team_id', desc: 'encoded team id to get logs from, required if org token is used.' c.flag 'user', desc: "Filter logs generated by this user's actions. Defaults to all logs." diff --git a/bin/commands/usergroups.rb b/bin/commands/usergroups.rb index 7c245a0d..7391c026 100644 --- a/bin/commands/usergroups.rb +++ b/bin/commands/usergroups.rb @@ -6,8 +6,8 @@ module Cli class App desc 'Usergroups methods.' command 'usergroups' do |g| - g.desc 'Create a User Group' - g.long_desc %( Create a User Group ) + g.desc 'Create a User Group.' + g.long_desc %( Create a User Group. ) g.command 'create' do |c| 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.' @@ -20,8 +20,8 @@ class App end end - g.desc 'Disable an existing User Group' - g.long_desc %( Disable an existing User Group ) + g.desc 'Disable an existing User Group.' + g.long_desc %( Disable an existing User Group. ) g.command 'disable' do |c| c.flag 'usergroup', desc: 'The encoded ID of the User Group to disable.' c.flag 'include_count', desc: 'Include the number of users in the User Group.' @@ -31,8 +31,8 @@ class App end end - g.desc 'Enable a User Group' - g.long_desc %( Enable a User Group ) + g.desc 'Enable a User Group.' + g.long_desc %( Enable a User Group. ) g.command 'enable' do |c| c.flag 'usergroup', desc: 'The encoded ID of the User Group to enable.' c.flag 'include_count', desc: 'Include the number of users in the User Group.' @@ -42,8 +42,8 @@ class App end end - g.desc 'List all User Groups for a team' - g.long_desc %( List all User Groups for a team ) + g.desc 'List all User Groups for a team.' + g.long_desc %( List all User Groups for a team. ) g.command 'list' do |c| c.flag 'include_count', desc: 'Include the number of users in each User Group.' c.flag 'include_disabled', desc: 'Include disabled User Groups.' @@ -54,8 +54,8 @@ class App end end - g.desc 'Update an existing User Group' - g.long_desc %( Update an existing User Group ) + g.desc 'Update an existing User Group.' + g.long_desc %( Update an existing User Group. ) g.command 'update' do |c| 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.' diff --git a/bin/commands/usergroups_users.rb b/bin/commands/usergroups_users.rb index 73b35cca..6531db00 100644 --- a/bin/commands/usergroups_users.rb +++ b/bin/commands/usergroups_users.rb @@ -6,10 +6,10 @@ module Cli class App desc 'UsergroupsUsers methods.' command 'usergroups_users' do |g| - g.desc 'List all users in a User Group' - g.long_desc %( List all users in a User Group ) + g.desc 'List all users in a User Group.' + g.long_desc %( List all users in a User Group. ) g.command 'list' do |c| - c.flag 'usergroup', desc: 'The encoded ID of the User Group to update.' + c.flag 'usergroup', desc: 'The encoded ID of the User Group to list users for.' c.flag 'include_disabled', desc: 'Allow results that involve disabled User Groups.' c.flag 'team_id', desc: 'encoded team id where the user group exists, required if org token is used.' c.action do |_global_options, options, _args| @@ -17,8 +17,8 @@ class App end end - g.desc 'Update the list of users for a User Group' - g.long_desc %( Update the list of users for a User Group ) + g.desc 'Update the list of users for a User Group.' + g.long_desc %( Update the list of users for a User Group. ) g.command 'update' do |c| c.flag 'usergroup', desc: 'The encoded ID of the User Group to update.' c.flag 'users', desc: 'A comma separated string of encoded user IDs that represent the entire list of users for the User Group.' diff --git a/lib/slack/web/api/endpoints/admin_apps_activities.rb b/lib/slack/web/api/endpoints/admin_apps_activities.rb index 99f9870e..988c4745 100644 --- a/lib/slack/web/api/endpoints/admin_apps_activities.rb +++ b/lib/slack/web/api/endpoints/admin_apps_activities.rb @@ -12,9 +12,9 @@ module AdminAppsActivities # @option options [Object] :app_id # The ID of the app to get activities from. # @option options [string] :component_id - # The component ID of log events to be returned. Will be 'FnXXXXXX' for functions, and 'WfXXXXXX' for worflows. + # The component ID of log events to be returned. Will be FnXXXXXX for functions, and WfXXXXXX for worflows. # @option options [string] :component_type - # The component type of log events to be returned. Acceptable values are ('events_api', 'workflows', 'functions', 'tables'). + # The component type of log events to be returned. Acceptable values are events_api, workflows, functions and tables. # @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. See pagination for more detail. # @option options [integer] :limit @@ -26,11 +26,11 @@ module AdminAppsActivities # @option options [integer] :min_date_created # The earliest timestamp of the log to retrieve (epoch microseconds). # @option options [string] :min_log_level - # The minimum log level of the log events to be returned. Defaults to 'info'. Acceptable values (in order of relative importance from smallest to largest) are ('trace', 'debug', 'info', 'warn', 'error', 'fatal'). + # The minimum log level of the log events to be returned. Defaults to info. Acceptable values (in order of relative importance from smallest to largest) are trace, debug, info, warn, error and fatal. # @option options [string] :sort_direction # The direction you want the data sorted by (always by timestamp). # @option options [string] :source - # The source of log events to be returned. Acceptable values are ('slack', 'developer'). + # The source of log events to be returned. Acceptable values are slack and developer. # @option options [string] :team_id # The team who owns this log. # @option options [string] :trace_id diff --git a/lib/slack/web/api/endpoints/admin_apps_config.rb b/lib/slack/web/api/endpoints/admin_apps_config.rb index a1cb382f..ed9f2565 100644 --- a/lib/slack/web/api/endpoints/admin_apps_config.rb +++ b/lib/slack/web/api/endpoints/admin_apps_config.rb @@ -24,9 +24,9 @@ def admin_apps_config_lookup(options = {}) # @option options [Object] :app_id # The encoded app ID to set the app config for. # @option options [object] :domain_restrictions - # Domain restrictions for the app. + # Domain restrictions for the app. Should be an object with two properties: urls and emails. Each is an array of strings, and each sets the allowed URLs and emails for connector authorization, respectively. # @option options [string] :workflow_auth_strategy - # The workflow auth permission. + # The workflow auth permission. Can be one of builder_choice or end_user_only. # @see https://api.slack.com/methods/admin.apps.config.set # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/admin.apps.config/admin.apps.config.set.json def admin_apps_config_set(options = {}) diff --git a/lib/slack/web/api/endpoints/admin_conversations.rb b/lib/slack/web/api/endpoints/admin_conversations.rb index 6431d5b4..325b494f 100644 --- a/lib/slack/web/api/endpoints/admin_conversations.rb +++ b/lib/slack/web/api/endpoints/admin_conversations.rb @@ -264,6 +264,8 @@ def admin_conversations_rename(options = {}) # Sort direction. Possible values are asc for ascending order like (1, 2, 3) or (a, b, c), and desc for descending order like (3, 2, 1) or (c, b, a). # @option options [array] :team_ids # Comma separated string of team IDs, signifying the internal workspaces to search through. + # @option options [boolean] :total_count_only + # Only return the total_count of channels. Omits channel data and allows access for admins without channel manager permissions. # @see https://api.slack.com/methods/admin.conversations.search # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/admin.conversations/admin.conversations.search.json def admin_conversations_search(options = {}) diff --git a/lib/slack/web/api/endpoints/admin_users.rb b/lib/slack/web/api/endpoints/admin_users.rb index 7ff147b6..00a8819f 100644 --- a/lib/slack/web/api/endpoints/admin_users.rb +++ b/lib/slack/web/api/endpoints/admin_users.rb @@ -64,6 +64,10 @@ def admin_users_invite(options = {}) # # @option options [string] :cursor # Set cursor to next_cursor returned by the previous call to list items in the next page. + # @option options [boolean] :include_deactivated_user_workspaces + # Only applies with org token and no team_id. If true, return workspaces for a user even if they may be deactivated on them. If false, return workspaces for a user only when user is active on them. Default is false. + # @option options [boolean] :is_active + # If true, only active users will be returned. If false, only deactivated users will be returned. Default is true. # @option options [integer] :limit # Limit for how many users to be retrieved per page. # @option options [Object] :team_id diff --git a/lib/slack/web/api/endpoints/chat.rb b/lib/slack/web/api/endpoints/chat.rb index 4f5f7ab8..24b46f38 100644 --- a/lib/slack/web/api/endpoints/chat.rb +++ b/lib/slack/web/api/endpoints/chat.rb @@ -96,16 +96,16 @@ def chat_meMessage(options = {}) # # @option options [channel] :channel # Channel, private group, or IM channel to send message to. Can be an encoded ID, or a name. - # @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 [user] :user # id of the user who will receive the ephemeral message. The user should be in the channel specified by the channel argument. - # @option options [boolean] :as_user - # (Legacy) Pass true to post the message as the authed user. Defaults to true if the chat:write:bot scope is not included. Otherwise, defaults to false. # @option options [string] :attachments # A JSON-based array of structured attachments, presented as a URL-encoded string. # @option options [blocks[] as string] :blocks # A JSON-based array of structured blocks, presented as a URL-encoded string. + # @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. Defaults to true if the chat:write:bot scope is not included. Otherwise, defaults to false. # @option options [string] :icon_emoji # Emoji to use as the icon for this message. Overrides icon_url. # @option options [string] :icon_url @@ -122,8 +122,8 @@ def chat_meMessage(options = {}) # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/chat/chat.postEphemeral.json def chat_postEphemeral(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, '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? 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) @@ -139,7 +139,7 @@ def chat_postEphemeral(options = {}) # @option options [blocks[] as string] :blocks # A JSON-based array of structured blocks, presented as a URL-encoded string. # @option options [string] :text - # The formatted text of the message to be published. If blocks are included, this will become the fallback text used in notifications. + # 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. # @option options [string] :icon_emoji @@ -156,6 +156,8 @@ def chat_postEphemeral(options = {}) # Change how messages are treated. See below. # @option options [boolean] :reply_broadcast # Used in conjunction with thread_ts and indicates whether reply should be made visible to everyone in the channel or conversation. Defaults to false. + # @option options [string] :service_team_id + # For a message posted in App Home, Team ID corresponding to the selected app installation. # @option options [string] :thread_ts # Provide another message's ts value to make this message a reply. Avoid using a reply's ts value; use its parent instead. # @option options [boolean] :unfurl_links @@ -180,14 +182,14 @@ def chat_postMessage(options = {}) # Channel, private group, or DM channel to send message to. Can be an encoded ID, or a name. See below for more details. # @option options [integer] :post_at # Unix EPOCH timestamp of time in future to send the message. - # @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 - # Set to true to post the message as the authed user, instead of as a bot. Defaults to false. Cannot be used by new Slack apps. See chat.postMessage. # @option options [string] :attachments # A JSON-based array of structured attachments, presented as a URL-encoded string. # @option options [blocks[] as string] :blocks # A JSON-based array of structured blocks, presented as a URL-encoded string. + # @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 + # Set to true to post the message as the authed user, instead of as a bot. Defaults to false. Cannot be used by new Slack apps. See chat.postMessage. # @option options [boolean] :link_names # Find and link user groups. No longer supports linking individual users; use syntax shown in Mentioning Users instead. # @option options [string] :metadata @@ -207,7 +209,7 @@ 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, 'Required arguments :text missing' if options[:text].nil? + raise ArgumentError, 'At least one of :attachments, :blocks, :text is required' if options[:attachments].nil? && options[:blocks].nil? && options[:text].nil? options = encode_options_as_json(options, %i[attachments blocks metadata]) post('chat.scheduleMessage', options) end @@ -251,12 +253,14 @@ def chat_unfurl(options = {}) # Channel containing the message to be updated. # @option options [timestamp] :ts # Timestamp of the message to be updated. - # @option options [boolean] :as_user - # 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. This field is required when not presenting text. If you don't include this field, the message's previous attachments will be retained. To remove previous attachments, include an empty array for this field. + # A JSON-based array of structured attachments, presented as a URL-encoded string. # @option options [blocks[] as string] :blocks - # A JSON-based array of structured blocks, presented as a URL-encoded string. If you don't include this field, the message's previous blocks will be retained. To remove previous blocks, include an empty array for this field. + # A JSON-based array of structured blocks, presented as a URL-encoded string. + # @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 + # Pass true to update the message as the authed user. Bot users in this context are considered authed users. # @option options [array] :file_ids # Array of new file ids that will be sent with this message. # @option options [boolean] :link_names @@ -267,14 +271,12 @@ def chat_unfurl(options = {}) # Change how messages are treated. Defaults to client, unlike chat.postMessage. Accepts either none or full. If you do not specify a value for this field, the original value set for the message will be overwritten with the default, client. # @option options [boolean] :reply_broadcast # Broadcast an existing thread reply to make it visible to everyone in the channel or conversation. - # @option options [string] :text - # New text for the message, using the default formatting rules. It's not required when presenting blocks or attachments. # @see https://api.slack.com/methods/chat.update # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/chat/chat.update.json 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, :reply_broadcast is required' if options[:attachments].nil? && options[:blocks].nil? && options[:text].nil? && options[:reply_broadcast].nil? + raise ArgumentError, 'At least one of :attachments, :blocks, :text is required' if options[:attachments].nil? && options[:blocks].nil? && options[:text].nil? options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel] options = encode_options_as_json(options, %i[attachments blocks metadata]) post('chat.update', options) diff --git a/lib/slack/web/api/endpoints/conversations.rb b/lib/slack/web/api/endpoints/conversations.rb index 0011ff13..8b74d6aa 100644 --- a/lib/slack/web/api/endpoints/conversations.rb +++ b/lib/slack/web/api/endpoints/conversations.rb @@ -232,7 +232,7 @@ def conversations_leave(options = {}) # @option options [boolean] :exclude_archived # Set to true to exclude archived channels from the list. # @option options [number] :limit - # The maximum number of items to return. Fewer than the requested number of items may be returned, even if the end of the list hasn't been reached. Must be an integer no larger than 1000. + # The maximum number of items to return. Fewer than the requested number of items may be returned, even if the end of the list hasn't been reached. Must be an integer under 1000. # @option options [string] :team_id # encoded team id to list channels in, required if token belongs to org-wide app. # @option options [string] :types diff --git a/lib/slack/web/api/endpoints/team.rb b/lib/slack/web/api/endpoints/team.rb index 214ad0b9..54986bb8 100644 --- a/lib/slack/web/api/endpoints/team.rb +++ b/lib/slack/web/api/endpoints/team.rb @@ -72,7 +72,7 @@ def team_info(options = {}) # @option options [string] :app_id # Filter logs to this Slack app. Defaults to all logs. # @option options [string] :change_type - # Filter logs with this change type. Defaults to all logs. + # Filter logs with this change type. Possible values are added, removed, enabled, disabled, and updated. Defaults to all logs. # @option options [string] :service_id # Filter logs to this service. Defaults to all logs. # @option options [string] :team_id diff --git a/lib/slack/web/api/endpoints/usergroups.rb b/lib/slack/web/api/endpoints/usergroups.rb index 5cb562e9..600a00e7 100644 --- a/lib/slack/web/api/endpoints/usergroups.rb +++ b/lib/slack/web/api/endpoints/usergroups.rb @@ -7,7 +7,7 @@ module Api module Endpoints module Usergroups # - # Create a User Group + # Create a User Group. # # @option options [string] :name # A name for the User Group. Must be unique among User Groups. @@ -29,7 +29,7 @@ def usergroups_create(options = {}) end # - # Disable an existing User Group + # Disable an existing User Group. # # @option options [Object] :usergroup # The encoded ID of the User Group to disable. @@ -45,7 +45,7 @@ def usergroups_disable(options = {}) end # - # Enable a User Group + # Enable a User Group. # # @option options [string] :usergroup # The encoded ID of the User Group to enable. @@ -61,7 +61,7 @@ def usergroups_enable(options = {}) end # - # List all User Groups for a team + # List all User Groups for a team. # # @option options [boolean] :include_count # Include the number of users in each User Group. @@ -78,7 +78,7 @@ def usergroups_list(options = {}) end # - # Update an existing User Group + # Update an existing User Group. # # @option options [Object] :usergroup # The encoded ID of the User Group to update. diff --git a/lib/slack/web/api/endpoints/usergroups_users.rb b/lib/slack/web/api/endpoints/usergroups_users.rb index 56cf10f8..3f64bf93 100644 --- a/lib/slack/web/api/endpoints/usergroups_users.rb +++ b/lib/slack/web/api/endpoints/usergroups_users.rb @@ -7,10 +7,10 @@ module Api module Endpoints module UsergroupsUsers # - # List all users in a User Group + # List all users in a User Group. # # @option options [string] :usergroup - # The encoded ID of the User Group to update. + # The encoded ID of the User Group to list users for. # @option options [boolean] :include_disabled # Allow results that involve disabled User Groups. # @option options [string] :team_id @@ -23,7 +23,7 @@ def usergroups_users_list(options = {}) end # - # Update the list of users for a User Group + # Update the list of users for a User Group. # # @option options [string] :usergroup # The encoded ID of the User Group to update. diff --git a/lib/slack/web/api/errors.rb b/lib/slack/web/api/errors.rb index b8ede5b7..3ea4fd1a 100644 --- a/lib/slack/web/api/errors.rb +++ b/lib/slack/web/api/errors.rb @@ -240,6 +240,7 @@ class HasAlreadyConnectedToOrg < SlackError; end class HashConflict < SlackError; end class InactiveCall < SlackError; end class InactiveInvite < SlackError; end + class IncludeDeactivatedUserWorkspacesInvalid < SlackError; end class InsecureRequest < SlackError; end class InternalError < SlackError; end class InvalidAction < SlackError; end @@ -384,6 +385,7 @@ class MissingArgument < SlackError; end class MissingChannel < SlackError; end class MissingDialog < SlackError; end class MissingDuration < SlackError; end + class MissingFileData < SlackError; end class MissingPostType < SlackError; end class MissingProfileId < SlackError; end class MissingResource < SlackError; end @@ -855,6 +857,7 @@ class WorkflowsExportCsvNotEnabled < SlackError; end 'hash_conflict' => HashConflict, 'inactive_call' => InactiveCall, 'inactive_invite' => InactiveInvite, + 'include_deactivated_user_workspaces_invalid' => IncludeDeactivatedUserWorkspacesInvalid, 'insecure_request' => InsecureRequest, 'internal_error' => InternalError, 'invalid_action' => InvalidAction, @@ -999,6 +1002,7 @@ class WorkflowsExportCsvNotEnabled < SlackError; end 'missing_channel' => MissingChannel, 'missing_dialog' => MissingDialog, 'missing_duration' => MissingDuration, + 'missing_file_data' => MissingFileData, 'missing_post_type' => MissingPostType, 'missing_profile_id' => MissingProfileId, 'missing_resource' => MissingResource, diff --git a/lib/slack/web/api/slack-api-ref b/lib/slack/web/api/slack-api-ref index d3eba1e6..bc545649 160000 --- a/lib/slack/web/api/slack-api-ref +++ b/lib/slack/web/api/slack-api-ref @@ -1 +1 @@ -Subproject commit d3eba1e6e06f1ea3f4f2eaaec832c68ff0163e78 +Subproject commit bc5456491123c88cac7b2b05faa2000cd284e596 diff --git a/spec/slack/web/api/endpoints/chat_spec.rb b/spec/slack/web/api/endpoints/chat_spec.rb index 841a6e7e..5e823b62 100644 --- a/spec/slack/web/api/endpoints/chat_spec.rb +++ b/spec/slack/web/api/endpoints/chat_spec.rb @@ -6,9 +6,33 @@ RSpec.describe Slack::Web::Api::Endpoints::Chat do let(:client) { Slack::Web::Client.new } context 'chat_postEphemeral' do + it 'requires one of attachments, blocks, text' do + expect { client.chat_postEphemeral(channel: %q[C1234567890], 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[C1234567890], user: %q[U0BPQUNTA]}) + client.chat_postEphemeral(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[C1234567890], user: %q[U0BPQUNTA]) + + expect(client).to receive(:post).with('chat.postEphemeral', {blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], channel: %q[C1234567890], user: %q[U0BPQUNTA]}) + client.chat_postEphemeral(blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], channel: %q[C1234567890], user: %q[U0BPQUNTA]) + + expect(client).to receive(:post).with('chat.postEphemeral', {text: %q[Hello world], channel: %q[C1234567890], user: %q[U0BPQUNTA]}) + client.chat_postEphemeral(text: %q[Hello world], channel: %q[C1234567890], 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[C1234567890], 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[C1234567890], 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[C1234567890], user: %q[U0BPQUNTA]}) + client.chat_postEphemeral(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], text: %q[Hello world], channel: %q[C1234567890], 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[C1234567890], user: %q[U0BPQUNTA]}) + client.chat_postEphemeral(blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], text: %q[Hello world], channel: %q[C1234567890], 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[C1234567890], 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[C1234567890], user: %q[U0BPQUNTA]) + end it 'encodes attachments, blocks as json' do - expect(client).to receive(:post).with('chat.postEphemeral', {channel: %q[C1234567890], text: %q[Hello world], user: %q[U0BPQUNTA], attachments: %q[{"data":["data"]}], blocks: %q[{"data":["data"]}]}) - client.chat_postEphemeral(channel: %q[C1234567890], text: %q[Hello world], user: %q[U0BPQUNTA], attachments: {:data=>["data"]}, blocks: {:data=>["data"]}) + expect(client).to receive(:post).with('chat.postEphemeral', {channel: %q[C1234567890], user: %q[U0BPQUNTA], attachments: %q[{"data":["data"]}], blocks: %q[{"data":["data"]}]}) + client.chat_postEphemeral(channel: %q[C1234567890], user: %q[U0BPQUNTA], attachments: {:data=>["data"]}, blocks: {:data=>["data"]}) end end context 'chat_postMessage' do @@ -42,9 +66,33 @@ end end context 'chat_scheduleMessage' do + it 'requires one of attachments, blocks, text' do + expect { client.chat_scheduleMessage(channel: %q[C1234567890], 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[C1234567890], post_at: %q[299876400]}) + client.chat_scheduleMessage(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[C1234567890], post_at: %q[299876400]) + + expect(client).to receive(:post).with('chat.scheduleMessage', {blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], channel: %q[C1234567890], post_at: %q[299876400]}) + client.chat_scheduleMessage(blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], channel: %q[C1234567890], post_at: %q[299876400]) + + expect(client).to receive(:post).with('chat.scheduleMessage', {text: %q[Hello world], channel: %q[C1234567890], post_at: %q[299876400]}) + client.chat_scheduleMessage(text: %q[Hello world], channel: %q[C1234567890], 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[C1234567890], 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[C1234567890], 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[C1234567890], post_at: %q[299876400]}) + client.chat_scheduleMessage(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], text: %q[Hello world], channel: %q[C1234567890], 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[C1234567890], post_at: %q[299876400]}) + client.chat_scheduleMessage(blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], text: %q[Hello world], channel: %q[C1234567890], post_at: %q[299876400]) + + expect(client).to receive(:post).with('chat.scheduleMessage', {attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], text: %q[Hello world], channel: %q[C1234567890], post_at: %q[299876400]}) + client.chat_scheduleMessage(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], text: %q[Hello world], channel: %q[C1234567890], post_at: %q[299876400]) + end it 'encodes attachments, blocks, metadata as json' do - expect(client).to receive(:post).with('chat.scheduleMessage', {channel: %q[C1234567890], post_at: %q[299876400], text: %q[Hello world], attachments: %q[{"data":["data"]}], blocks: %q[{"data":["data"]}], metadata: %q[{"data":["data"]}]}) - client.chat_scheduleMessage(channel: %q[C1234567890], post_at: %q[299876400], text: %q[Hello world], attachments: {:data=>["data"]}, blocks: {:data=>["data"]}, metadata: {:data=>["data"]}) + expect(client).to receive(:post).with('chat.scheduleMessage', {channel: %q[C1234567890], post_at: %q[299876400], attachments: %q[{"data":["data"]}], blocks: %q[{"data":["data"]}], metadata: %q[{"data":["data"]}]}) + client.chat_scheduleMessage(channel: %q[C1234567890], post_at: %q[299876400], attachments: {:data=>["data"]}, blocks: {:data=>["data"]}, metadata: {:data=>["data"]}) end end context 'chat_unfurl' do @@ -54,6 +102,30 @@ end end context 'chat_update' do + it 'requires one of attachments, blocks, text' do + expect { client.chat_update(channel: %q[C1234567890], 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[C1234567890], ts: %q["1405894322.002768"]}) + client.chat_update(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[C1234567890], ts: %q["1405894322.002768"]) + + expect(client).to receive(:post).with('chat.update', {blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], channel: %q[C1234567890], ts: %q["1405894322.002768"]}) + client.chat_update(blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], channel: %q[C1234567890], ts: %q["1405894322.002768"]) + + expect(client).to receive(:post).with('chat.update', {text: %q[Hello world], channel: %q[C1234567890], ts: %q["1405894322.002768"]}) + client.chat_update(text: %q[Hello world], channel: %q[C1234567890], 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[C1234567890], 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[C1234567890], 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[C1234567890], ts: %q["1405894322.002768"]}) + client.chat_update(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], text: %q[Hello world], channel: %q[C1234567890], 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[C1234567890], ts: %q["1405894322.002768"]}) + client.chat_update(blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], text: %q[Hello world], channel: %q[C1234567890], ts: %q["1405894322.002768"]) + + expect(client).to receive(:post).with('chat.update', {attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], text: %q[Hello world], channel: %q[C1234567890], ts: %q["1405894322.002768"]}) + client.chat_update(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], text: %q[Hello world], channel: %q[C1234567890], ts: %q["1405894322.002768"]) + end it 'encodes attachments, blocks, metadata as json' do expect(client).to receive(:post).with('chat.update', {channel: %q[C1234567890], ts: %q["1405894322.002768"], attachments: %q[{"data":["data"]}], blocks: %q[{"data":["data"]}], metadata: %q[{"data":["data"]}]}) client.chat_update(channel: %q[C1234567890], ts: %q["1405894322.002768"], attachments: {:data=>["data"]}, blocks: {:data=>["data"]}, metadata: {:data=>["data"]}) From 31bdee4e0025f6564fa2c7bd89821c1587713128 Mon Sep 17 00:00:00 2001 From: "Daniel (dB.) Doubrovkine" Date: Wed, 1 Nov 2023 23:32:31 -0400 Subject: [PATCH 3/3] Update CHANGELOG. --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70e49bbf..4ff04f64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,8 @@ ### 2.2.1 (Next) -* Your contribution here. * [#494](https://github.com/slack-ruby/slack-ruby-client/pull/494): Configure Dependabot to update GitHub Actions - [@olleolleolle](https://github.com/olleolleolle). +* [#503](https://github.com/slack-ruby/slack-ruby-client/pull/503): Update Slack API Update API from [slack-api-ref@bc545649](https://github.com/slack-ruby/slack-api-ref/commit/bc545649) - [@dblock](https://github.com/dblock). +* Your contribution here. ### 2.2.0 (2023/09/17)