slack-ruby-client-bhe 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. checksums.yaml +17 -0
  2. data/.gitignore +4 -0
  3. data/.gitmodules +3 -0
  4. data/.rspec +2 -0
  5. data/.rubocop.yml +6 -0
  6. data/.rubocop_todo.yml +78 -0
  7. data/.travis.yml +26 -0
  8. data/CHANGELOG.md +79 -0
  9. data/CONTRIBUTING.md +157 -0
  10. data/Gemfile +5 -0
  11. data/LICENSE.md +22 -0
  12. data/README.md +385 -0
  13. data/RELEASING.md +69 -0
  14. data/Rakefile +19 -0
  15. data/UPGRADING.md +26 -0
  16. data/bin/commands.rb +21 -0
  17. data/bin/commands/api.rb +14 -0
  18. data/bin/commands/auth.rb +12 -0
  19. data/bin/commands/channels.rb +149 -0
  20. data/bin/commands/chat.rb +47 -0
  21. data/bin/commands/dnd.rb +47 -0
  22. data/bin/commands/emoji.rb +12 -0
  23. data/bin/commands/files.rb +72 -0
  24. data/bin/commands/groups.rb +167 -0
  25. data/bin/commands/im.rb +53 -0
  26. data/bin/commands/mpim.rb +53 -0
  27. data/bin/commands/oauth.rb +16 -0
  28. data/bin/commands/pins.rb +37 -0
  29. data/bin/commands/reactions.rb +53 -0
  30. data/bin/commands/rtm.rb +15 -0
  31. data/bin/commands/search.rb +40 -0
  32. data/bin/commands/stars.rb +37 -0
  33. data/bin/commands/team.rb +32 -0
  34. data/bin/commands/usergroups.rb +73 -0
  35. data/bin/commands/users.rb +57 -0
  36. data/bin/slack +50 -0
  37. data/examples/hi_real_time/Gemfile +5 -0
  38. data/examples/hi_real_time/hi.gif +0 -0
  39. data/examples/hi_real_time/hi.rb +32 -0
  40. data/examples/hi_real_time_and_web/Gemfile +5 -0
  41. data/examples/hi_real_time_and_web/hi.gif +0 -0
  42. data/examples/hi_real_time_and_web/hi.rb +24 -0
  43. data/examples/hi_real_time_async/Gemfile +5 -0
  44. data/examples/hi_real_time_async/hi.rb +29 -0
  45. data/examples/hi_web/Gemfile +3 -0
  46. data/examples/hi_web/hi.gif +0 -0
  47. data/examples/hi_web/hi.rb +12 -0
  48. data/examples/new_ticket/Gemfile +3 -0
  49. data/examples/new_ticket/new_ticket.rb +25 -0
  50. data/lib/slack-ruby-client.rb +29 -0
  51. data/lib/slack.rb +1 -0
  52. data/lib/slack/config.rb +21 -0
  53. data/lib/slack/messages/formatting.rb +30 -0
  54. data/lib/slack/real_time/api/message.rb +20 -0
  55. data/lib/slack/real_time/api/message_id.rb +14 -0
  56. data/lib/slack/real_time/api/ping.rb +16 -0
  57. data/lib/slack/real_time/api/typing.rb +17 -0
  58. data/lib/slack/real_time/client.rb +152 -0
  59. data/lib/slack/real_time/concurrency.rb +8 -0
  60. data/lib/slack/real_time/concurrency/celluloid.rb +93 -0
  61. data/lib/slack/real_time/concurrency/eventmachine.rb +39 -0
  62. data/lib/slack/real_time/config.rb +55 -0
  63. data/lib/slack/real_time/socket.rb +81 -0
  64. data/lib/slack/version.rb +3 -0
  65. data/lib/slack/web/api/endpoints.rb +53 -0
  66. data/lib/slack/web/api/endpoints/api.rb +24 -0
  67. data/lib/slack/web/api/endpoints/auth.rb +20 -0
  68. data/lib/slack/web/api/endpoints/channels.rb +220 -0
  69. data/lib/slack/web/api/endpoints/chat.rb +91 -0
  70. data/lib/slack/web/api/endpoints/dnd.rb +64 -0
  71. data/lib/slack/web/api/endpoints/emoji.rb +20 -0
  72. data/lib/slack/web/api/endpoints/files.rb +108 -0
  73. data/lib/slack/web/api/endpoints/groups.rb +247 -0
  74. data/lib/slack/web/api/endpoints/im.rb +85 -0
  75. data/lib/slack/web/api/endpoints/mpim.rb +84 -0
  76. data/lib/slack/web/api/endpoints/oauth.rb +32 -0
  77. data/lib/slack/web/api/endpoints/pins.rb +64 -0
  78. data/lib/slack/web/api/endpoints/presence.rb +23 -0
  79. data/lib/slack/web/api/endpoints/reactions.rb +89 -0
  80. data/lib/slack/web/api/endpoints/rtm.rb +27 -0
  81. data/lib/slack/web/api/endpoints/search.rb +65 -0
  82. data/lib/slack/web/api/endpoints/stars.rb +61 -0
  83. data/lib/slack/web/api/endpoints/team.rb +47 -0
  84. data/lib/slack/web/api/endpoints/usergroups.rb +113 -0
  85. data/lib/slack/web/api/endpoints/users.rb +73 -0
  86. data/lib/slack/web/api/error.rb +14 -0
  87. data/lib/slack/web/api/mixins.rb +3 -0
  88. data/lib/slack/web/api/mixins/channels.id.json +20 -0
  89. data/lib/slack/web/api/mixins/channels.id.rb +26 -0
  90. data/lib/slack/web/api/mixins/groups.id.json +20 -0
  91. data/lib/slack/web/api/mixins/groups.id.rb +26 -0
  92. data/lib/slack/web/api/mixins/users.id.json +20 -0
  93. data/lib/slack/web/api/mixins/users.id.rb +26 -0
  94. data/lib/slack/web/api/patches/chat.1.text-attachments-required.patch +13 -0
  95. data/lib/slack/web/api/patches/chat.2.attachments-json.patch +17 -0
  96. data/lib/slack/web/api/schema/group.json +14 -0
  97. data/lib/slack/web/api/schema/method.json +45 -0
  98. data/lib/slack/web/api/tasks/generate.rake +61 -0
  99. data/lib/slack/web/api/templates/command.erb +34 -0
  100. data/lib/slack/web/api/templates/commands.erb +5 -0
  101. data/lib/slack/web/api/templates/endpoints.erb +21 -0
  102. data/lib/slack/web/api/templates/method.erb +49 -0
  103. data/lib/slack/web/client.rb +28 -0
  104. data/lib/slack/web/config.rb +41 -0
  105. data/lib/slack/web/faraday/connection.rb +29 -0
  106. data/lib/slack/web/faraday/request.rb +39 -0
  107. data/lib/slack/web/faraday/response/raise_error.rb +15 -0
  108. data/lib/slack_ruby_client.rb +1 -0
  109. data/screenshots/register-bot.png +0 -0
  110. data/slack-ruby-client.gemspec +31 -0
  111. data/slack.png +0 -0
  112. data/spec/fixtures/slack/web/429_error.yml +83 -0
  113. data/spec/fixtures/slack/web/auth_test_error.yml +48 -0
  114. data/spec/fixtures/slack/web/auth_test_success.yml +57 -0
  115. data/spec/fixtures/slack/web/channels_info.yml +46 -0
  116. data/spec/fixtures/slack/web/groups_info.yml +43 -0
  117. data/spec/fixtures/slack/web/rtm_start.yml +73 -0
  118. data/spec/fixtures/slack/web/users_info.yml +130 -0
  119. data/spec/fixtures/slack/web/users_list.yml +72 -0
  120. data/spec/integration/integration_spec.rb +107 -0
  121. data/spec/slack/config_spec.rb +14 -0
  122. data/spec/slack/messages/formatting_spec.rb +43 -0
  123. data/spec/slack/real_time/api/message_spec.rb +15 -0
  124. data/spec/slack/real_time/api/ping_spec.rb +15 -0
  125. data/spec/slack/real_time/api/typing_spec.rb +15 -0
  126. data/spec/slack/real_time/client_spec.rb +198 -0
  127. data/spec/slack/real_time/concurrency/celluloid_spec.rb +58 -0
  128. data/spec/slack/real_time/concurrency/eventmachine_spec.rb +49 -0
  129. data/spec/slack/slack_spec.rb +58 -0
  130. data/spec/slack/version_spec.rb +7 -0
  131. data/spec/slack/web/api/endpoints/auth_spec.rb +20 -0
  132. data/spec/slack/web/api/endpoints/channels_spec.rb +11 -0
  133. data/spec/slack/web/api/endpoints/chat_spec.rb +33 -0
  134. data/spec/slack/web/api/endpoints/groups_spec.rb +11 -0
  135. data/spec/slack/web/api/endpoints/users_spec.rb +17 -0
  136. data/spec/slack/web/api/error_spec.rb +14 -0
  137. data/spec/slack/web/api/mixins/channels_spec.rb +31 -0
  138. data/spec/slack/web/api/mixins/groups_spec.rb +31 -0
  139. data/spec/slack/web/api/mixins/users_spec.rb +31 -0
  140. data/spec/slack/web/client_spec.rb +134 -0
  141. data/spec/spec_helper.rb +14 -0
  142. data/spec/support/queue_with_timeout.rb +34 -0
  143. data/spec/support/real_time/concurrency/mock.rb +31 -0
  144. data/spec/support/real_time/connected_client.rb +16 -0
  145. data/spec/support/token.rb +10 -0
  146. data/spec/support/vcr.rb +8 -0
  147. metadata +392 -0
@@ -0,0 +1,3 @@
1
+ module Slack
2
+ VERSION = '0.5.4'
3
+ end
@@ -0,0 +1,53 @@
1
+ # This file was auto-generated by lib/slack/web/api/tasks/generate.rake
2
+
3
+ require 'slack/web/api/endpoints/api'
4
+ require 'slack/web/api/endpoints/auth'
5
+ require 'slack/web/api/endpoints/channels'
6
+ require 'slack/web/api/endpoints/chat'
7
+ require 'slack/web/api/endpoints/dnd'
8
+ require 'slack/web/api/endpoints/emoji'
9
+ require 'slack/web/api/endpoints/files'
10
+ require 'slack/web/api/endpoints/groups'
11
+ require 'slack/web/api/endpoints/im'
12
+ require 'slack/web/api/endpoints/mpim'
13
+ require 'slack/web/api/endpoints/oauth'
14
+ require 'slack/web/api/endpoints/pins'
15
+ require 'slack/web/api/endpoints/reactions'
16
+ require 'slack/web/api/endpoints/rtm'
17
+ require 'slack/web/api/endpoints/search'
18
+ require 'slack/web/api/endpoints/stars'
19
+ require 'slack/web/api/endpoints/team'
20
+ require 'slack/web/api/endpoints/usergroups'
21
+ require 'slack/web/api/endpoints/users'
22
+
23
+ module Slack
24
+ module Web
25
+ module Api
26
+ module Endpoints
27
+ include Slack::Web::Api::Mixins::Channels
28
+ include Slack::Web::Api::Mixins::Users
29
+ include Slack::Web::Api::Mixins::Groups
30
+
31
+ include Api
32
+ include Auth
33
+ include Channels
34
+ include Chat
35
+ include Dnd
36
+ include Emoji
37
+ include Files
38
+ include Groups
39
+ include Im
40
+ include Mpim
41
+ include Oauth
42
+ include Pins
43
+ include Reactions
44
+ include Rtm
45
+ include Search
46
+ include Stars
47
+ include Team
48
+ include Usergroups
49
+ include Users
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,24 @@
1
+ # This file was auto-generated by lib/slack/web/api/tasks/generate.rake
2
+
3
+ module Slack
4
+ module Web
5
+ module Api
6
+ module Endpoints
7
+ module Api
8
+ #
9
+ # This method helps you test your calling code.
10
+ #
11
+ # @option options [Object] :error
12
+ # Error response to return.
13
+ # @option options [Object] :foo
14
+ # example property to return.
15
+ # @see https://api.slack.com/methods/api.test
16
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/api.test.json
17
+ def api_test(options = {})
18
+ post('api.test', options)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,20 @@
1
+ # This file was auto-generated by lib/slack/web/api/tasks/generate.rake
2
+
3
+ module Slack
4
+ module Web
5
+ module Api
6
+ module Endpoints
7
+ module Auth
8
+ #
9
+ # This method checks authentication and tells you who you are.
10
+ #
11
+ # @see https://api.slack.com/methods/auth.test
12
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/auth.test.json
13
+ def auth_test(options = {})
14
+ post('auth.test', options)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,220 @@
1
+ # This file was auto-generated by lib/slack/web/api/tasks/generate.rake
2
+
3
+ module Slack
4
+ module Web
5
+ module Api
6
+ module Endpoints
7
+ module Channels
8
+ #
9
+ # This method archives a channel.
10
+ #
11
+ # @option options [channel] :channel
12
+ # Channel to archive.
13
+ # @see https://api.slack.com/methods/channels.archive
14
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/channels.archive.json
15
+ def channels_archive(options = {})
16
+ throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
17
+ options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
18
+ post('channels.archive', options)
19
+ end
20
+
21
+ #
22
+ # This method is used to create a channel.
23
+ #
24
+ # @option options [Object] :name
25
+ # Name of channel to create.
26
+ # @see https://api.slack.com/methods/channels.create
27
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/channels.create.json
28
+ def channels_create(options = {})
29
+ throw ArgumentError.new('Required arguments :name missing') if options[:name].nil?
30
+ post('channels.create', options)
31
+ end
32
+
33
+ #
34
+ # This method returns a portion of messages/events from the specified channel.
35
+ # To read the entire history for a channel, call the method with no latest or
36
+ # oldest arguments, and then continue paging using the instructions below.
37
+ #
38
+ # @option options [channel] :channel
39
+ # Channel to fetch history for.
40
+ # @option options [timestamp] :latest
41
+ # End of time range of messages to include in results.
42
+ # @option options [timestamp] :oldest
43
+ # Start of time range of messages to include in results.
44
+ # @option options [Object] :inclusive
45
+ # Include messages with latest or oldest timestamp in results.
46
+ # @option options [Object] :unreads
47
+ # Include unread_count_display in the output?.
48
+ # @see https://api.slack.com/methods/channels.history
49
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/channels.history.json
50
+ def channels_history(options = {})
51
+ throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
52
+ options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
53
+ post('channels.history', options)
54
+ end
55
+
56
+ #
57
+ # This method returns information about a team channel.
58
+ #
59
+ # @option options [channel] :channel
60
+ # Channel to get info on.
61
+ # @see https://api.slack.com/methods/channels.info
62
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/channels.info.json
63
+ def channels_info(options = {})
64
+ throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
65
+ options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
66
+ post('channels.info', options)
67
+ end
68
+
69
+ #
70
+ # This method is used to invite a user to a channel. The calling user must be a member of the channel.
71
+ #
72
+ # @option options [channel] :channel
73
+ # Channel to invite user to.
74
+ # @option options [user] :user
75
+ # User to invite to channel.
76
+ # @see https://api.slack.com/methods/channels.invite
77
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/channels.invite.json
78
+ def channels_invite(options = {})
79
+ throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
80
+ throw ArgumentError.new('Required arguments :user missing') if options[:user].nil?
81
+ options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
82
+ options = options.merge(user: users_id(options)['user']['id']) if options[:user]
83
+ post('channels.invite', options)
84
+ end
85
+
86
+ #
87
+ # This method is used to join a channel. If the channel does not exist, it is
88
+ # created.
89
+ #
90
+ # @option options [Object] :name
91
+ # Name of channel to join.
92
+ # @see https://api.slack.com/methods/channels.join
93
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/channels.join.json
94
+ def channels_join(options = {})
95
+ throw ArgumentError.new('Required arguments :name missing') if options[:name].nil?
96
+ post('channels.join', options)
97
+ end
98
+
99
+ #
100
+ # This method allows a user to remove another member from a team channel.
101
+ #
102
+ # @option options [channel] :channel
103
+ # Channel to remove user from.
104
+ # @option options [user] :user
105
+ # User to remove from channel.
106
+ # @see https://api.slack.com/methods/channels.kick
107
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/channels.kick.json
108
+ def channels_kick(options = {})
109
+ throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
110
+ throw ArgumentError.new('Required arguments :user missing') if options[:user].nil?
111
+ options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
112
+ options = options.merge(user: users_id(options)['user']['id']) if options[:user]
113
+ post('channels.kick', options)
114
+ end
115
+
116
+ #
117
+ # This method is used to leave a channel.
118
+ #
119
+ # @option options [channel] :channel
120
+ # Channel to leave.
121
+ # @see https://api.slack.com/methods/channels.leave
122
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/channels.leave.json
123
+ def channels_leave(options = {})
124
+ throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
125
+ options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
126
+ post('channels.leave', options)
127
+ end
128
+
129
+ #
130
+ # 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.
131
+ #
132
+ # @option options [Object] :exclude_archived
133
+ # Don't return archived channels.
134
+ # @see https://api.slack.com/methods/channels.list
135
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/channels.list.json
136
+ def channels_list(options = {})
137
+ post('channels.list', options)
138
+ end
139
+
140
+ #
141
+ # This method moves the read cursor in a channel.
142
+ #
143
+ # @option options [channel] :channel
144
+ # Channel to set reading cursor in.
145
+ # @option options [timestamp] :ts
146
+ # Timestamp of the most recently seen message.
147
+ # @see https://api.slack.com/methods/channels.mark
148
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/channels.mark.json
149
+ def channels_mark(options = {})
150
+ throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
151
+ throw ArgumentError.new('Required arguments :ts missing') if options[:ts].nil?
152
+ options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
153
+ post('channels.mark', options)
154
+ end
155
+
156
+ #
157
+ # This method renames a team channel.
158
+ #
159
+ # @option options [channel] :channel
160
+ # Channel to rename.
161
+ # @option options [Object] :name
162
+ # New name for channel.
163
+ # @see https://api.slack.com/methods/channels.rename
164
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/channels.rename.json
165
+ def channels_rename(options = {})
166
+ throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
167
+ throw ArgumentError.new('Required arguments :name missing') if options[:name].nil?
168
+ options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
169
+ post('channels.rename', options)
170
+ end
171
+
172
+ #
173
+ # This method is used to change the purpose of a channel. The calling user must be a member of the channel.
174
+ #
175
+ # @option options [channel] :channel
176
+ # Channel to set the purpose of.
177
+ # @option options [Object] :purpose
178
+ # The new purpose.
179
+ # @see https://api.slack.com/methods/channels.setPurpose
180
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/channels.setPurpose.json
181
+ def channels_setPurpose(options = {})
182
+ throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
183
+ throw ArgumentError.new('Required arguments :purpose missing') if options[:purpose].nil?
184
+ options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
185
+ post('channels.setPurpose', options)
186
+ end
187
+
188
+ #
189
+ # This method is used to change the topic of a channel. The calling user must be a member of the channel.
190
+ #
191
+ # @option options [channel] :channel
192
+ # Channel to set the topic of.
193
+ # @option options [Object] :topic
194
+ # The new topic.
195
+ # @see https://api.slack.com/methods/channels.setTopic
196
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/channels.setTopic.json
197
+ def channels_setTopic(options = {})
198
+ throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
199
+ throw ArgumentError.new('Required arguments :topic missing') if options[:topic].nil?
200
+ options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
201
+ post('channels.setTopic', options)
202
+ end
203
+
204
+ #
205
+ # This method unarchives a channel. The calling user is added to the channel.
206
+ #
207
+ # @option options [channel] :channel
208
+ # Channel to unarchive.
209
+ # @see https://api.slack.com/methods/channels.unarchive
210
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/channels.unarchive.json
211
+ def channels_unarchive(options = {})
212
+ throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
213
+ options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
214
+ post('channels.unarchive', options)
215
+ end
216
+ end
217
+ end
218
+ end
219
+ end
220
+ end
@@ -0,0 +1,91 @@
1
+ # This file was auto-generated by lib/slack/web/api/tasks/generate.rake
2
+
3
+ module Slack
4
+ module Web
5
+ module Api
6
+ module Endpoints
7
+ module Chat
8
+ #
9
+ # This method deletes a message from a channel.
10
+ #
11
+ # @option options [timestamp] :ts
12
+ # Timestamp of the message to be deleted.
13
+ # @option options [channel] :channel
14
+ # Channel containing the message to be deleted.
15
+ # @see https://api.slack.com/methods/chat.delete
16
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/chat.delete.json
17
+ def chat_delete(options = {})
18
+ throw ArgumentError.new('Required arguments :ts missing') if options[:ts].nil?
19
+ throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
20
+ options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
21
+ post('chat.delete', options)
22
+ end
23
+
24
+ #
25
+ # This method posts a message to a public channel, private group, or IM channel.
26
+ #
27
+ # @option options [channel] :channel
28
+ # Channel, private group, or IM channel to send message to. Can be an encoded ID, or a name. See below for more details.
29
+ # @option options [Object] :text
30
+ # Text of the message to send. See below for an explanation of formatting.
31
+ # @option options [Object] :username
32
+ # Name of bot.
33
+ # @option options [Object] :as_user
34
+ # Pass true to post the message as the authed user, instead of as a bot.
35
+ # @option options [Object] :parse
36
+ # Change how messages are treated. See below.
37
+ # @option options [Object] :link_names
38
+ # Find and link channel names and usernames.
39
+ # @option options [Object] :attachments
40
+ # Structured message attachments.
41
+ # @option options [Object] :unfurl_links
42
+ # Pass true to enable unfurling of primarily text-based content.
43
+ # @option options [Object] :unfurl_media
44
+ # Pass false to disable unfurling of media content.
45
+ # @option options [Object] :icon_url
46
+ # URL to an image to use as the icon for this message.
47
+ # @option options [Object] :icon_emoji
48
+ # emoji to use as the icon for this message. Overrides icon_url.
49
+ # @see https://api.slack.com/methods/chat.postMessage
50
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/chat.postMessage.json
51
+ def chat_postMessage(options = {})
52
+ throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
53
+ throw ArgumentError.new('Required arguments :text or :attachments missing') if options[:text].nil? && options[:attachments].nil?
54
+ # attachments must be passed as an encoded JSON string
55
+ if options.key?(:attachments)
56
+ attachments = options[:attachments]
57
+ attachments = JSON.dump(attachments) unless attachments.is_a?(String)
58
+ options = options.merge(attachments: attachments)
59
+ end
60
+ post('chat.postMessage', options)
61
+ end
62
+
63
+ #
64
+ # This method updates a message in a channel.
65
+ #
66
+ # @option options [timestamp] :ts
67
+ # Timestamp of the message to be updated.
68
+ # @option options [channel] :channel
69
+ # Channel containing the message to be updated.
70
+ # @option options [Object] :text
71
+ # New text for the message, using the default formatting rules.
72
+ # @option options [Object] :attachments
73
+ # Structured message attachments.
74
+ # @option options [Object] :parse
75
+ # Change how messages are treated. See below.
76
+ # @option options [Object] :link_names
77
+ # Find and link channel names and usernames.
78
+ # @see https://api.slack.com/methods/chat.update
79
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/chat.update.json
80
+ def chat_update(options = {})
81
+ throw ArgumentError.new('Required arguments :ts missing') if options[:ts].nil?
82
+ throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
83
+ throw ArgumentError.new('Required arguments :text missing') if options[:text].nil?
84
+ options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
85
+ post('chat.update', options)
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,64 @@
1
+ # This file was auto-generated by lib/slack/web/api/tasks/generate.rake
2
+
3
+ module Slack
4
+ module Web
5
+ module Api
6
+ module Endpoints
7
+ module Dnd
8
+ #
9
+ # Ends the user's currently scheduled Do Not Disturb session immediately.
10
+ #
11
+ # @see https://api.slack.com/methods/dnd.endDnd
12
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/dnd.endDnd.json
13
+ def dnd_endDnd(options = {})
14
+ post('dnd.endDnd', options)
15
+ end
16
+
17
+ #
18
+ # Ends the current user's snooze mode immediately.
19
+ #
20
+ # @see https://api.slack.com/methods/dnd.endSnooze
21
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/dnd.endSnooze.json
22
+ def dnd_endSnooze(options = {})
23
+ post('dnd.endSnooze', options)
24
+ end
25
+
26
+ #
27
+ # Provides information about a user's current Do Not Disturb settings.
28
+ #
29
+ # @option options [user] :user
30
+ # User to fetch status for (defaults to current user).
31
+ # @see https://api.slack.com/methods/dnd.info
32
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/dnd.info.json
33
+ def dnd_info(options = {})
34
+ options = options.merge(user: users_id(options)['user']['id']) if options[:user]
35
+ post('dnd.info', options)
36
+ end
37
+
38
+ #
39
+ # Adjusts the snooze duration for a user's Do Not Disturb settings. If a snooze session is not already active for the user, invoking this method will begin one for the specified duration.
40
+ #
41
+ # @option options [Object] :num_minutes
42
+ # Number of minutes, from now, to snooze until.
43
+ # @see https://api.slack.com/methods/dnd.setSnooze
44
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/dnd.setSnooze.json
45
+ def dnd_setSnooze(options = {})
46
+ throw ArgumentError.new('Required arguments :num_minutes missing') if options[:num_minutes].nil?
47
+ post('dnd.setSnooze', options)
48
+ end
49
+
50
+ #
51
+ # Provides information about the current Do Not Disturb settings for users of a Slack team.
52
+ #
53
+ # @option options [Object] :users
54
+ # Comma-separated list of users to fetch Do Not Disturb status for.
55
+ # @see https://api.slack.com/methods/dnd.teamInfo
56
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/dnd.teamInfo.json
57
+ def dnd_teamInfo(options = {})
58
+ post('dnd.teamInfo', options)
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end