slack-web-api 0.0.1

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 (45) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.gitmodules +3 -0
  4. data/.rspec +2 -0
  5. data/.travis.yml +6 -0
  6. data/Gemfile +4 -0
  7. data/Guardfile +13 -0
  8. data/LICENSE.txt +22 -0
  9. data/README.md +33 -0
  10. data/Rakefile +13 -0
  11. data/examples/basic.rb +35 -0
  12. data/lib/faraday/raise_http_exception.rb +51 -0
  13. data/lib/slack.rb +27 -0
  14. data/lib/slack/api.rb +24 -0
  15. data/lib/slack/client.rb +4 -0
  16. data/lib/slack/configuration.rb +76 -0
  17. data/lib/slack/connection.rb +29 -0
  18. data/lib/slack/endpoint.rb +43 -0
  19. data/lib/slack/endpoint/api.rb +23 -0
  20. data/lib/slack/endpoint/auth.rb +19 -0
  21. data/lib/slack/endpoint/channels.rb +236 -0
  22. data/lib/slack/endpoint/chat.rb +86 -0
  23. data/lib/slack/endpoint/emoji.rb +19 -0
  24. data/lib/slack/endpoint/files.rb +100 -0
  25. data/lib/slack/endpoint/groups.rb +262 -0
  26. data/lib/slack/endpoint/im.rb +90 -0
  27. data/lib/slack/endpoint/mpim.rb +90 -0
  28. data/lib/slack/endpoint/oauth.rb +31 -0
  29. data/lib/slack/endpoint/pins.rb +64 -0
  30. data/lib/slack/endpoint/presence.rb +22 -0
  31. data/lib/slack/endpoint/reactions.rb +94 -0
  32. data/lib/slack/endpoint/search.rb +80 -0
  33. data/lib/slack/endpoint/stars.rb +65 -0
  34. data/lib/slack/endpoint/team.rb +57 -0
  35. data/lib/slack/endpoint/usergroups.rb +122 -0
  36. data/lib/slack/endpoint/users.rb +78 -0
  37. data/lib/slack/error.rb +19 -0
  38. data/lib/slack/request.rb +41 -0
  39. data/lib/slack/version.rb +3 -0
  40. data/slack.gemspec +38 -0
  41. data/spec/api_spec.rb +23 -0
  42. data/spec/auth_spec.rb +22 -0
  43. data/spec/channels_spec.rb +247 -0
  44. data/spec/spec_helper.rb +86 -0
  45. metadata +313 -0
@@ -0,0 +1,19 @@
1
+ # This file was auto-generated by lib/generators/tasks/generate.rb
2
+
3
+ module Slack
4
+ module Endpoint
5
+ module Auth
6
+ #
7
+ # This method checks authentication and tells you who you are.
8
+ #
9
+ # @see https://api.slack.com/methods/auth.test
10
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/auth.test.md
11
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/auth.test.json
12
+ def auth_test(options={})
13
+ options[:attachments] = options[:attachments].to_json if Hash === options[:attachments]
14
+ post("auth.test", options)
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,236 @@
1
+ # This file was auto-generated by lib/generators/tasks/generate.rb
2
+
3
+ module Slack
4
+ module Endpoint
5
+ module Channels
6
+ #
7
+ # This method archives a channel.
8
+ #
9
+ # @option options [Object] :channel
10
+ # Channel to archive
11
+ # @see https://api.slack.com/methods/channels.archive
12
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/channels.archive.md
13
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/channels.archive.json
14
+ def channels_archive(options={})
15
+ throw ArgumentError.new("Required arguments :channel missing") if options[:channel].nil?
16
+ options[:attachments] = options[:attachments].to_json if Hash === options[:attachments]
17
+ post("channels.archive", options)
18
+ end
19
+
20
+ #
21
+ # This method is used to create a channel.
22
+ #
23
+ # @option options [Object] :name
24
+ # Name of channel to create
25
+ # @see https://api.slack.com/methods/channels.create
26
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/channels.create.md
27
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/channels.create.json
28
+ def channels_create(options={})
29
+ throw ArgumentError.new("Required arguments :name missing") if options[:name].nil?
30
+ options[:attachments] = options[:attachments].to_json if Hash === options[:attachments]
31
+ post("channels.create", options)
32
+ end
33
+
34
+ #
35
+ # This method returns a portion of messages/events from the specified channel.
36
+ # To read the entire history for a channel, call the method with no latest or
37
+ # oldest arguments, and then continue paging using the instructions below.
38
+ #
39
+ # @option options [Object] :channel
40
+ # Channel to fetch history for.
41
+ # @option options [Object] :latest
42
+ # End of time range of messages to include in results.
43
+ # @option options [Object] :oldest
44
+ # Start of time range of messages to include in results.
45
+ # @option options [Object] :inclusive
46
+ # Include messages with latest or oldest timestamp in results.
47
+ # @option options [Object] :count
48
+ # Number of messages to return, between 1 and 1000.
49
+ # @option options [Object] :unreads
50
+ # Include unread_count_display in the output?
51
+ # @see https://api.slack.com/methods/channels.history
52
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/channels.history.md
53
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/channels.history.json
54
+ def channels_history(options={})
55
+ throw ArgumentError.new("Required arguments :channel missing") if options[:channel].nil?
56
+ options[:attachments] = options[:attachments].to_json if Hash === options[:attachments]
57
+ post("channels.history", options)
58
+ end
59
+
60
+ #
61
+ # This method returns information about a team channel.
62
+ #
63
+ # @option options [Object] :channel
64
+ # Channel to get info on
65
+ # @see https://api.slack.com/methods/channels.info
66
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/channels.info.md
67
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/channels.info.json
68
+ def channels_info(options={})
69
+ throw ArgumentError.new("Required arguments :channel missing") if options[:channel].nil?
70
+ options[:attachments] = options[:attachments].to_json if Hash === options[:attachments]
71
+ post("channels.info", options)
72
+ end
73
+
74
+ #
75
+ # This method is used to invite a user to a channel. The calling user must be a member of the channel.
76
+ #
77
+ # @option options [Object] :channel
78
+ # Channel to invite user to.
79
+ # @option options [Object] :user
80
+ # User to invite to channel.
81
+ # @see https://api.slack.com/methods/channels.invite
82
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/channels.invite.md
83
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/channels.invite.json
84
+ def channels_invite(options={})
85
+ throw ArgumentError.new("Required arguments :channel missing") if options[:channel].nil?
86
+ throw ArgumentError.new("Required arguments :user missing") if options[:user].nil?
87
+ options[:attachments] = options[:attachments].to_json if Hash === options[:attachments]
88
+ post("channels.invite", options)
89
+ end
90
+
91
+ #
92
+ # This method is used to join a channel. If the channel does not exist, it is
93
+ # created.
94
+ #
95
+ # @option options [Object] :name
96
+ # Name of channel to join
97
+ # @see https://api.slack.com/methods/channels.join
98
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/channels.join.md
99
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/channels.join.json
100
+ def channels_join(options={})
101
+ throw ArgumentError.new("Required arguments :name missing") if options[:name].nil?
102
+ options[:attachments] = options[:attachments].to_json if Hash === options[:attachments]
103
+ post("channels.join", options)
104
+ end
105
+
106
+ #
107
+ # This method allows a user to remove another member from a team channel.
108
+ #
109
+ # @option options [Object] :channel
110
+ # Channel to remove user from.
111
+ # @option options [Object] :user
112
+ # User to remove from channel.
113
+ # @see https://api.slack.com/methods/channels.kick
114
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/channels.kick.md
115
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/channels.kick.json
116
+ def channels_kick(options={})
117
+ throw ArgumentError.new("Required arguments :channel missing") if options[:channel].nil?
118
+ throw ArgumentError.new("Required arguments :user missing") if options[:user].nil?
119
+ options[:attachments] = options[:attachments].to_json if Hash === options[:attachments]
120
+ post("channels.kick", options)
121
+ end
122
+
123
+ #
124
+ # This method is used to leave a channel.
125
+ #
126
+ # @option options [Object] :channel
127
+ # Channel to leave
128
+ # @see https://api.slack.com/methods/channels.leave
129
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/channels.leave.md
130
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/channels.leave.json
131
+ def channels_leave(options={})
132
+ throw ArgumentError.new("Required arguments :channel missing") if options[:channel].nil?
133
+ options[:attachments] = options[:attachments].to_json if Hash === options[:attachments]
134
+ post("channels.leave", options)
135
+ end
136
+
137
+ #
138
+ # This method returns a list of all channels in the team. This includes channels the caller is in, channels
139
+ # they are not currently in, and archived channels. The number of (non-deactivated) members in each channel
140
+ # is also returned.
141
+ #
142
+ # @option options [Object] :exclude_archived
143
+ # Don't return archived channels.
144
+ # @see https://api.slack.com/methods/channels.list
145
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/channels.list.md
146
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/channels.list.json
147
+ def channels_list(options={})
148
+ options[:attachments] = options[:attachments].to_json if Hash === options[:attachments]
149
+ post("channels.list", options)
150
+ end
151
+
152
+ #
153
+ # This method moves the read cursor in a channel.
154
+ #
155
+ # @option options [Object] :channel
156
+ # Channel to set reading cursor in.
157
+ # @option options [Object] :ts
158
+ # Timestamp of the most recently seen message.
159
+ # @see https://api.slack.com/methods/channels.mark
160
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/channels.mark.md
161
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/channels.mark.json
162
+ def channels_mark(options={})
163
+ throw ArgumentError.new("Required arguments :channel missing") if options[:channel].nil?
164
+ throw ArgumentError.new("Required arguments :ts missing") if options[:ts].nil?
165
+ options[:attachments] = options[:attachments].to_json if Hash === options[:attachments]
166
+ post("channels.mark", options)
167
+ end
168
+
169
+ #
170
+ # This method renames a team channel.
171
+ #
172
+ # @option options [Object] :channel
173
+ # Channel to rename
174
+ # @option options [Object] :name
175
+ # New name for channel.
176
+ # @see https://api.slack.com/methods/channels.rename
177
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/channels.rename.md
178
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/channels.rename.json
179
+ def channels_rename(options={})
180
+ throw ArgumentError.new("Required arguments :channel missing") if options[:channel].nil?
181
+ throw ArgumentError.new("Required arguments :name missing") if options[:name].nil?
182
+ options[:attachments] = options[:attachments].to_json if Hash === options[:attachments]
183
+ post("channels.rename", options)
184
+ end
185
+
186
+ #
187
+ # This method is used to change the purpose of a channel. The calling user must be a member of the channel.
188
+ #
189
+ # @option options [Object] :channel
190
+ # Channel to set the purpose of
191
+ # @option options [Object] :purpose
192
+ # The new purpose
193
+ # @see https://api.slack.com/methods/channels.setPurpose
194
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/channels.setPurpose.md
195
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/channels.setPurpose.json
196
+ def channels_setPurpose(options={})
197
+ throw ArgumentError.new("Required arguments :channel missing") if options[:channel].nil?
198
+ throw ArgumentError.new("Required arguments :purpose missing") if options[:purpose].nil?
199
+ options[:attachments] = options[:attachments].to_json if Hash === options[:attachments]
200
+ post("channels.setPurpose", options)
201
+ end
202
+
203
+ #
204
+ # This method is used to change the topic of a channel. The calling user must be a member of the channel.
205
+ #
206
+ # @option options [Object] :channel
207
+ # Channel to set the topic of
208
+ # @option options [Object] :topic
209
+ # The new topic
210
+ # @see https://api.slack.com/methods/channels.setTopic
211
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/channels.setTopic.md
212
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/channels.setTopic.json
213
+ def channels_setTopic(options={})
214
+ throw ArgumentError.new("Required arguments :channel missing") if options[:channel].nil?
215
+ throw ArgumentError.new("Required arguments :topic missing") if options[:topic].nil?
216
+ options[:attachments] = options[:attachments].to_json if Hash === options[:attachments]
217
+ post("channels.setTopic", options)
218
+ end
219
+
220
+ #
221
+ # This method unarchives a channel. The calling user is added to the channel.
222
+ #
223
+ # @option options [Object] :channel
224
+ # Channel to unarchive
225
+ # @see https://api.slack.com/methods/channels.unarchive
226
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/channels.unarchive.md
227
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/channels.unarchive.json
228
+ def channels_unarchive(options={})
229
+ throw ArgumentError.new("Required arguments :channel missing") if options[:channel].nil?
230
+ options[:attachments] = options[:attachments].to_json if Hash === options[:attachments]
231
+ post("channels.unarchive", options)
232
+ end
233
+
234
+ end
235
+ end
236
+ end
@@ -0,0 +1,86 @@
1
+ # This file was auto-generated by lib/generators/tasks/generate.rb
2
+
3
+ module Slack
4
+ module Endpoint
5
+ module Chat
6
+ #
7
+ # This method deletes a message from a channel.
8
+ #
9
+ # @option options [Object] :ts
10
+ # Timestamp of the message to be deleted.
11
+ # @option options [Object] :channel
12
+ # Channel containing the message to be deleted.
13
+ # @see https://api.slack.com/methods/chat.delete
14
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/chat.delete.md
15
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/chat.delete.json
16
+ def chat_delete(options={})
17
+ throw ArgumentError.new("Required arguments :ts missing") if options[:ts].nil?
18
+ throw ArgumentError.new("Required arguments :channel missing") if options[:channel].nil?
19
+ options[:attachments] = options[:attachments].to_json if Hash === options[:attachments]
20
+ post("chat.delete", options)
21
+ end
22
+
23
+ #
24
+ # This method posts a message to a public channel, private group, or IM channel.
25
+ #
26
+ # @option options [Object] :channel
27
+ # Channel, private group, or IM channel to send message to. Can be an encoded ID, or a name. See below for more details.
28
+ # @option options [Object] :text
29
+ # Text of the message to send. See below for an explanation of formatting.
30
+ # @option options [Object] :username
31
+ # Name of bot.
32
+ # @option options [Object] :as_user
33
+ # Pass true to post the message as the authed user, instead of as a bot
34
+ # @option options [Object] :parse
35
+ # Change how messages are treated. See below.
36
+ # @option options [Object] :link_names
37
+ # Find and link channel names and usernames.
38
+ # @option options [Object] :attachments
39
+ # Structured message attachments.
40
+ # @option options [Object] :unfurl_links
41
+ # Pass true to enable unfurling of primarily text-based content.
42
+ # @option options [Object] :unfurl_media
43
+ # Pass false to disable unfurling of media content.
44
+ # @option options [Object] :icon_url
45
+ # URL to an image to use as the icon for this message
46
+ # @option options [Object] :icon_emoji
47
+ # emoji to use as the icon for this message. Overrides icon_url.
48
+ # @see https://api.slack.com/methods/chat.postMessage
49
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/chat.postMessage.md
50
+ # @see https://github.com/aki017/slack-api-docs/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 missing") if options[:text].nil?
54
+ options[:attachments] = options[:attachments].to_json if Hash === options[:attachments]
55
+ post("chat.postMessage", options)
56
+ end
57
+
58
+ #
59
+ # This method updates a message in a channel.
60
+ #
61
+ # @option options [Object] :ts
62
+ # Timestamp of the message to be updated.
63
+ # @option options [Object] :channel
64
+ # Channel containing the message to be updated.
65
+ # @option options [Object] :text
66
+ # New text for the message, using the default formatting rules.
67
+ # @option options [Object] :attachments
68
+ # Structured message attachments.
69
+ # @option options [Object] :parse
70
+ # Change how messages are treated. See below.
71
+ # @option options [Object] :link_names
72
+ # Find and link channel names and usernames.
73
+ # @see https://api.slack.com/methods/chat.update
74
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/chat.update.md
75
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/chat.update.json
76
+ def chat_update(options={})
77
+ throw ArgumentError.new("Required arguments :ts missing") if options[:ts].nil?
78
+ throw ArgumentError.new("Required arguments :channel missing") if options[:channel].nil?
79
+ throw ArgumentError.new("Required arguments :text missing") if options[:text].nil?
80
+ options[:attachments] = options[:attachments].to_json if Hash === options[:attachments]
81
+ post("chat.update", options)
82
+ end
83
+
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,19 @@
1
+ # This file was auto-generated by lib/generators/tasks/generate.rb
2
+
3
+ module Slack
4
+ module Endpoint
5
+ module Emoji
6
+ #
7
+ # This method lists the custom emoji for a team.
8
+ #
9
+ # @see https://api.slack.com/methods/emoji.list
10
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/emoji.list.md
11
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/emoji.list.json
12
+ def emoji_list(options={})
13
+ options[:attachments] = options[:attachments].to_json if Hash === options[:attachments]
14
+ post("emoji.list", options)
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,100 @@
1
+ # This file was auto-generated by lib/generators/tasks/generate.rb
2
+
3
+ module Slack
4
+ module Endpoint
5
+ module Files
6
+ #
7
+ # This method deletes a file from your team.
8
+ #
9
+ # @option options [Object] :file
10
+ # ID of file to delete.
11
+ # @see https://api.slack.com/methods/files.delete
12
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/files.delete.md
13
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/files.delete.json
14
+ def files_delete(options={})
15
+ throw ArgumentError.new("Required arguments :file missing") if options[:file].nil?
16
+ options[:attachments] = options[:attachments].to_json if Hash === options[:attachments]
17
+ post("files.delete", options)
18
+ end
19
+
20
+ #
21
+ # This method returns information about a file in your team.
22
+ #
23
+ # @option options [Object] :file
24
+ # File to fetch info for
25
+ # @option options [Object] :count
26
+ # Number of items to return per page.
27
+ # @option options [Object] :page
28
+ # Page number of results to return.
29
+ # @see https://api.slack.com/methods/files.info
30
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/files.info.md
31
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/files.info.json
32
+ def files_info(options={})
33
+ throw ArgumentError.new("Required arguments :file missing") if options[:file].nil?
34
+ options[:attachments] = options[:attachments].to_json if Hash === options[:attachments]
35
+ post("files.info", options)
36
+ end
37
+
38
+ #
39
+ # This method returns a list of files within the team. It can be filtered and sliced in various ways.
40
+ #
41
+ # @option options [Object] :user
42
+ # Filter files created by a single user.
43
+ # @option options [Object] :ts_from
44
+ # Filter files created after this timestamp (inclusive).
45
+ # @option options [Object] :ts_to
46
+ # Filter files created before this timestamp (inclusive).
47
+ # @option options [Object] :types
48
+ # Filter files by type:
49
+ #
50
+ #
51
+ # all - All files
52
+ # posts - Posts
53
+ # snippets - Snippets
54
+ # images - Image files
55
+ # gdocs - Google docs
56
+ # zips - Zip files
57
+ # pdfs - PDF files
58
+ #
59
+ #
60
+ # You can pass multiple values in the types argument, like types=posts,snippets.The default value is all, which does not filter the list.
61
+ # @option options [Object] :count
62
+ # Number of items to return per page.
63
+ # @option options [Object] :page
64
+ # Page number of results to return.
65
+ # @see https://api.slack.com/methods/files.list
66
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/files.list.md
67
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/files.list.json
68
+ def files_list(options={})
69
+ options[:attachments] = options[:attachments].to_json if Hash === options[:attachments]
70
+ post("files.list", options)
71
+ end
72
+
73
+ #
74
+ # This method allows you to create or upload an existing file.
75
+ #
76
+ # @option options [Object] :file
77
+ # File contents via multipart/form-data.
78
+ # @option options [Object] :content
79
+ # File contents via a POST var.
80
+ # @option options [Object] :filetype
81
+ # Slack-internal file type identifier.
82
+ # @option options [Object] :filename
83
+ # Filename of file.
84
+ # @option options [Object] :title
85
+ # Title of file.
86
+ # @option options [Object] :initial_comment
87
+ # Initial comment to add to file.
88
+ # @option options [Object] :channels
89
+ # Comma separated list of channels to share the file into.
90
+ # @see https://api.slack.com/methods/files.upload
91
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/files.upload.md
92
+ # @see https://github.com/aki017/slack-api-docs/blob/master/methods/files.upload.json
93
+ def files_upload(options={})
94
+ options[:attachments] = options[:attachments].to_json if Hash === options[:attachments]
95
+ post("files.upload", options)
96
+ end
97
+
98
+ end
99
+ end
100
+ end