slack-ruby-client 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. checksums.yaml +4 -4
  2. data/.coveralls.yml +2 -0
  3. data/.github/workflows/test.yml +6 -0
  4. data/.github/workflows/update_api.yml +76 -0
  5. data/.gitignore +1 -0
  6. data/.rubocop_todo.yml +17 -29
  7. data/CHANGELOG.md +23 -1
  8. data/CONTRIBUTING.md +35 -32
  9. data/Gemfile +2 -0
  10. data/README.md +123 -14
  11. data/bin/commands/admin_apps_activities.rb +32 -0
  12. data/bin/commands/admin_apps_approved.rb +1 -0
  13. data/bin/commands/admin_apps_config.rb +31 -0
  14. data/bin/commands/admin_apps_requests.rb +1 -0
  15. data/bin/commands/admin_apps_restricted.rb +1 -0
  16. data/bin/commands/admin_functions.rb +23 -0
  17. data/bin/commands/admin_functions_permissions.rb +31 -0
  18. data/bin/commands/admin_roles.rb +1 -1
  19. data/bin/commands/admin_teams.rb +1 -1
  20. data/bin/commands/admin_users.rb +2 -2
  21. data/bin/commands/admin_workflows.rb +38 -0
  22. data/bin/commands/admin_workflows_collaborators.rb +31 -0
  23. data/bin/commands/admin_workflows_permissions.rb +21 -0
  24. data/bin/commands/apps_activities.rb +32 -0
  25. data/bin/commands/apps_auth_external.rb +32 -0
  26. data/bin/commands/apps_datastore.rb +70 -0
  27. data/bin/commands/auth_teams.rb +2 -2
  28. data/bin/commands/calls.rb +1 -1
  29. data/bin/commands/chat.rb +6 -6
  30. data/bin/commands/chat_scheduledMessages.rb +2 -2
  31. data/bin/commands/conversations.rb +3 -3
  32. data/bin/commands/dnd.rb +1 -1
  33. data/bin/commands/functions_workflows_steps.rb +2 -1
  34. data/bin/commands/functions_workflows_steps_responses.rb +2 -1
  35. data/bin/commands/reminders.rb +1 -1
  36. data/bin/commands/stars.rb +4 -4
  37. data/bin/commands/team.rb +3 -1
  38. data/bin/commands/users.rb +1 -1
  39. data/lib/slack/messages/formatting.rb +44 -0
  40. data/lib/slack/real_time/client.rb +14 -2
  41. data/lib/slack/real_time/concurrency/async.rb +4 -0
  42. data/lib/slack/real_time/config.rb +3 -0
  43. data/lib/slack/real_time/socket.rb +4 -0
  44. data/lib/slack/real_time/stores/starter.rb +2 -2
  45. data/lib/slack/real_time/stores/store.rb +2 -2
  46. data/lib/slack/version.rb +1 -1
  47. data/lib/slack/web/api/endpoints/admin_apps_activities.rb +53 -0
  48. data/lib/slack/web/api/endpoints/admin_apps_approved.rb +2 -0
  49. data/lib/slack/web/api/endpoints/admin_apps_config.rb +40 -0
  50. data/lib/slack/web/api/endpoints/admin_apps_requests.rb +2 -0
  51. data/lib/slack/web/api/endpoints/admin_apps_restricted.rb +2 -0
  52. data/lib/slack/web/api/endpoints/admin_conversations.rb +1 -0
  53. data/lib/slack/web/api/endpoints/admin_functions.rb +36 -0
  54. data/lib/slack/web/api/endpoints/admin_functions_permissions.rb +41 -0
  55. data/lib/slack/web/api/endpoints/admin_roles.rb +1 -1
  56. data/lib/slack/web/api/endpoints/admin_teams.rb +1 -1
  57. data/lib/slack/web/api/endpoints/admin_users.rb +2 -2
  58. data/lib/slack/web/api/endpoints/admin_workflows.rb +59 -0
  59. data/lib/slack/web/api/endpoints/admin_workflows_collaborators.rb +42 -0
  60. data/lib/slack/web/api/endpoints/admin_workflows_permissions.rb +26 -0
  61. data/lib/slack/web/api/endpoints/apps_activities.rb +54 -0
  62. data/lib/slack/web/api/endpoints/apps_auth_external.rb +41 -0
  63. data/lib/slack/web/api/endpoints/apps_datastore.rb +110 -0
  64. data/lib/slack/web/api/endpoints/apps_manifest.rb +2 -0
  65. data/lib/slack/web/api/endpoints/auth_teams.rb +1 -1
  66. data/lib/slack/web/api/endpoints/calls.rb +1 -1
  67. data/lib/slack/web/api/endpoints/chat.rb +14 -45
  68. data/lib/slack/web/api/endpoints/chat_scheduledMessages.rb +2 -2
  69. data/lib/slack/web/api/endpoints/conversations.rb +3 -3
  70. data/lib/slack/web/api/endpoints/dialog.rb +1 -6
  71. data/lib/slack/web/api/endpoints/dnd.rb +1 -1
  72. data/lib/slack/web/api/endpoints/functions_workflows_steps.rb +3 -1
  73. data/lib/slack/web/api/endpoints/functions_workflows_steps_responses.rb +3 -1
  74. data/lib/slack/web/api/endpoints/reminders.rb +1 -1
  75. data/lib/slack/web/api/endpoints/stars.rb +2 -2
  76. data/lib/slack/web/api/endpoints/team.rb +12 -2
  77. data/lib/slack/web/api/endpoints/users.rb +1 -1
  78. data/lib/slack/web/api/endpoints/users_profile.rb +1 -0
  79. data/lib/slack/web/api/endpoints/views.rb +7 -23
  80. data/lib/slack/web/api/endpoints/workflows.rb +2 -0
  81. data/lib/slack/web/api/endpoints.rb +20 -0
  82. data/lib/slack/web/api/errors.rb +66 -4
  83. data/lib/slack/web/api/options.rb +26 -0
  84. data/lib/slack/web/api/patches/chat.attachments-blocks.patch +7 -55
  85. data/lib/slack/web/api/templates/method.erb +12 -0
  86. data/lib/slack/web/api/templates/method_spec.erb +40 -4
  87. data/lib/slack/web/client.rb +1 -0
  88. data/lib/slack-ruby-client.rb +1 -0
  89. data/lib/tasks/web.rake +2 -4
  90. data/slack-ruby-client.gemspec +1 -0
  91. data/spec/slack/messages/formatting_spec.rb +60 -0
  92. data/spec/slack/real_time/client_spec.rb +25 -7
  93. data/spec/slack/real_time/concurrency/clients/async_spec.rb +16 -0
  94. data/spec/slack/web/api/endpoints/admin_apps_activities_spec.rb +8 -0
  95. data/spec/slack/web/api/endpoints/admin_apps_config_spec.rb +18 -0
  96. data/spec/slack/web/api/endpoints/admin_auth_policy_spec.rb +6 -6
  97. data/spec/slack/web/api/endpoints/admin_conversations_spec.rb +14 -10
  98. data/spec/slack/web/api/endpoints/admin_functions_permissions_spec.rb +21 -0
  99. data/spec/slack/web/api/endpoints/admin_functions_spec.rb +13 -0
  100. data/spec/slack/web/api/endpoints/admin_roles_spec.rb +6 -6
  101. data/spec/slack/web/api/endpoints/admin_teams_settings_spec.rb +1 -1
  102. data/spec/slack/web/api/endpoints/admin_usergroups_spec.rb +6 -6
  103. data/spec/slack/web/api/endpoints/admin_users_session_spec.rb +2 -2
  104. data/spec/slack/web/api/endpoints/admin_users_spec.rb +8 -8
  105. data/spec/slack/web/api/endpoints/admin_workflows_collaborators_spec.rb +24 -0
  106. data/spec/slack/web/api/endpoints/admin_workflows_permissions_spec.rb +13 -0
  107. data/spec/slack/web/api/endpoints/admin_workflows_spec.rb +13 -0
  108. data/spec/slack/web/api/endpoints/apps_activities_spec.rb +13 -0
  109. data/spec/slack/web/api/endpoints/apps_auth_external_spec.rb +13 -0
  110. data/spec/slack/web/api/endpoints/apps_datastore_spec.rb +45 -0
  111. data/spec/slack/web/api/endpoints/apps_manifest_spec.rb +8 -0
  112. data/spec/slack/web/api/endpoints/apps_spec.rb +2 -2
  113. data/spec/slack/web/api/endpoints/auth_spec.rb +8 -0
  114. data/spec/slack/web/api/endpoints/bookmarks_spec.rb +4 -4
  115. data/spec/slack/web/api/endpoints/calls_participants_spec.rb +4 -4
  116. data/spec/slack/web/api/endpoints/calls_spec.rb +2 -2
  117. data/spec/slack/web/api/endpoints/chat_spec.rb +62 -0
  118. data/spec/slack/web/api/endpoints/conversations_spec.rb +8 -0
  119. data/spec/slack/web/api/endpoints/custom_specs/chat_spec.rb +3 -3
  120. data/spec/slack/web/api/endpoints/custom_specs/views_spec.rb +1 -1
  121. data/spec/slack/web/api/endpoints/dialog_spec.rb +14 -0
  122. data/spec/slack/web/api/endpoints/files_comments_spec.rb +2 -2
  123. data/spec/slack/web/api/endpoints/files_remote_spec.rb +3 -3
  124. data/spec/slack/web/api/endpoints/files_spec.rb +2 -2
  125. data/spec/slack/web/api/endpoints/oauth_v2_spec.rb +2 -2
  126. data/spec/slack/web/api/endpoints/reactions_spec.rb +3 -3
  127. data/spec/slack/web/api/endpoints/reminders_spec.rb +2 -2
  128. data/spec/slack/web/api/endpoints/usergroups_users_spec.rb +2 -2
  129. data/spec/slack/web/api/endpoints/users_profile_spec.rb +6 -0
  130. data/spec/slack/web/api/endpoints/users_spec.rb +8 -0
  131. data/spec/slack/web/api/endpoints/views_spec.rb +65 -0
  132. data/spec/slack/web/api/endpoints/workflows_spec.rb +8 -0
  133. data/spec/slack/web/api/options_spec.rb +69 -0
  134. data/spec/spec_helper.rb +9 -0
  135. metadata +45 -5
  136. data/lib/slack/web/api/patches/dialog.encoded-json.patch +0 -17
  137. data/lib/slack/web/api/patches/views.view-json.patch +0 -55
@@ -20,6 +20,7 @@ module Slack
20
20
  g.desc 'List app requests for a team/workspace.'
21
21
  g.long_desc %( List app requests for a team/workspace. )
22
22
  g.command 'list' do |c|
23
+ c.flag 'certified', desc: 'Include requests for certified apps.'
23
24
  c.flag 'cursor', desc: 'Set cursor to next_cursor returned by the previous call to list items in the next page.'
24
25
  c.flag 'enterprise_id', desc: '.'
25
26
  c.flag 'limit', desc: 'The maximum number of items to return. Must be between 1 - 1000 both inclusive.'
@@ -9,6 +9,7 @@ module Slack
9
9
  g.desc 'List restricted apps for an org or workspace.'
10
10
  g.long_desc %( List restricted apps for an org or workspace. )
11
11
  g.command 'list' do |c|
12
+ c.flag 'certified', desc: 'Limit the results to only include certified apps. When false, no certified apps will appear in the result.'
12
13
  c.flag 'cursor', desc: 'Set cursor to next_cursor returned by the previous call to list items in the next page.'
13
14
  c.flag 'enterprise_id', desc: '.'
14
15
  c.flag 'limit', desc: 'The maximum number of items to return. Must be between 1 - 1000 both inclusive.'
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+ # This file was auto-generated by lib/tasks/web.rake
3
+
4
+ module Slack
5
+ module Cli
6
+ class App
7
+ desc 'AdminFunctions methods.'
8
+ command 'admin_functions' do |g|
9
+ g.desc 'Look up functions by a set of apps'
10
+ g.long_desc %( Look up functions by a set of apps )
11
+ g.command 'list' do |c|
12
+ c.flag 'app_ids', desc: 'Comma-separated array of app IDs to get functions for; max 50.'
13
+ c.flag 'cursor', desc: 'Set cursor to next_cursor returned by the previous call to list items in the next page.'
14
+ c.flag 'limit', desc: 'The number of results that will be returned by the API on each invocation. Must be between 1 and 1000, both inclusive.'
15
+ c.flag 'team_id', desc: 'The team context to retrieve functions from.'
16
+ c.action do |_global_options, options, _args|
17
+ puts JSON.dump(@client.admin_functions_list(options))
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+ # This file was auto-generated by lib/tasks/web.rake
3
+
4
+ module Slack
5
+ module Cli
6
+ class App
7
+ desc 'AdminFunctionsPermissions methods.'
8
+ command 'admin_functions_permissions' do |g|
9
+ g.desc 'Lookup the visibility of multiple Slack functions and include the users if it is limited to particular named entities.'
10
+ g.long_desc %( Lookup the visibility of multiple Slack functions and include the users if it is limited to particular named entities. )
11
+ g.command 'lookup' do |c|
12
+ c.flag 'function_ids', desc: 'An array of function IDs to get permissions for.'
13
+ c.action do |_global_options, options, _args|
14
+ puts JSON.dump(@client.admin_functions_permissions_lookup(options))
15
+ end
16
+ end
17
+
18
+ g.desc 'Set the visibility of a Slack function and define the users or workspaces if it is set to named_entities'
19
+ g.long_desc %( Set the visibility of a Slack function and define the users or workspaces if it is set to named_entities )
20
+ g.command 'set' do |c|
21
+ c.flag 'function_id', desc: 'The function ID to set permissions for.'
22
+ c.flag 'visibility', desc: 'The function visibility.'
23
+ c.flag 'user_ids', desc: 'List of user IDs to allow for named_entities visibility.'
24
+ c.action do |_global_options, options, _args|
25
+ puts JSON.dump(@client.admin_functions_permissions_set(options))
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -22,7 +22,7 @@ module Slack
22
22
  g.command 'listAssignments' do |c|
23
23
  c.flag 'cursor', desc: 'Set cursor to next_cursor returned by the previous call to list items in the next page.'
24
24
  c.flag 'entity_ids', desc: 'The entities for which the roles apply.'
25
- c.flag 'limit', desc: 'The maximum number of items to return. Must be between 1 - 100 both inclusive.'
25
+ c.flag 'limit', desc: 'The maximum number of items to return. Must be between 1 - 200 both inclusive.'
26
26
  c.flag 'role_ids', desc: 'collection of role ids to scope results by.'
27
27
  c.flag 'sort_dir', desc: 'Sort direction. Default is descending on date_create, can be either ASC or DESC.'
28
28
  c.action do |_global_options, options, _args|
@@ -22,7 +22,7 @@ module Slack
22
22
  g.long_desc %( List all teams on an Enterprise organization )
23
23
  g.command 'list' do |c|
24
24
  c.flag 'cursor', desc: 'Set cursor to next_cursor returned by the previous call to list items in the next page.'
25
- c.flag 'limit', desc: 'The maximum number of items to return. Must be between 1 - 100 both inclusive.'
25
+ c.flag 'limit', desc: 'The maximum number of items to return. Must be a positive integer no larger than 1000.'
26
26
  c.action do |_global_options, options, _args|
27
27
  puts JSON.dump(@client.admin_teams_list(options))
28
28
  end
@@ -31,7 +31,7 @@ module Slack
31
31
  c.flag 'is_restricted', desc: 'Is this user a multi-channel guest user? (default: false).'
32
32
  c.flag 'is_ultra_restricted', desc: 'Is this user a single channel guest user? (default: false).'
33
33
  c.flag 'real_name', desc: 'Full name of the user.'
34
- c.flag 'resend', desc: 'Allow this invite to be resent in the future if a user has not signed up yet. (default: false).'
34
+ c.flag 'resend', desc: 'Allow this invite to be resent in the future if a user has not signed up yet. Resending can only be done via the UI and has no expiration. (default: false).'
35
35
  c.action do |_global_options, options, _args|
36
36
  puts JSON.dump(@client.admin_users_invite(options))
37
37
  end
@@ -71,7 +71,7 @@ module Slack
71
71
  g.desc 'Set an expiration for a guest user'
72
72
  g.long_desc %( Set an expiration for a guest user )
73
73
  g.command 'setExpiration' do |c|
74
- c.flag 'expiration_ts', desc: 'Timestamp when guest account should be disabled.'
74
+ c.flag 'expiration_ts', desc: 'Epoch timestamp in seconds when guest account should be disabled.'
75
75
  c.flag 'user_id', desc: 'The ID of the user to set an expiration for.'
76
76
  c.flag 'team_id', desc: 'The ID (T1234) of the workspace.'
77
77
  c.action do |_global_options, options, _args|
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+ # This file was auto-generated by lib/tasks/web.rake
3
+
4
+ module Slack
5
+ module Cli
6
+ class App
7
+ desc 'AdminWorkflows methods.'
8
+ command 'admin_workflows' do |g|
9
+ g.desc 'Search workflows within the team or enterprise'
10
+ g.long_desc %( Search workflows within the team or enterprise )
11
+ g.command 'search' do |c|
12
+ c.flag 'app_id', desc: 'The parent app ID for which to return workflows.'
13
+ c.flag 'collaborator_ids', desc: 'Only include workflows by the collaborators inputted.'
14
+ c.flag 'cursor', desc: 'Set cursor to next_cursor returned by the previous call to list items in the next page.'
15
+ c.flag 'limit', desc: 'The number of results that will be returned by the API on each invocation.'
16
+ c.flag 'no_collaborators', desc: 'Only include workflows with no collaborators in the result; default is false.'
17
+ c.flag 'num_trigger_ids', desc: 'Number of trigger IDs to fetch for each workflow; default is 0.'
18
+ c.flag 'query', desc: 'A search query to filter for workflow name or description.'
19
+ c.flag 'sort', desc: 'The field used to sort the returned workflows.'
20
+ 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).'
21
+ c.flag 'source', desc: 'Source of workflow creation, either from code or workflow builder.'
22
+ c.action do |_global_options, options, _args|
23
+ puts JSON.dump(@client.admin_workflows_search(options))
24
+ end
25
+ end
26
+
27
+ g.desc 'Unpublish workflows within the team or enterprise'
28
+ g.long_desc %( Unpublish workflows within the team or enterprise )
29
+ g.command 'unpublish' do |c|
30
+ c.flag 'workflow_ids', desc: 'Array of workflow IDs to unpublish.'
31
+ c.action do |_global_options, options, _args|
32
+ puts JSON.dump(@client.admin_workflows_unpublish(options))
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+ # This file was auto-generated by lib/tasks/web.rake
3
+
4
+ module Slack
5
+ module Cli
6
+ class App
7
+ desc 'AdminWorkflowsCollaborators methods.'
8
+ command 'admin_workflows_collaborators' do |g|
9
+ g.desc 'Add collaborators to workflows within the team or enterprise'
10
+ g.long_desc %( Add collaborators to workflows within the team or enterprise )
11
+ g.command 'add' do |c|
12
+ c.flag 'collaborator_ids', desc: 'Array of collaborators (encoded user IDs) to add; max 50.'
13
+ c.flag 'workflow_ids', desc: 'Array of workflow IDs to edit; max 50.'
14
+ c.action do |_global_options, options, _args|
15
+ puts JSON.dump(@client.admin_workflows_collaborators_add(options))
16
+ end
17
+ end
18
+
19
+ g.desc 'Remove collaborators from workflows within the team or enterprise'
20
+ g.long_desc %( Remove collaborators from workflows within the team or enterprise )
21
+ g.command 'remove' do |c|
22
+ c.flag 'collaborator_ids', desc: 'Array of collaborators (encoded user IDs) to remove; max 50.'
23
+ c.flag 'workflow_ids', desc: 'Array of workflow IDs to edit; max 50.'
24
+ c.action do |_global_options, options, _args|
25
+ puts JSON.dump(@client.admin_workflows_collaborators_remove(options))
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+ # This file was auto-generated by lib/tasks/web.rake
3
+
4
+ module Slack
5
+ module Cli
6
+ class App
7
+ desc 'AdminWorkflowsPermissions methods.'
8
+ command 'admin_workflows_permissions' do |g|
9
+ g.desc 'Look up the permissions for a set of workflows'
10
+ g.long_desc %( Look up the permissions for a set of workflows )
11
+ g.command 'lookup' do |c|
12
+ c.flag 'workflow_ids', desc: 'An array of workflow IDs to look up permissions for.'
13
+ c.flag 'max_workflow_triggers', desc: 'Maximum number of triggers to fetch for each workflow when determining overall run permissions; max 1000.'
14
+ c.action do |_global_options, options, _args|
15
+ puts JSON.dump(@client.admin_workflows_permissions_lookup(options))
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+ # This file was auto-generated by lib/tasks/web.rake
3
+
4
+ module Slack
5
+ module Cli
6
+ class App
7
+ desc 'AppsActivities methods.'
8
+ command 'apps_activities' do |g|
9
+ g.desc 'Get logs for a specified app'
10
+ g.long_desc %( Get logs for a specified app )
11
+ g.command 'list' do |c|
12
+ c.flag 'app_id', desc: 'The id of the app to get activities from.'
13
+ c.flag 'component_id', desc: "The component id of log events to be returned. Will be 'FnXXXXXX' for functions, and 'WfXXXXXX' for worflows."
14
+ c.flag 'component_type', desc: "The component type of log events to be returned. Acceptable values are ('events_api', 'workflows', 'functions', 'tables')."
15
+ 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."
16
+ c.flag 'limit', desc: 'The maximum number of items to return.'
17
+ c.flag 'log_event_type', desc: 'The event type of log events to be returned.'
18
+ c.flag 'max_date_created', desc: 'The latest timestamp of the log to retrieve (epoch microseconds).'
19
+ c.flag 'min_date_created', desc: 'The earliest timestamp of the log to retrieve (epoch microseconds).'
20
+ 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')."
21
+ c.flag 'sort_direction', desc: 'The direction you want the data sorted by (always by timestamp).'
22
+ c.flag 'source', desc: "The source of log events to be returned. Acceptable values are ('slack', 'developer')."
23
+ c.flag 'team_id', desc: 'The team who owns this log.'
24
+ c.flag 'trace_id', desc: 'The trace id of log events to be returned.'
25
+ c.action do |_global_options, options, _args|
26
+ puts JSON.dump(@client.apps_activities_list(options))
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+ # This file was auto-generated by lib/tasks/web.rake
3
+
4
+ module Slack
5
+ module Cli
6
+ class App
7
+ desc 'AppsAuthExternal methods.'
8
+ command 'apps_auth_external' do |g|
9
+ g.desc 'Delete external auth tokens only on the Slack side'
10
+ g.long_desc %( Delete external auth tokens only on the Slack side )
11
+ g.command 'delete' do |c|
12
+ c.flag 'app_id', desc: 'The id of the app whose tokens you want to delete.'
13
+ c.flag 'external_token_id', desc: 'The id of the token that you want to delete.'
14
+ c.flag 'provider_key', desc: 'The provider key of the provider whose tokens you want to delete.'
15
+ c.action do |_global_options, options, _args|
16
+ puts JSON.dump(@client.apps_auth_external_delete(options))
17
+ end
18
+ end
19
+
20
+ g.desc 'Get the access token for the provided token ID'
21
+ g.long_desc %( Get the access token for the provided token ID )
22
+ g.command 'get' do |c|
23
+ c.flag 'external_token_id', desc: 'The id of the token you want to get the token for.'
24
+ c.flag 'force_refresh', desc: 'Always refresh existing token before returning even when the token has not expired.'
25
+ c.action do |_global_options, options, _args|
26
+ puts JSON.dump(@client.apps_auth_external_get(options))
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+ # This file was auto-generated by lib/tasks/web.rake
3
+
4
+ module Slack
5
+ module Cli
6
+ class App
7
+ desc 'AppsDatastore methods.'
8
+ command 'apps_datastore' do |g|
9
+ g.desc 'Delete an item from a datastore'
10
+ g.long_desc %( Delete an item from a datastore )
11
+ g.command 'delete' do |c|
12
+ c.flag 'datastore', desc: 'name of the datastore.'
13
+ c.flag 'id', desc: 'item id.'
14
+ c.flag 'app_id', desc: '.'
15
+ c.action do |_global_options, options, _args|
16
+ puts JSON.dump(@client.apps_datastore_delete(options))
17
+ end
18
+ end
19
+
20
+ g.desc 'Get an item from a datastore'
21
+ g.long_desc %( Get an item from a datastore )
22
+ g.command 'get' do |c|
23
+ c.flag 'datastore', desc: 'name of the datastore.'
24
+ c.flag 'id', desc: 'item id.'
25
+ c.flag 'app_id', desc: '.'
26
+ c.action do |_global_options, options, _args|
27
+ puts JSON.dump(@client.apps_datastore_get(options))
28
+ end
29
+ end
30
+
31
+ g.desc 'Creates a new item, or replaces an old item with a new item.'
32
+ g.long_desc %( Creates a new item, or replaces an old item with a new item. )
33
+ g.command 'put' do |c|
34
+ c.flag 'datastore', desc: 'name of the datastore.'
35
+ c.flag 'item', desc: 'attribute names and values of the item.'
36
+ c.flag 'app_id', desc: '.'
37
+ c.action do |_global_options, options, _args|
38
+ puts JSON.dump(@client.apps_datastore_put(options))
39
+ end
40
+ end
41
+
42
+ g.desc 'Query a datastore for items'
43
+ g.long_desc %( Query a datastore for items )
44
+ g.command 'query' do |c|
45
+ c.flag 'datastore', desc: 'Name of the datastore.'
46
+ c.flag 'app_id', desc: 'Required if calling with user token.'
47
+ c.flag 'cursor', desc: 'Set cursor to next_cursor returned by the previous call to list items in the next page.'
48
+ c.flag 'expression', desc: 'A query filter expression https://api.slack.com/future/datastores.'
49
+ c.flag 'expression_attributes', desc: 'A map of attributes referenced in expression.'
50
+ c.flag 'expression_values', desc: 'A map of values referenced in expression.'
51
+ c.flag 'limit', desc: 'The maximum number of items to evaluate for a given request (not necessarily the number of matching items). If the given request dataset size exceeds 1 MB before reaching the limit, the returned item count will likely be less than the limit. In any case where there are more items available beyond an imposed limit, a next_cursor value will be provided for use in subsequent requests.'
52
+ c.action do |_global_options, options, _args|
53
+ puts JSON.dump(@client.apps_datastore_query(options))
54
+ end
55
+ end
56
+
57
+ g.desc "Edits an existing item's attributes, or adds a new item if it does not already exist."
58
+ g.long_desc %( Edits an existing item's attributes, or adds a new item if it does not already exist. )
59
+ g.command 'update' do |c|
60
+ c.flag 'datastore', desc: 'name of the datastore.'
61
+ c.flag 'item', desc: 'attribute names and values to be updated.'
62
+ c.flag 'app_id', desc: '.'
63
+ c.action do |_global_options, options, _args|
64
+ puts JSON.dump(@client.apps_datastore_update(options))
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -6,8 +6,8 @@ module Slack
6
6
  class App
7
7
  desc 'AuthTeams methods.'
8
8
  command 'auth_teams' do |g|
9
- g.desc 'List the workspaces a token can access.'
10
- g.long_desc %( List the workspaces a token can access. )
9
+ g.desc 'Obtain a full list of workspaces your org-wide app has been approved for.'
10
+ g.long_desc %( Obtain a full list of workspaces your org-wide app has been approved for. )
11
11
  g.command 'list' do |c|
12
12
  c.flag 'cursor', desc: 'Set cursor to next_cursor returned by the previous call to list items in the next page.'
13
13
  c.flag 'include_icon', desc: 'Whether to return icon paths for each workspace. An icon path represents a URI pointing to the image signifying the workspace.'
@@ -12,7 +12,7 @@ module Slack
12
12
  c.flag 'external_unique_id', desc: 'An ID supplied by the 3rd-party Call provider. It must be unique across all Calls from that service.'
13
13
  c.flag 'join_url', desc: 'The URL required for a client to join the Call.'
14
14
  c.flag 'created_by', desc: 'The valid Slack user ID of the user who created this Call. When this method is called with a user token, the created_by field is optional and defaults to the authed user of the token. Otherwise, the field is required.'
15
- c.flag 'date_start', desc: 'Call start time in UTC UNIX timestamp format.'
15
+ c.flag 'date_start', desc: 'Unix timestamp of the call start time.'
16
16
  c.flag 'desktop_app_join_url', desc: 'When supplied, available Slack clients will attempt to directly launch the 3rd-party Call with this URL.'
17
17
  c.flag 'external_display_id', desc: 'An optional, human-readable ID supplied by the 3rd-party Call provider. If supplied, this ID will be displayed in the Call object.'
18
18
  c.flag 'title', desc: 'The name of the Call.'
data/bin/commands/chat.rb CHANGED
@@ -68,12 +68,12 @@ module Slack
68
68
  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.'
69
69
  c.flag 'attachments', desc: 'A JSON-based array of structured attachments, presented as a URL-encoded string.'
70
70
  c.flag 'blocks', desc: 'A JSON-based array of structured blocks, presented as a URL-encoded string.'
71
- c.flag 'icon_emoji', desc: 'Emoji to use as the icon for this message. Overrides icon_url. Must be used in conjunction with as_user set to false, otherwise ignored. See authorship below.'
72
- c.flag 'icon_url', desc: 'URL to an image to use as the icon for this message. Must be used in conjunction with as_user set to false, otherwise ignored. See authorship below.'
71
+ c.flag 'icon_emoji', desc: 'Emoji to use as the icon for this message. Overrides icon_url.'
72
+ c.flag 'icon_url', desc: 'URL to an image to use as the icon for this message.'
73
73
  c.flag 'link_names', desc: 'Find and link channel names and usernames.'
74
74
  c.flag 'parse', desc: 'Change how messages are treated. Defaults to none. See below.'
75
75
  c.flag 'thread_ts', desc: "Provide another message's ts value to post this message in a thread. Avoid using a reply's ts value; use its parent's value instead. Ephemeral messages in threads are only shown if there is already an active thread."
76
- c.flag 'username', desc: "Set your bot's user name. Must be used in conjunction with as_user set to false, otherwise ignored. See authorship below."
76
+ c.flag 'username', desc: "Set your bot's user name."
77
77
  c.action do |_global_options, options, _args|
78
78
  puts JSON.dump(@client.chat_postEphemeral(options))
79
79
  end
@@ -87,8 +87,8 @@ module Slack
87
87
  c.flag 'blocks', desc: 'A JSON-based array of structured blocks, presented as a URL-encoded string.'
88
88
  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.'
89
89
  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.'
90
- c.flag 'icon_emoji', desc: 'Emoji to use as the icon for this message. Overrides icon_url. Must be used in conjunction with as_user set to false, otherwise ignored. See authorship below.'
91
- c.flag 'icon_url', desc: 'URL to an image to use as the icon for this message. Must be used in conjunction with as_user set to false, otherwise ignored. See authorship below.'
90
+ c.flag 'icon_emoji', desc: 'Emoji to use as the icon for this message. Overrides icon_url.'
91
+ c.flag 'icon_url', desc: 'URL to an image to use as the icon for this message.'
92
92
  c.flag 'link_names', desc: 'Find and link user groups. No longer supports linking individual users; use syntax shown in Mentioning Users instead.'
93
93
  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.'
94
94
  c.flag 'mrkdwn', desc: 'Disable Slack markup parsing by setting to false. Enabled by default.'
@@ -97,7 +97,7 @@ module Slack
97
97
  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."
98
98
  c.flag 'unfurl_links', desc: 'Pass true to enable unfurling of primarily text-based content.'
99
99
  c.flag 'unfurl_media', desc: 'Pass false to disable unfurling of media content.'
100
- c.flag 'username', desc: "Set your bot's user name. Must be used in conjunction with as_user set to false, otherwise ignored. See authorship below."
100
+ c.flag 'username', desc: "Set your bot's user name."
101
101
  c.action do |_global_options, options, _args|
102
102
  puts JSON.dump(@client.chat_postMessage(options))
103
103
  end
@@ -11,9 +11,9 @@ module Slack
11
11
  g.command 'list' do |c|
12
12
  c.flag 'channel', desc: 'The channel of the scheduled messages.'
13
13
  c.flag 'cursor', desc: 'For pagination purposes, this is the cursor value returned from a previous call to chat.scheduledmessages.list indicating where you want to start this call from.'
14
- c.flag 'latest', desc: 'A UNIX timestamp of the latest value in the time range.'
14
+ c.flag 'latest', desc: 'A Unix timestamp of the latest value in the time range.'
15
15
  c.flag 'limit', desc: 'Maximum number of original entries to return.'
16
- c.flag 'oldest', desc: 'A UNIX timestamp of the oldest value in the time range.'
16
+ c.flag 'oldest', desc: 'A Unix timestamp of the oldest value in the time range.'
17
17
  c.flag 'team_id', desc: 'encoded team id to list channels in, required if org token is used.'
18
18
  c.action do |_global_options, options, _args|
19
19
  puts JSON.dump(@client.chat_scheduledMessages_list(options))
@@ -12,7 +12,7 @@ module Slack
12
12
  c.flag 'channel_name', desc: 'Name of the channel. If the channel does not exist already in your workspace, this name is the one that the channel will take.'
13
13
  c.flag 'channel_id', desc: "ID of the channel that you'd like to accept. Must provide either invite_id or channel_id."
14
14
  c.flag 'free_trial_accepted', desc: "Whether you'd like to use your workspace's free trial to begin using Slack Connect."
15
- c.flag 'invite_id', desc: 'See the shared_channel_invite_received event payload for more details on how to retrieve the ID of the invitation.'
15
+ c.flag 'invite_id', desc: "ID of the invite that you'd like to accept. Must provide either invite_id or channel_id. See the shared_channel_invite_received event payload for more details on how to retrieve the ID of the invitation."
16
16
  c.flag 'is_private', desc: 'Whether the channel should be private.'
17
17
  c.flag 'team_id', desc: 'The ID of the workspace to accept the channel in. If an org-level token is used to call this method, the team_id argument is required.'
18
18
  c.action do |_global_options, options, _args|
@@ -109,9 +109,9 @@ module Slack
109
109
  g.long_desc %( Sends an invitation to a Slack Connect channel )
110
110
  g.command 'inviteShared' do |c|
111
111
  c.flag 'channel', desc: "ID of the channel on your team that you'd like to share."
112
- c.flag 'emails', desc: 'Optional email to receive this invite. Either emails or user_ids must be provided.'
112
+ c.flag 'emails', desc: 'Optional email to receive this invite. Either emails or user_ids must be provided. Only one email or one user ID may be invited at a time.'
113
113
  c.flag 'external_limited', desc: 'Optional boolean on whether invite is to a external limited member. Defaults to true.'
114
- c.flag 'user_ids', desc: 'Optional user_id to receive this invite. Either emails or user_ids must be provided.'
114
+ c.flag 'user_ids', desc: 'Optional user_id to receive this invite. Either emails or user_ids must be provided. Only one email or one user ID may be invited at a time.'
115
115
  c.action do |_global_options, options, _args|
116
116
  puts JSON.dump(@client.conversations_inviteShared(options))
117
117
  end
data/bin/commands/dnd.rb CHANGED
@@ -35,7 +35,7 @@ module Slack
35
35
  g.desc 'Turns on Do Not Disturb mode for the current user, or changes its duration.'
36
36
  g.long_desc %( Turns on Do Not Disturb mode for the current user, or changes its duration. )
37
37
  g.command 'setSnooze' do |c|
38
- c.flag 'num_minutes', desc: 'Number of minutes, from now, to snooze until.'
38
+ c.flag 'num_minutes', desc: 'This argument is required. Number of minutes, from now, to snooze until.'
39
39
  c.action do |_global_options, options, _args|
40
40
  puts JSON.dump(@client.dnd_setSnooze(options))
41
41
  end
@@ -9,8 +9,9 @@ module Slack
9
9
  g.desc "List the steps of a specific function of a workflow's versions"
10
10
  g.long_desc %( List the steps of a specific function of a workflow's versions )
11
11
  g.command 'list' do |c|
12
- c.flag 'function_id', desc: '.'
12
+ c.flag 'function_id', desc: 'The ID of the function to query.'
13
13
  c.flag 'workflow', desc: 'The workflow encoded ID or workflow reference.'
14
+ c.flag 'workflow_app_id', desc: 'The app tied to the workflow reference.'
14
15
  c.flag 'workflow_id', desc: 'The workflow ID, starts with Wf*.'
15
16
  c.action do |_global_options, options, _args|
16
17
  puts JSON.dump(@client.functions_workflows_steps_list(options))
@@ -9,8 +9,9 @@ module Slack
9
9
  g.desc 'Download form responses of a workflow'
10
10
  g.long_desc %( Download form responses of a workflow )
11
11
  g.command 'export' do |c|
12
- c.flag 'step_id', desc: '.'
12
+ c.flag 'step_id', desc: 'The ID of the OpenForm step to export.'
13
13
  c.flag 'workflow', desc: 'The workflow encoded ID or workflow reference.'
14
+ c.flag 'workflow_app_id', desc: 'The app tied to the workflow reference.'
14
15
  c.flag 'workflow_id', desc: 'The workflow ID, starts with Wf*.'
15
16
  c.action do |_global_options, options, _args|
16
17
  puts JSON.dump(@client.functions_workflows_steps_responses_export(options))
@@ -13,7 +13,7 @@ module Slack
13
13
  c.flag 'time', desc: 'When this reminder should happen: the Unix timestamp (up to five years from now), the number of seconds until the reminder (if within 24 hours), or a natural language description (Ex. "in 15 minutes," or "every Thursday").'
14
14
  c.flag 'recurrence', desc: 'Specify the repeating behavior of a reminder. Available options: daily, weekly, monthly, or yearly. If weekly, may further specify the days of the week.'
15
15
  c.flag 'team_id', desc: 'Encoded team id, required if org token is used.'
16
- c.flag 'user', desc: 'The user who will receive the reminder. If no user is specified, the reminder will go to user who created it.'
16
+ c.flag 'user', desc: 'No longer supported - reminders cannot be set for other users. Previously, was the user who would receive the reminder.'
17
17
  c.action do |_global_options, options, _args|
18
18
  puts JSON.dump(@client.reminders_add(options))
19
19
  end
@@ -6,8 +6,8 @@ module Slack
6
6
  class App
7
7
  desc 'Stars methods.'
8
8
  command 'stars' do |g|
9
- g.desc 'Save an item for later. Formerly known as _adding a star_.'
10
- g.long_desc %( Save an item for later. Formerly known as _adding a star_. )
9
+ g.desc 'Save an item for later. Formerly known as adding a star.'
10
+ g.long_desc %( Save an item for later. Formerly known as adding a star. )
11
11
  g.command 'add' do |c|
12
12
  c.flag 'channel', desc: 'Channel to add star to, or channel where the message to add star to was posted (used with timestamp).'
13
13
  c.flag 'file', desc: 'File to add star to.'
@@ -18,8 +18,8 @@ module Slack
18
18
  end
19
19
  end
20
20
 
21
- g.desc "List a user's saved items, formerly known as _stars_."
22
- g.long_desc %( List a user's saved items, formerly known as _stars_. )
21
+ g.desc "Listed a user's saved items, formerly known as stars."
22
+ g.long_desc %( Listed a user's saved items, formerly known as stars. )
23
23
  g.command 'list' do |c|
24
24
  c.flag 'cursor', desc: "Parameter for pagination. Set cursor equal to the next_cursor attribute returned by the previous request's response_metadata. This parameter is optional, but pagination is mandatory: the default value simply fetches the first 'page' of the collection. See pagination for more details."
25
25
  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."
data/bin/commands/team.rb CHANGED
@@ -10,6 +10,8 @@ module Slack
10
10
  g.long_desc %( Gets the access logs for the current team. )
11
11
  g.command 'accessLogs' do |c|
12
12
  c.flag 'before', desc: 'End of time range of logs to include in results (inclusive).'
13
+ c.flag 'cursor', desc: "Parameter for pagination. Set cursor equal to the next_cursor attribute returned by the previous request's response_metadata. This parameter is optional, but pagination is mandatory: the default value simply fetches the first 'page' of the collection. See pagination for more details."
14
+ 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. If specified, result is returned using a cursor-based approach instead of a classic one."
13
15
  c.flag 'team_id', desc: 'encoded team id to get logs from, required if org token is used.'
14
16
  c.action do |_global_options, options, _args|
15
17
  puts JSON.dump(@client.team_accessLogs(options))
@@ -32,7 +34,7 @@ module Slack
32
34
  g.long_desc %( Gets information about the current team. )
33
35
  g.command 'info' do |c|
34
36
  c.flag 'domain', desc: 'Query by domain instead of team (only when team is null). This only works for domains in the same enterprise as the querying team token. This also expects the domain to belong to a team and not the enterprise itself.'
35
- c.flag 'team', desc: 'Team to get info on, if omitted, will return information about the current team. Will only return team that the authenticated token is allowed to see through external shared channels.'
37
+ c.flag 'team', desc: 'Team to get info about; if omitted, will return information about the current team.'
36
38
  c.action do |_global_options, options, _args|
37
39
  puts JSON.dump(@client.team_info(options))
38
40
  end
@@ -11,7 +11,7 @@ module Slack
11
11
  g.command 'conversations' do |c|
12
12
  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."
13
13
  c.flag 'exclude_archived', desc: 'Set to true to exclude archived channels from the list.'
14
- 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."
14
+ 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 with a max value of 999."
15
15
  c.flag 'team_id', desc: 'encoded team id to list conversations in, required if org token is used.'
16
16
  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.'
17
17
  c.flag 'user', desc: "Browse conversations by a specific user ID's membership. Non-public channels are restricted to those where the calling user shares membership."
@@ -24,6 +24,50 @@ module Slack
24
24
  end
25
25
  end)
26
26
  end
27
+
28
+ #
29
+ # Escape a message.
30
+ # @see https://api.slack.com/reference/surfaces/formatting#escaping
31
+ #
32
+ def escape(message)
33
+ message
34
+ .gsub('&', '&')
35
+ .gsub('>', '>')
36
+ .gsub('<', '&lt;')
37
+ end
38
+
39
+ #
40
+ # Format a DateTime or Time object as a date and time in a Slack message
41
+ # @see https://api.slack.com/reference/surfaces/formatting#date-formatting
42
+ #
43
+ def date(time, format: '{date_num} {time_secs}', link: nil, text: nil)
44
+ args = [time.to_i, format, link].compact
45
+ "<!date^#{args.join('^')}|#{text || time}>"
46
+ end
47
+
48
+ #
49
+ # Embed a link to a Slack channel in a message by channel ID
50
+ # @see https://api.slack.com/reference/surfaces/formatting#linking-channels
51
+ #
52
+ def channel_link(channel_id)
53
+ "<##{channel_id}>"
54
+ end
55
+
56
+ #
57
+ # Embed a link to a user in a message by user ID
58
+ # @see https://api.slack.com/reference/surfaces/formatting#mentioning-users
59
+ #
60
+ def user_link(user_id)
61
+ "<@#{user_id}>"
62
+ end
63
+
64
+ #
65
+ # Embed a URL with custom link text in a message
66
+ # @see https://api.slack.com/reference/surfaces/formatting#linking-urls
67
+ #
68
+ def url_link(text, url)
69
+ "<#{url}|#{text}>"
70
+ end
27
71
  end
28
72
  end
29
73
  end
@@ -234,14 +234,26 @@ module Slack
234
234
 
235
235
  def run_handlers(type, data)
236
236
  handlers = store.class.events[type.to_s]
237
- handlers.each do |handler|
238
- store.instance_exec(data, self, &handler)
237
+ case async_handlers
238
+ when :all
239
+ @socket.run_async { handlers_loop(handlers, data) }
240
+ when :none
241
+ handlers_loop(handlers, data)
242
+ else
243
+ raise Config::InvalidAsyncHandlersError,
244
+ "Invalid value '#{async_handlers.inspect}' for config#async_handlers, must be :all or :none."
239
245
  end
240
246
  rescue StandardError => e
241
247
  logger.error("#{self}##{__method__}") { e }
242
248
  false
243
249
  end
244
250
 
251
+ def handlers_loop(handlers, data)
252
+ handlers.each do |handler|
253
+ store.instance_exec(data, self, &handler)
254
+ end
255
+ end
256
+
245
257
  def run_callbacks(type, data)
246
258
  callbacks = self.callbacks[type]
247
259
  return false unless callbacks