slack-ruby-client 0.14.2 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (322) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +1 -0
  3. data/.rubocop.yml +23 -7
  4. data/.rubocop_todo.yml +103 -43
  5. data/.travis.yml +0 -1
  6. data/CHANGELOG.md +39 -2
  7. data/CONTRIBUTING.md +24 -6
  8. data/Dangerfile +2 -1
  9. data/Gemfile +10 -3
  10. data/README.md +90 -30
  11. data/Rakefile +1 -0
  12. data/UPGRADING.md +16 -0
  13. data/bin/commands.rb +24 -0
  14. data/bin/commands/admin_apps.rb +27 -0
  15. data/bin/commands/admin_apps_approved.rb +17 -0
  16. data/bin/commands/admin_apps_requests.rb +16 -0
  17. data/bin/commands/admin_apps_restricted.rb +17 -0
  18. data/bin/commands/admin_conversations.rb +17 -0
  19. data/bin/commands/admin_conversations_restrictAccess.rb +37 -0
  20. data/bin/commands/admin_conversations_whitelist.rb +37 -0
  21. data/bin/commands/admin_emoji.rb +54 -0
  22. data/bin/commands/admin_inviteRequests.rb +36 -0
  23. data/bin/commands/admin_inviteRequests_approved.rb +16 -0
  24. data/bin/commands/admin_inviteRequests_denied.rb +16 -0
  25. data/bin/commands/admin_teams.rb +27 -0
  26. data/bin/commands/admin_teams_admins.rb +16 -0
  27. data/bin/commands/admin_teams_owners.rb +16 -0
  28. data/bin/commands/admin_teams_settings.rb +64 -0
  29. data/bin/commands/admin_usergroups.rb +48 -0
  30. data/bin/commands/admin_users.rb +97 -0
  31. data/bin/commands/admin_users_session.rb +16 -0
  32. data/bin/commands/api.rb +3 -2
  33. data/bin/commands/apps.rb +3 -2
  34. data/bin/commands/apps_permissions.rb +5 -4
  35. data/bin/commands/apps_permissions_resources.rb +3 -2
  36. data/bin/commands/apps_permissions_scopes.rb +3 -2
  37. data/bin/commands/apps_permissions_users.rb +5 -4
  38. data/bin/commands/auth.rb +5 -4
  39. data/bin/commands/bots.rb +3 -2
  40. data/bin/commands/calls.rb +52 -0
  41. data/bin/commands/calls_participants.rb +25 -0
  42. data/bin/commands/channels.rb +31 -30
  43. data/bin/commands/chat.rb +36 -32
  44. data/bin/commands/chat_scheduledMessages.rb +3 -2
  45. data/bin/commands/conversations.rb +36 -36
  46. data/bin/commands/dialog.rb +3 -2
  47. data/bin/commands/dnd.rb +9 -8
  48. data/bin/commands/emoji.rb +3 -2
  49. data/bin/commands/files.rb +14 -12
  50. data/bin/commands/files_comments.rb +3 -2
  51. data/bin/commands/files_remote.rb +78 -0
  52. data/bin/commands/groups.rb +33 -32
  53. data/bin/commands/im.rb +13 -12
  54. data/bin/commands/migration.rb +3 -2
  55. data/bin/commands/mpim.rb +11 -10
  56. data/bin/commands/oauth.rb +6 -5
  57. data/bin/commands/oauth_v2.rb +17 -0
  58. data/bin/commands/pins.rb +7 -8
  59. data/bin/commands/reactions.rb +10 -11
  60. data/bin/commands/reminders.rb +11 -10
  61. data/bin/commands/rtm.rb +5 -4
  62. data/bin/commands/search.rb +7 -6
  63. data/bin/commands/stars.rb +7 -6
  64. data/bin/commands/team.rb +10 -8
  65. data/bin/commands/team_profile.rb +3 -2
  66. data/bin/commands/usergroups.rb +11 -10
  67. data/bin/commands/usergroups_users.rb +5 -4
  68. data/bin/commands/users.rb +21 -20
  69. data/bin/commands/users_admin.rb +1 -0
  70. data/bin/commands/users_prefs.rb +1 -0
  71. data/bin/commands/users_profile.rb +5 -4
  72. data/bin/commands/views.rb +48 -0
  73. data/bin/slack +1 -2
  74. data/examples/hi_real_time/Gemfile +1 -0
  75. data/examples/hi_real_time/hi.rb +7 -3
  76. data/examples/hi_real_time_and_web/Gemfile +1 -0
  77. data/examples/hi_real_time_and_web/hi.rb +7 -3
  78. data/examples/hi_real_time_async_async/Gemfile +1 -0
  79. data/examples/hi_real_time_async_async/hi.rb +6 -2
  80. data/examples/hi_real_time_async_celluloid/Gemfile +1 -0
  81. data/examples/hi_real_time_async_celluloid/hi.rb +7 -3
  82. data/examples/hi_real_time_async_eventmachine/Gemfile +1 -0
  83. data/examples/hi_real_time_async_eventmachine/hi.rb +7 -3
  84. data/examples/hi_web/Gemfile +1 -0
  85. data/examples/hi_web/hi.rb +1 -0
  86. data/examples/new_ticket/Gemfile +1 -0
  87. data/examples/new_ticket/new_ticket.rb +1 -0
  88. data/lib/slack-ruby-client.rb +4 -4
  89. data/lib/slack.rb +1 -0
  90. data/lib/slack/config.rb +1 -0
  91. data/lib/slack/events/config.rb +1 -0
  92. data/lib/slack/events/request.rb +3 -1
  93. data/lib/slack/logger.rb +6 -5
  94. data/lib/slack/messages/formatting.rb +1 -0
  95. data/lib/slack/messages/message.rb +1 -4
  96. data/lib/slack/real_time/api/message.rb +3 -1
  97. data/lib/slack/real_time/api/message_id.rb +1 -0
  98. data/lib/slack/real_time/api/ping.rb +5 -2
  99. data/lib/slack/real_time/api/typing.rb +3 -1
  100. data/lib/slack/real_time/client.rb +46 -22
  101. data/lib/slack/real_time/concurrency.rb +1 -0
  102. data/lib/slack/real_time/concurrency/async.rb +18 -9
  103. data/lib/slack/real_time/concurrency/celluloid.rb +10 -4
  104. data/lib/slack/real_time/concurrency/eventmachine.rb +9 -6
  105. data/lib/slack/real_time/config.rb +6 -1
  106. data/lib/slack/real_time/models.rb +1 -0
  107. data/lib/slack/real_time/models/base.rb +1 -4
  108. data/lib/slack/real_time/models/bot.rb +1 -0
  109. data/lib/slack/real_time/models/channel.rb +1 -0
  110. data/lib/slack/real_time/models/group.rb +1 -0
  111. data/lib/slack/real_time/models/im.rb +1 -0
  112. data/lib/slack/real_time/models/team.rb +1 -0
  113. data/lib/slack/real_time/models/user.rb +1 -0
  114. data/lib/slack/real_time/socket.rb +16 -13
  115. data/lib/slack/real_time/stores.rb +1 -0
  116. data/lib/slack/real_time/stores/base.rb +4 -1
  117. data/lib/slack/real_time/stores/starter.rb +11 -0
  118. data/lib/slack/real_time/stores/store.rb +26 -25
  119. data/lib/slack/version.rb +2 -1
  120. data/lib/slack/web/api/endpoints.rb +48 -0
  121. data/lib/slack/web/api/endpoints/admin_apps.rb +42 -0
  122. data/lib/slack/web/api/endpoints/admin_apps_approved.rb +35 -0
  123. data/lib/slack/web/api/endpoints/admin_apps_requests.rb +33 -0
  124. data/lib/slack/web/api/endpoints/admin_apps_restricted.rb +35 -0
  125. data/lib/slack/web/api/endpoints/admin_conversations.rb +30 -0
  126. data/lib/slack/web/api/endpoints/admin_conversations_restrictAccess.rb +61 -0
  127. data/lib/slack/web/api/endpoints/admin_conversations_whitelist.rb +64 -0
  128. data/lib/slack/web/api/endpoints/admin_emoji.rb +88 -0
  129. data/lib/slack/web/api/endpoints/admin_inviteRequests.rb +61 -0
  130. data/lib/slack/web/api/endpoints/admin_inviteRequests_approved.rb +33 -0
  131. data/lib/slack/web/api/endpoints/admin_inviteRequests_denied.rb +33 -0
  132. data/lib/slack/web/api/endpoints/admin_teams.rb +50 -0
  133. data/lib/slack/web/api/endpoints/admin_teams_admins.rb +34 -0
  134. data/lib/slack/web/api/endpoints/admin_teams_owners.rb +34 -0
  135. data/lib/slack/web/api/endpoints/admin_teams_settings.rb +99 -0
  136. data/lib/slack/web/api/endpoints/admin_usergroups.rb +77 -0
  137. data/lib/slack/web/api/endpoints/admin_users.rb +163 -0
  138. data/lib/slack/web/api/endpoints/admin_users_session.rb +28 -0
  139. data/lib/slack/web/api/endpoints/api.rb +2 -1
  140. data/lib/slack/web/api/endpoints/apps.rb +2 -1
  141. data/lib/slack/web/api/endpoints/apps_permissions.rb +3 -2
  142. data/lib/slack/web/api/endpoints/apps_permissions_resources.rb +2 -1
  143. data/lib/slack/web/api/endpoints/apps_permissions_scopes.rb +2 -1
  144. data/lib/slack/web/api/endpoints/apps_permissions_users.rb +3 -2
  145. data/lib/slack/web/api/endpoints/auth.rb +3 -2
  146. data/lib/slack/web/api/endpoints/bots.rb +2 -1
  147. data/lib/slack/web/api/endpoints/calls.rb +83 -0
  148. data/lib/slack/web/api/endpoints/calls_participants.rb +42 -0
  149. data/lib/slack/web/api/endpoints/channels.rb +44 -29
  150. data/lib/slack/web/api/endpoints/chat.rb +38 -31
  151. data/lib/slack/web/api/endpoints/chat_scheduledMessages.rb +3 -2
  152. data/lib/slack/web/api/endpoints/conversations.rb +34 -35
  153. data/lib/slack/web/api/endpoints/dialog.rb +2 -1
  154. data/lib/slack/web/api/endpoints/dnd.rb +6 -4
  155. data/lib/slack/web/api/endpoints/emoji.rb +2 -1
  156. data/lib/slack/web/api/endpoints/files.rb +11 -8
  157. data/lib/slack/web/api/endpoints/files_comments.rb +2 -1
  158. data/lib/slack/web/api/endpoints/files_remote.rb +127 -0
  159. data/lib/slack/web/api/endpoints/groups.rb +33 -18
  160. data/lib/slack/web/api/endpoints/im.rb +17 -12
  161. data/lib/slack/web/api/endpoints/migration.rb +2 -1
  162. data/lib/slack/web/api/endpoints/mpim.rb +16 -11
  163. data/lib/slack/web/api/endpoints/oauth.rb +4 -6
  164. data/lib/slack/web/api/endpoints/oauth_v2.rb +30 -0
  165. data/lib/slack/web/api/endpoints/pins.rb +8 -12
  166. data/lib/slack/web/api/endpoints/reactions.rb +12 -15
  167. data/lib/slack/web/api/endpoints/reminders.rb +6 -5
  168. data/lib/slack/web/api/endpoints/rtm.rb +3 -2
  169. data/lib/slack/web/api/endpoints/search.rb +4 -3
  170. data/lib/slack/web/api/endpoints/stars.rb +6 -7
  171. data/lib/slack/web/api/endpoints/team.rb +7 -5
  172. data/lib/slack/web/api/endpoints/team_profile.rb +2 -1
  173. data/lib/slack/web/api/endpoints/usergroups.rb +6 -5
  174. data/lib/slack/web/api/endpoints/usergroups_users.rb +3 -2
  175. data/lib/slack/web/api/endpoints/users.rb +11 -12
  176. data/lib/slack/web/api/endpoints/users_admin.rb +1 -0
  177. data/lib/slack/web/api/endpoints/users_prefs.rb +1 -0
  178. data/lib/slack/web/api/endpoints/users_profile.rb +3 -2
  179. data/lib/slack/web/api/endpoints/views.rb +97 -0
  180. data/lib/slack/web/api/error.rb +1 -0
  181. data/lib/slack/web/api/errors.rb +656 -0
  182. data/lib/slack/web/api/errors/slack_error.rb +14 -1
  183. data/lib/slack/web/api/errors/too_many_requests_error.rb +1 -0
  184. data/lib/slack/web/api/mixins.rb +2 -0
  185. data/lib/slack/web/api/mixins/channels.id.rb +1 -0
  186. data/lib/slack/web/api/mixins/conversations.id.rb +27 -0
  187. data/lib/slack/web/api/mixins/groups.id.rb +1 -0
  188. data/lib/slack/web/api/mixins/ids.id.rb +1 -0
  189. data/lib/slack/web/api/mixins/users.id.rb +1 -0
  190. data/lib/slack/web/api/mixins/users.search.rb +1 -0
  191. data/lib/slack/web/api/patches/{chat.6.block-kit-support.patch → chat.1.patch} +29 -26
  192. data/lib/slack/web/api/patches/views.1.view-json.patch +40 -0
  193. data/lib/slack/web/api/patches/views.1.views-published.patch +16 -0
  194. data/lib/slack/web/api/templates/command.erb +1 -0
  195. data/lib/slack/web/api/templates/commands.erb +1 -0
  196. data/lib/slack/web/api/templates/endpoints.erb +1 -0
  197. data/lib/slack/web/api/templates/errors.erb +20 -0
  198. data/lib/slack/web/api/templates/method.erb +5 -1
  199. data/lib/slack/web/api/templates/method_spec.erb +1 -0
  200. data/lib/slack/web/client.rb +2 -1
  201. data/lib/slack/web/config.rb +1 -0
  202. data/lib/slack/web/faraday/connection.rb +24 -20
  203. data/lib/slack/web/faraday/request.rb +1 -0
  204. data/lib/slack/web/faraday/response/raise_error.rb +10 -6
  205. data/lib/slack/web/pagination/cursor.rb +3 -2
  206. data/lib/slack_ruby_client.rb +1 -0
  207. data/lib/tasks/git.rake +1 -0
  208. data/lib/tasks/real_time.rake +13 -5
  209. data/lib/tasks/update.rake +1 -0
  210. data/lib/tasks/web.rake +27 -7
  211. data/screenshots/create-app.png +0 -0
  212. data/slack-ruby-client.gemspec +6 -3
  213. data/spec/fixtures/slack/web/channels_info.yml +108 -15
  214. data/spec/fixtures/slack/web/views_open_error.yml +76 -0
  215. data/spec/integration/integration_spec.rb +26 -23
  216. data/spec/slack/config_spec.rb +2 -0
  217. data/spec/slack/events/config_spec.rb +8 -4
  218. data/spec/slack/events/request_spec.rb +67 -37
  219. data/spec/slack/messages/formatting_spec.rb +25 -13
  220. data/spec/slack/real_time/api/message_spec.rb +6 -1
  221. data/spec/slack/real_time/api/ping_spec.rb +2 -0
  222. data/spec/slack/real_time/api/typing_spec.rb +5 -1
  223. data/spec/slack/real_time/client_spec.rb +178 -32
  224. data/spec/slack/real_time/concurrency/celluloid_spec.rb +11 -6
  225. data/spec/slack/real_time/concurrency/eventmachine_spec.rb +9 -1
  226. data/spec/slack/real_time/concurrency/it_behaves_like_a_realtime_socket.rb +2 -0
  227. data/spec/slack/real_time/event_handlers/bot_spec.rb +2 -1
  228. data/spec/slack/real_time/event_handlers/channel_spec.rb +9 -6
  229. data/spec/slack/real_time/event_handlers/event_handlers_spec.rb +2 -1
  230. data/spec/slack/real_time/event_handlers/group_spec.rb +5 -4
  231. data/spec/slack/real_time/event_handlers/im_spec.rb +4 -3
  232. data/spec/slack/real_time/event_handlers/team_spec.rb +3 -1
  233. data/spec/slack/real_time/event_handlers/user_spec.rb +1 -0
  234. data/spec/slack/real_time/rtm_connect_spec.rb +1 -0
  235. data/spec/slack/real_time/rtm_start_spec.rb +1 -0
  236. data/spec/slack/real_time/store_spec.rb +2 -1
  237. data/spec/slack/slack_spec.rb +37 -5
  238. data/spec/slack/version_spec.rb +2 -1
  239. data/spec/slack/web/api/endpoints/admin_apps_approved_spec.rb +8 -0
  240. data/spec/slack/web/api/endpoints/admin_apps_requests_spec.rb +8 -0
  241. data/spec/slack/web/api/endpoints/admin_apps_restricted_spec.rb +8 -0
  242. data/spec/slack/web/api/endpoints/admin_apps_spec.rb +8 -0
  243. data/spec/slack/web/api/endpoints/admin_conversations_restrictAccess_spec.rb +32 -0
  244. data/spec/slack/web/api/endpoints/admin_conversations_spec.rb +13 -0
  245. data/spec/slack/web/api/endpoints/admin_conversations_whitelist_spec.rb +32 -0
  246. data/spec/slack/web/api/endpoints/admin_emoji_spec.rb +37 -0
  247. data/spec/slack/web/api/endpoints/admin_inviteRequests_approved_spec.rb +8 -0
  248. data/spec/slack/web/api/endpoints/admin_inviteRequests_denied_spec.rb +8 -0
  249. data/spec/slack/web/api/endpoints/admin_inviteRequests_spec.rb +18 -0
  250. data/spec/slack/web/api/endpoints/admin_teams_admins_spec.rb +13 -0
  251. data/spec/slack/web/api/endpoints/admin_teams_owners_spec.rb +13 -0
  252. data/spec/slack/web/api/endpoints/admin_teams_settings_spec.rb +53 -0
  253. data/spec/slack/web/api/endpoints/admin_teams_spec.rb +16 -0
  254. data/spec/slack/web/api/endpoints/admin_usergroups_spec.rb +37 -0
  255. data/spec/slack/web/api/endpoints/admin_users_session_spec.rb +13 -0
  256. data/spec/slack/web/api/endpoints/admin_users_spec.rb +75 -0
  257. data/spec/slack/web/api/endpoints/api_spec.rb +1 -0
  258. data/spec/slack/web/api/endpoints/apps_permissions_resources_spec.rb +1 -0
  259. data/spec/slack/web/api/endpoints/apps_permissions_scopes_spec.rb +1 -0
  260. data/spec/slack/web/api/endpoints/apps_permissions_spec.rb +3 -2
  261. data/spec/slack/web/api/endpoints/apps_permissions_users_spec.rb +4 -3
  262. data/spec/slack/web/api/endpoints/apps_spec.rb +1 -0
  263. data/spec/slack/web/api/endpoints/bots_spec.rb +1 -0
  264. data/spec/slack/web/api/endpoints/calls_participants_spec.rb +24 -0
  265. data/spec/slack/web/api/endpoints/calls_spec.rb +31 -0
  266. data/spec/slack/web/api/endpoints/chat_scheduledMessages_spec.rb +1 -0
  267. data/spec/slack/web/api/endpoints/conversations_spec.rb +2 -1
  268. data/spec/slack/web/api/endpoints/custom_specs/auth_spec.rb +5 -1
  269. data/spec/slack/web/api/endpoints/custom_specs/channels_spec.rb +5 -3
  270. data/spec/slack/web/api/endpoints/custom_specs/chat_spec.rb +80 -25
  271. data/spec/slack/web/api/endpoints/custom_specs/dialog_spec.rb +12 -4
  272. data/spec/slack/web/api/endpoints/custom_specs/groups_spec.rb +2 -0
  273. data/spec/slack/web/api/endpoints/custom_specs/users_spec.rb +6 -1
  274. data/spec/slack/web/api/endpoints/custom_specs/views_spec.rb +95 -0
  275. data/spec/slack/web/api/endpoints/dnd_spec.rb +6 -0
  276. data/spec/slack/web/api/endpoints/emoji_spec.rb +1 -0
  277. data/spec/slack/web/api/endpoints/files_comments_spec.rb +1 -0
  278. data/spec/slack/web/api/endpoints/files_remote_spec.rb +24 -0
  279. data/spec/slack/web/api/endpoints/files_spec.rb +1 -0
  280. data/spec/slack/web/api/endpoints/im_spec.rb +1 -0
  281. data/spec/slack/web/api/endpoints/migration_spec.rb +1 -0
  282. data/spec/slack/web/api/endpoints/mpim_spec.rb +1 -0
  283. data/spec/slack/web/api/endpoints/oauth_spec.rb +1 -11
  284. data/spec/slack/web/api/endpoints/oauth_v2_spec.rb +13 -0
  285. data/spec/slack/web/api/endpoints/pins_spec.rb +5 -1
  286. data/spec/slack/web/api/endpoints/reactions_spec.rb +8 -1
  287. data/spec/slack/web/api/endpoints/reminders_spec.rb +1 -0
  288. data/spec/slack/web/api/endpoints/rtm_spec.rb +1 -0
  289. data/spec/slack/web/api/endpoints/search_spec.rb +1 -0
  290. data/spec/slack/web/api/endpoints/stars_spec.rb +1 -0
  291. data/spec/slack/web/api/endpoints/team_profile_spec.rb +1 -0
  292. data/spec/slack/web/api/endpoints/team_spec.rb +1 -0
  293. data/spec/slack/web/api/endpoints/usergroups_spec.rb +1 -0
  294. data/spec/slack/web/api/endpoints/usergroups_users_spec.rb +1 -0
  295. data/spec/slack/web/api/endpoints/users_admin_spec.rb +1 -0
  296. data/spec/slack/web/api/endpoints/users_prefs_spec.rb +1 -0
  297. data/spec/slack/web/api/endpoints/users_profile_spec.rb +1 -0
  298. data/spec/slack/web/api/endpoints/views_spec.rb +29 -0
  299. data/spec/slack/web/api/error_spec.rb +4 -2
  300. data/spec/slack/web/api/errors/service_unavailable_spec.rb +8 -5
  301. data/spec/slack/web/api/errors/slack_error_spec.rb +26 -2
  302. data/spec/slack/web/api/mixins/channels_spec.rb +17 -7
  303. data/spec/slack/web/api/mixins/conversations_spec.rb +41 -0
  304. data/spec/slack/web/api/mixins/groups_spec.rb +17 -7
  305. data/spec/slack/web/api/mixins/users_spec.rb +17 -8
  306. data/spec/slack/web/api/pagination/cursor_spec.rb +40 -10
  307. data/spec/slack/web/client_spec.rb +71 -18
  308. data/spec/slack/web/faraday/response/raise_error_spec.rb +41 -7
  309. data/spec/spec_helper.rb +2 -1
  310. data/spec/support/queue_with_timeout.rb +1 -0
  311. data/spec/support/real_time/concurrency/mock.rb +1 -0
  312. data/spec/support/real_time/connected_client.rb +9 -3
  313. data/spec/support/real_time/event.rb +1 -0
  314. data/spec/support/token.rb +1 -0
  315. data/spec/support/vcr.rb +1 -0
  316. metadata +156 -30
  317. data/lib/slack/web/api/patches/chat.1.text-attachments-required.patch +0 -13
  318. data/lib/slack/web/api/patches/chat.2.attachments-json.patch +0 -17
  319. data/lib/slack/web/api/patches/chat.3.update-attachments-support.patch +0 -21
  320. data/lib/slack/web/api/patches/chat.4.postEphemeral-attachments-support.patch +0 -17
  321. data/lib/slack/web/api/patches/chat.5.postEphemeral-text-or-attachments.patch +0 -13
  322. data/screenshots/register-bot.png +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 358de8d699475c86a5e79c8c96e082dd55b9f60fcb44ed806f62758c3e99479e
4
- data.tar.gz: ae9bceefa9fef8950b823bcb6f6ff7023ca027a268022500a9e48d8d5aa28f85
3
+ metadata.gz: c889cedf29a72dd4c60c2d8c1338538c2f35ed7be9d42defa10f04866466997a
4
+ data.tar.gz: f23223bf65696509321856a536f60411db15c3fe34db3c42f2284672fbc99f47
5
5
  SHA512:
6
- metadata.gz: 03c79a47ba7b75a13ca37bb1a592faca4c3d6c4d1f53b34ba205a8587bb72b26a6d009fb22cb9a57b63e017dac6b05ef344f13b68f045b57679fd950e0ed686a
7
- data.tar.gz: 1761adca1f3ab450cb630102ea77f293340815c9a7e6c17b6afcf0f1fd73172f79cef25e4f89905c134a5b171a4f247d4e733f4c551ca90c57c1519e8f851801
6
+ metadata.gz: b1c55f1840dbb1604294e83e922188467aa63a8aa04c2d38c744e6e96287db2ba961b33f408ee83c68dae70f9554d362e1fb1278c36dc45b1e1a5190e6b3189f
7
+ data.tar.gz: 582c4f3d190b998521b5c7e358188c0662d1e3c2c43021cf9e93345e7ca162c027e0d170364c87367ba548132aeb4c0ab989d08c01bc4e5eec4f8312dbaf8ea6
@@ -0,0 +1 @@
1
+ github: [dblock]
@@ -1,21 +1,37 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ require:
4
+ - rubocop-performance
5
+ - rubocop-rspec
6
+
1
7
  AllCops:
8
+ DisplayCopNames: true
2
9
  Exclude:
10
+ - bin/**/*
3
11
  - vendor/**/*
4
12
  - lib/slack/web/api/slack-api-ref/**/*
13
+ - lib/slack/web/api/endpoints/* # Auto-generated
14
+ - lib/slack/web/api/errors.rb # Auto-generated
15
+ - spec/slack/web/api/endpoints/* # Auto-generated
5
16
 
6
- Metrics:
17
+ Layout/EmptyLineAfterMagicComment:
7
18
  Enabled: false
8
19
 
9
- Metrics/LineLength:
10
- Max: 512
20
+ Metrics/BlockLength:
21
+ Max: 250
11
22
 
12
- Style/Documentation:
13
- Enabled: false
23
+ Metrics/ClassLength:
24
+ Max: 250
14
25
 
15
- Naming/MethodName:
26
+ Layout/LineLength:
27
+ Max: 128
28
+
29
+ Style/Documentation:
16
30
  Enabled: false
17
31
 
18
32
  Style/ModuleFunction:
19
33
  Enabled: false
20
34
 
21
- inherit_from: .rubocop_todo.yml
35
+ Naming/FileName:
36
+ Exclude:
37
+ - lib/slack-ruby-client.rb # Required to match gemspec name
@@ -1,74 +1,134 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2019-04-09 22:16:03 -0500 using RuboCop version 0.61.1.
3
+ # on 2020-06-29 08:44:31 -0400 using RuboCop version 0.82.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 2
10
- # Configuration parameters: AllowSafeAssignment.
11
- Lint/AssignmentInCondition:
9
+ # Offense count: 1
10
+ # Cop supports --auto-correct.
11
+ Lint/NonDeterministicRequireOrder:
12
12
  Exclude:
13
- - 'lib/slack/real_time/concurrency/async.rb'
14
- - 'lib/slack/real_time/socket.rb'
13
+ - 'spec/spec_helper.rb'
15
14
 
16
- # Offense count: 4
17
- Lint/HandleExceptions:
15
+ # Offense count: 2
16
+ # Cop supports --auto-correct.
17
+ Lint/RedundantCopDisableDirective:
18
18
  Exclude:
19
19
  - 'lib/slack-ruby-client.rb'
20
+
21
+ # Offense count: 2
22
+ # Configuration parameters: AllowComments.
23
+ Lint/SuppressedException:
24
+ Exclude:
20
25
  - 'spec/slack/real_time/concurrency/celluloid_spec.rb'
21
26
  - 'spec/slack/real_time/concurrency/eventmachine_spec.rb'
22
27
 
23
- # Offense count: 4
24
- # Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
25
- # AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
26
- Naming/FileName:
27
- Exclude:
28
- - 'bin/commands/chat_scheduledMessages.rb'
29
- - 'lib/slack-ruby-client.rb'
30
- - 'lib/slack/web/api/endpoints/chat_scheduledMessages.rb'
31
- - 'spec/slack/web/api/endpoints/chat_scheduledMessages_spec.rb'
28
+ # Offense count: 11
29
+ # Configuration parameters: IgnoredMethods.
30
+ Metrics/AbcSize:
31
+ Max: 39
32
+
33
+ # Offense count: 2
34
+ # Configuration parameters: IgnoredMethods.
35
+ Metrics/CyclomaticComplexity:
36
+ Max: 9
37
+
38
+ # Offense count: 14
39
+ # Configuration parameters: CountComments, ExcludedMethods.
40
+ Metrics/MethodLength:
41
+ Max: 32
32
42
 
33
43
  # Offense count: 1
34
- # Configuration parameters: EnforcedStyleForLeadingUnderscores.
35
- # SupportedStylesForLeadingUnderscores: disallowed, required, optional
36
- Naming/MemoizedInstanceVariableName:
44
+ # Configuration parameters: IgnoredMethods.
45
+ Metrics/PerceivedComplexity:
46
+ Max: 9
47
+
48
+ # Offense count: 2
49
+ # Cop supports --auto-correct.
50
+ Performance/RegexpMatch:
37
51
  Exclude:
38
- - 'lib/slack/logger.rb'
52
+ - 'lib/tasks/web.rake'
39
53
 
40
54
  # Offense count: 1
41
- Security/Open:
55
+ RSpec/AnyInstance:
42
56
  Exclude:
43
- - 'lib/slack/real_time/client.rb'
57
+ - 'spec/slack/real_time/concurrency/celluloid_spec.rb'
44
58
 
45
- # Offense count: 2
46
- # Configuration parameters: EnforcedStyle.
47
- # SupportedStyles: inline, group
48
- Style/AccessModifierDeclarations:
59
+ # Offense count: 5
60
+ # Cop supports --auto-correct.
61
+ RSpec/ContextMethod:
49
62
  Exclude:
50
- - 'lib/slack/real_time/concurrency/eventmachine.rb'
51
- - 'lib/slack/real_time/socket.rb'
63
+ - 'spec/slack/messages/formatting_spec.rb'
64
+ - 'spec/slack/web/api/mixins/channels_spec.rb'
65
+ - 'spec/slack/web/api/mixins/groups_spec.rb'
66
+ - 'spec/slack/web/api/mixins/users_spec.rb'
52
67
 
53
- # Offense count: 154
54
- # Configuration parameters: AllowedVariables.
55
- Style/GlobalVars:
68
+ # Offense count: 71
69
+ # Configuration parameters: Prefixes.
70
+ # Prefixes: when, with, without
71
+ RSpec/ContextWording:
56
72
  Enabled: false
57
73
 
58
- # Offense count: 3
59
- # Configuration parameters: MinBodyLength.
60
- Style/GuardClause:
74
+ # Offense count: 129
75
+ # Cop supports --auto-correct.
76
+ # Configuration parameters: AllowConsecutiveOneLiners.
77
+ RSpec/EmptyLineAfterExample:
78
+ Enabled: false
79
+
80
+ # Offense count: 66
81
+ # Configuration parameters: Max.
82
+ RSpec/ExampleLength:
83
+ Enabled: false
84
+
85
+ # Offense count: 17
86
+ # Configuration parameters: CustomTransform, IgnoreMethods.
87
+ RSpec/FilePath:
88
+ Enabled: false
89
+
90
+ # Offense count: 13
91
+ # Configuration parameters: AssignmentOnly.
92
+ RSpec/InstanceVariable:
61
93
  Exclude:
62
- - 'lib/slack/real_time/socket.rb'
63
- - 'lib/slack/real_time/stores/store.rb'
64
- - 'lib/slack/web/faraday/response/raise_error.rb'
94
+ - 'spec/integration/integration_spec.rb'
95
+ - 'spec/slack/real_time/client_spec.rb'
96
+ - 'spec/slack/slack_spec.rb'
65
97
 
66
- # Offense count: 1
67
- Style/MixinUsage:
98
+ # Offense count: 77
99
+ # Configuration parameters: .
100
+ # SupportedStyles: have_received, receive
101
+ RSpec/MessageSpies:
102
+ EnforcedStyle: receive
103
+
104
+ # Offense count: 95
105
+ RSpec/MultipleExpectations:
106
+ Max: 5
107
+
108
+ # Offense count: 35
109
+ RSpec/NestedGroups:
110
+ Max: 6
111
+
112
+ # Offense count: 3
113
+ RSpec/SubjectStub:
68
114
  Exclude:
69
- - 'bin/slack'
115
+ - 'spec/slack/web/api/mixins/channels_spec.rb'
116
+ - 'spec/slack/web/api/mixins/groups_spec.rb'
117
+ - 'spec/slack/web/api/mixins/users_spec.rb'
70
118
 
71
- # Offense count: 1
72
- Style/MultilineTernaryOperator:
119
+ # Offense count: 16
120
+ # Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
121
+ RSpec/VerifiedDoubles:
73
122
  Exclude:
123
+ - 'spec/slack/events/request_spec.rb'
124
+ - 'spec/slack/real_time/client_spec.rb'
125
+ - 'spec/slack/real_time/concurrency/celluloid_spec.rb'
126
+ - 'spec/slack/real_time/concurrency/eventmachine_spec.rb'
127
+ - 'spec/slack/web/faraday/response/raise_error_spec.rb'
74
128
  - 'spec/support/real_time/connected_client.rb'
129
+
130
+ # Offense count: 4
131
+ # Configuration parameters: .
132
+ # SupportedStyles: annotated, template, unannotated
133
+ Style/FormatStringToken:
134
+ EnforcedStyle: unannotated
@@ -3,7 +3,6 @@ language: ruby
3
3
  cache: bundler
4
4
 
5
5
  rvm:
6
- - 2.3.8
7
6
  - 2.5.3
8
7
  - 2.6.0
9
8
  - ruby-head
@@ -1,3 +1,40 @@
1
+ ### 0.15.0 (2020/7/26)
2
+
3
+ * [#322](https://github.com/slack-ruby/slack-ruby-client/pull/322): Cache `Faraday::Connection` for persistent adapters - [@drbrain](https://github.com/drbrain).
4
+ * [#324](https://github.com/slack-ruby/slack-ruby-client/pull/324): Require Faraday >= 1.0 - [@dblock](https://github.com/dblock).
5
+ * [#324](https://github.com/slack-ruby/slack-ruby-client/pull/324): Upgrade slack-ruby-danger, rubocop, rubocop-rspec and rubocop-performance - [@dblock](https://github.com/dblock).
6
+ * [#327](https://github.com/slack-ruby/slack-ruby-client/pull/327), [#326](https://github.com/slack-ruby/slack-ruby-client/pull/326): Added `admin_conversations_whitelist`, `admin_usergroups`, `calls` and `calls_participants` endpoints - [@wasabigeek](https://github.com/wasabigeek).
7
+ * [#329](https://github.com/slack-ruby/slack-ruby-client/pull/329): Log when methods are deprecated - [@wasabigeek](https://github.com/wasabigeek).
8
+ * [#325](https://github.com/slack-ruby/slack-ruby-client/pull/325): Remove activesupport dependency - [@ianks](https://github.com/ianks).
9
+ * [#331](https://github.com/slack-ruby/slack-ruby-client/pull/331): Use `conversations_list` instead of deprecated `channels_list`. Added `admin_conversations_restrictAccess_addGroup`, `admin_conversations_restrictAccess_listGroups` and `admin_conversations_restrictAccess_removeGroup` endpoints - [@wasabigeek](https://github.com/wasabigeek).
10
+
11
+ ### 0.14.6 (2020/3/28)
12
+
13
+ * [#305](https://github.com/slack-ruby/slack-ruby-client/pull/305): Added `admin_inviteRequests_approve`, `admin_inviteRequests_deny`, `admin_inviteRequests_list`, `admin_inviteRequests_approved_list`, `admin_inviteRequests_denied_list`, `admin_teams_create`, `admin_teams_list`, `admin_teams_admins_list`, `admin_teams_owners_list`, `admin_teams_settings`, `admin_teams_settings_setIcon`, `admin_teams_settings_setName`, `admin_teams_settings_setDescription`, `admin_users_assign`, `admin_users_invite`, `admin_users_remove`, `admin_users_setAdmin`, `admin_users_setOwner` and `admin_users_setRegular` endpoints - [@manuelmeurer](https://github.com/manuelmeurer).
14
+ * [#311](https://github.com/slack-ruby/slack-ruby-client/pull/311): Made Web API `response_metadata` more accessible in errors - [@jmanian](https://github.com/jmanian).
15
+ * [#312](https://github.com/slack-ruby/slack-ruby-client/pull/312): Added specific error classes for Web API - [@jmanian](https://github.com/jmanian).
16
+ * [#313](https://github.com/slack-ruby/slack-ruby-client/pull/313): Added `admin_teams_settings_info`, `admin_users_list`, `admin_users_setExpiration`, `admin_apps_approved_list`, `admin_apps_restricted_list`, `admin_conversations_setTeams`, `admin_emoji_add`, `admin_emoji_addAlias`, `admin_emoji_list`, `admin_emoji_remove` and `admin_emoji_rename` endpoints - [@dblock](https://github.com/dblock).
17
+
18
+ ### 0.14.5 (2019/12/23)
19
+
20
+ * [#293](https://github.com/slack-ruby/slack-ruby-client/pull/293): Rubocop auto-correct and comprehensive todo - [@jcraigk](https://github.com/jcraigk).
21
+ * [#297](https://github.com/slack-ruby/slack-ruby-client/pull/297): Various Rubocop fixes - [@jcraigk](https://github.com/jcraigk).
22
+ * [#298](https://github.com/slack-ruby/slack-ruby-client/pull/298): Added `admin_apps`, `admin_app_requests` and `views` endpoints - [@jmanian](https://github.com/jmanian).
23
+ * [#303](https://github.com/slack-ruby/slack-ruby-client/pull/303): Added `oauth_v2_access` and `views_publish` endpoints - [@jwright](https://github.com/jwright).
24
+ * [#309](https://github.com/slack-ruby/slack-ruby-client/pull/309): Stop ping on `inactive_account` and `invalid_auth` - [@dblock](https://github.com/dblock).
25
+
26
+ ### 0.14.4 (2019/7/28)
27
+
28
+ * [#289](https://github.com/slack-ruby/slack-ruby-client/pull/289): Fix reconnects when ping timers under/overshoot - [@georgyangelov](https://github.com/georgyangelov).
29
+ * [#290](https://github.com/slack-ruby/slack-ruby-client/pull/290): Expose Slack::RealTime::Client.logger accessor publicly - [@jcraigk](https://github.com/jcraigk).
30
+
31
+ ### 0.14.3 (2019/7/23)
32
+
33
+ * [#279](https://github.com/slack-ruby/slack-ruby-client/pull/279): Prevent ping worker from dying on unexpected errors - [@dblock](https://github.com/dblock).
34
+ * [#281](https://github.com/slack-ruby/slack-ruby-client/pull/281): Added `admin_users_session_reset` to Web API - [@dblock](https://github.com/dblock).
35
+ * [#283](https://github.com/slack-ruby/slack-ruby-client/pull/283): Fail when used with incompatible async-websocket > 0.8.0 - [@dblock](https://github.com/dblock).
36
+ * [#284](https://github.com/slack-ruby/slack-ruby-client/pull/284): Include team id, name and domain in log output - [@dblock](https://github.com/dblock).
37
+
1
38
  ### 0.14.2 (2019/4/12)
2
39
 
3
40
  * [#256](https://github.com/slack-ruby/slack-ruby-client/pull/256): Added support for specifying signing secrets on a per-request basis via optional parameters to the `Slack::Events::Request` constructor - [@gabrielmdeal](https://github.com/gabrielmdeal).
@@ -147,8 +184,8 @@
147
184
  ### 0.7.1 (2016/5/2)
148
185
 
149
186
  * [#82](https://github.com/slack-ruby/slack-ruby-client/pull/82): Fix `usergroups.users.{list,update}` and `files.comments.{add,edit,delete}` APIs - [@masatomo](https://github.com/masatomo).
150
- * [#73](https://github.com/slack-ruby/slack-ruby-client/issues/73): Add a `closed` event - [@rkadyb](https://github.com/rkadyb).
151
- * [#69](https://github.com/slack-ruby/slack-ruby-client/issues/69): Add attachments support for `Slack::Web::Api::Endpoints::Chat.chat_update` - [@nicka](https://github.com/nicka).
187
+ * [#73](https://github.com/slack-ruby/slack-ruby-client/issues/73): Added a `closed` event - [@rkadyb](https://github.com/rkadyb).
188
+ * [#69](https://github.com/slack-ruby/slack-ruby-client/issues/69): Added attachments support for `Slack::Web::Api::Endpoints::Chat.chat_update` - [@nicka](https://github.com/nicka).
152
189
  * [#85](https://github.com/slack-ruby/slack-ruby-client/issues/85): Compatibility with WebMock 2.0 - [@dblock](https://github.com/dblock).
153
190
  * Added `as_user` to `chat_delete` Web API - [@dblock](https://github.com/dblock).
154
191
  * Added `reminders_add`, `reminders_complete`, `reminders_delete`, `reminders_info` and `reminders_list` to Web API - [@dblock](https://github.com/dblock).
@@ -75,13 +75,31 @@ rake slack:api:update
75
75
 
76
76
  Sometimes it's necessary to patch auto-generated Slack Web API methods. For example, we want to help clients with calling `to_json` on the `attachments` parameter sent to `chat_postMessage`. See [#20](https://github.com/slack-ruby/slack-ruby-client/issues/20).
77
77
 
78
- Make a change to a generated file, for example `lib/slack/web/api/endpoints/chat.rb` and generate a patch.
78
+ The broad steps are:
79
+ 1. Run `rake slack:api:update` to check that existing patches are still valid.
80
+ - If you run into a `failed to apply patch` error, the auto-generated methods likely drifted from the last patch. Follow the steps [below](#resolving-patch-errors).
81
+ - This may add new methods if the API has updated, please split them up into multiple PRs if so.
82
+ 2. Make a change to a generated file, for example `lib/slack/web/api/endpoints/chat.rb`.
83
+ 3. Generate a patch:
84
+ ```
85
+ git diff --no-color HEAD lib/slack/web/api/endpoints/chat.rb > lib/slack/web/api/patches/chat.1.patch
86
+ ```
87
+ 4. Run `rake slack:api:update` to ensure that the patch is cleanly applied. Implement a test for the added or modified functionality and commit the patch file.
88
+
89
+ ##### Resolving Patch Errors
90
+
91
+ The auto-generated method files may drift overtime e.g. new arguments may be added or descriptions changed. Since previous patches were based on the older auto-generated files, git may be unable to apply them to the new files. Resolving them requires some good ol' splicing:
92
+ 1. Comment out the patching code in `lib/tasks/web.rake`:
93
+ ```ruby
94
+ # Dir.glob("lib/slack/web/api/patches/#{group}*.patch").sort.each do |patch|
95
+ # puts "- patching #{patch}"
96
+ # system("git apply #{patch}") || raise('failed to apply patch')
97
+ # end
98
+ ```
99
+ 2. Run `rake slack:api:update` to create the raw auto-generated files. Commit the files that you are updating, so we can run `git diff` later.
100
+ 3. Go through the old patches for the files (e.g. in `lib/slack/web/api/patches/chat.1.patch`), copying code into the new files.
101
+ 4. Continue with Step 2 [above](#patching-slack-web-api).
79
102
 
80
- ```
81
- git diff --no-color HEAD lib/slack/web/api/endpoints/chat.rb > lib/slack/web/api/patches/chat.1.patch
82
- ```
83
-
84
- Run `rake slack:api:update` to ensure that the patch is cleanly applied. Implement a test for the added or modified functionality and commit the patch file.
85
103
 
86
104
  ### Write Documentation
87
105
 
data/Dangerfile CHANGED
@@ -1,2 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  danger.import_dangerfile(gem: 'slack-ruby-danger')
2
- toc.check
data/Gemfile CHANGED
@@ -1,10 +1,17 @@
1
+ # frozen_string_literal: true
1
2
  source 'http://rubygems.org'
2
3
 
3
4
  gemspec
4
5
 
5
- gem ENV['CONCURRENCY'], require: false if ENV.key?('CONCURRENCY')
6
+ if ENV.key?('CONCURRENCY')
7
+ case ENV['CONCURRENCY']
8
+ when 'async-websocket'
9
+ gem 'async-websocket', '~> 0.8.0', require: false
10
+ else
11
+ gem ENV['CONCURRENCY'], require: false
12
+ end
13
+ end
6
14
 
7
15
  group :test do
8
- gem 'danger-toc', '~> 0.1.3', require: false
9
- gem 'slack-ruby-danger', '~> 0.1.0', require: false
16
+ gem 'slack-ruby-danger', '~> 0.2.0', require: false
10
17
  end
data/README.md CHANGED
@@ -16,20 +16,26 @@ A Ruby client for the Slack [Web](https://api.slack.com/web), [RealTime Messagin
16
16
  - [Installation](#installation)
17
17
  - [Usage](#usage)
18
18
  - [Create a New Bot Integration](#create-a-new-bot-integration)
19
- - [Use the API Token](#use-the-api-token)
19
+ - [OAuth Code Grant](#oauth-code-grant)
20
+ - [Using the Legacy API Token](#using-the-legacy-api-token)
20
21
  - [Global Settings](#global-settings)
21
22
  - [Web Client](#web-client)
22
- - [Test Auth](#test-auth)
23
- - [Send Messages](#send-messages)
24
- - [List Channels](#list-channels)
25
- - [Upload a File](#upload-a-file)
26
- - [Get Channel Info](#get-channel-info)
27
- - [Get User Info](#get-user-info)
28
- - [Search for a User](#search-for-a-user)
29
- - [Other](#other)
23
+ - [Web Client Examples](#web-client-examples)
24
+ - [Test Auth](#test-auth)
25
+ - [Send Messages](#send-messages)
26
+ - [List Channels](#list-channels)
27
+ - [Upload a File](#upload-a-file)
28
+ - [Get Channel Info](#get-channel-info)
29
+ - [Get User Info](#get-user-info)
30
+ - [Search for a User](#search-for-a-user)
31
+ - [Other](#other)
30
32
  - [Web Client Options](#web-client-options)
31
33
  - [Pagination Support](#pagination-support)
34
+ - [Character Encoding](#character-encoding)
32
35
  - [Error Handling](#error-handling)
36
+ - [Slack Errors](#slack-errors)
37
+ - [Rate Limiting](#rate-limiting)
38
+ - [Other Errors](#other-errors)
33
39
  - [RealTime Client](#realtime-client)
34
40
  - [Slack::RealTime::Stores::Store](#slackrealtimestoresstore)
35
41
  - [Slack::RealTime::Stores::Starter](#slackrealtimestoresstarter)
@@ -61,12 +67,12 @@ A Ruby client for the Slack [Web](https://api.slack.com/web), [RealTime Messagin
61
67
 
62
68
  * This library will let you send messages to Slack via the Web API, send and receive messages via the Real Time Messaging API and facilitate integration with the Events API.
63
69
  * To respond to slash commands, interactive components or events, implement a web application using your favorite web framework and use this library to call the Slack Web API and to verify that events are coming from Slack.
64
- * To build a bot using the Real Time Messaging API, use [slack-ruby-bot](https://github.com/dblock/slack-ruby-bot), which uses this library.
65
- * To roll out a complete service using the Real Time Messaging API with Slack button integration to multiple teams, check out [slack-ruby-bot-server](https://github.com/dblock/slack-ruby-bot-server), which is built on top of slack-ruby-bot, which uses this library.
70
+ * To build a bot using the Real Time Messaging API, use [slack-ruby-bot](https://github.com/slack-ruby/slack-ruby-bot), which uses this library.
71
+ * To roll out a complete service using the Real Time Messaging API with Slack button integration to multiple teams, check out [slack-ruby-bot-server](https://github.com/slack-ruby/slack-ruby-bot-server), which is built on top of slack-ruby-bot, which uses this library.
66
72
 
67
73
  ## Stable Release
68
74
 
69
- You're reading the documentation for the **stable** release of slack-ruby-client, 0.14.2. See [UPGRADING](UPGRADING.md) when upgrading from an older version.
75
+ You're reading the documentation for the **stale** release of slack-ruby-client, v0.15.0. See [UPGRADING](UPGRADING.md) when upgrading from an older version.
70
76
 
71
77
  ## Installation
72
78
 
@@ -79,7 +85,7 @@ gem 'slack-ruby-client'
79
85
  If you're going to be using the RealTime client, add either `async-websocket`, `eventmachine` and `faye-websocket` or `celluloid-io`. See below for more information about concurrency. We recommend you use `async-websocket`.
80
86
 
81
87
  ```
82
- gem 'async-websocket'
88
+ gem 'async-websocket', '~> 0.8.0'
83
89
  ```
84
90
 
85
91
  Run `bundle install`.
@@ -88,11 +94,17 @@ Run `bundle install`.
88
94
 
89
95
  ### Create a New Bot Integration
90
96
 
91
- This is something done in Slack, under [integrations](https://my.slack.com/services). Create a [new bot](https://my.slack.com/services/new/bot), and note its API token.
97
+ To integrate your bot with Slack, you must first create a new [Slack App](https://api.slack.com/apps).
98
+
99
+ ![](screenshots/create-app.png)
100
+
101
+ ### OAuth Code Grant
102
+
103
+ Once created, go to the app's Basic Info tab and grab the Client ID and Client Secret. You'll need these in order complete an [OAuth code grant flow](https://api.slack.com/docs/oauth#flow) as described at [slack-ruby-bot-server](https://github.com/slack-ruby/slack-ruby-bot-server).
92
104
 
93
- ![](screenshots/register-bot.png)
105
+ ### Using the Legacy API Token
94
106
 
95
- ### Use the API Token
107
+ Although OAuth is recommended, you can still [generate a legacy API token](https://api.slack.com/custom-integrations/legacy-tokens) for your app and use it for some interactions.
96
108
 
97
109
  ```ruby
98
110
  Slack.configure do |config|
@@ -115,14 +127,18 @@ logger | An optional logger, defaults to `::Logger.new(STDOUT)` at `Logger
115
127
 
116
128
  The Slack Web API allows you to build applications that interact with Slack.
117
129
 
118
- #### Test Auth
130
+ #### Web Client Examples
131
+
132
+ Here are some examples of how to use the web client with the Web API.
133
+
134
+ ##### Test Auth
119
135
 
120
136
  ```ruby
121
137
  client = Slack::Web::Client.new
122
138
  client.auth_test
123
139
  ```
124
140
 
125
- #### Send Messages
141
+ ##### Send Messages
126
142
 
127
143
  Send messages with [chat_PostMessage](https://api.slack.com/methods/chat.postMessage).
128
144
 
@@ -134,7 +150,7 @@ See a fully working example in [examples/hi_web](examples/hi_web/hi.rb).
134
150
 
135
151
  ![](examples/hi_web/hi.gif)
136
152
 
137
- #### List Channels
153
+ ##### List Channels
138
154
 
139
155
  List channels with [channels_list](https://api.slack.com/methods/channels.list).
140
156
 
@@ -144,7 +160,7 @@ channels = client.channels_list.channels
144
160
  general_channel = channels.detect { |c| c.name == 'general' }
145
161
  ```
146
162
 
147
- #### Upload a File
163
+ ##### Upload a File
148
164
 
149
165
  Upload a file with [files_upload](https://api.slack.com/methods/files.upload).
150
166
 
@@ -159,7 +175,7 @@ client.files_upload(
159
175
  )
160
176
  ```
161
177
 
162
- ### Get Channel Info
178
+ ##### Get Channel Info
163
179
 
164
180
  You can use a channel ID or name (prefixed with `#`) in all functions that take a `:channel` argument. Lookup by name is not supported by the Slack API and the `channels_id` method called invokes `channels_list` in order to locate the channel ID.
165
181
 
@@ -171,7 +187,7 @@ client.channels_info(channel: 'C04KB5X4D') # calls channels_info
171
187
  client.channels_info(channel: '#general') # calls channels_list followed by channels_info
172
188
  ```
173
189
 
174
- ### Get User Info
190
+ ##### Get User Info
175
191
 
176
192
  You can use a user ID or name (prefixed with `@`) in all functions that take a `:user` argument. Lookup by name is not supported by the Slack API and the `users_id` method called invokes `users_list` in order to locate the user ID.
177
193
 
@@ -183,7 +199,7 @@ client.users_info(user: 'U092BDCLV') # calls users_info
183
199
  client.users_info(user: '@dblock') # calls users_list followed by users_info
184
200
  ```
185
201
 
186
- ### Search for a User
202
+ ##### Search for a User
187
203
 
188
204
  Constructs an in-memory index of users and searches it. If you want to use this functionality, add the [picky](https://github.com/floere/picky) gem to your project's Gemfile.
189
205
 
@@ -191,7 +207,7 @@ Constructs an in-memory index of users and searches it. If you want to use this
191
207
  client.users_search(user: 'dblock')
192
208
  ```
193
209
 
194
- #### Other
210
+ ##### Other
195
211
 
196
212
  Refer to the [Slack Web API Method Reference](https://api.slack.com/methods) for the list of all available functions.
197
213
 
@@ -261,11 +277,53 @@ end
261
277
  all_members # many thousands of team members retrieved 10 at a time
262
278
  ```
263
279
 
280
+ #### Character Encoding
281
+
282
+ Note that Slack expects `text` to be UTF-8 encoded. If your messages appear with text such as `BAD+11` in Slack, check `text.encoding` and `.encode(Encoding::UTF_8)` your messages before sending them to Slack.
283
+
284
+ ```ruby
285
+ text = 'characters such as "Ñ", "Á", "É"'
286
+ text.encoding
287
+ => #<Encoding:UTF-8>
288
+ client.chat_postMessage(channel: '#general', text: text, as_user: true)
289
+ # renders 'characters such as "Ñ", "Á", "É"' in Slack
290
+
291
+ text = text.encode(Encoding::ISO_8859_1)
292
+ text.encoding
293
+ # => #<Encoding:ISO-8859-1>
294
+ client.chat_postMessage(channel: '#general', text: text, as_user: true)
295
+ # renders 'characters such as "BAD+11", "", "BAD+9"' in Slack
296
+ ```
297
+
264
298
  #### Error Handling
265
299
 
266
- If a request fails, a `Slack::Web::Api::Errors::SlackError` will be raised. The error message contains the error code. In case of multiple errors, the error codes are separated by commas. The original response is also accessible using the `response` attribute.
300
+ ##### Slack Errors
267
301
 
268
- If you exceed [Slack’s rate limits](https://api.slack.com/docs/rate-limits), a `Slack::Web::Api::Errors::TooManyRequestsError` will be raised instead.
302
+ If Slack returns an error for the request, then an error will be raised. The error class is specific to the type of error that Slack returns. For instance if Slack returns `account_inactive` then the error will be `Slack::Web::Api::Errors::AccountInactive`. This allows you to handle certain types of errors as needed:
303
+
304
+ ```ruby
305
+ rescue Slack::Web::Api::Errors::AccountInactive => e
306
+ # deal with inactive account
307
+ end
308
+ ```
309
+
310
+ All of these errors inherit from `Slack::Web::Api::Errors::SlackError`, so you can handle or silence all errors if necessary:
311
+
312
+ ```ruby
313
+ rescue Slack::Web::Api::Errors::SlackError => e
314
+ # capture all Slack errors
315
+ end
316
+ ```
317
+
318
+ If there's a new error type that is not yet known by this library, then it will raise `Slack::Web::Api::Errors::SlackError`. (Update the Web API if you find that errors are missing — see [CONTRIBUTING](CONTRIBUTING.md).)
319
+
320
+ In all of these cases the error message contains the error code, which is also accessible with `slack_error.error`. In case of multiple errors, the error message contains the error codes separated by commas, or they are accessible as an array with `slack_error.errors`. The original response is also accessible using the `response` attribute. The `response_metadata` is accessible with `slack_error.response_metadata`.
321
+
322
+ ##### Rate Limiting
323
+
324
+ If you exceed [Slack’s rate limits](https://api.slack.com/docs/rate-limits), a `Slack::Web::Api::Errors::TooManyRequestsError` will be raised instead. (This does not inherit from `Slack::Web::Api::Errors::SlackError`.)
325
+
326
+ ##### Other Errors
269
327
 
270
328
  In any other case, a `Faraday::ClientError` will be raised. This may be the case if Slack is temporarily unavailable, for example.
271
329
 
@@ -374,9 +432,11 @@ See a fully working example in [examples/hi_real_time](examples/hi_real_time/hi.
374
432
  ##### `websocket_ping`
375
433
  This setting determines how long the socket can be idle before sending a ping message to confirm it's still connected.
376
434
 
377
- It's important to note that if a ping message was sent and no response was received within the amount of time specified in `websocket_ping`; the client will attempt to reestablish it's connection to the message server.
435
+ It's important to note that if a ping message was sent and no response was received within the amount of time specified in `websocket_ping` the client will attempt to reestablish it's connection to the message server.
436
+
437
+ Note that the ping may take between `websocket_ping` and `websocket_ping * 3/2` seconds to actually trigger when there is no activity on the socket. This is because the timer that checks whether to ping is triggered at every `websocket_ping / 2` interval.
378
438
 
379
- To disable this feature; set `websocket_ping` to 0.
439
+ To disable this feature set `websocket_ping` to 0.
380
440
 
381
441
  ### Connection Methods
382
442
 
@@ -438,7 +498,7 @@ Slack::RealTime.configure do |config|
438
498
  end
439
499
  ```
440
500
 
441
- Use `client.start_async` instead of `client.start!`. A good example of such application is [slack-bot-server](https://github.com/dblock/slack-bot-server).
501
+ Use `client.start_async` instead of `client.start!`. A good example of such application is [slack-ruby-bot-server](https://github.com/slack-ruby/slack-ruby-bot-server).
442
502
 
443
503
  ```ruby
444
504
  client = Slack::RealTime::Client.new
@@ -513,7 +573,7 @@ Slack::Events::Request.new(http_request,
513
573
  signature_expires_in: signature_expires_in)
514
574
  ```
515
575
 
516
- The `verify!` call may raise `Slack::Events::MissingSigningSecret`, `Slack::Events::InvalidSignature` or `Slack::Events::TimestampExpired` errors.
576
+ The `verify!` call may raise `Slack::Events::Request::MissingSigningSecret`, `Slack::Events::Request::InvalidSignature` or `Slack::Events::Request::TimestampExpired` errors.
517
577
 
518
578
  ### Message Parsing
519
579