slack-ruby-client 2.3.0 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (228) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +22 -12
  3. data/.github/workflows/update_api.yml +1 -1
  4. data/.gitignore +1 -0
  5. data/.rubocop_todo.yml +43 -13
  6. data/CHANGELOG.md +19 -0
  7. data/CONTRIBUTING.md +7 -7
  8. data/Gemfile +1 -0
  9. data/README.md +68 -25
  10. data/bin/commands/admin_conversations.rb +21 -0
  11. data/bin/commands/admin_emoji.rb +1 -1
  12. data/bin/commands/admin_users.rb +4 -4
  13. data/bin/commands/admin_users_session.rb +1 -1
  14. data/bin/commands/admin_workflows.rb +6 -2
  15. data/bin/commands/admin_workflows_triggers_types_permissions.rb +31 -0
  16. data/bin/commands/apps_datastore.rb +46 -0
  17. data/bin/commands/assistant_threads.rb +45 -0
  18. data/bin/commands/bookmarks.rb +1 -0
  19. data/bin/commands/canvases.rb +40 -0
  20. data/bin/commands/canvases_access.rb +34 -0
  21. data/bin/commands/canvases_sections.rb +21 -0
  22. data/bin/commands/chat.rb +7 -3
  23. data/bin/commands/conversations.rb +6 -6
  24. data/bin/commands/conversations_canvases.rb +21 -0
  25. data/bin/commands/conversations_externalInvitePermissions.rb +22 -0
  26. data/bin/commands/conversations_requestSharedInvite.rb +48 -0
  27. data/bin/commands/files.rb +2 -1
  28. data/bin/commands/functions_distributions_permissions.rb +59 -0
  29. data/bin/commands/oauth.rb +2 -2
  30. data/bin/commands/oauth_v2.rb +2 -2
  31. data/bin/commands/reminders.rb +1 -1
  32. data/bin/commands/team_externalTeams.rb +35 -0
  33. data/bin/commands/usergroups.rb +5 -0
  34. data/bin/commands/usergroups_users.rb +2 -0
  35. data/bin/commands/users_discoverableContacts.rb +20 -0
  36. data/bin/commands/workflows_triggers_permissions.rb +60 -0
  37. data/examples/files_upload_v2/.env.example +1 -0
  38. data/examples/files_upload_v2/Gemfile +5 -0
  39. data/examples/files_upload_v2/README.md +13 -0
  40. data/examples/files_upload_v2/files_upload_v2.rb +37 -0
  41. data/examples/oauth_v2/.env.example +4 -0
  42. data/examples/oauth_v2/Gemfile +7 -0
  43. data/examples/oauth_v2/README.md +33 -0
  44. data/examples/oauth_v2/oauth_v2.rb +60 -0
  45. data/lib/slack/messages/formatting.rb +13 -0
  46. data/lib/slack/version.rb +1 -1
  47. data/lib/slack/web/api/endpoints/admin_conversations.rb +35 -0
  48. data/lib/slack/web/api/endpoints/admin_emoji.rb +1 -1
  49. data/lib/slack/web/api/endpoints/admin_users.rb +2 -2
  50. data/lib/slack/web/api/endpoints/admin_users_session.rb +2 -3
  51. data/lib/slack/web/api/endpoints/admin_workflows.rb +10 -2
  52. data/lib/slack/web/api/endpoints/admin_workflows_triggers_types_permissions.rb +41 -0
  53. data/lib/slack/web/api/endpoints/apps_datastore.rb +71 -0
  54. data/lib/slack/web/api/endpoints/assistant_threads.rb +68 -0
  55. data/lib/slack/web/api/endpoints/bookmarks.rb +2 -0
  56. data/lib/slack/web/api/endpoints/canvases.rb +52 -0
  57. data/lib/slack/web/api/endpoints/canvases_access.rb +47 -0
  58. data/lib/slack/web/api/endpoints/canvases_sections.rb +27 -0
  59. data/lib/slack/web/api/endpoints/chat.rb +12 -3
  60. data/lib/slack/web/api/endpoints/conversations.rb +5 -5
  61. data/lib/slack/web/api/endpoints/conversations_canvases.rb +26 -0
  62. data/lib/slack/web/api/endpoints/conversations_externalInvitePermissions.rb +31 -0
  63. data/lib/slack/web/api/endpoints/conversations_requestSharedInvite.rb +73 -0
  64. data/lib/slack/web/api/endpoints/dnd.rb +1 -0
  65. data/lib/slack/web/api/endpoints/files.rb +3 -1
  66. data/lib/slack/web/api/endpoints/functions_distributions_permissions.rb +80 -0
  67. data/lib/slack/web/api/endpoints/oauth.rb +2 -2
  68. data/lib/slack/web/api/endpoints/oauth_v2.rb +2 -2
  69. data/lib/slack/web/api/endpoints/reminders.rb +1 -1
  70. data/lib/slack/web/api/endpoints/team_externalTeams.rb +53 -0
  71. data/lib/slack/web/api/endpoints/usergroups.rb +10 -0
  72. data/lib/slack/web/api/endpoints/usergroups_users.rb +4 -0
  73. data/lib/slack/web/api/endpoints/users_discoverableContacts.rb +24 -0
  74. data/lib/slack/web/api/endpoints/workflows_triggers_permissions.rb +87 -0
  75. data/lib/slack/web/api/endpoints.rb +24 -0
  76. data/lib/slack/web/api/errors.rb +118 -8
  77. data/lib/slack/web/api/helpers/files.rb +87 -0
  78. data/lib/slack/web/api/helpers.rb +13 -0
  79. data/lib/slack/web/api/templates/method.erb +1 -0
  80. data/lib/slack/web/api/templates/method_spec.erb +6 -4
  81. data/lib/slack/web/client.rb +1 -0
  82. data/lib/slack/web/faraday/connection.rb +13 -26
  83. data/lib/slack/web/faraday/options.rb +24 -0
  84. data/lib/slack/web/faraday/request.rb +2 -1
  85. data/lib/slack-ruby-client.rb +2 -0
  86. data/slack-ruby-client.gemspec +2 -1
  87. metadata +52 -144
  88. data/screenshots/create-app.png +0 -0
  89. data/spec/fixtures/slack/web/429_error.yml +0 -81
  90. data/spec/fixtures/slack/web/auth_test_error.yml +0 -81
  91. data/spec/fixtures/slack/web/auth_test_success.yml +0 -81
  92. data/spec/fixtures/slack/web/conversations_info.yml +0 -167
  93. data/spec/fixtures/slack/web/conversations_setTopic.yml +0 -84
  94. data/spec/fixtures/slack/web/conversations_setTopic_one_page.yml +0 -172
  95. data/spec/fixtures/slack/web/conversations_setTopic_paginated.yml +0 -253
  96. data/spec/fixtures/slack/web/paginated_users_list.yml +0 -613
  97. data/spec/fixtures/slack/web/rtm_connect.yml +0 -391
  98. data/spec/fixtures/slack/web/users_info.yml +0 -214
  99. data/spec/fixtures/slack/web/users_list.yml +0 -133
  100. data/spec/fixtures/slack/web/views_open_error.yml +0 -83
  101. data/spec/integration/integration_spec.rb +0 -207
  102. data/spec/slack/config_spec.rb +0 -16
  103. data/spec/slack/events/config_spec.rb +0 -35
  104. data/spec/slack/events/request_spec.rb +0 -199
  105. data/spec/slack/messages/formatting_spec.rb +0 -124
  106. data/spec/slack/real_time/api/message_spec.rb +0 -20
  107. data/spec/slack/real_time/api/ping_spec.rb +0 -17
  108. data/spec/slack/real_time/api/typing_spec.rb +0 -19
  109. data/spec/slack/real_time/client_spec.rb +0 -601
  110. data/spec/slack/real_time/concurrency/clients/async_spec.rb +0 -16
  111. data/spec/slack/real_time/concurrency/it_behaves_like_a_realtime_socket.rb +0 -21
  112. data/spec/slack/real_time/concurrency/with_concurrency_spec.rb +0 -10
  113. data/spec/slack/real_time/concurrency/without_concurrency_spec.rb +0 -10
  114. data/spec/slack/real_time/event_handlers/bot_spec.rb +0 -47
  115. data/spec/slack/real_time/event_handlers/event_handlers_spec.rb +0 -16
  116. data/spec/slack/real_time/event_handlers/im_spec.rb +0 -51
  117. data/spec/slack/real_time/event_handlers/private_channel_spec.rb +0 -99
  118. data/spec/slack/real_time/event_handlers/public_channel_spec.rb +0 -123
  119. data/spec/slack/real_time/event_handlers/team_spec.rb +0 -63
  120. data/spec/slack/real_time/event_handlers/user_spec.rb +0 -65
  121. data/spec/slack/real_time/rtm_connect_spec.rb +0 -14
  122. data/spec/slack/real_time/stores/store_spec.rb +0 -50
  123. data/spec/slack/slack_spec.rb +0 -93
  124. data/spec/slack/version_spec.rb +0 -8
  125. data/spec/slack/web/api/endpoints/admin_analytics_spec.rb +0 -13
  126. data/spec/slack/web/api/endpoints/admin_apps_activities_spec.rb +0 -8
  127. data/spec/slack/web/api/endpoints/admin_apps_approved_spec.rb +0 -8
  128. data/spec/slack/web/api/endpoints/admin_apps_config_spec.rb +0 -18
  129. data/spec/slack/web/api/endpoints/admin_apps_requests_spec.rb +0 -13
  130. data/spec/slack/web/api/endpoints/admin_apps_restricted_spec.rb +0 -8
  131. data/spec/slack/web/api/endpoints/admin_apps_spec.rb +0 -18
  132. data/spec/slack/web/api/endpoints/admin_audit_anomaly_allow_spec.rb +0 -8
  133. data/spec/slack/web/api/endpoints/admin_auth_policy_spec.rb +0 -35
  134. data/spec/slack/web/api/endpoints/admin_barriers_spec.rb +0 -38
  135. data/spec/slack/web/api/endpoints/admin_conversations_ekm_spec.rb +0 -8
  136. data/spec/slack/web/api/endpoints/admin_conversations_restrictAccess_spec.rb +0 -32
  137. data/spec/slack/web/api/endpoints/admin_conversations_spec.rb +0 -133
  138. data/spec/slack/web/api/endpoints/admin_emoji_spec.rb +0 -37
  139. data/spec/slack/web/api/endpoints/admin_functions_permissions_spec.rb +0 -21
  140. data/spec/slack/web/api/endpoints/admin_functions_spec.rb +0 -13
  141. data/spec/slack/web/api/endpoints/admin_inviteRequests_approved_spec.rb +0 -8
  142. data/spec/slack/web/api/endpoints/admin_inviteRequests_denied_spec.rb +0 -8
  143. data/spec/slack/web/api/endpoints/admin_inviteRequests_spec.rb +0 -18
  144. data/spec/slack/web/api/endpoints/admin_roles_spec.rb +0 -30
  145. data/spec/slack/web/api/endpoints/admin_teams_admins_spec.rb +0 -13
  146. data/spec/slack/web/api/endpoints/admin_teams_owners_spec.rb +0 -13
  147. data/spec/slack/web/api/endpoints/admin_teams_settings_spec.rb +0 -53
  148. data/spec/slack/web/api/endpoints/admin_teams_spec.rb +0 -16
  149. data/spec/slack/web/api/endpoints/admin_usergroups_spec.rb +0 -37
  150. data/spec/slack/web/api/endpoints/admin_users_session_spec.rb +0 -41
  151. data/spec/slack/web/api/endpoints/admin_users_spec.rb +0 -67
  152. data/spec/slack/web/api/endpoints/admin_users_unsupportedVersions_spec.rb +0 -8
  153. data/spec/slack/web/api/endpoints/admin_workflows_collaborators_spec.rb +0 -24
  154. data/spec/slack/web/api/endpoints/admin_workflows_permissions_spec.rb +0 -13
  155. data/spec/slack/web/api/endpoints/admin_workflows_spec.rb +0 -13
  156. data/spec/slack/web/api/endpoints/api_spec.rb +0 -8
  157. data/spec/slack/web/api/endpoints/apps_activities_spec.rb +0 -13
  158. data/spec/slack/web/api/endpoints/apps_auth_external_spec.rb +0 -13
  159. data/spec/slack/web/api/endpoints/apps_connections_spec.rb +0 -8
  160. data/spec/slack/web/api/endpoints/apps_datastore_spec.rb +0 -45
  161. data/spec/slack/web/api/endpoints/apps_event_authorizations_spec.rb +0 -13
  162. data/spec/slack/web/api/endpoints/apps_manifest_spec.rb +0 -44
  163. data/spec/slack/web/api/endpoints/apps_spec.rb +0 -16
  164. data/spec/slack/web/api/endpoints/auth_spec.rb +0 -8
  165. data/spec/slack/web/api/endpoints/auth_teams_spec.rb +0 -8
  166. data/spec/slack/web/api/endpoints/bookmarks_spec.rb +0 -40
  167. data/spec/slack/web/api/endpoints/bots_spec.rb +0 -8
  168. data/spec/slack/web/api/endpoints/calls_participants_spec.rb +0 -24
  169. data/spec/slack/web/api/endpoints/calls_spec.rb +0 -31
  170. data/spec/slack/web/api/endpoints/chat_scheduledMessages_spec.rb +0 -8
  171. data/spec/slack/web/api/endpoints/chat_spec.rb +0 -134
  172. data/spec/slack/web/api/endpoints/conversations_spec.rb +0 -8
  173. data/spec/slack/web/api/endpoints/custom_specs/auth_spec.rb +0 -27
  174. data/spec/slack/web/api/endpoints/custom_specs/chat_spec.rb +0 -206
  175. data/spec/slack/web/api/endpoints/custom_specs/conversations_spec.rb +0 -13
  176. data/spec/slack/web/api/endpoints/custom_specs/dialog_spec.rb +0 -40
  177. data/spec/slack/web/api/endpoints/custom_specs/users_spec.rb +0 -38
  178. data/spec/slack/web/api/endpoints/custom_specs/views_spec.rb +0 -112
  179. data/spec/slack/web/api/endpoints/dialog_spec.rb +0 -14
  180. data/spec/slack/web/api/endpoints/dnd_spec.rb +0 -13
  181. data/spec/slack/web/api/endpoints/emoji_spec.rb +0 -8
  182. data/spec/slack/web/api/endpoints/files_comments_spec.rb +0 -16
  183. data/spec/slack/web/api/endpoints/files_remote_spec.rb +0 -24
  184. data/spec/slack/web/api/endpoints/files_spec.rb +0 -57
  185. data/spec/slack/web/api/endpoints/functions_spec.rb +0 -28
  186. data/spec/slack/web/api/endpoints/functions_workflows_steps_responses_spec.rb +0 -13
  187. data/spec/slack/web/api/endpoints/functions_workflows_steps_spec.rb +0 -13
  188. data/spec/slack/web/api/endpoints/migration_spec.rb +0 -13
  189. data/spec/slack/web/api/endpoints/oauth_spec.rb +0 -8
  190. data/spec/slack/web/api/endpoints/oauth_v2_spec.rb +0 -16
  191. data/spec/slack/web/api/endpoints/openid_connect_spec.rb +0 -8
  192. data/spec/slack/web/api/endpoints/pins_spec.rb +0 -23
  193. data/spec/slack/web/api/endpoints/reactions_spec.rb +0 -24
  194. data/spec/slack/web/api/endpoints/reminders_spec.rb +0 -31
  195. data/spec/slack/web/api/endpoints/rtm_spec.rb +0 -8
  196. data/spec/slack/web/api/endpoints/search_spec.rb +0 -23
  197. data/spec/slack/web/api/endpoints/stars_spec.rb +0 -8
  198. data/spec/slack/web/api/endpoints/team_billing_spec.rb +0 -8
  199. data/spec/slack/web/api/endpoints/team_preferences_spec.rb +0 -8
  200. data/spec/slack/web/api/endpoints/team_profile_spec.rb +0 -8
  201. data/spec/slack/web/api/endpoints/team_spec.rb +0 -8
  202. data/spec/slack/web/api/endpoints/tooling_tokens_spec.rb +0 -13
  203. data/spec/slack/web/api/endpoints/usergroups_spec.rb +0 -28
  204. data/spec/slack/web/api/endpoints/usergroups_users_spec.rb +0 -21
  205. data/spec/slack/web/api/endpoints/users_admin_spec.rb +0 -18
  206. data/spec/slack/web/api/endpoints/users_prefs_spec.rb +0 -8
  207. data/spec/slack/web/api/endpoints/users_profile_spec.rb +0 -14
  208. data/spec/slack/web/api/endpoints/users_spec.rb +0 -8
  209. data/spec/slack/web/api/endpoints/views_spec.rb +0 -65
  210. data/spec/slack/web/api/endpoints/workflows_spec.rb +0 -34
  211. data/spec/slack/web/api/error_spec.rb +0 -14
  212. data/spec/slack/web/api/errors/slack_error_spec.rb +0 -33
  213. data/spec/slack/web/api/mixins/conversations_list_spec.rb +0 -21
  214. data/spec/slack/web/api/mixins/conversations_spec.rb +0 -45
  215. data/spec/slack/web/api/mixins/users_spec.rb +0 -52
  216. data/spec/slack/web/api/options_spec.rb +0 -69
  217. data/spec/slack/web/api/pagination/cursor_spec.rb +0 -102
  218. data/spec/slack/web/client_spec.rb +0 -359
  219. data/spec/slack/web/faraday/request_spec.rb +0 -80
  220. data/spec/slack/web/faraday/response/raise_error_spec.rb +0 -86
  221. data/spec/spec_helper.rb +0 -30
  222. data/spec/support/queue_with_timeout.rb +0 -35
  223. data/spec/support/real_time/concurrency/mock.rb +0 -31
  224. data/spec/support/real_time/connected_client.rb +0 -21
  225. data/spec/support/real_time/event.rb +0 -12
  226. data/spec/support/real_time/loaded_client.rb +0 -120
  227. data/spec/support/token.rb +0 -11
  228. data/spec/support/vcr.rb +0 -45
@@ -0,0 +1,13 @@
1
+ Samples for using `files_upload_v2`.
2
+
3
+ ## Usage
4
+
5
+ Create a Slack app and obtain a User OAuth Token [here](https://api.slack.com/tutorials/tracks/getting-a-token) or use the [oauth_v2](../oauth_v2) example to obtain a User OAuth Token.
6
+ Make sure to select `files:write` and `files:read` scopes under "User Token Scopes".
7
+
8
+ Create `.env` file with `SLACK_API_TOKEN` or set the `SLACK_API_TOKEN` environment variable.
9
+
10
+ ```
11
+ bundle install
12
+ bundle exec dotenv ruby files_upload_v2.rb
13
+ ```
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+ require 'slack-ruby-client'
3
+ require 'securerandom'
4
+
5
+ Slack.configure do |config|
6
+ config.token = ENV['SLACK_API_TOKEN']
7
+ raise 'Missing ENV[SLACK_API_TOKEN]!' unless config.token
8
+ end
9
+
10
+ client = Slack::Web::Client.new
11
+
12
+ auth = client.auth_test
13
+ puts "Connected to team #{auth.team} (#{auth.team_id}) as #{auth.user}."
14
+
15
+ puts client.files_upload_v2(
16
+ filename: 'files_upload_v2.txt',
17
+ content: SecureRandom.hex
18
+ ).files.first.permalink_public
19
+
20
+ puts client.files_upload_v2(
21
+ filename: 'files_upload_v2_to_general_channel.txt',
22
+ content: SecureRandom.hex,
23
+ channel: '#general'
24
+ ).files.first.permalink_public
25
+
26
+ puts client.files_upload_v2(
27
+ filename: 'files_upload_v2_to_general_and_random_channels.txt',
28
+ content: SecureRandom.hex,
29
+ channels: ['#general', '#random']
30
+ ).files.first.permalink_public
31
+
32
+ channel_id = client.conversations_id(channel: '#general')['channel']['id']
33
+ puts client.files_upload_v2(
34
+ filename: 'files_upload_v2_to_general_by_id.txt',
35
+ content: SecureRandom.hex,
36
+ channel_id: channel_id
37
+ ).files.first.permalink_public
@@ -0,0 +1,4 @@
1
+ SLACK_CLIENT_ID=
2
+ SLACK_CLIENT_SECRET=
3
+ REDIRECT_URI=https://...ngrok-free.app
4
+ SCOPE=files:read,files:write,files:write:user
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+ source 'http://rubygems.org'
3
+
4
+ gem 'activesupport'
5
+ gem 'dotenv'
6
+ gem 'slack-ruby-client', path: '../..'
7
+ gem 'webrick'
@@ -0,0 +1,33 @@
1
+ Obtain a user OAuth token from Slack.
2
+
3
+ Create a Slack app [here](https://api.slack.com/tutorials/tracks/getting-a-token).
4
+
5
+ The new app has a pre-configured User OAuth Token which you can use for most of the examples.
6
+ However you may want to obtain a token for a different user, which can be accomplished as follows.
7
+
8
+ To test locally use [ngrok](https://ngrok.com/) to expose your local server to the internet.
9
+
10
+ ```sh
11
+ ngrok http 4242
12
+ ```
13
+
14
+ Add the ngrok URL to the app's "Redirect URLs" under "OAuth & Permissions" in the app's settings.
15
+
16
+ Create a `.env` file with the following:
17
+
18
+ ```
19
+ SLACK_CLIENT_ID=[App Client ID]
20
+ SLACK_CLIENT_SECRET=[App Client Secret]
21
+ REDIRECT_URI=[Your ngrok URL, e.g. https://...ngrok-free.app]
22
+ SCOPE=[Bot User OAuth Scopes Requested]
23
+ USER_SCOPE=[User OAuth Token Scopes Requested]
24
+ ```
25
+
26
+ Run the example.
27
+
28
+ ```sh
29
+ bundle install
30
+ bundle exec dotenv ruby oauth_v2.rb
31
+ ```
32
+
33
+ A browser window will open to complete the OAuth flow.
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'dotenv/load'
5
+ require 'webrick'
6
+ require 'slack-ruby-client'
7
+ require 'active_support'
8
+ require 'active_support/core_ext/object/to_query'
9
+
10
+ server = WEBrick::HTTPServer.new(Port: ENV['PORT'] || 4242)
11
+
12
+ trap 'INT' do
13
+ server.shutdown
14
+ end
15
+
16
+ server.mount_proc '/' do |req, res|
17
+ client = Slack::Web::Client.new
18
+
19
+ response = client.oauth_v2_access(
20
+ req.query.merge(
21
+ client_id: ENV['SLACK_CLIENT_ID'],
22
+ client_secret: ENV['SLACK_CLIENT_SECRET'],
23
+ grant_type: 'authorization_code'
24
+ )
25
+ )
26
+
27
+ pp response
28
+
29
+ res.body = %(
30
+ <html>
31
+ <body>
32
+ <ul>
33
+ <li>bot access_token: #{response.access_token}</li>
34
+ <li>token_type: #{response.token_type}</li>
35
+ <li>app_id: #{response.app_id}</li>
36
+ <li>scope: #{response.scope}</li>
37
+ <li>user: #{response.authed_user.id}</li>
38
+ <li>user access token: #{response.authed_user.access_token}</li>
39
+ </ul>
40
+ <body>
41
+ </html>
42
+ )
43
+
44
+ pp Slack::Web::Client.new(token: response.authed_user.access_token || response.access_token).auth_test
45
+
46
+ server.shutdown
47
+ end
48
+
49
+ query = {
50
+ client_id: ENV['SLACK_CLIENT_ID'],
51
+ redirect_uri: ENV['REDIRECT_URI'],
52
+ scope: ENV['SCOPE'],
53
+ user_scope: ENV['USER_SCOPE']
54
+ }
55
+
56
+ url = "https://slack.com/oauth/v2/authorize?#{query.to_query}"
57
+ puts "Opening browser at #{url}."
58
+ system 'open', url
59
+
60
+ server.start
@@ -68,6 +68,19 @@ module Slack
68
68
  def url_link(text, url)
69
69
  "<#{url}|#{text}>"
70
70
  end
71
+
72
+ #
73
+ # Converts text from basic markdown into Slack's mishmash
74
+ # @see https://api.slack.com/reference/surfaces/formatting#basic-formatting
75
+ #
76
+ def markdown(text)
77
+ text
78
+ .gsub(/(?<!\*)\*([^*\n]+)\*(?!\*)/, '_\1_') # italic
79
+ .gsub(/\*\*\*(.*?)\*\*\*/, '*_\1_*') # bold & italic
80
+ .gsub(/\*\*(.*?)\*\*/, '*\1*') # bold
81
+ .gsub(/~~(.*?)~~/, '~\1~') # strikethrough
82
+ .gsub(/\[(.*?)\]\((.*?)\)/, '<\2|\1>') # links
83
+ end
71
84
  end
72
85
  end
73
86
  end
data/lib/slack/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Slack
3
- VERSION = '2.3.0'
3
+ VERSION = '2.5.0'
4
4
  end
@@ -191,6 +191,25 @@ module Slack
191
191
  post('admin.conversations.invite', options)
192
192
  end
193
193
 
194
+ #
195
+ # Link a Salesforce record to a channel
196
+ #
197
+ # @option options [channel] :channel
198
+ # Channel ID for Slack channel that will be linked to a Salesforce record.
199
+ # @option options [string] :record_id
200
+ # Salesforce record ID (15 or 18 digit accepted). See here for how to look up record ID.
201
+ # @option options [string] :salesforce_org_id
202
+ # Salesforce org ID (15 or 18 digit accepted). See here for how to look up Salesforce org ID.
203
+ # @see https://api.slack.com/methods/admin.conversations.linkObjects
204
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/admin.conversations/admin.conversations.linkObjects.json
205
+ def admin_conversations_linkObjects(options = {})
206
+ raise ArgumentError, 'Required arguments :channel missing' if options[:channel].nil?
207
+ raise ArgumentError, 'Required arguments :record_id missing' if options[:record_id].nil?
208
+ raise ArgumentError, 'Required arguments :salesforce_org_id missing' if options[:salesforce_org_id].nil?
209
+ options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
210
+ post('admin.conversations.linkObjects', options)
211
+ end
212
+
194
213
  #
195
214
  # Returns channels on the given team using the filters.
196
215
  #
@@ -338,6 +357,22 @@ module Slack
338
357
  raise ArgumentError, 'Required arguments :channel_id missing' if options[:channel_id].nil?
339
358
  post('admin.conversations.unarchive', options)
340
359
  end
360
+
361
+ #
362
+ # Unlink a Salesforce record from a channel
363
+ #
364
+ # @option options [channel] :channel
365
+ # Channel ID for Slack channel that will be unlinked from the Salesforce record.
366
+ # @option options [string] :new_name
367
+ # Channel name you would like to give to the channel that is being unlinked from the Salesforce record.
368
+ # @see https://api.slack.com/methods/admin.conversations.unlinkObjects
369
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/admin.conversations/admin.conversations.unlinkObjects.json
370
+ def admin_conversations_unlinkObjects(options = {})
371
+ raise ArgumentError, 'Required arguments :channel missing' if options[:channel].nil?
372
+ raise ArgumentError, 'Required arguments :new_name missing' if options[:new_name].nil?
373
+ options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
374
+ post('admin.conversations.unlinkObjects', options)
375
+ end
341
376
  end
342
377
  end
343
378
  end
@@ -10,7 +10,7 @@ module Slack
10
10
  # Add an emoji.
11
11
  #
12
12
  # @option options [string] :name
13
- # The name of the emoji to be added. Colons (:myemoji:) around the value are not required, although they may be included.
13
+ # The name of the emoji to be added (using lower-case letters only). Colons (:myemoji:) around the value are not required, although they may be included.
14
14
  # @option options [string] :url
15
15
  # The URL of a file to use as an image for the emoji. Square images under 128KB and with transparent backgrounds work best.
16
16
  # @see https://api.slack.com/methods/admin.emoji.add
@@ -100,7 +100,7 @@ module Slack
100
100
  end
101
101
 
102
102
  #
103
- # Set an existing guest, regular user, or owner to be an admin user.
103
+ # Set an existing regular user or owner to be a workspace admin.
104
104
  #
105
105
  # @option options [Object] :team_id
106
106
  # The ID (T1234) of the workspace.
@@ -132,7 +132,7 @@ module Slack
132
132
  end
133
133
 
134
134
  #
135
- # Set an existing guest, regular user, or admin user to be a workspace owner.
135
+ # Set an existing regular user or admin to be a workspace owner.
136
136
  #
137
137
  # @option options [Object] :team_id
138
138
  # The ID (T1234) of the workspace.
@@ -35,13 +35,12 @@ module Slack
35
35
  #
36
36
  # @option options [integer] :session_id
37
37
  # ID of the session to invalidate.
38
- # @option options [string] :team_id
39
- # ID of the workspace that the session belongs to.
38
+ # @option options [Object] :user_id
39
+ # ID of the user that the session belongs to.
40
40
  # @see https://api.slack.com/methods/admin.users.session.invalidate
41
41
  # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/admin.users.session/admin.users.session.invalidate.json
42
42
  def admin_users_session_invalidate(options = {})
43
43
  raise ArgumentError, 'Required arguments :session_id missing' if options[:session_id].nil?
44
- raise ArgumentError, 'Required arguments :team_id missing' if options[:team_id].nil?
45
44
  post('admin.users.session.invalidate', options)
46
45
  end
47
46
 
@@ -12,15 +12,19 @@ module Slack
12
12
  # @option options [Object] :app_id
13
13
  # The parent app ID for which to return workflows.
14
14
  # @option options [array] :collaborator_ids
15
- # Only include workflows by the collaborators inputted.
15
+ # Only include workflows where all of the provided user IDs are a manager/collaborator of that workflow.
16
16
  # @option options [string] :cursor
17
17
  # Set cursor to next_cursor returned by the previous call to list items in the next page.
18
+ # @option options [boolean] :is_sales_elevate
19
+ # Filter workflows by their Sales Elevate status.
18
20
  # @option options [integer] :limit
19
21
  # The number of results that will be returned by the API on each invocation.
20
22
  # @option options [boolean] :no_collaborators
21
23
  # Only include workflows with no collaborators in the result; default is false.
22
24
  # @option options [integer] :num_trigger_ids
23
- # Number of trigger IDs to fetch for each workflow; default is 0.
25
+ # Number of trigger IDs to fetch for each workflow; default is 10.
26
+ # @option options [enum] :publish_status
27
+ # Filter workflows by their published status.
24
28
  # @option options [string] :query
25
29
  # A search query to filter for workflow name or description.
26
30
  # @option options [enum] :sort
@@ -29,6 +33,10 @@ module Slack
29
33
  # 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).
30
34
  # @option options [enum] :source
31
35
  # Source of workflow creation, either from code or workflow builder.
36
+ # @option options [array] :step_function_ids
37
+ # Only include workflows that use all of the provided step function ids.
38
+ # @option options [string] :trigger_type_id
39
+ # Only include workflows with this trigger type.
32
40
  # @see https://api.slack.com/methods/admin.workflows.search
33
41
  # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/admin.workflows/admin.workflows.search.json
34
42
  def admin_workflows_search(options = {})
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+ # This file was auto-generated by lib/tasks/web.rake
3
+
4
+ module Slack
5
+ module Web
6
+ module Api
7
+ module Endpoints
8
+ module AdminWorkflowsTriggersTypesPermissions
9
+ #
10
+ # list the permissions for using each trigger type
11
+ #
12
+ # @option options [array] :trigger_type_ids
13
+ # The trigger types IDs for which to get the permissions.
14
+ # @see https://api.slack.com/methods/admin.workflows.triggers.types.permissions.lookup
15
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/admin.workflows.triggers.types.permissions/admin.workflows.triggers.types.permissions.lookup.json
16
+ def admin_workflows_triggers_types_permissions_lookup(options = {})
17
+ raise ArgumentError, 'Required arguments :trigger_type_ids missing' if options[:trigger_type_ids].nil?
18
+ post('admin.workflows.triggers.types.permissions.lookup', options)
19
+ end
20
+
21
+ #
22
+ # Set the permissions for using a trigger type
23
+ #
24
+ # @option options [Object] :id
25
+ # The trigger type ID for which to set the permissions.
26
+ # @option options [enum] :visibility
27
+ # The function visibility.
28
+ # @option options [array] :user_ids
29
+ # List of user IDs to allow for named_entities visibility.
30
+ # @see https://api.slack.com/methods/admin.workflows.triggers.types.permissions.set
31
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/admin.workflows.triggers.types.permissions/admin.workflows.triggers.types.permissions.set.json
32
+ def admin_workflows_triggers_types_permissions_set(options = {})
33
+ raise ArgumentError, 'Required arguments :id missing' if options[:id].nil?
34
+ raise ArgumentError, 'Required arguments :visibility missing' if options[:visibility].nil?
35
+ post('admin.workflows.triggers.types.permissions.set', options)
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -6,6 +6,77 @@ module Slack
6
6
  module Api
7
7
  module Endpoints
8
8
  module AppsDatastore
9
+ #
10
+ # Delete items from a datastore in bulk
11
+ #
12
+ # @option options [string] :datastore
13
+ # name of the datastore.
14
+ # @option options [array] :ids
15
+ # IDs of items to be deleted.
16
+ # @option options [Object] :app_id
17
+ # .
18
+ # @see https://api.slack.com/methods/apps.datastore.bulkDelete
19
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/apps.datastore/apps.datastore.bulkDelete.json
20
+ def apps_datastore_bulkDelete(options = {})
21
+ raise ArgumentError, 'Required arguments :datastore missing' if options[:datastore].nil?
22
+ raise ArgumentError, 'Required arguments :ids missing' if options[:ids].nil?
23
+ post('apps.datastore.bulkDelete', options)
24
+ end
25
+
26
+ #
27
+ # Get items from a datastore in bulk
28
+ #
29
+ # @option options [string] :datastore
30
+ # name of the datastore.
31
+ # @option options [array] :ids
32
+ # items' ids.
33
+ # @option options [Object] :app_id
34
+ # .
35
+ # @see https://api.slack.com/methods/apps.datastore.bulkGet
36
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/apps.datastore/apps.datastore.bulkGet.json
37
+ def apps_datastore_bulkGet(options = {})
38
+ raise ArgumentError, 'Required arguments :datastore missing' if options[:datastore].nil?
39
+ raise ArgumentError, 'Required arguments :ids missing' if options[:ids].nil?
40
+ post('apps.datastore.bulkGet', options)
41
+ end
42
+
43
+ #
44
+ # Creates or replaces existing items in bulk
45
+ #
46
+ # @option options [string] :datastore
47
+ # name of the datastore.
48
+ # @option options [array] :items
49
+ # attribute names and values of the items; limit of 25.
50
+ # @option options [Object] :app_id
51
+ # .
52
+ # @see https://api.slack.com/methods/apps.datastore.bulkPut
53
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/apps.datastore/apps.datastore.bulkPut.json
54
+ def apps_datastore_bulkPut(options = {})
55
+ raise ArgumentError, 'Required arguments :datastore missing' if options[:datastore].nil?
56
+ raise ArgumentError, 'Required arguments :items missing' if options[:items].nil?
57
+ post('apps.datastore.bulkPut', options)
58
+ end
59
+
60
+ #
61
+ # Count the number of items in a datastore that match a query
62
+ #
63
+ # @option options [string] :datastore
64
+ # Name of the datastore.
65
+ # @option options [Object] :app_id
66
+ # Required if calling with user token.
67
+ # @option options [string] :expression
68
+ # A query filter expression https://api.slack.com/future/datastores.
69
+ # @option options [object] :expression_attributes
70
+ # A map of attributes referenced in expression.
71
+ # @option options [object] :expression_values
72
+ # A map of values referenced in expression.
73
+ # @see https://api.slack.com/methods/apps.datastore.count
74
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/apps.datastore/apps.datastore.count.json
75
+ def apps_datastore_count(options = {})
76
+ raise ArgumentError, 'Required arguments :datastore missing' if options[:datastore].nil?
77
+ post('apps.datastore.count', options)
78
+ end
79
+
9
80
  #
10
81
  # Delete an item from a datastore
11
82
  #
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+ # This file was auto-generated by lib/tasks/web.rake
3
+
4
+ module Slack
5
+ module Web
6
+ module Api
7
+ module Endpoints
8
+ module AssistantThreads
9
+ #
10
+ # Set the status for an AI assistant thread.
11
+ #
12
+ # @option options [Object] :channel_id
13
+ # Channel ID containing the assistant thread.
14
+ # @option options [string] :status
15
+ # Status of the specified bot user, e.g. 'is thinking...'.
16
+ # @option options [string] :thread_ts
17
+ # Message timestamp of the thread of where to set the status.
18
+ # @see https://api.slack.com/methods/assistant.threads.setStatus
19
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/assistant.threads/assistant.threads.setStatus.json
20
+ def assistant_threads_setStatus(options = {})
21
+ raise ArgumentError, 'Required arguments :channel_id missing' if options[:channel_id].nil?
22
+ raise ArgumentError, 'Required arguments :status missing' if options[:status].nil?
23
+ raise ArgumentError, 'Required arguments :thread_ts missing' if options[:thread_ts].nil?
24
+ post('assistant.threads.setStatus', options)
25
+ end
26
+
27
+ #
28
+ # Set suggested prompts for the given assistant thread
29
+ #
30
+ # @option options [Object] :channel_id
31
+ # Channel ID containing the assistant thread.
32
+ # @option options [Object] :prompts
33
+ # Each prompt should be supplied with its title and message attribute.
34
+ # @option options [string] :thread_ts
35
+ # Message timestamp of the thread to set suggested prompts for.
36
+ # @option options [string] :title
37
+ # Title for the list of provided prompts. For example: Suggested Prompts, Related Questions.
38
+ # @see https://api.slack.com/methods/assistant.threads.setSuggestedPrompts
39
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/assistant.threads/assistant.threads.setSuggestedPrompts.json
40
+ def assistant_threads_setSuggestedPrompts(options = {})
41
+ raise ArgumentError, 'Required arguments :channel_id missing' if options[:channel_id].nil?
42
+ raise ArgumentError, 'Required arguments :prompts missing' if options[:prompts].nil?
43
+ raise ArgumentError, 'Required arguments :thread_ts missing' if options[:thread_ts].nil?
44
+ post('assistant.threads.setSuggestedPrompts', options)
45
+ end
46
+
47
+ #
48
+ # Set the title for the given assistant thread
49
+ #
50
+ # @option options [Object] :channel_id
51
+ # Channel ID containing the assistant thread.
52
+ # @option options [string] :thread_ts
53
+ # Message timestamp of the thread to set suggested prompts for.
54
+ # @option options [string] :title
55
+ # The title to use for the thread.
56
+ # @see https://api.slack.com/methods/assistant.threads.setTitle
57
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/assistant.threads/assistant.threads.setTitle.json
58
+ def assistant_threads_setTitle(options = {})
59
+ raise ArgumentError, 'Required arguments :channel_id missing' if options[:channel_id].nil?
60
+ raise ArgumentError, 'Required arguments :thread_ts missing' if options[:thread_ts].nil?
61
+ raise ArgumentError, 'Required arguments :title missing' if options[:title].nil?
62
+ post('assistant.threads.setTitle', options)
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -15,6 +15,8 @@ module Slack
15
15
  # Title for the bookmark.
16
16
  # @option options [string] :type
17
17
  # Type of the bookmark i.e link.
18
+ # @option options [enum] :access_level
19
+ # The level that we are setting the file's permission to (read or write).
18
20
  # @option options [string] :emoji
19
21
  # Emoji tag to apply to the link.
20
22
  # @option options [string] :entity_id
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+ # This file was auto-generated by lib/tasks/web.rake
3
+
4
+ module Slack
5
+ module Web
6
+ module Api
7
+ module Endpoints
8
+ module Canvases
9
+ #
10
+ # Create canvas for a user
11
+ #
12
+ # @option options [Object] :document_content
13
+ # Structure describing the type and value of the content to create.
14
+ # @option options [string] :title
15
+ # Title of the newly created canvas.
16
+ # @see https://api.slack.com/methods/canvases.create
17
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/canvases/canvases.create.json
18
+ def canvases_create(options = {})
19
+ post('canvases.create', options)
20
+ end
21
+
22
+ #
23
+ # Deletes a canvas
24
+ #
25
+ # @option options [Object] :canvas_id
26
+ # Encoded ID of the canvas.
27
+ # @see https://api.slack.com/methods/canvases.delete
28
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/canvases/canvases.delete.json
29
+ def canvases_delete(options = {})
30
+ raise ArgumentError, 'Required arguments :canvas_id missing' if options[:canvas_id].nil?
31
+ post('canvases.delete', options)
32
+ end
33
+
34
+ #
35
+ # Update an existing canvas
36
+ #
37
+ # @option options [Object] :canvas_id
38
+ # Encoded ID of the canvas.
39
+ # @option options [array] :changes
40
+ # List of changes to apply on the specified canvas.
41
+ # @see https://api.slack.com/methods/canvases.edit
42
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/canvases/canvases.edit.json
43
+ def canvases_edit(options = {})
44
+ raise ArgumentError, 'Required arguments :canvas_id missing' if options[:canvas_id].nil?
45
+ raise ArgumentError, 'Required arguments :changes missing' if options[:changes].nil?
46
+ post('canvases.edit', options)
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+ # This file was auto-generated by lib/tasks/web.rake
3
+
4
+ module Slack
5
+ module Web
6
+ module Api
7
+ module Endpoints
8
+ module CanvasesAccess
9
+ #
10
+ # Remove access to a canvas for specified entities
11
+ #
12
+ # @option options [Object] :canvas_id
13
+ # Encoded ID of the canvas.
14
+ # @option options [array] :channel_ids
15
+ # List of channels you wish to update access for.
16
+ # @option options [array] :user_ids
17
+ # List of users you wish to update access for.
18
+ # @see https://api.slack.com/methods/canvases.access.delete
19
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/canvases.access/canvases.access.delete.json
20
+ def canvases_access_delete(options = {})
21
+ raise ArgumentError, 'Required arguments :canvas_id missing' if options[:canvas_id].nil?
22
+ post('canvases.access.delete', options)
23
+ end
24
+
25
+ #
26
+ # Sets the access level to a canvas for specified entities
27
+ #
28
+ # @option options [enum] :access_level
29
+ # Desired level of access.
30
+ # @option options [Object] :canvas_id
31
+ # Encoded ID of the canvas.
32
+ # @option options [array] :channel_ids
33
+ # List of channels you wish to update access for. Can only be used if user_ids is not provided.
34
+ # @option options [array] :user_ids
35
+ # List of users you wish to update access for. Can only be used if channel_ids is not provided.
36
+ # @see https://api.slack.com/methods/canvases.access.set
37
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/canvases.access/canvases.access.set.json
38
+ def canvases_access_set(options = {})
39
+ raise ArgumentError, 'Required arguments :access_level missing' if options[:access_level].nil?
40
+ raise ArgumentError, 'Required arguments :canvas_id missing' if options[:canvas_id].nil?
41
+ post('canvases.access.set', options)
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+ # This file was auto-generated by lib/tasks/web.rake
3
+
4
+ module Slack
5
+ module Web
6
+ module Api
7
+ module Endpoints
8
+ module CanvasesSections
9
+ #
10
+ # Find sections matching the provided criteria
11
+ #
12
+ # @option options [Object] :canvas_id
13
+ # Encoded ID of the canvas.
14
+ # @option options [Object] :criteria
15
+ # Filtering criteria.
16
+ # @see https://api.slack.com/methods/canvases.sections.lookup
17
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/canvases.sections/canvases.sections.lookup.json
18
+ def canvases_sections_lookup(options = {})
19
+ raise ArgumentError, 'Required arguments :canvas_id missing' if options[:canvas_id].nil?
20
+ raise ArgumentError, 'Required arguments :criteria missing' if options[:criteria].nil?
21
+ post('canvases.sections.lookup', options)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end