slack-api-wrapper 0.0.2 → 0.0.5
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.
- checksums.yaml +4 -4
- data/.gitignore +8 -0
- data/lib/slack-api-wrapper.rb +3 -5
- data/lib/slack/client.rb +2 -2
- data/lib/slack/oauth2/flow.rb +2 -2
- data/lib/slack/version.rb +1 -1
- data/lib/slack/web.rb +2 -1
- data/lib/slack/web/api.rb +14 -0
- data/lib/slack/web/auth.rb +2 -2
- data/lib/slack/web/channels.rb +57 -28
- data/lib/slack/web/chat.rb +13 -24
- data/lib/slack/web/emoji.rb +2 -2
- data/lib/slack/web/files.rb +10 -30
- data/lib/slack/web/groups.rb +60 -30
- data/lib/slack/web/im.rb +19 -10
- data/lib/slack/web/search.rb +12 -6
- data/lib/slack/web/stars.rb +4 -3
- data/lib/slack/web/team.rb +14 -0
- data/lib/slack/web/users.rb +13 -10
- data/slack-api-wrapper.gemspec +1 -1
- data/spec/slack/client_spec.rb +1 -4
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82f17a8e6d648e7e04b4e738de427049fb6c80c0
|
4
|
+
data.tar.gz: 13a7ebe3f6728d354dad95647164ad92456b135c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1130982045e83c3cd01862e94bd4b79b5535f0c6691de714407e4b5002b83a853b67a2044360059e938e63d64d72ef5fe31dcce5cd94b4e3b77b44e3830b22bc
|
7
|
+
data.tar.gz: d6d2f26145bae90283bb9c96dffbc9f22949362f1e49ddd6e3ade5e149290510fa26449ecb7cab48fbdf8b22537afc3eac8c3ecb452b39320a866b89ab710ac3
|
data/.gitignore
CHANGED
data/lib/slack-api-wrapper.rb
CHANGED
@@ -49,7 +49,7 @@ module Slack # :nodoc:
|
|
49
49
|
# and parses them. It also checks for errors and raises exceptions with the appropriate messages.
|
50
50
|
def self.parse_response(response, raw=false) # :nodoc:
|
51
51
|
if response.kind_of?(Net::HTTPServerError)
|
52
|
-
raise
|
52
|
+
raise SlackError.new("Slack Server Error: #{response} - #{response.body}", response)
|
53
53
|
elsif response.kind_of?(Net::HTTPUnauthorized)
|
54
54
|
raise SlackAuthError.new("User is not authenticated.", response)
|
55
55
|
elsif !response.kind_of?(Net::HTTPSuccess)
|
@@ -58,10 +58,8 @@ module Slack # :nodoc:
|
|
58
58
|
rescue
|
59
59
|
raise SlackError.new("Slack Server Error: body=#{response.body}", response)
|
60
60
|
end
|
61
|
-
|
62
|
-
raise SlackError.new(d['
|
63
|
-
else
|
64
|
-
raise SlackError.new(response.body, response)
|
61
|
+
unless d['ok'] == true
|
62
|
+
raise SlackError.new(d['ok'], response)
|
65
63
|
end
|
66
64
|
end
|
67
65
|
|
data/lib/slack/client.rb
CHANGED
@@ -3,12 +3,12 @@ require_relative 'web'
|
|
3
3
|
|
4
4
|
module Slack
|
5
5
|
# Use this class to make Slack API calls. You'll need to obtain an OAuth 2 access token
|
6
|
-
# first; you can get one using
|
6
|
+
# first; you can get one using SlackOAuth2Flow.
|
7
7
|
class Client
|
8
8
|
include Web
|
9
9
|
|
10
10
|
# Args:
|
11
|
-
# * +oauth2_access_token+: Obtained via Slack::OAuth2::Flow
|
11
|
+
# * +oauth2_access_token+: Obtained via Slack::OAuth2::Flow.
|
12
12
|
def initialize(oauth2_access_token)
|
13
13
|
if oauth2_access_token.is_a?(String)
|
14
14
|
@session = OAuth2Session.new(oauth2_access_token)
|
data/lib/slack/oauth2/flow.rb
CHANGED
@@ -80,11 +80,11 @@ module Slack
|
|
80
80
|
|
81
81
|
error = query_params['error']
|
82
82
|
|
83
|
-
unless
|
83
|
+
unless error.nil? || code.nil?
|
84
84
|
raise BadRequestError.new("Query parameters 'code' and 'error' are both set;" +
|
85
85
|
" only one must be set.")
|
86
86
|
end
|
87
|
-
if error.nil?
|
87
|
+
if error.nil? && code.nil?
|
88
88
|
raise BadRequestError.new("Neither query parameter 'code' or 'error' is set.")
|
89
89
|
end
|
90
90
|
|
data/lib/slack/version.rb
CHANGED
data/lib/slack/web.rb
CHANGED
@@ -7,6 +7,7 @@ require_relative 'web/groups'
|
|
7
7
|
require_relative 'web/im'
|
8
8
|
require_relative 'web/search'
|
9
9
|
require_relative 'web/stars'
|
10
|
+
require_relative 'web/team'
|
10
11
|
require_relative 'web/users'
|
11
12
|
require_relative 'error'
|
12
13
|
|
@@ -21,8 +22,8 @@ module Slack
|
|
21
22
|
include Im
|
22
23
|
include Stars
|
23
24
|
include Search
|
25
|
+
include Team
|
24
26
|
include Users
|
25
27
|
|
26
|
-
class NotImplementedError < Exception; end
|
27
28
|
end
|
28
29
|
end
|
data/lib/slack/web/auth.rb
CHANGED
data/lib/slack/web/channels.rb
CHANGED
@@ -4,77 +4,106 @@ module Slack
|
|
4
4
|
SCOPE = "channels"
|
5
5
|
|
6
6
|
# Archives a channel.
|
7
|
-
def channels_archive(
|
8
|
-
|
7
|
+
def channels_archive(params = {})
|
8
|
+
throw ArgumentError.new("Required arguments :channel missing") if params['channel'].nil?
|
9
|
+
response = @session.do_get "#{SCOPE}.archive", params
|
9
10
|
Slack::parse_response(response)
|
10
11
|
end
|
11
12
|
|
12
13
|
# Creates a channel.
|
13
|
-
def channels_create(
|
14
|
-
|
14
|
+
def channels_create(params = {})
|
15
|
+
throw ArgumentError.new("Required arguments :name missing") if params['name'].nil?
|
16
|
+
response = @session.do_get "#{SCOPE}.create", params
|
15
17
|
Slack::parse_response(response)
|
16
18
|
end
|
17
19
|
|
18
20
|
# Fetches history of messages and events from a channel.
|
19
|
-
def channels_history(
|
20
|
-
|
21
|
+
def channels_history(params={})
|
22
|
+
throw ArgumentError.new("Required arguments :channel missing") if params['channel'].nil?
|
23
|
+
response = @session.do_get "#{SCOPE}.history", params
|
24
|
+
Slack::parse_response(response)
|
21
25
|
end
|
22
26
|
|
23
27
|
# Gets information about a channel.
|
24
|
-
def channels_info(
|
25
|
-
|
28
|
+
def channels_info(params={})
|
29
|
+
throw ArgumentError.new("Required arguments :channel missing") if params['channel'].nil?
|
30
|
+
response = @session.do_get "#{SCOPE}.info", params
|
26
31
|
Slack::parse_response(response)
|
27
32
|
end
|
28
33
|
|
29
34
|
# Invites a user to a channel.
|
30
|
-
def channels_invite(
|
31
|
-
|
35
|
+
def channels_invite(params={})
|
36
|
+
throw ArgumentError.new("Required arguments :channel missing") if params['channel'].nil?
|
37
|
+
throw ArgumentError.new("Required arguments :user missing") if params['user'].nil?
|
38
|
+
response = @session.do_get "#{SCOPE}.invite", params
|
39
|
+
Slack::parse_response(response)
|
32
40
|
end
|
33
41
|
|
34
42
|
# Joins a channel, creating it if needed.
|
35
|
-
def channels_join(
|
36
|
-
|
43
|
+
def channels_join(params={})
|
44
|
+
throw ArgumentError.new("Required arguments :name missing") if params['name'].nil?
|
45
|
+
response = @session.do_get "#{SCOPE}.join", params
|
46
|
+
Slack::parse_response(response)
|
37
47
|
end
|
38
48
|
|
39
49
|
# Removes a user from a channel.
|
40
|
-
def channels_kick(
|
41
|
-
|
50
|
+
def channels_kick(params={})
|
51
|
+
throw ArgumentError.new("Required arguments :channel missing") if params['channel'].nil?
|
52
|
+
throw ArgumentError.new("Required arguments :user missing") if params['user'].nil?
|
53
|
+
response = @session.do_get "#{SCOPE}.kick", params
|
54
|
+
Slack::parse_response(response)
|
42
55
|
end
|
43
56
|
|
44
57
|
# Leaves a channel.
|
45
|
-
def channels_leave(
|
46
|
-
|
58
|
+
def channels_leave(params={})
|
59
|
+
throw ArgumentError.new("Required arguments :channel missing") if params['channel'].nil?
|
60
|
+
response = @session.do_get "#{SCOPE}.leave", params
|
61
|
+
Slack::parse_response(response)
|
47
62
|
end
|
48
63
|
|
49
64
|
# Lists all channels in a Slack team.
|
50
|
-
def channels_list(
|
51
|
-
response = @session.do_get "#{SCOPE}.list",
|
65
|
+
def channels_list(params={})
|
66
|
+
response = @session.do_get "#{SCOPE}.list", params
|
52
67
|
Slack::parse_response(response)
|
53
68
|
end
|
54
69
|
|
55
70
|
# Sets the read cursor in a channel.
|
56
|
-
def channels_mark(
|
57
|
-
|
71
|
+
def channels_mark(params={})
|
72
|
+
throw ArgumentError.new("Required arguments :channel missing") if params['channel'].nil?
|
73
|
+
throw ArgumentError.new("Required arguments :ts missing") if params['ts'].nil?
|
74
|
+
response = @session.do_get "#{SCOPE}.mark", params
|
75
|
+
Slack::parse_response(response)
|
58
76
|
end
|
59
77
|
|
60
78
|
# Renames a channel.
|
61
|
-
def channels_rename(
|
62
|
-
|
79
|
+
def channels_rename(params={})
|
80
|
+
throw ArgumentError.new("Required arguments :channel missing") if params['channel'].nil?
|
81
|
+
throw ArgumentError.new("Required arguments :name missing") if params['name'].nil?
|
82
|
+
response = @session.do_get "#{SCOPE}.rename", params
|
83
|
+
Slack::parse_response(response)
|
63
84
|
end
|
64
85
|
|
65
86
|
# Sets the purpose for a channel.
|
66
|
-
def channels_set_purpose(
|
67
|
-
|
87
|
+
def channels_set_purpose(params={})
|
88
|
+
throw ArgumentError.new("Required arguments :channel missing") if params['channel'].nil?
|
89
|
+
throw ArgumentError.new("Required arguments :purpose missing") if params['purpose'].nil?
|
90
|
+
response = @session.do_get "#{SCOPE}.setPurpose", params
|
91
|
+
Slack::parse_response(response)
|
68
92
|
end
|
69
93
|
|
70
94
|
# Sets the topic for a channel.
|
71
|
-
def channels_set_topic(
|
72
|
-
|
95
|
+
def channels_set_topic(params={})
|
96
|
+
throw ArgumentError.new("Required arguments :channel missing") if params['channel'].nil?
|
97
|
+
throw ArgumentError.new("Required arguments :topic missing") if params['topic'].nil?
|
98
|
+
response = @session.do_get "#{SCOPE}.setTopic", params
|
99
|
+
Slack::parse_response(response)
|
73
100
|
end
|
74
101
|
|
75
102
|
# Unarchives a channel.
|
76
|
-
def channels_unarchive(
|
77
|
-
|
103
|
+
def channels_unarchive(params={})
|
104
|
+
throw ArgumentError.new("Required arguments :channel missing") if params['channel'].nil?
|
105
|
+
response = @session.do_get "#{SCOPE}.unarchive", params
|
106
|
+
Slack::parse_response(response)
|
78
107
|
end
|
79
108
|
|
80
109
|
end
|
data/lib/slack/web/chat.rb
CHANGED
@@ -4,38 +4,27 @@ module Slack
|
|
4
4
|
SCOPE = "chat"
|
5
5
|
|
6
6
|
# Deletes a message.
|
7
|
-
def chat_delete(
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
}
|
12
|
-
response = @session.do_get "#{SCOPE}.delete", param
|
7
|
+
def chat_delete(params = {})
|
8
|
+
throw ArgumentError.new("Required arguments :ts missing") if params['ts'].nil?
|
9
|
+
throw ArgumentError.new("Required arguments :channel missing") if params['channel'].nil?
|
10
|
+
response = @session.do_get "#{SCOPE}.delete", params
|
13
11
|
Slack::parse_response(response)
|
14
12
|
end
|
15
13
|
|
16
14
|
# Sends a message to a channel.
|
17
|
-
def chat_post_message(
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
"username" => username,
|
22
|
-
"as_user" => as_user,
|
23
|
-
"parse" => parse,
|
24
|
-
"link_names" => link_names,
|
25
|
-
"attachments" => attachments
|
26
|
-
}
|
27
|
-
response = @session.do_get "#{SCOPE}.postMessage", param
|
15
|
+
def chat_post_message(params = {})
|
16
|
+
throw ArgumentError.new("Required arguments :channel missing") if params['channel'].nil?
|
17
|
+
throw ArgumentError.new("Required arguments :text missing") if params['text'].nil?
|
18
|
+
response = @session.do_get "#{SCOPE}.postMessage", params
|
28
19
|
Slack::parse_response(response)
|
29
20
|
end
|
30
21
|
|
31
22
|
# Updates a message.
|
32
|
-
def chat_update(
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
}
|
38
|
-
response = @session.do_get "#{SCOPE}.update", param
|
23
|
+
def chat_update(params = {})
|
24
|
+
throw ArgumentError.new("Required arguments :ts missing") if params['ts'].nil?
|
25
|
+
throw ArgumentError.new("Required arguments :channel missing") if params['channel'].nil?
|
26
|
+
throw ArgumentError.new("Required arguments :text missing") if params['text'].nil?
|
27
|
+
response = @session.do_get "#{SCOPE}.update", params
|
39
28
|
Slack::parse_response(response)
|
40
29
|
end
|
41
30
|
|
data/lib/slack/web/emoji.rb
CHANGED
data/lib/slack/web/files.rb
CHANGED
@@ -4,48 +4,28 @@ module Slack
|
|
4
4
|
SCOPE = "files"
|
5
5
|
|
6
6
|
#Deletes a file.
|
7
|
-
def files_delete(
|
8
|
-
|
7
|
+
def files_delete(params={})
|
8
|
+
throw ArgumentError.new("Required arguments :file missing") if params['file'].nil?
|
9
|
+
response = @session.do_get "#{SCOPE}.delete", params
|
9
10
|
Slack::parse_response(response)
|
10
11
|
end
|
11
12
|
|
12
13
|
# Gets information about a team file.
|
13
|
-
def files_info(
|
14
|
-
|
15
|
-
|
16
|
-
"count" => count,
|
17
|
-
"page" => page
|
18
|
-
}
|
19
|
-
response = @session.do_get "#{SCOPE}.info", param
|
14
|
+
def files_info(params={})
|
15
|
+
throw ArgumentError.new("Required arguments :file missing") if params['file'].nil
|
16
|
+
response = @session.do_get "#{SCOPE}.info", params
|
20
17
|
Slack::parse_response(response)
|
21
18
|
end
|
22
19
|
|
23
20
|
# Lists & filters team files.
|
24
|
-
def files_list(
|
25
|
-
|
26
|
-
"user" => user,
|
27
|
-
"ts_from" => ts_from,
|
28
|
-
"ts_to" => ts_to,
|
29
|
-
"types" => types,
|
30
|
-
"count" => count,
|
31
|
-
"page" => page
|
32
|
-
}
|
33
|
-
response = @session.do_get "#{SCOPE}.list", param
|
21
|
+
def files_list(params={})
|
22
|
+
response = @session.do_get "#{SCOPE}.list", params
|
34
23
|
Slack::parse_response(response)
|
35
24
|
end
|
36
25
|
|
37
26
|
# Uploads or creates a file.
|
38
|
-
def files_upload(
|
39
|
-
|
40
|
-
"file" => file,
|
41
|
-
"content" => content,
|
42
|
-
"filetype" => filetype,
|
43
|
-
"filename" => filename,
|
44
|
-
"title" => title,
|
45
|
-
"initial_comment" => initial_comment,
|
46
|
-
"channels" => channels
|
47
|
-
}
|
48
|
-
response = @session.do_get "#{SCOPE}.upload", param
|
27
|
+
def files_upload(params={})
|
28
|
+
response = @session.do_get "#{SCOPE}.upload", params
|
49
29
|
Slack::parse_response(response)
|
50
30
|
end
|
51
31
|
end
|
data/lib/slack/web/groups.rb
CHANGED
@@ -4,83 +4,113 @@ module Slack
|
|
4
4
|
SCOPE = "groups"
|
5
5
|
|
6
6
|
# Archives a private group.
|
7
|
-
def groups_archive(
|
8
|
-
|
7
|
+
def groups_archive(params={})
|
8
|
+
throw ArgumentError.new("Required arguments :channel missing") if params['channel'].nil?
|
9
|
+
response = @session.do_get "#{SCOPE}.archive", params
|
9
10
|
Slack::parse_response(response)
|
10
11
|
end
|
11
12
|
|
12
13
|
# Closes a private group.
|
13
|
-
def groups_close(
|
14
|
-
|
14
|
+
def groups_close(params={})
|
15
|
+
throw ArgumentError.new("Required arguments :channel missing") if params['channel'].nil?
|
16
|
+
response = @session.do_get "#{SCOPE}.close", params
|
15
17
|
Slack::parse_response(response)
|
16
18
|
end
|
17
19
|
|
18
20
|
# Creates a private group.
|
19
|
-
def groups_create(
|
20
|
-
|
21
|
+
def groups_create(params={})
|
22
|
+
throw ArgumentError.new("Required arguments :name missing") if params['name'].nil?
|
23
|
+
response = @session.do_get "#{SCOPE}.create", params
|
21
24
|
Slack::parse_response(response)
|
22
25
|
end
|
23
26
|
|
24
27
|
# Clones and archives a private group.
|
25
|
-
def groups_create_child(
|
26
|
-
|
28
|
+
def groups_create_child(params={})
|
29
|
+
throw ArgumentError.new("Required arguments :channel missing") if params['channel'].nil?
|
30
|
+
response = @session.do_get "#{SCOPE}.createChild", params
|
27
31
|
Slack::parse_response(response)
|
28
32
|
end
|
29
33
|
|
30
34
|
# Fetches history of messages and events from a private group.
|
31
|
-
def groups_history(
|
32
|
-
|
35
|
+
def groups_history(params={})
|
36
|
+
throw ArgumentError.new("Required arguments :channel missing") if params['channel'].nil?
|
37
|
+
response = @session.do_get "#{SCOPE}.history", params
|
38
|
+
Slack::parse_response(response)
|
33
39
|
end
|
34
40
|
|
35
41
|
# Invites a user to a private group.
|
36
|
-
def groups_invite(
|
37
|
-
|
42
|
+
def groups_invite(params={})
|
43
|
+
throw ArgumentError.new("Required arguments :channel missing") if params['channel'].nil?
|
44
|
+
throw ArgumentError.new("Required arguments :user missing") if params['user'].nil?
|
45
|
+
response = @session.do_get "#{SCOPE}.invite", params
|
46
|
+
Slack::parse_response(response)
|
38
47
|
end
|
39
48
|
|
40
49
|
# Removes a user from a private group.
|
41
|
-
def groups_kick(
|
42
|
-
|
50
|
+
def groups_kick(params={})
|
51
|
+
throw ArgumentError.new("Required arguments :channel missing") if params['channel'].nil?
|
52
|
+
throw ArgumentError.new("Required arguments :user missing") if params['user'].nil?
|
53
|
+
response = @session.do_get "#{SCOPE}.kick", params
|
54
|
+
Slack::parse_response(response)
|
43
55
|
end
|
44
56
|
|
45
57
|
# Leaves a private group.
|
46
|
-
def groups_leave(
|
47
|
-
|
58
|
+
def groups_leave(params={})
|
59
|
+
throw ArgumentError.new("Required arguments :channel missing") if params['channel'].nil?
|
60
|
+
response = @session.do_get "#{SCOPE}.leave", params
|
61
|
+
Slack::parse_response(response)
|
48
62
|
end
|
49
63
|
|
50
64
|
# Lists private groups that the calling user has access to..
|
51
|
-
def groups_list(
|
52
|
-
response = @session.do_get "#{SCOPE}.list",
|
65
|
+
def groups_list(params={})
|
66
|
+
response = @session.do_get "#{SCOPE}.list", params
|
53
67
|
Slack::parse_response(response)
|
54
68
|
end
|
55
69
|
|
56
70
|
# Sets the read cursor in a private group.
|
57
|
-
def groups_mark(
|
58
|
-
|
71
|
+
def groups_mark(params={})
|
72
|
+
throw ArgumentError.new("Required arguments :channel missing") if params['channel'].nil?
|
73
|
+
throw ArgumentError.new("Required arguments :ts missing") if params['ts'].nil?
|
74
|
+
response = @session.do_get "#{SCOPE}.mark", params
|
75
|
+
Slack::parse_response(response)
|
59
76
|
end
|
60
77
|
|
61
78
|
# Opens a private group.
|
62
|
-
def groups_open(
|
63
|
-
|
79
|
+
def groups_open(params={})
|
80
|
+
throw ArgumentError.new("Required arguments :channel missing") if params['channel'].nil?
|
81
|
+
response = @session.do_get "#{SCOPE}.open", params
|
82
|
+
Slack::parse_response(response)
|
64
83
|
end
|
65
84
|
|
66
85
|
# Renames a private group.
|
67
|
-
def groups_rename(
|
68
|
-
|
86
|
+
def groups_rename(params={})
|
87
|
+
throw ArgumentError.new("Required arguments :channel missing") if params['channel'].nil?
|
88
|
+
throw ArgumentError.new("Required arguments :name missing") if params['name'].nil?
|
89
|
+
response = @session.do_get "#{SCOPE}.rename", params
|
90
|
+
Slack::parse_response(response)
|
69
91
|
end
|
70
92
|
|
71
93
|
# Sets the purpose for a private group.
|
72
|
-
def groups_set_purpose(
|
73
|
-
|
94
|
+
def groups_set_purpose(params={})
|
95
|
+
throw ArgumentError.new("Required arguments :channel missing") if params['channel'].nil?
|
96
|
+
throw ArgumentError.new("Required arguments :pupose missing") if params['purpos'].nil?
|
97
|
+
response = @session.do_get "#{SCOPE}.setPurpose", params
|
98
|
+
Slack::parse_response(response)
|
74
99
|
end
|
75
100
|
|
76
101
|
# Sets the topic for a private group.
|
77
|
-
def groups_set_topic(
|
78
|
-
|
102
|
+
def groups_set_topic(params={})
|
103
|
+
throw ArgumentError.new("Required arguments :channel missing") if params['channel'].nil?
|
104
|
+
throw ArgumentError.new("Required arguments :topic missing") if params['topic'].nil?
|
105
|
+
response = @session.do_get "#{SCOPE}.setTopic", params
|
106
|
+
Slack::parse_response(response)
|
79
107
|
end
|
80
108
|
|
81
109
|
# Unarchives a private group.
|
82
|
-
def groups_unarchive(
|
83
|
-
|
110
|
+
def groups_unarchive(params={})
|
111
|
+
throw ArgumentError.new("Required arguments :channel missing") if params['channel'].nil?
|
112
|
+
response = @session.do_get "#{SCOPE}.unarchive", params
|
113
|
+
Slack::parse_response(response)
|
84
114
|
end
|
85
115
|
|
86
116
|
end
|
data/lib/slack/web/im.rb
CHANGED
@@ -4,29 +4,38 @@ module Slack
|
|
4
4
|
SCOPE = "im"
|
5
5
|
|
6
6
|
# Close a direct message channel.
|
7
|
-
def im_close(
|
8
|
-
|
7
|
+
def im_close(params={})
|
8
|
+
throw ArgumentError.new("Required arguments :channel missing") if params['channel'].nil?
|
9
|
+
response = @session.do_get "#{SCOPE}.close", params
|
10
|
+
Slack::parse_response(response)
|
9
11
|
end
|
10
12
|
|
11
13
|
# Fetches history of messages and events from direct message channel.
|
12
|
-
def im_history(
|
13
|
-
|
14
|
+
def im_history(params={})
|
15
|
+
throw ArgumentError.new("Required arguments :channel missing") if params['channel'].nil?
|
16
|
+
response = @session.do_get "#{SCOPE}.history", params
|
17
|
+
Slack::parse_response(response)
|
14
18
|
end
|
15
19
|
|
16
20
|
# Lists direct message channels for the calling user.
|
17
|
-
def im_list
|
18
|
-
response = @session.do_get "#{SCOPE}.list"
|
21
|
+
def im_list(params={})
|
22
|
+
response = @session.do_get "#{SCOPE}.list", params
|
19
23
|
Slack::parse_response(response)
|
20
24
|
end
|
21
25
|
|
22
26
|
# Sets the read cursor in a direct message channel.
|
23
|
-
def im_mark(
|
24
|
-
|
27
|
+
def im_mark(params={})
|
28
|
+
throw ArgumentError.new("Required arguments :channel missing") if params['channel'].nil?
|
29
|
+
throw ArgumentError.new("Required arguments :ts missing") if params['ts'].nil?
|
30
|
+
response = @session.do_get "#{SCOPE}.mark", params
|
31
|
+
Slack::parse_response(response)
|
25
32
|
end
|
26
33
|
|
27
34
|
# Opens a direct message channel.
|
28
|
-
def im_open(
|
29
|
-
|
35
|
+
def im_open(params={})
|
36
|
+
throw ArgumentError.new("Required arguments :user missing") if params['user'].nil?
|
37
|
+
response = @session.do_get "#{SCOPE}.open", params
|
38
|
+
Slack::parse_response(response)
|
30
39
|
end
|
31
40
|
|
32
41
|
end
|
data/lib/slack/web/search.rb
CHANGED
@@ -4,18 +4,24 @@ module Slack
|
|
4
4
|
SCOPE = "search"
|
5
5
|
|
6
6
|
# Searches for messages and files matching a query.
|
7
|
-
def search_all(
|
8
|
-
|
7
|
+
def search_all(params={})
|
8
|
+
throw ArgumentError.new("Required arguments :query missing") if params['query'].nil?
|
9
|
+
response = @session.do_get "#{SCOPE}.all", params
|
10
|
+
Slack::parse_response(response)
|
9
11
|
end
|
10
12
|
|
11
13
|
# Searches for files matching a query.
|
12
|
-
def search_files(
|
13
|
-
|
14
|
+
def search_files(params={})
|
15
|
+
throw ArgumentError.new("Required arguments :query missing") if params['query'].nil?
|
16
|
+
response = @session.do_get "#{SCOPE}.files", params
|
17
|
+
Slack::parse_response(response)
|
14
18
|
end
|
15
19
|
|
16
20
|
# Searches for messages matching a query.
|
17
|
-
def search_messages(
|
18
|
-
|
21
|
+
def search_messages(params={})
|
22
|
+
throw ArgumentError.new("Required arguments :query missing") if params['query'].nil?
|
23
|
+
response = @session.do_get "#{SCOPE}.messages", params
|
24
|
+
Slack::parse_response(response)
|
19
25
|
end
|
20
26
|
|
21
27
|
end
|
data/lib/slack/web/stars.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
module Slack
|
2
2
|
module Web
|
3
3
|
module Stars
|
4
|
-
SCOPE = "
|
4
|
+
SCOPE = "stars"
|
5
5
|
|
6
6
|
# Lists stars for a user.
|
7
|
-
def stars_list(
|
8
|
-
|
7
|
+
def stars_list(params={})
|
8
|
+
response = @session.do_get "#{SCOPE}.list", params
|
9
|
+
Slack::parse_response(response)
|
9
10
|
end
|
10
11
|
|
11
12
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Slack
|
2
|
+
module Web
|
3
|
+
module Team
|
4
|
+
SCOPE = "team"
|
5
|
+
|
6
|
+
# Gets the access logs for a team.
|
7
|
+
def team_access_logs(params={})
|
8
|
+
response = @session.do_get "#{SCOPE}.accessLogs", params
|
9
|
+
Slack::parse_response(response)
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/slack/web/users.rb
CHANGED
@@ -4,32 +4,35 @@ module Slack
|
|
4
4
|
SCOPE = "users"
|
5
5
|
|
6
6
|
# Gets user presence information.
|
7
|
-
def users_get_presence(
|
8
|
-
|
7
|
+
def users_get_presence(params={})
|
8
|
+
throw ArgumentError.new("Required arguments :user missing") if params['user'].nil?
|
9
|
+
response = @session.do_get "#{SCOPE}.getPresence", params
|
9
10
|
Slack::parse_response(response)
|
10
11
|
end
|
11
12
|
|
12
13
|
# Gets information about a user.
|
13
|
-
def users_info(
|
14
|
-
|
14
|
+
def users_info(params={})
|
15
|
+
throw ArgumentError.new("Required arguments :user missing") if params['user'].nil?
|
16
|
+
response = @session.do_get "#{SCOPE}.info", params
|
15
17
|
Slack::parse_response(response)
|
16
18
|
end
|
17
19
|
|
18
20
|
# Lists all users in a Slack team.
|
19
|
-
def users_list
|
20
|
-
response = @session.do_get "#{SCOPE}.list"
|
21
|
+
def users_list(params={})
|
22
|
+
response = @session.do_get "#{SCOPE}.list", params
|
21
23
|
Slack::parse_response(response)
|
22
24
|
end
|
23
25
|
|
24
26
|
# Marks a user as active.
|
25
|
-
def users_set_active
|
26
|
-
response = @session.do_get "#{SCOPE}.setActive"
|
27
|
+
def users_set_active(params={})
|
28
|
+
response = @session.do_get "#{SCOPE}.setActive", params
|
27
29
|
Slack::parse_response(response)
|
28
30
|
end
|
29
31
|
|
30
32
|
# Manually sets user presence.
|
31
|
-
def users_set_presence(
|
32
|
-
|
33
|
+
def users_set_presence(params={})
|
34
|
+
throw ArgumentError.new("Required arguments :presence missing") if params['presence'].nil?
|
35
|
+
response = @session.do_get "#{SCOPE}.setPresence", params
|
33
36
|
Slack::parse_response(response)
|
34
37
|
end
|
35
38
|
|
data/slack-api-wrapper.gemspec
CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
|
|
13
13
|
A library that provides a plain function-call interface to the
|
14
14
|
Slack API web endpoints.
|
15
15
|
EOF
|
16
|
-
spec.homepage = ""
|
16
|
+
spec.homepage = "https://github.com/gssbzn/slack-api-wrapper"
|
17
17
|
spec.license = "MIT"
|
18
18
|
|
19
19
|
spec.files = `git ls-files -z`.split("\x0")
|
data/spec/slack/client_spec.rb
CHANGED
@@ -8,8 +8,5 @@ describe Slack::Client do
|
|
8
8
|
it 'Validates token is string' do
|
9
9
|
expect{Slack::Client.new(1)}.to raise_error(ArgumentError)
|
10
10
|
end
|
11
|
-
|
12
|
-
client = Slack::Client.new("")
|
13
|
-
expect{client.groups_open("")}.to raise_error(Slack::Web::NotImplementedError)
|
14
|
-
end
|
11
|
+
|
15
12
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slack-api-wrapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gustavo Bazan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -83,6 +83,7 @@ files:
|
|
83
83
|
- lib/slack/session.rb
|
84
84
|
- lib/slack/version.rb
|
85
85
|
- lib/slack/web.rb
|
86
|
+
- lib/slack/web/api.rb
|
86
87
|
- lib/slack/web/auth.rb
|
87
88
|
- lib/slack/web/channels.rb
|
88
89
|
- lib/slack/web/chat.rb
|
@@ -92,6 +93,7 @@ files:
|
|
92
93
|
- lib/slack/web/im.rb
|
93
94
|
- lib/slack/web/search.rb
|
94
95
|
- lib/slack/web/stars.rb
|
96
|
+
- lib/slack/web/team.rb
|
95
97
|
- lib/slack/web/users.rb
|
96
98
|
- slack-api-wrapper.gemspec
|
97
99
|
- spec/slack/client_spec.rb
|
@@ -100,7 +102,7 @@ files:
|
|
100
102
|
- spec/slack/oauth2_spec.rb
|
101
103
|
- spec/slack_spec.rb
|
102
104
|
- spec/spec_helper.rb
|
103
|
-
homepage:
|
105
|
+
homepage: https://github.com/gssbzn/slack-api-wrapper
|
104
106
|
licenses:
|
105
107
|
- MIT
|
106
108
|
metadata: {}
|
@@ -120,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
122
|
version: '0'
|
121
123
|
requirements: []
|
122
124
|
rubyforge_project:
|
123
|
-
rubygems_version: 2.4.
|
125
|
+
rubygems_version: 2.4.6
|
124
126
|
signing_key:
|
125
127
|
specification_version: 4
|
126
128
|
summary: Slack API Wrapper
|