slack-ruby-client 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +19 -17
  3. data/.travis.yml +1 -0
  4. data/CHANGELOG.md +8 -0
  5. data/README.md +24 -4
  6. data/bin/commands/chat.rb +10 -9
  7. data/bin/commands/files.rb +19 -1
  8. data/examples/hi_real_time/hi.rb +2 -0
  9. data/lib/slack-ruby-client.rb +4 -2
  10. data/lib/slack/config.rb +4 -0
  11. data/lib/slack/logger.rb +13 -0
  12. data/lib/slack/messages/message.rb +6 -0
  13. data/lib/slack/real_time/api/schema/event.json +1 -0
  14. data/lib/slack/real_time/api/templates/event_handler.erb +4 -18
  15. data/lib/slack/real_time/client.rb +29 -5
  16. data/lib/slack/real_time/concurrency/celluloid.rb +6 -0
  17. data/lib/slack/real_time/concurrency/eventmachine.rb +22 -1
  18. data/lib/slack/real_time/config.rb +5 -1
  19. data/lib/slack/real_time/socket.rb +5 -0
  20. data/lib/slack/real_time/stores.rb +10 -0
  21. data/lib/slack/real_time/stores/base.rb +34 -0
  22. data/lib/slack/real_time/stores/starter.rb +361 -0
  23. data/lib/slack/real_time/stores/store.rb +479 -0
  24. data/lib/slack/version.rb +1 -1
  25. data/lib/slack/web/api/endpoints/api.rb +1 -1
  26. data/lib/slack/web/api/endpoints/auth.rb +1 -1
  27. data/lib/slack/web/api/endpoints/channels.rb +14 -14
  28. data/lib/slack/web/api/endpoints/chat.rb +15 -13
  29. data/lib/slack/web/api/endpoints/dnd.rb +5 -5
  30. data/lib/slack/web/api/endpoints/emoji.rb +1 -1
  31. data/lib/slack/web/api/endpoints/files.rb +30 -6
  32. data/lib/slack/web/api/endpoints/groups.rb +16 -16
  33. data/lib/slack/web/api/endpoints/im.rb +5 -5
  34. data/lib/slack/web/api/endpoints/mpim.rb +5 -5
  35. data/lib/slack/web/api/endpoints/oauth.rb +1 -1
  36. data/lib/slack/web/api/endpoints/pins.rb +3 -3
  37. data/lib/slack/web/api/endpoints/reactions.rb +4 -4
  38. data/lib/slack/web/api/endpoints/rtm.rb +1 -1
  39. data/lib/slack/web/api/endpoints/search.rb +3 -3
  40. data/lib/slack/web/api/endpoints/stars.rb +3 -3
  41. data/lib/slack/web/api/endpoints/team.rb +3 -3
  42. data/lib/slack/web/api/endpoints/usergroups.rb +6 -6
  43. data/lib/slack/web/api/endpoints/users.rb +5 -5
  44. data/lib/slack/web/api/patches/chat.1.text-attachments-required.patch +1 -1
  45. data/lib/slack/web/api/templates/method.erb +1 -1
  46. data/lib/slack/web/client.rb +1 -0
  47. data/lib/tasks/real_time.rake +27 -21
  48. data/slack-ruby-client.gemspec +1 -0
  49. data/spec/integration/integration_spec.rb +13 -1
  50. data/spec/slack/real_time/client_spec.rb +40 -5
  51. data/spec/slack/real_time/concurrency/celluloid_spec.rb +2 -1
  52. data/spec/slack/real_time/concurrency/eventmachine_spec.rb +3 -2
  53. data/spec/slack/real_time/event_handlers/event_handlers_spec.rb +15 -0
  54. data/spec/slack/real_time/event_handlers/team_spec.rb +54 -52
  55. data/spec/slack/web/api/endpoints/files_spec.rb +10 -0
  56. data/spec/slack/web/client_spec.rb +1 -1
  57. data/spec/support/real_time/connected_client.rb +3 -3
  58. metadata +23 -71
  59. data/lib/slack/real_time/api/templates/event_handlers.erb +0 -5
  60. data/lib/slack/real_time/event_handlers.rb +0 -66
  61. data/lib/slack/real_time/event_handlers/accounts_changed.rb +0 -18
  62. data/lib/slack/real_time/event_handlers/bot_added.rb +0 -16
  63. data/lib/slack/real_time/event_handlers/bot_changed.rb +0 -17
  64. data/lib/slack/real_time/event_handlers/channel_archive.rb +0 -17
  65. data/lib/slack/real_time/event_handlers/channel_created.rb +0 -17
  66. data/lib/slack/real_time/event_handlers/channel_deleted.rb +0 -16
  67. data/lib/slack/real_time/event_handlers/channel_history_changed.rb +0 -18
  68. data/lib/slack/real_time/event_handlers/channel_joined.rb +0 -22
  69. data/lib/slack/real_time/event_handlers/channel_left.rb +0 -17
  70. data/lib/slack/real_time/event_handlers/channel_marked.rb +0 -18
  71. data/lib/slack/real_time/event_handlers/channel_rename.rb +0 -17
  72. data/lib/slack/real_time/event_handlers/channel_unarchive.rb +0 -17
  73. data/lib/slack/real_time/event_handlers/commands_changed.rb +0 -18
  74. data/lib/slack/real_time/event_handlers/dnd_updated.rb +0 -18
  75. data/lib/slack/real_time/event_handlers/dnd_updated_user.rb +0 -18
  76. data/lib/slack/real_time/event_handlers/email_domain_changed.rb +0 -16
  77. data/lib/slack/real_time/event_handlers/emoji_changed.rb +0 -18
  78. data/lib/slack/real_time/event_handlers/file_change.rb +0 -18
  79. data/lib/slack/real_time/event_handlers/file_comment_added.rb +0 -18
  80. data/lib/slack/real_time/event_handlers/file_comment_deleted.rb +0 -18
  81. data/lib/slack/real_time/event_handlers/file_comment_edited.rb +0 -18
  82. data/lib/slack/real_time/event_handlers/file_created.rb +0 -18
  83. data/lib/slack/real_time/event_handlers/file_deleted.rb +0 -18
  84. data/lib/slack/real_time/event_handlers/file_private.rb +0 -18
  85. data/lib/slack/real_time/event_handlers/file_public.rb +0 -18
  86. data/lib/slack/real_time/event_handlers/file_shared.rb +0 -18
  87. data/lib/slack/real_time/event_handlers/file_unshared.rb +0 -18
  88. data/lib/slack/real_time/event_handlers/group_archive.rb +0 -17
  89. data/lib/slack/real_time/event_handlers/group_close.rb +0 -16
  90. data/lib/slack/real_time/event_handlers/group_history_changed.rb +0 -18
  91. data/lib/slack/real_time/event_handlers/group_joined.rb +0 -16
  92. data/lib/slack/real_time/event_handlers/group_left.rb +0 -17
  93. data/lib/slack/real_time/event_handlers/group_marked.rb +0 -18
  94. data/lib/slack/real_time/event_handlers/group_open.rb +0 -16
  95. data/lib/slack/real_time/event_handlers/group_rename.rb +0 -17
  96. data/lib/slack/real_time/event_handlers/group_unarchive.rb +0 -17
  97. data/lib/slack/real_time/event_handlers/im_close.rb +0 -16
  98. data/lib/slack/real_time/event_handlers/im_created.rb +0 -16
  99. data/lib/slack/real_time/event_handlers/im_history_changed.rb +0 -18
  100. data/lib/slack/real_time/event_handlers/im_marked.rb +0 -18
  101. data/lib/slack/real_time/event_handlers/im_open.rb +0 -16
  102. data/lib/slack/real_time/event_handlers/manual_presence_change.rb +0 -16
  103. data/lib/slack/real_time/event_handlers/pin_added.rb +0 -18
  104. data/lib/slack/real_time/event_handlers/pin_removed.rb +0 -18
  105. data/lib/slack/real_time/event_handlers/pref_change.rb +0 -16
  106. data/lib/slack/real_time/event_handlers/presence_change.rb +0 -17
  107. data/lib/slack/real_time/event_handlers/reaction_added.rb +0 -18
  108. data/lib/slack/real_time/event_handlers/reaction_removed.rb +0 -18
  109. data/lib/slack/real_time/event_handlers/reconnect_url.rb +0 -18
  110. data/lib/slack/real_time/event_handlers/star_added.rb +0 -18
  111. data/lib/slack/real_time/event_handlers/star_removed.rb +0 -18
  112. data/lib/slack/real_time/event_handlers/subteam_created.rb +0 -18
  113. data/lib/slack/real_time/event_handlers/subteam_self_added.rb +0 -18
  114. data/lib/slack/real_time/event_handlers/subteam_self_removed.rb +0 -18
  115. data/lib/slack/real_time/event_handlers/subteam_updated.rb +0 -18
  116. data/lib/slack/real_time/event_handlers/team_domain_change.rb +0 -17
  117. data/lib/slack/real_time/event_handlers/team_join.rb +0 -16
  118. data/lib/slack/real_time/event_handlers/team_migration_started.rb +0 -18
  119. data/lib/slack/real_time/event_handlers/team_plan_change.rb +0 -16
  120. data/lib/slack/real_time/event_handlers/team_pref_change.rb +0 -16
  121. data/lib/slack/real_time/event_handlers/team_profile_change.rb +0 -18
  122. data/lib/slack/real_time/event_handlers/team_profile_delete.rb +0 -18
  123. data/lib/slack/real_time/event_handlers/team_profile_reorder.rb +0 -18
  124. data/lib/slack/real_time/event_handlers/team_rename.rb +0 -16
  125. data/lib/slack/real_time/event_handlers/user_change.rb +0 -16
  126. data/lib/slack/real_time/event_handlers/user_typing.rb +0 -18
  127. data/lib/slack/real_time/store.rb +0 -47
@@ -11,7 +11,7 @@ module Slack
11
11
  # @option options [im] :channel
12
12
  # Direct message channel to close.
13
13
  # @see https://api.slack.com/methods/im.close
14
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/im.close.json
14
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/im/im.close.json
15
15
  def im_close(options = {})
16
16
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
17
17
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
@@ -34,7 +34,7 @@ module Slack
34
34
  # @option options [Object] :unreads
35
35
  # Include unread_count_display in the output?.
36
36
  # @see https://api.slack.com/methods/im.history
37
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/im.history.json
37
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/im/im.history.json
38
38
  def im_history(options = {})
39
39
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
40
40
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
@@ -45,7 +45,7 @@ module Slack
45
45
  # This method returns a list of all im channels that the user has.
46
46
  #
47
47
  # @see https://api.slack.com/methods/im.list
48
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/im.list.json
48
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/im/im.list.json
49
49
  def im_list(options = {})
50
50
  post('im.list', options)
51
51
  end
@@ -58,7 +58,7 @@ module Slack
58
58
  # @option options [timestamp] :ts
59
59
  # Timestamp of the most recently seen message.
60
60
  # @see https://api.slack.com/methods/im.mark
61
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/im.mark.json
61
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/im/im.mark.json
62
62
  def im_mark(options = {})
63
63
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
64
64
  throw ArgumentError.new('Required arguments :ts missing') if options[:ts].nil?
@@ -72,7 +72,7 @@ module Slack
72
72
  # @option options [user] :user
73
73
  # User to open a direct message channel with.
74
74
  # @see https://api.slack.com/methods/im.open
75
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/im.open.json
75
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/im/im.open.json
76
76
  def im_open(options = {})
77
77
  throw ArgumentError.new('Required arguments :user missing') if options[:user].nil?
78
78
  options = options.merge(user: users_id(options)['user']['id']) if options[:user]
@@ -11,7 +11,7 @@ module Slack
11
11
  # @option options [channel] :channel
12
12
  # MPIM to close.
13
13
  # @see https://api.slack.com/methods/mpim.close
14
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/mpim.close.json
14
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/mpim/mpim.close.json
15
15
  def mpim_close(options = {})
16
16
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
17
17
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
@@ -34,7 +34,7 @@ module Slack
34
34
  # @option options [Object] :unreads
35
35
  # Include unread_count_display in the output?.
36
36
  # @see https://api.slack.com/methods/mpim.history
37
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/mpim.history.json
37
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/mpim/mpim.history.json
38
38
  def mpim_history(options = {})
39
39
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
40
40
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
@@ -45,7 +45,7 @@ module Slack
45
45
  # This method returns a list of all multiparty direct message channels that the user has.
46
46
  #
47
47
  # @see https://api.slack.com/methods/mpim.list
48
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/mpim.list.json
48
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/mpim/mpim.list.json
49
49
  def mpim_list(options = {})
50
50
  post('mpim.list', options)
51
51
  end
@@ -58,7 +58,7 @@ module Slack
58
58
  # @option options [timestamp] :ts
59
59
  # Timestamp of the most recently seen message.
60
60
  # @see https://api.slack.com/methods/mpim.mark
61
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/mpim.mark.json
61
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/mpim/mpim.mark.json
62
62
  def mpim_mark(options = {})
63
63
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
64
64
  throw ArgumentError.new('Required arguments :ts missing') if options[:ts].nil?
@@ -72,7 +72,7 @@ module Slack
72
72
  # @option options [Object] :users
73
73
  # Comma separated lists of users. The ordering of the users is preserved whenever a MPIM group is returned.
74
74
  # @see https://api.slack.com/methods/mpim.open
75
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/mpim.open.json
75
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/mpim/mpim.open.json
76
76
  def mpim_open(options = {})
77
77
  throw ArgumentError.new('Required arguments :users missing') if options[:users].nil?
78
78
  post('mpim.open', options)
@@ -18,7 +18,7 @@ module Slack
18
18
  # @option options [Object] :redirect_uri
19
19
  # This must match the originally submitted URI (if one was sent).
20
20
  # @see https://api.slack.com/methods/oauth.access
21
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/oauth.access.json
21
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/oauth/oauth.access.json
22
22
  def oauth_access(options = {})
23
23
  throw ArgumentError.new('Required arguments :client_id missing') if options[:client_id].nil?
24
24
  throw ArgumentError.new('Required arguments :client_secret missing') if options[:client_secret].nil?
@@ -18,7 +18,7 @@ module Slack
18
18
  # @option options [Object] :timestamp
19
19
  # Timestamp of the message to pin.
20
20
  # @see https://api.slack.com/methods/pins.add
21
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/pins.add.json
21
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/pins/pins.add.json
22
22
  def pins_add(options = {})
23
23
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
24
24
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
@@ -31,7 +31,7 @@ module Slack
31
31
  # @option options [channel] :channel
32
32
  # Channel to get pinned items for.
33
33
  # @see https://api.slack.com/methods/pins.list
34
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/pins.list.json
34
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/pins/pins.list.json
35
35
  def pins_list(options = {})
36
36
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
37
37
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
@@ -51,7 +51,7 @@ module Slack
51
51
  # @option options [Object] :timestamp
52
52
  # Timestamp of the message to un-pin.
53
53
  # @see https://api.slack.com/methods/pins.remove
54
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/pins.remove.json
54
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/pins/pins.remove.json
55
55
  def pins_remove(options = {})
56
56
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
57
57
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
@@ -20,7 +20,7 @@ module Slack
20
20
  # @option options [Object] :timestamp
21
21
  # Timestamp of the message to add reaction to.
22
22
  # @see https://api.slack.com/methods/reactions.add
23
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/reactions.add.json
23
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/reactions/reactions.add.json
24
24
  def reactions_add(options = {})
25
25
  throw ArgumentError.new('Required arguments :name missing') if options[:name].nil?
26
26
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
@@ -41,7 +41,7 @@ module Slack
41
41
  # @option options [Object] :full
42
42
  # If true always return the complete reaction list.
43
43
  # @see https://api.slack.com/methods/reactions.get
44
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/reactions.get.json
44
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/reactions/reactions.get.json
45
45
  def reactions_get(options = {})
46
46
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
47
47
  post('reactions.get', options)
@@ -55,7 +55,7 @@ module Slack
55
55
  # @option options [Object] :full
56
56
  # If true always return the complete reaction list.
57
57
  # @see https://api.slack.com/methods/reactions.list
58
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/reactions.list.json
58
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/reactions/reactions.list.json
59
59
  def reactions_list(options = {})
60
60
  options = options.merge(user: users_id(options)['user']['id']) if options[:user]
61
61
  post('reactions.list', options)
@@ -76,7 +76,7 @@ module Slack
76
76
  # @option options [Object] :timestamp
77
77
  # Timestamp of the message to remove reaction from.
78
78
  # @see https://api.slack.com/methods/reactions.remove
79
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/reactions.remove.json
79
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/reactions/reactions.remove.json
80
80
  def reactions_remove(options = {})
81
81
  throw ArgumentError.new('Required arguments :name missing') if options[:name].nil?
82
82
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
@@ -16,7 +16,7 @@ module Slack
16
16
  # @option options [Object] :mpim_aware
17
17
  # Returns MPIMs to the client in the API response.
18
18
  # @see https://api.slack.com/methods/rtm.start
19
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/rtm.start.json
19
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/rtm/rtm.start.json
20
20
  def rtm_start(options = {})
21
21
  post('rtm.start', options)
22
22
  end
@@ -17,7 +17,7 @@ module Slack
17
17
  # @option options [Object] :highlight
18
18
  # Pass a value of 1 to enable query highlight markers (see below).
19
19
  # @see https://api.slack.com/methods/search.all
20
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/search.all.json
20
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/search/search.all.json
21
21
  def search_all(options = {})
22
22
  throw ArgumentError.new('Required arguments :query missing') if options[:query].nil?
23
23
  post('search.all', options)
@@ -35,7 +35,7 @@ module Slack
35
35
  # @option options [Object] :highlight
36
36
  # Pass a value of 1 to enable query highlight markers (see below).
37
37
  # @see https://api.slack.com/methods/search.files
38
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/search.files.json
38
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/search/search.files.json
39
39
  def search_files(options = {})
40
40
  throw ArgumentError.new('Required arguments :query missing') if options[:query].nil?
41
41
  post('search.files', options)
@@ -53,7 +53,7 @@ module Slack
53
53
  # @option options [Object] :highlight
54
54
  # Pass a value of 1 to enable query highlight markers (see below).
55
55
  # @see https://api.slack.com/methods/search.messages
56
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/search.messages.json
56
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/search/search.messages.json
57
57
  def search_messages(options = {})
58
58
  throw ArgumentError.new('Required arguments :query missing') if options[:query].nil?
59
59
  post('search.messages', options)
@@ -18,7 +18,7 @@ module Slack
18
18
  # @option options [Object] :timestamp
19
19
  # Timestamp of the message to add star to.
20
20
  # @see https://api.slack.com/methods/stars.add
21
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/stars.add.json
21
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/stars/stars.add.json
22
22
  def stars_add(options = {})
23
23
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
24
24
  post('stars.add', options)
@@ -30,7 +30,7 @@ module Slack
30
30
  # @option options [user] :user
31
31
  # Show stars by this user. Defaults to the authed user.
32
32
  # @see https://api.slack.com/methods/stars.list
33
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/stars.list.json
33
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/stars/stars.list.json
34
34
  def stars_list(options = {})
35
35
  options = options.merge(user: users_id(options)['user']['id']) if options[:user]
36
36
  post('stars.list', options)
@@ -49,7 +49,7 @@ module Slack
49
49
  # @option options [Object] :timestamp
50
50
  # Timestamp of the message to remove star from.
51
51
  # @see https://api.slack.com/methods/stars.remove
52
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/stars.remove.json
52
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/stars/stars.remove.json
53
53
  def stars_remove(options = {})
54
54
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
55
55
  post('stars.remove', options)
@@ -9,7 +9,7 @@ module Slack
9
9
  # This method is used to get the access logs for users on a team.
10
10
  #
11
11
  # @see https://api.slack.com/methods/team.accessLogs
12
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/team.accessLogs.json
12
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/team/team.accessLogs.json
13
13
  def team_accessLogs(options = {})
14
14
  post('team.accessLogs', options)
15
15
  end
@@ -18,7 +18,7 @@ module Slack
18
18
  # This method provides information about your team.
19
19
  #
20
20
  # @see https://api.slack.com/methods/team.info
21
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/team.info.json
21
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/team/team.info.json
22
22
  def team_info(options = {})
23
23
  post('team.info', options)
24
24
  end
@@ -35,7 +35,7 @@ module Slack
35
35
  # @option options [Object] :change_type
36
36
  # Filter logs with this change type. Defaults to all logs.
37
37
  # @see https://api.slack.com/methods/team.integrationLogs
38
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/team.integrationLogs.json
38
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/team/team.integrationLogs.json
39
39
  def team_integrationLogs(options = {})
40
40
  options = options.merge(user: users_id(options)['user']['id']) if options[:user]
41
41
  post('team.integrationLogs', options)
@@ -19,7 +19,7 @@ module Slack
19
19
  # @option options [Object] :include_count
20
20
  # Include the number of users in each user group.
21
21
  # @see https://api.slack.com/methods/usergroups.create
22
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/usergroups.create.json
22
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/usergroups/usergroups.create.json
23
23
  def usergroups_create(options = {})
24
24
  throw ArgumentError.new('Required arguments :name missing') if options[:name].nil?
25
25
  post('usergroups.create', options)
@@ -33,7 +33,7 @@ module Slack
33
33
  # @option options [Object] :include_count
34
34
  # Include the number of users in the user group.
35
35
  # @see https://api.slack.com/methods/usergroups.disable
36
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/usergroups.disable.json
36
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/usergroups/usergroups.disable.json
37
37
  def usergroups_disable(options = {})
38
38
  throw ArgumentError.new('Required arguments :usergroup missing') if options[:usergroup].nil?
39
39
  post('usergroups.disable', options)
@@ -47,7 +47,7 @@ module Slack
47
47
  # @option options [Object] :include_count
48
48
  # Include the number of users in the user group.
49
49
  # @see https://api.slack.com/methods/usergroups.enable
50
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/usergroups.enable.json
50
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/usergroups/usergroups.enable.json
51
51
  def usergroups_enable(options = {})
52
52
  throw ArgumentError.new('Required arguments :usergroup missing') if options[:usergroup].nil?
53
53
  post('usergroups.enable', options)
@@ -63,7 +63,7 @@ module Slack
63
63
  # @option options [Object] :include_users
64
64
  # Include the list of users for each user group.
65
65
  # @see https://api.slack.com/methods/usergroups.list
66
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/usergroups.list.json
66
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/usergroups/usergroups.list.json
67
67
  def usergroups_list(options = {})
68
68
  post('usergroups.list', options)
69
69
  end
@@ -84,7 +84,7 @@ module Slack
84
84
  # @option options [Object] :include_count
85
85
  # Include the number of users in the user group.
86
86
  # @see https://api.slack.com/methods/usergroups.update
87
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/usergroups.update.json
87
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/usergroups/usergroups.update.json
88
88
  def usergroups_update(options = {})
89
89
  throw ArgumentError.new('Required arguments :usergroup missing') if options[:usergroup].nil?
90
90
  post('usergroups.update', options)
@@ -100,7 +100,7 @@ module Slack
100
100
  # @option options [Object] :include_count
101
101
  # Include the number of users in the user group.
102
102
  # @see https://api.slack.com/methods/usergroups.users
103
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/usergroups.users.json
103
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/usergroups/usergroups.users.json
104
104
  def usergroups_users(options = {})
105
105
  throw ArgumentError.new('Required arguments :usergroup missing') if options[:usergroup].nil?
106
106
  throw ArgumentError.new('Required arguments :users missing') if options[:users].nil?
@@ -12,7 +12,7 @@ module Slack
12
12
  # @option options [user] :user
13
13
  # User to get presence info on. Defaults to the authed user.
14
14
  # @see https://api.slack.com/methods/users.getPresence
15
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/users.getPresence.json
15
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/users/users.getPresence.json
16
16
  def users_getPresence(options = {})
17
17
  throw ArgumentError.new('Required arguments :user missing') if options[:user].nil?
18
18
  options = options.merge(user: users_id(options)['user']['id']) if options[:user]
@@ -25,7 +25,7 @@ module Slack
25
25
  # @option options [user] :user
26
26
  # User to get info on.
27
27
  # @see https://api.slack.com/methods/users.info
28
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/users.info.json
28
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/users/users.info.json
29
29
  def users_info(options = {})
30
30
  throw ArgumentError.new('Required arguments :user missing') if options[:user].nil?
31
31
  options = options.merge(user: users_id(options)['user']['id']) if options[:user]
@@ -38,7 +38,7 @@ module Slack
38
38
  # @option options [Object] :presence
39
39
  # Whether to include presence data in the output.
40
40
  # @see https://api.slack.com/methods/users.list
41
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/users.list.json
41
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/users/users.list.json
42
42
  def users_list(options = {})
43
43
  post('users.list', options)
44
44
  end
@@ -49,7 +49,7 @@ module Slack
49
49
  # more details.
50
50
  #
51
51
  # @see https://api.slack.com/methods/users.setActive
52
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/users.setActive.json
52
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/users/users.setActive.json
53
53
  def users_setActive(options = {})
54
54
  post('users.setActive', options)
55
55
  end
@@ -61,7 +61,7 @@ module Slack
61
61
  # @option options [Object] :presence
62
62
  # Either auto or away.
63
63
  # @see https://api.slack.com/methods/users.setPresence
64
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/users.setPresence.json
64
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/users/users.setPresence.json
65
65
  def users_setPresence(options = {})
66
66
  throw ArgumentError.new('Required arguments :presence missing') if options[:presence].nil?
67
67
  post('users.setPresence', options)
@@ -3,7 +3,7 @@ index 1f7a8d7..2ec4bed 100644
3
3
  --- a/lib/slack/web/api/endpoints/chat.rb
4
4
  +++ b/lib/slack/web/api/endpoints/chat.rb
5
5
  @@ -49,7 +49,7 @@ module Slack
6
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/chat.postMessage.json
6
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/chat/chat.postMessage.json
7
7
  def chat_postMessage(options = {})
8
8
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
9
9
  - throw ArgumentError.new('Required arguments :text missing') if options[:text].nil?
@@ -26,7 +26,7 @@ module Slack
26
26
  <% end %>
27
27
  <% end %>
28
28
  # @see https://api.slack.com/methods/<%= group %>.<%= name %>
29
- # @see https://github.com/dblock/slack-api-ref/blob/master/methods/<%= group %>.<%= name %>.json
29
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/<%= group %>/<%= group %>.<%= name %>.json
30
30
  def <%= group %>_<%= name %>(options = {})
31
31
  <% data['args'].select{ |k, v| v['required'] }.each do |arg_name, arg_v| %>
32
32
  throw ArgumentError.new('Required arguments :<%= arg_name %> missing') if options[:<%= arg_name %>].nil?
@@ -11,6 +11,7 @@ module Slack
11
11
  Slack::Web::Config::ATTRIBUTES.each do |key|
12
12
  send("#{key}=", options[key] || Slack::Web.config.send(key))
13
13
  end
14
+ @logger ||= Slack::Config.logger || Slack::Logger.default
14
15
  @token ||= Slack.config.token
15
16
  end
16
17
 
@@ -5,6 +5,8 @@ require 'erubis'
5
5
  namespace :slack do
6
6
  namespace :real_time do
7
7
  namespace :api do
8
+ REAL_TIME_EVENTS_MARKER = '### RealTime Events'
9
+
8
10
  desc 'Update API.'
9
11
  task update: [:git_update] do
10
12
  event_schema = JSON.parse(File.read('lib/slack/real_time/api/schema/event.json'))
@@ -15,29 +17,33 @@ namespace :slack do
15
17
  next if %w(message hello).include?(name)
16
18
  result[name] = parsed
17
19
  end
18
- # event_handlers.rb
19
- event_handlers_filename = 'lib/slack/real_time/event_handlers.rb'
20
- if File.exist?(event_handlers_filename)
21
- puts "Skipping #{event_handlers_filename}."
22
- else
23
- event_handlers_template = Erubis::Eruby.new(File.read('lib/slack/real_time/api/templates/event_handlers.erb'))
24
- File.write event_handlers_filename, event_handlers_template.result(events: events.keys)
25
- end
26
- # each event handler
20
+
27
21
  event_handler_template = Erubis::Eruby.new(File.read('lib/slack/real_time/api/templates/event_handler.erb'))
28
- events.each_pair do |name, json|
29
- event_handler_filename = "lib/slack/real_time/event_handlers/#{name}.rb"
30
- if File.exist?(event_handler_filename)
31
- puts "Skipping #{event_handler_filename}."
32
- else
33
- puts "Creating #{event_handler_filename}."
34
- rendered_event_handler = event_handler_template.result(
35
- name: json['name'],
36
- class_name: json['name'].split('_').each(&:capitalize!).join,
37
- desc: json['desc']
38
- )
39
- File.write event_handler_filename, rendered_event_handler
22
+ Dir.glob('lib/slack/real_time/stores/**/*.rb').each do |store_file|
23
+ next if File.basename(store_file) == 'base.rb'
24
+ STDOUT.write "#{File.basename(store_file)}:"
25
+
26
+ store_file_contents = File.read(store_file)
27
+
28
+ events.each_pair do |event_name, event_data|
29
+ if store_file_contents.include?("on :#{event_name} do")
30
+ STDOUT.write('.')
31
+ else
32
+ STDOUT.write('x')
33
+ rendered_event_handler = event_handler_template.result(
34
+ name: event_data['name'],
35
+ desc: event_data['desc']
36
+ )
37
+
38
+ store_file_contents.gsub! REAL_TIME_EVENTS_MARKER, REAL_TIME_EVENTS_MARKER + "\n\n" + rendered_event_handler.rstrip
39
+ end
40
+ end
41
+
42
+ File.open store_file, 'w' do |f|
43
+ f.write store_file_contents
40
44
  end
45
+
46
+ puts ' done.'
41
47
  end
42
48
  end
43
49
  end
@@ -16,6 +16,7 @@ Gem::Specification.new do |s|
16
16
  s.homepage = 'http://github.com/dblock/slack-ruby-client'
17
17
  s.licenses = ['MIT']
18
18
  s.summary = 'Slack Web and RealTime API client.'
19
+ s.add_dependency 'activesupport'
19
20
  s.add_dependency 'faraday'
20
21
  s.add_dependency 'faraday_middleware'
21
22
  s.add_dependency 'json'
@@ -7,11 +7,23 @@ RSpec.describe 'integration test', skip: !ENV['SLACK_API_TOKEN'] && 'missing SLA
7
7
  WebMock.disable_net_connect!
8
8
  end
9
9
 
10
+ let(:logger) do
11
+ logger = Logger.new(STDOUT)
12
+ logger.level = Logger::DEBUG
13
+ logger
14
+ end
15
+
10
16
  before do
11
17
  Thread.abort_on_exception = true
18
+
19
+ Slack.configure do |slack|
20
+ slack.logger = logger
21
+ end
12
22
  end
13
23
 
14
- let(:logger) { Logger.new(STDOUT) }
24
+ after do
25
+ Slack.config.reset
26
+ end
15
27
 
16
28
  let(:queue) { QueueWithTimeout.new }
17
29