slack-ruby-client 0.9.0 → 0.11.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 (142) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +3 -0
  4. data/.rubocop_todo.yml +40 -39
  5. data/.travis.yml +1 -9
  6. data/CHANGELOG.md +24 -0
  7. data/CONTRIBUTING.md +2 -2
  8. data/Gemfile +3 -1
  9. data/README.md +40 -12
  10. data/Rakefile +1 -1
  11. data/UPGRADING.md +1 -1
  12. data/bin/commands/api.rb +2 -2
  13. data/bin/commands/apps_permissions.rb +22 -0
  14. data/bin/commands/auth.rb +4 -4
  15. data/bin/commands/bots.rb +2 -2
  16. data/bin/commands/channels.rb +52 -40
  17. data/bin/commands/chat.rb +63 -25
  18. data/bin/commands/conversations.rb +178 -0
  19. data/bin/commands/dialog.rb +14 -0
  20. data/bin/commands/dnd.rb +8 -8
  21. data/bin/commands/emoji.rb +2 -2
  22. data/bin/commands/files.rb +38 -17
  23. data/bin/commands/files_comments.rb +6 -6
  24. data/bin/commands/groups.rb +44 -51
  25. data/bin/commands/im.rb +16 -13
  26. data/bin/commands/migration.rb +14 -0
  27. data/bin/commands/mpim.rb +11 -11
  28. data/bin/commands/oauth.rb +15 -2
  29. data/bin/commands/pins.rb +6 -6
  30. data/bin/commands/reactions.rb +13 -13
  31. data/bin/commands/reminders.rb +10 -10
  32. data/bin/commands/rtm.rb +9 -6
  33. data/bin/commands/search.rb +9 -9
  34. data/bin/commands/stars.rb +8 -8
  35. data/bin/commands/team.rb +10 -10
  36. data/bin/commands/team_profile.rb +2 -2
  37. data/bin/commands/usergroups.rb +16 -16
  38. data/bin/commands/usergroups_users.rb +4 -4
  39. data/bin/commands/users.rb +40 -36
  40. data/bin/commands/users_admin.rb +28 -0
  41. data/bin/commands/users_prefs.rb +12 -0
  42. data/bin/commands/users_profile.rb +7 -7
  43. data/bin/commands.rb +7 -1
  44. data/bin/slack +1 -1
  45. data/examples/hi_real_time/hi.rb +1 -1
  46. data/examples/hi_real_time_and_web/hi.rb +1 -1
  47. data/examples/hi_real_time_async_celluloid/hi.rb +1 -1
  48. data/examples/hi_real_time_async_eventmachine/hi.rb +1 -1
  49. data/examples/hi_web/hi.rb +1 -1
  50. data/examples/new_ticket/new_ticket.rb +1 -1
  51. data/lib/slack/messages/formatting.rb +4 -4
  52. data/lib/slack/messages/message.rb +1 -2
  53. data/lib/slack/real_time/api/templates/event_handler.erb +1 -1
  54. data/lib/slack/real_time/client.rb +11 -10
  55. data/lib/slack/real_time/concurrency/celluloid.rb +6 -2
  56. data/lib/slack/real_time/config.rb +11 -11
  57. data/lib/slack/real_time/models/base.rb +1 -2
  58. data/lib/slack/real_time/socket.rb +2 -2
  59. data/lib/slack/real_time/stores/base.rb +1 -2
  60. data/lib/slack/real_time/stores/starter.rb +92 -72
  61. data/lib/slack/real_time/stores/store.rb +120 -90
  62. data/lib/slack/version.rb +1 -1
  63. data/lib/slack/web/api/endpoints/api.rb +2 -2
  64. data/lib/slack/web/api/endpoints/apps_permissions.rb +35 -0
  65. data/lib/slack/web/api/endpoints/auth.rb +4 -4
  66. data/lib/slack/web/api/endpoints/bots.rb +2 -2
  67. data/lib/slack/web/api/endpoints/channels.rb +57 -34
  68. data/lib/slack/web/api/endpoints/chat.rb +107 -37
  69. data/lib/slack/web/api/endpoints/conversations.rb +301 -0
  70. data/lib/slack/web/api/endpoints/dialog.rb +32 -0
  71. data/lib/slack/web/api/endpoints/dnd.rb +9 -9
  72. data/lib/slack/web/api/endpoints/emoji.rb +2 -2
  73. data/lib/slack/web/api/endpoints/files.rb +53 -23
  74. data/lib/slack/web/api/endpoints/files_comments.rb +11 -11
  75. data/lib/slack/web/api/endpoints/groups.rb +38 -50
  76. data/lib/slack/web/api/endpoints/im.rb +27 -17
  77. data/lib/slack/web/api/endpoints/migration.rb +25 -0
  78. data/lib/slack/web/api/endpoints/mpim.rb +13 -15
  79. data/lib/slack/web/api/endpoints/oauth.rb +24 -3
  80. data/lib/slack/web/api/endpoints/pins.rb +6 -8
  81. data/lib/slack/web/api/endpoints/presence.rb +1 -1
  82. data/lib/slack/web/api/endpoints/reactions.rb +18 -20
  83. data/lib/slack/web/api/endpoints/reminders.rb +10 -10
  84. data/lib/slack/web/api/endpoints/rtm.rb +14 -8
  85. data/lib/slack/web/api/endpoints/search.rb +12 -12
  86. data/lib/slack/web/api/endpoints/stars.rb +10 -12
  87. data/lib/slack/web/api/endpoints/team.rb +12 -13
  88. data/lib/slack/web/api/endpoints/team_profile.rb +2 -2
  89. data/lib/slack/web/api/endpoints/usergroups.rb +22 -22
  90. data/lib/slack/web/api/endpoints/usergroups_users.rb +4 -4
  91. data/lib/slack/web/api/endpoints/users.rb +34 -24
  92. data/lib/slack/web/api/endpoints/users_admin.rb +46 -0
  93. data/lib/slack/web/api/endpoints/users_prefs.rb +19 -0
  94. data/lib/slack/web/api/endpoints/users_profile.rb +10 -10
  95. data/lib/slack/web/api/endpoints.rb +14 -2
  96. data/lib/slack/web/api/mixins/ids.id.rb +1 -1
  97. data/lib/slack/web/api/mixins/users.search.rb +38 -36
  98. data/lib/slack/web/api/patches/chat.1.text-attachments-required.patch +1 -1
  99. data/lib/slack/web/api/patches/chat.3.update-attachments-support.patch +4 -3
  100. data/lib/slack/web/api/patches/chat.4.postEphemeral-attachments-support.patch +17 -0
  101. data/lib/slack/web/api/patches/dialog.1.open-json-support.patch +17 -0
  102. data/lib/slack/web/api/templates/command.erb +4 -3
  103. data/lib/slack/web/api/templates/commands.erb +1 -1
  104. data/lib/slack/web/api/templates/endpoints.erb +2 -2
  105. data/lib/slack/web/api/templates/method.erb +18 -3
  106. data/lib/slack/web/api/templates/method_spec.erb +1 -1
  107. data/lib/slack/web/config.rb +16 -12
  108. data/lib/slack/web/faraday/connection.rb +1 -1
  109. data/lib/slack/web/faraday/response/raise_error.rb +3 -3
  110. data/lib/slack/web/pagination/cursor.rb +48 -0
  111. data/lib/slack-ruby-client.rb +6 -0
  112. data/lib/tasks/git.rake +1 -1
  113. data/lib/tasks/real_time.rake +1 -1
  114. data/lib/tasks/web.rake +4 -1
  115. data/slack-ruby-client.gemspec +2 -3
  116. data/spec/fixtures/slack/web/paginated_users_list.yml +181 -0
  117. data/spec/integration/integration_spec.rb +1 -1
  118. data/spec/slack/messages/formatting_spec.rb +1 -1
  119. data/spec/slack/real_time/client_spec.rb +62 -63
  120. data/spec/slack/real_time/concurrency/celluloid_spec.rb +41 -31
  121. data/spec/slack/real_time/concurrency/it_behaves_like_a_realtime_socket.rb +1 -1
  122. data/spec/slack/real_time/event_handlers/bot_spec.rb +4 -2
  123. data/spec/slack/real_time/event_handlers/event_handlers_spec.rb +1 -1
  124. data/spec/slack/real_time/event_handlers/user_spec.rb +4 -2
  125. data/spec/slack/web/api/endpoints/apps_permissions_spec.rb +15 -0
  126. data/spec/slack/web/api/endpoints/conversations_spec.rb +100 -0
  127. data/spec/slack/web/api/endpoints/custom_specs/chat_spec.rb +37 -1
  128. data/spec/slack/web/api/endpoints/custom_specs/dialog_spec.rb +28 -0
  129. data/spec/slack/web/api/endpoints/custom_specs/users_spec.rb +16 -6
  130. data/spec/slack/web/api/endpoints/files_comments_spec.rb +8 -8
  131. data/spec/slack/web/api/endpoints/files_spec.rb +16 -5
  132. data/spec/slack/web/api/endpoints/migration_spec.rb +12 -0
  133. data/spec/slack/web/api/endpoints/oauth_spec.rb +11 -0
  134. data/spec/slack/web/api/endpoints/users_admin_spec.rb +17 -0
  135. data/spec/slack/web/api/endpoints/users_prefs_spec.rb +7 -0
  136. data/spec/slack/web/api/error_spec.rb +1 -1
  137. data/spec/slack/web/api/errors/slack_error_spec.rb +1 -1
  138. data/spec/slack/web/api/mixins/users_spec.rb +6 -4
  139. data/spec/slack/web/api/pagination/cursor_spec.rb +70 -0
  140. data/spec/support/queue_with_timeout.rb +1 -1
  141. data/spec/support/real_time/concurrency/mock.rb +1 -2
  142. metadata +47 -30
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c27d0774e9e56d2188bf8e9aea953b86821a9156
4
- data.tar.gz: d4ca8180bcc3d643e5dcc0b326975086831df51f
3
+ metadata.gz: b4523b02fb8e41e2a529f21283e9631aca6e04bb
4
+ data.tar.gz: 6324f7a54941b201b7aa729178418241accf836c
5
5
  SHA512:
6
- metadata.gz: '0395ba1c14c66f1f3360c71a9bb294fd33ed88775de08c933e6cb7c23aa47485a864e151a3dd41354debd266cd9d9fa1ba80d0c5260afb5f62b60c46c1784a4c'
7
- data.tar.gz: bbe81ee65b8358950dc946791bb72c8e8e3c84ce6ac52fe73a9a66c2f70073394153d604fce446b3eff3590b94ff87a4236a5d447522c8e0e10af4dd54daeddd
6
+ metadata.gz: 958f43b8c6c3591d81761e60c310c6cf2638b26ab79b9bf56748768a2e8800fdad85733262c5a93d4272b3861f475b2cbb2f1eabb01fadb3a2848a09c82be3d7
7
+ data.tar.gz: 1787862cbf85c3cd762c8b044afd89d98c92ee0cd959aaf94da5b5d513cd3c24c3d8de005eece992a5f13ed76a8279231d40d8ade39dd32c4efe692c9118b79c
data/.gitignore CHANGED
@@ -3,3 +3,4 @@ pkg
3
3
  Gemfile.lock
4
4
  .DS_Store
5
5
  .bundle
6
+ .idea
data/.rubocop.yml CHANGED
@@ -3,4 +3,7 @@ AllCops:
3
3
  - vendor/**/*
4
4
  - lib/slack/web/api/slack-api-ref/**/*
5
5
 
6
+ Naming/MethodName:
7
+ Enabled: false
8
+
6
9
  inherit_from: .rubocop_todo.yml
data/.rubocop_todo.yml CHANGED
@@ -1,12 +1,12 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2017-04-30 12:02:22 -0400 using RuboCop version 0.35.0.
3
+ # on 2017-11-25 11:28:32 -0500 using RuboCop version 0.51.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: 3
9
+ # Offense count: 4
10
10
  Lint/HandleExceptions:
11
11
  Exclude:
12
12
  - 'lib/slack-ruby-client.rb'
@@ -14,61 +14,74 @@ Lint/HandleExceptions:
14
14
  - 'spec/slack/real_time/concurrency/eventmachine_spec.rb'
15
15
 
16
16
  # Offense count: 1
17
- # Cop supports --auto-correct.
18
- # Configuration parameters: IgnoreEmptyBlocks.
19
- Lint/UnusedBlockArgument:
17
+ Lint/RescueWithoutErrorClass:
20
18
  Exclude:
21
- - 'lib/slack/messages/formatting.rb'
19
+ - 'lib/slack/real_time/concurrency/celluloid.rb'
22
20
 
23
- # Offense count: 14
21
+ # Offense count: 18
24
22
  Metrics/AbcSize:
25
23
  Max: 44
26
24
 
25
+ # Offense count: 81
26
+ # Configuration parameters: CountComments, ExcludedMethods.
27
+ Metrics/BlockLength:
28
+ Max: 421
29
+
27
30
  # Offense count: 2
28
31
  # Configuration parameters: CountComments.
29
32
  Metrics/ClassLength:
30
- Max: 165
33
+ Max: 166
31
34
 
32
- # Offense count: 3
35
+ # Offense count: 4
33
36
  Metrics/CyclomaticComplexity:
34
37
  Max: 9
35
38
 
36
- # Offense count: 720
37
- # Configuration parameters: AllowURI, URISchemes.
39
+ # Offense count: 741
40
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
41
+ # URISchemes: http, https
38
42
  Metrics/LineLength:
39
- Max: 288
43
+ Max: 266
40
44
 
41
- # Offense count: 7
45
+ # Offense count: 10
42
46
  # Configuration parameters: CountComments.
43
47
  Metrics/MethodLength:
44
- Max: 32
48
+ Max: 42
45
49
 
46
- # Offense count: 2
50
+ # Offense count: 1
51
+ # Configuration parameters: CountComments.
52
+ Metrics/ModuleLength:
53
+ Max: 113
54
+
55
+ # Offense count: 3
47
56
  Metrics/PerceivedComplexity:
48
57
  Max: 11
49
58
 
50
- # Offense count: 59
51
- # Configuration parameters: Exclude.
52
- Style/Documentation:
53
- Enabled: false
54
-
55
59
  # Offense count: 1
56
- # Configuration parameters: Exclude.
57
- Style/FileName:
60
+ # Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
61
+ # 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
62
+ Naming/FileName:
58
63
  Exclude:
59
64
  - 'lib/slack-ruby-client.rb'
60
65
 
61
- # Offense count: 116
66
+ # Offense count: 63
67
+ Style/Documentation:
68
+ Enabled: false
69
+
70
+ # Offense count: 137
62
71
  # Configuration parameters: AllowedVariables.
63
72
  Style/GlobalVars:
64
73
  Enabled: false
65
74
 
66
- # Offense count: 21
67
- # Configuration parameters: EnforcedStyle, SupportedStyles.
68
- Style/MethodName:
69
- Enabled: false
75
+ # Offense count: 2
76
+ # Configuration parameters: MinBodyLength.
77
+ Style/GuardClause:
78
+ Exclude:
79
+ - 'lib/slack/real_time/stores/store.rb'
80
+ - 'lib/slack/web/faraday/response/raise_error.rb'
70
81
 
71
82
  # Offense count: 3
83
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
84
+ # SupportedStyles: module_function, extend_self
72
85
  Style/ModuleFunction:
73
86
  Exclude:
74
87
  - 'lib/slack/config.rb'
@@ -79,15 +92,3 @@ Style/ModuleFunction:
79
92
  Style/MultilineTernaryOperator:
80
93
  Exclude:
81
94
  - 'spec/support/real_time/connected_client.rb'
82
-
83
- # Offense count: 1
84
- # Cop supports --auto-correct.
85
- Style/RescueModifier:
86
- Exclude:
87
- - 'lib/slack/real_time/concurrency/celluloid.rb'
88
-
89
- # Offense count: 2
90
- # Cop supports --auto-correct.
91
- Style/SpecialGlobalVars:
92
- Exclude:
93
- - 'lib/slack/messages/formatting.rb'
data/.travis.yml CHANGED
@@ -5,9 +5,7 @@ cache: bundler
5
5
  rvm:
6
6
  - 2.2
7
7
  - 2.1
8
- - 2.0
9
- - rbx-2
10
- - jruby-19mode
8
+ - 2.3.4
11
9
  - ruby-head
12
10
  - jruby-head
13
11
 
@@ -20,15 +18,9 @@ matrix:
20
18
  env: CONCURRENCY=celluloid-io
21
19
  - rvm: 2.4.1
22
20
  env: CONCURRENCY=faye-websocket
23
- - rvm: 2.3.4
24
- env: CONCURRENCY=celluloid-io
25
- - rvm: 2.3.4
26
- env: CONCURRENCY=faye-websocket
27
21
  allow_failures:
28
22
  - rvm: ruby-head
29
23
  - rvm: jruby-head
30
- - rvm: jruby-19mode
31
- - rvm: rbx-2
32
24
 
33
25
  git:
34
26
  submodules: false
data/CHANGELOG.md CHANGED
@@ -1,3 +1,27 @@
1
+ ### 0.11.0 (11/25/2017)
2
+
3
+ * [#173](https://github.com/slack-ruby/slack-ruby-client/issues/173): Added dialog support - [@alexagranov](https://github.com/alexagranov).
4
+ * [#176](https://github.com/slack-ruby/slack-ruby-client/issues/176): Drop dependency on `json` gem - [@seuros](https://github.com/seuros).
5
+ * [#177](https://github.com/slack-ruby/slack-ruby-client/pull/177): Fix api ref repo - [@manuelmeurer](https://github.com/manuelmeurer).
6
+ * [#180](https://github.com/slack-ruby/slack-ruby-client/pull/180): Upgraded RuboCop 0.51.0 - [@dblock](https://github.com/dblock).
7
+ * [#181](https://github.com/slack-ruby/slack-ruby-client/pull/181): Added `chat_getPermalink`, `migration_exchange` - [@dblock](https://github.com/dblock).
8
+ * [#182](https://github.com/slack-ruby/slack-ruby-client/pull/182): Added undocumented methods support with `channels_delete`, `chat_command`, `files_edit`, `files_share`, `users_admin_invite`, `users_admin_setInactive` and `users_prefs_get` - [@dblock](https://github.com/dblock).
9
+
10
+ ### 0.10.0 (9/19/2017)
11
+
12
+ * [#169](https://github.com/slack-ruby/slack-ruby-client/pull/169): Added [Conversations API](https://api.slack.com/docs/conversations-api) - [@jmanian](https://github.com/jmanian).
13
+ * [#169](https://github.com/slack-ruby/slack-ruby-client/pull/169): Added `include_locale` parameter to several methods (`channels_info`, `groups_info`, `im_open`, `rtm_start`, `users_info`, `users_list`) - [@jmanian](https://github.com/jmanian).
14
+ * [#169](https://github.com/slack-ruby/slack-ruby-client/pull/169): Removed `groups_close` - [@jmanian](https://github.com/jmanian).
15
+ * [#167](https://github.com/slack-ruby/slack-ruby-client/pull/167): Added support for pausing between paginated requests that can cause Slack rate limiting - [@jmanian](https://github.com/jmanian).
16
+ * [#163](https://github.com/slack-ruby/slack-ruby-client/pull/164): Use `OpenSSL::X509::DEFAULT_CERT_DIR` and `OpenSSL::X509::DEFAULT_CERT_FILE` for default ca_cert and ca_file - [@leifcr](https://github.com/leifcr).
17
+ * [#161](https://github.com/slack-ruby/slack-ruby-client/pull/161): Added support for cursor pagination - [@dblock](https://github.com/dblock).
18
+ * [#162](https://github.com/slack-ruby/slack-ruby-client/pull/162): Gracefully close websocket on `Errno::EPIPE` - [@johanoskarsson](https://github.com/johanoskarsson).
19
+ * [#172](https://github.com/slack-ruby/slack-ruby-client/pull/172): Use `rtm.start` when store is a subclass of `Slack::RealTime::Stores::Store` (default) - [@kstole](https://github.com/kstole).
20
+
21
+ ### 0.9.1 (8/24/2017)
22
+
23
+ * [#158](https://github.com/slack-ruby/slack-ruby-client/issues/158): Updated to latest slack-api-ref; Updated chat.3.update patch to reflect argument reordering; Added chat.4.postEphemeral patch to apply the attachments JSON fix (whitespace last line of diff matters! ;-) - [@alexagranov](https://github.com/alexagranov).
24
+
1
25
  ### 0.9.0 (8/6/2017)
2
26
 
3
27
  * [#146](https://github.com/slack-ruby/slack-ruby-client/issues/146): Fix: `undefined method running?` and `ThreadError: Target thread must not be current thread` with `Celluloid::IO` - [@dblock](https://github.com/dblock).
data/CONTRIBUTING.md CHANGED
@@ -65,7 +65,7 @@ Make sure that `bundle exec rake` completes without errors.
65
65
 
66
66
  ### Update Slack Web API
67
67
 
68
- Slack Web API is updated from https://github.com/dblock/slack-api-ref, a maintained, machine-readable version of Slack API Docs, generated by scraping [api.slack.com](https://api.slack.com). To update the Web API from the latest definition run the following Rake task.
68
+ Slack Web API is updated from https://github.com/slack-ruby/slack-api-ref, a maintained, machine-readable version of Slack API Docs, generated by scraping [api.slack.com](https://api.slack.com). To update the Web API from the latest definition run the following Rake task.
69
69
 
70
70
  ```
71
71
  rake slack:api:update
@@ -78,7 +78,7 @@ Sometimes it's necessary to patch auto-generated Slack Web API methods. For exam
78
78
  Make a change to a generated file, for example `lib/slack/web/api/endpoints/chat.rb` and generate a patch.
79
79
 
80
80
  ```
81
- git diff HEAD lib/slack/web/api/endpoints/chat.rb > lib/slack/web/api/patches/chat.1.patch
81
+ git diff --no-color HEAD lib/slack/web/api/endpoints/chat.rb > lib/slack/web/api/patches/chat.1.patch
82
82
  ```
83
83
 
84
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.
data/Gemfile CHANGED
@@ -3,8 +3,10 @@ source 'http://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  gem ENV['CONCURRENCY'], require: false if ENV.key?('CONCURRENCY')
6
- gem 'picky' unless RUBY_PLATFORM == 'java'
6
+ # rubocop:enable Bundler/OrderedGems
7
+
7
8
  gem 'activesupport', '~> 4.0'
9
+ gem 'picky' unless RUBY_PLATFORM == 'java'
8
10
 
9
11
  group :test do
10
12
  gem 'slack-ruby-danger', '~> 0.1.0', require: false
data/README.md CHANGED
@@ -18,7 +18,7 @@ A Ruby client for the Slack [Web](https://api.slack.com/web) and [RealTime Messa
18
18
 
19
19
  ## Stable Release
20
20
 
21
- You're reading the documentation for the **stable** release of slack-ruby-client, 0.9.0. See [UPGRADING](UPGRADING.md) when upgrading from an older version.
21
+ You're reading the documentation for the **stable** release of slack-ruby-client, 0.11.0. See [UPGRADING](UPGRADING.md) when upgrading from an older version.
22
22
 
23
23
  ## Installation
24
24
 
@@ -164,17 +164,19 @@ client = Slack::Web::Client.new(user_agent: 'Slack Ruby Client/1.0')
164
164
 
165
165
  The following settings are supported.
166
166
 
167
- setting | description
168
- -------------|-------------------------------------------------------------------------------------------------
169
- token | Slack API token.
170
- user_agent | User-agent, defaults to _Slack Ruby Client/version_.
171
- proxy | Optional HTTP proxy.
172
- ca_path | Optional SSL certificates path.
173
- ca_file | Optional SSL certificates file.
174
- endpoint | Slack endpoint, default is _https://slack.com/api_.
175
- logger | Optional `Logger` instance that logs HTTP requests.
176
- timeout | Optional open/read timeout in seconds.
177
- open_timeout | Optional connection open timeout in seconds.
167
+ setting | description
168
+ --------------------|-------------------------------------------------------------------------------------------------
169
+ token | Slack API token.
170
+ user_agent | User-agent, defaults to _Slack Ruby Client/version_.
171
+ proxy | Optional HTTP proxy.
172
+ ca_path | Optional SSL certificates path.
173
+ ca_file | Optional SSL certificates file.
174
+ endpoint | Slack endpoint, default is _https://slack.com/api_.
175
+ logger | Optional `Logger` instance that logs HTTP requests.
176
+ timeout | Optional open/read timeout in seconds.
177
+ open_timeout | Optional connection open timeout in seconds.
178
+ default_page_size | Optional page size for paginated requests, default is _100_.
179
+ default_max_retries | Optional number of retries for paginated requests, default is _100_.
178
180
 
179
181
  You can also pass request options, including `timeout` and `open_timeout` into individual calls.
180
182
 
@@ -182,6 +184,32 @@ You can also pass request options, including `timeout` and `open_timeout` into i
182
184
  client.channels_list(request: { timeout: 180 })
183
185
  ```
184
186
 
187
+ #### Pagination Support
188
+
189
+ The Web client natively supports [cursor pagination](https://api.slack.com/docs/pagination#cursors) for methods that allow it, such as `users_list`. Supply a block and the client will make repeated requests adjusting the value of `cursor` with every response. The default limit is set to 100 and can be adjusted via `Slack::Web::Client.config.default_page_size` or by passing it directly into the API call.
190
+
191
+ ```ruby
192
+ all_members = []
193
+ client.users_list(presence: true, limit: 10) do |response|
194
+ all_members.concat(response.members)
195
+ end
196
+ all_members # many thousands of team members retrieved 10 at a time
197
+ ```
198
+
199
+ When using cursor pagination the client will automatically pause and then retry the request if it runs into Slack rate limiting. (It will pause according to the `Retry-After` header in the 429 response before retrying the request.) If it receives too many rate-limited responses in a row it will give up and raise an error. The default number of retries is 100 and can be adjusted via `Slack::Web::Client.config.default_max_retries` or by passing it directly into the method as `max_retries`.
200
+
201
+ You can also proactively avoid rate limiting by adding a pause between every paginated request with the `sleep_interval` parameter, which is given in seconds.
202
+
203
+ ```ruby
204
+ all_members = []
205
+ client.users_list(presence: true, limit: 10, sleep_interval: 5, max_retries: 20) do |response|
206
+ # pauses for 5 seconds between each request
207
+ # gives up after 20 consecutive rate-limited responses
208
+ all_members.concat(response.members)
209
+ end
210
+ all_members # many thousands of team members retrieved 10 at a time
211
+ ```
212
+
185
213
  ### RealTime Client
186
214
 
187
215
  The Real Time Messaging API is a WebSocket-based API that allows you to receive events from Slack in real time and send messages as user.
data/Rakefile CHANGED
@@ -14,7 +14,7 @@ end
14
14
  require 'rubocop/rake_task'
15
15
  RuboCop::RakeTask.new
16
16
 
17
- task default: [:rubocop, :spec]
17
+ task default: %i[rubocop spec]
18
18
 
19
19
  load 'tasks/git.rake'
20
20
  load 'tasks/web.rake'
data/UPGRADING.md CHANGED
@@ -5,7 +5,7 @@ Upgrading Slack-Ruby-Client
5
5
 
6
6
  #### Changes in How the RTM Client Connects
7
7
 
8
- The RealTime client now automatically chooses either [rtm.start](https://api.slack.com/methods/rtm.start) or [rtm.connect](https://api.slack.com/methods/rtm.connect) to open a connection. The former retrieves a lot of team information while the latter only serves connection purposes and is newer and preferred, while the latter is required to use the full `Slack::RealTime::Stores::Store` storage class.
8
+ The RealTime client now automatically chooses either [rtm.start](https://api.slack.com/methods/rtm.start) or [rtm.connect](https://api.slack.com/methods/rtm.connect) to open a connection. The `rtm.connect` method is a newer, preferred method, which serves connection purposes and returns some basic team info. The `rtm.start` method additionally returns a lot of data about the team, its channels, and members, and is required to use the full `Slack::RealTime::Stores::Store` storage class.
9
9
 
10
10
  Prior versions always used `rtm.start`, to restore this behavior, configure `start_method`.
11
11
 
data/bin/commands/api.rb CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  desc 'Api methods.'
4
4
  command 'api' do |g|
5
- g.desc 'This method helps you test your calling code.'
6
- g.long_desc %( This method helps you test your calling code. )
5
+ g.desc 'Checks API calling code.'
6
+ g.long_desc %( Checks API calling code. )
7
7
  g.command 'test' do |c|
8
8
  c.flag 'error', desc: 'Error response to return.'
9
9
  c.flag 'foo', desc: 'example property to return.'
@@ -0,0 +1,22 @@
1
+ # This file was auto-generated by lib/tasks/web.rake
2
+
3
+ desc 'AppsPermissions methods.'
4
+ command 'apps_permissions' do |g|
5
+ g.desc 'Returns list of permissions this app has on a team.'
6
+ g.long_desc %( Returns list of permissions this app has on a team. )
7
+ g.command 'info' do |c|
8
+ c.action do |_global_options, options, _args|
9
+ puts JSON.dump($client.apps_permissions_info(options))
10
+ end
11
+ end
12
+
13
+ g.desc 'Allows an app to request additional scopes'
14
+ g.long_desc %( Allows an app to request additional scopes )
15
+ g.command 'request' do |c|
16
+ c.flag 'scopes', desc: 'A comma separated list of scopes to request for.'
17
+ c.flag 'trigger_id', desc: 'Token used to trigger the permissions API.'
18
+ c.action do |_global_options, options, _args|
19
+ puts JSON.dump($client.apps_permissions_request(options))
20
+ end
21
+ end
22
+ end
data/bin/commands/auth.rb CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  desc 'Auth methods.'
4
4
  command 'auth' do |g|
5
- g.desc 'This method revokes an access token. Use it when you no longer need a token. For example, with a Sign In With Slack app, call this to log a user out.'
6
- g.long_desc %( This method revokes an access token. Use it when you no longer need a token. For example, with a Sign In With Slack app, call this to log a user out. )
5
+ g.desc 'Revokes a token.'
6
+ g.long_desc %( Revokes a token. )
7
7
  g.command 'revoke' do |c|
8
8
  c.flag 'test', desc: 'Setting this parameter to 1 triggers a testing mode where the specified token will not actually be revoked.'
9
9
  c.action do |_global_options, options, _args|
@@ -11,8 +11,8 @@ command 'auth' do |g|
11
11
  end
12
12
  end
13
13
 
14
- g.desc 'This method checks authentication and tells you who you are.'
15
- g.long_desc %( This method checks authentication and tells you who you are. )
14
+ g.desc 'Checks authentication & identity.'
15
+ g.long_desc %( Checks authentication & identity. )
16
16
  g.command 'test' do |c|
17
17
  c.action do |_global_options, options, _args|
18
18
  puts JSON.dump($client.auth_test(options))
data/bin/commands/bots.rb CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  desc 'Bots methods.'
4
4
  command 'bots' do |g|
5
- g.desc 'This method returns information about a bot user.'
6
- g.long_desc %( This method returns information about a bot user. )
5
+ g.desc 'Gets information about a bot user.'
6
+ g.long_desc %( Gets information about a bot user. )
7
7
  g.command 'info' do |c|
8
8
  c.flag 'bot', desc: 'Bot user to get info on.'
9
9
  c.action do |_global_options, options, _args|
@@ -2,8 +2,8 @@
2
2
 
3
3
  desc "Get info on your team's Slack channels, create or archive channels, invite users, set the topic and purpose, and mark a channel as read."
4
4
  command 'channels' do |g|
5
- g.desc 'This method archives a channel.'
6
- g.long_desc %( This method archives a channel. )
5
+ g.desc 'Archives a channel.'
6
+ g.long_desc %( Archives a channel. )
7
7
  g.command 'archive' do |c|
8
8
  c.flag 'channel', desc: 'Channel to archive.'
9
9
  c.action do |_global_options, options, _args|
@@ -11,8 +11,8 @@ command 'channels' do |g|
11
11
  end
12
12
  end
13
13
 
14
- g.desc 'This method is used to create a channel.'
15
- g.long_desc %( This method is used to create a channel. )
14
+ g.desc 'Creates a channel.'
15
+ g.long_desc %( Creates a channel. )
16
16
  g.command 'create' do |c|
17
17
  c.flag 'name', desc: 'Name of channel to create.'
18
18
  c.flag 'validate', desc: 'Whether to return errors on invalid channel name instead of modifying it to meet the specified criteria.'
@@ -21,30 +21,49 @@ command 'channels' do |g|
21
21
  end
22
22
  end
23
23
 
24
- g.desc 'This method returns a portion of message events from the specified channel.'
25
- g.long_desc %( This method returns a portion of message events from the specified channel. )
24
+ g.desc 'Delete a channel (undocumented)'
25
+ g.long_desc %( Delete a channel )
26
+ g.command 'delete' do |c|
27
+ c.flag 'channel', desc: 'Channel to delete.'
28
+ c.action do |_global_options, options, _args|
29
+ puts JSON.dump($client.channels_delete(options))
30
+ end
31
+ end
32
+
33
+ g.desc 'Fetches history of messages and events from a channel.'
34
+ g.long_desc %( Fetches history of messages and events from a channel. )
26
35
  g.command 'history' do |c|
27
36
  c.flag 'channel', desc: 'Channel to fetch history for.'
37
+ c.flag 'inclusive', desc: 'Include messages with latest or oldest timestamp in results.'
28
38
  c.flag 'latest', desc: 'End of time range of messages to include in results.'
29
39
  c.flag 'oldest', desc: 'Start of time range of messages to include in results.'
30
- c.flag 'inclusive', desc: 'Include messages with latest or oldest timestamp in results.'
31
40
  c.flag 'unreads', desc: 'Include unread_count_display in the output?.'
32
41
  c.action do |_global_options, options, _args|
33
42
  puts JSON.dump($client.channels_history(options))
34
43
  end
35
44
  end
36
45
 
37
- g.desc 'This method returns information about a team channel.'
38
- g.long_desc %( This method returns information about a team channel. )
46
+ g.desc 'This method returns the ID of a team channel.'
47
+ g.long_desc %( This method returns the ID of a team channel. )
48
+ g.command 'id' do |c|
49
+ c.flag 'channel', desc: 'Channel to get ID for, prefixed with #.'
50
+ c.action do |_global_options, options, _args|
51
+ puts JSON.dump($client.channels_id(options))
52
+ end
53
+ end
54
+
55
+ g.desc 'Gets information about a channel.'
56
+ g.long_desc %( Gets information about a channel. )
39
57
  g.command 'info' do |c|
40
58
  c.flag 'channel', desc: 'Channel to get info on.'
59
+ c.flag 'include_locale', desc: 'Set this to true to receive the locale for this channel. Defaults to false.'
41
60
  c.action do |_global_options, options, _args|
42
61
  puts JSON.dump($client.channels_info(options))
43
62
  end
44
63
  end
45
64
 
46
- g.desc 'This method is used to invite a user to a channel. The calling user must be a member of the channel.'
47
- g.long_desc %( This method is used to invite a user to a channel. The calling user must be a member of the channel. )
65
+ g.desc 'Invites a user to a channel.'
66
+ g.long_desc %( Invites a user to a channel. )
48
67
  g.command 'invite' do |c|
49
68
  c.flag 'channel', desc: 'Channel to invite user to.'
50
69
  c.flag 'user', desc: 'User to invite to channel.'
@@ -53,8 +72,8 @@ command 'channels' do |g|
53
72
  end
54
73
  end
55
74
 
56
- g.desc 'This method is used to join a channel. If the channel does not exist, it is'
57
- g.long_desc %( This method is used to join a channel. If the channel does not exist, it is created. )
75
+ g.desc 'Joins a channel, creating it if needed.'
76
+ g.long_desc %( Joins a channel, creating it if needed. )
58
77
  g.command 'join' do |c|
59
78
  c.flag 'name', desc: 'Name of channel to join.'
60
79
  c.flag 'validate', desc: 'Whether to return errors on invalid channel name instead of modifying it to meet the specified criteria.'
@@ -63,8 +82,8 @@ command 'channels' do |g|
63
82
  end
64
83
  end
65
84
 
66
- g.desc 'This method allows a user to remove another member from a team channel.'
67
- g.long_desc %( This method allows a user to remove another member from a team channel. )
85
+ g.desc 'Removes a user from a channel.'
86
+ g.long_desc %( Removes a user from a channel. )
68
87
  g.command 'kick' do |c|
69
88
  c.flag 'channel', desc: 'Channel to remove user from.'
70
89
  c.flag 'user', desc: 'User to remove from channel.'
@@ -73,8 +92,8 @@ command 'channels' do |g|
73
92
  end
74
93
  end
75
94
 
76
- g.desc 'This method is used to leave a channel.'
77
- g.long_desc %( This method is used to leave a channel. )
95
+ g.desc 'Leaves a channel.'
96
+ g.long_desc %( Leaves a channel. )
78
97
  g.command 'leave' do |c|
79
98
  c.flag 'channel', desc: 'Channel to leave.'
80
99
  c.action do |_global_options, options, _args|
@@ -82,18 +101,20 @@ command 'channels' do |g|
82
101
  end
83
102
  end
84
103
 
85
- g.desc 'This method returns a list of all channels in the team. This includes channels the caller is in, channels they are not currently in, and archived channels but does not include private channels. The number of (non-deactivated) members in each channel is also returned.'
86
- g.long_desc %( This method returns a list of all channels in the team. This includes channels the caller is in, channels they are not currently in, and archived channels but does not include private channels. The number of (non-deactivated) members in each channel is also returned. )
104
+ g.desc 'Lists all channels in a Slack team.'
105
+ g.long_desc %( Lists all channels in a Slack team. )
87
106
  g.command 'list' do |c|
107
+ 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."
88
108
  c.flag 'exclude_archived', desc: 'Exclude archived channels from the list.'
89
109
  c.flag 'exclude_members', desc: 'Exclude the members collection from each channel.'
110
+ 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 users list hasn't been reached."
90
111
  c.action do |_global_options, options, _args|
91
112
  puts JSON.dump($client.channels_list(options))
92
113
  end
93
114
  end
94
115
 
95
- g.desc 'This method moves the read cursor in a channel.'
96
- g.long_desc %( This method moves the read cursor in a channel. )
116
+ g.desc 'Sets the read cursor in a channel.'
117
+ g.long_desc %( Sets the read cursor in a channel. )
97
118
  g.command 'mark' do |c|
98
119
  c.flag 'channel', desc: 'Channel to set reading cursor in.'
99
120
  c.flag 'ts', desc: 'Timestamp of the most recently seen message.'
@@ -102,8 +123,8 @@ command 'channels' do |g|
102
123
  end
103
124
  end
104
125
 
105
- g.desc 'This method renames a team channel.'
106
- g.long_desc %( This method renames a team channel. )
126
+ g.desc 'Renames a channel.'
127
+ g.long_desc %( Renames a channel. )
107
128
  g.command 'rename' do |c|
108
129
  c.flag 'channel', desc: 'Channel to rename.'
109
130
  c.flag 'name', desc: 'New name for channel.'
@@ -113,8 +134,8 @@ command 'channels' do |g|
113
134
  end
114
135
  end
115
136
 
116
- g.desc 'This method returns an entire thread (a message plus all the messages in reply to it).'
117
- g.long_desc %( This method returns an entire thread (a message plus all the messages in reply to it). )
137
+ g.desc 'Retrieve a thread of messages posted to a channel'
138
+ g.long_desc %( Retrieve a thread of messages posted to a channel )
118
139
  g.command 'replies' do |c|
119
140
  c.flag 'channel', desc: 'Channel to fetch thread from.'
120
141
  c.flag 'thread_ts', desc: "Unique identifier of a thread's parent message."
@@ -123,8 +144,8 @@ command 'channels' do |g|
123
144
  end
124
145
  end
125
146
 
126
- g.desc 'This method is used to change the purpose of a channel. The calling user must be a member of the channel.'
127
- g.long_desc %( This method is used to change the purpose of a channel. The calling user must be a member of the channel. )
147
+ g.desc 'Sets the purpose for a channel.'
148
+ g.long_desc %( Sets the purpose for a channel. )
128
149
  g.command 'setPurpose' do |c|
129
150
  c.flag 'channel', desc: 'Channel to set the purpose of.'
130
151
  c.flag 'purpose', desc: 'The new purpose.'
@@ -133,8 +154,8 @@ command 'channels' do |g|
133
154
  end
134
155
  end
135
156
 
136
- g.desc 'This method is used to change the topic of a channel. The calling user must be a member of the channel.'
137
- g.long_desc %( This method is used to change the topic of a channel. The calling user must be a member of the channel. )
157
+ g.desc 'Sets the topic for a channel.'
158
+ g.long_desc %( Sets the topic for a channel. )
138
159
  g.command 'setTopic' do |c|
139
160
  c.flag 'channel', desc: 'Channel to set the topic of.'
140
161
  c.flag 'topic', desc: 'The new topic.'
@@ -143,21 +164,12 @@ command 'channels' do |g|
143
164
  end
144
165
  end
145
166
 
146
- g.desc 'This method unarchives a channel. The calling user is added to the channel.'
147
- g.long_desc %( This method unarchives a channel. The calling user is added to the channel. )
167
+ g.desc 'Unarchives a channel.'
168
+ g.long_desc %( Unarchives a channel. )
148
169
  g.command 'unarchive' do |c|
149
170
  c.flag 'channel', desc: 'Channel to unarchive.'
150
171
  c.action do |_global_options, options, _args|
151
172
  puts JSON.dump($client.channels_unarchive(options))
152
173
  end
153
174
  end
154
-
155
- g.desc 'This method returns the ID of a team channel.'
156
- g.long_desc %( This method returns the ID of a team channel. )
157
- g.command 'id' do |c|
158
- c.flag 'channel', desc: 'Channel to get ID for, prefixed with #.'
159
- c.action do |_global_options, options, _args|
160
- puts JSON.dump($client.channels_id(options))
161
- end
162
- end
163
175
  end