slack-api-wrapper 0.0.5 → 0.0.6
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/Gemfile +1 -1
- data/lib/slack-api-wrapper.rb +40 -7
- data/lib/slack/client.rb +6 -4
- data/lib/slack/error.rb +12 -1
- data/lib/slack/oauth2.rb +4 -0
- data/lib/slack/oauth2/flow.rb +28 -18
- data/lib/slack/oauth2/flow_base.rb +5 -2
- data/lib/slack/session.rb +7 -3
- data/lib/slack/version.rb +5 -1
- data/lib/slack/web.rb +6 -1
- data/lib/slack/web/api.rb +15 -1
- data/lib/slack/web/auth.rb +14 -1
- data/lib/slack/web/channels.rb +143 -19
- data/lib/slack/web/chat.rb +63 -10
- data/lib/slack/web/emoji.rb +10 -0
- data/lib/slack/web/files.rb +72 -3
- data/lib/slack/web/groups.rb +151 -21
- data/lib/slack/web/im.rb +54 -5
- data/lib/slack/web/search.rb +60 -3
- data/lib/slack/web/stars.rb +16 -0
- data/lib/slack/web/team.rb +14 -0
- data/lib/slack/web/users.rb +40 -3
- data/slack-api-wrapper.gemspec +1 -0
- metadata +23 -2
data/lib/slack/web/im.rb
CHANGED
@@ -1,39 +1,88 @@
|
|
1
|
+
# Copyright (c) 2015 Gustavo Bazan
|
2
|
+
# MIT License
|
3
|
+
|
1
4
|
module Slack
|
2
5
|
module Web
|
6
|
+
# Module for the im methods.
|
7
|
+
# Get info on your direct messages.
|
3
8
|
module Im
|
9
|
+
# Endpoint scope
|
4
10
|
SCOPE = "im"
|
5
11
|
|
6
12
|
# Close a direct message channel.
|
13
|
+
#
|
14
|
+
# @param [Hash] params
|
15
|
+
# API call arguments
|
16
|
+
# @option params [im] 'channel'
|
17
|
+
# Direct message channel to close.
|
18
|
+
#
|
19
|
+
# @see https://api.slack.com/methods/im.close
|
7
20
|
def im_close(params={})
|
8
|
-
|
21
|
+
raise ArgumentError.new("Required arguments 'channel' missing") if params['channel'].nil?
|
9
22
|
response = @session.do_get "#{SCOPE}.close", params
|
10
23
|
Slack::parse_response(response)
|
11
24
|
end
|
12
25
|
|
13
26
|
# Fetches history of messages and events from direct message channel.
|
27
|
+
#
|
28
|
+
# @param [Hash] params
|
29
|
+
# API call arguments
|
30
|
+
# @option params [im] 'channel'
|
31
|
+
# Direct message channel to fetch history for.
|
32
|
+
# @option params [timestamp] 'latest'
|
33
|
+
# Latest message timestamp to include in results.
|
34
|
+
# @option params [timestamp] 'oldest'
|
35
|
+
# Oldest message timestamp to include in results.
|
36
|
+
# @option params [Object] 'inclusive'
|
37
|
+
# Include messages with latest or oldest timestamp in results.
|
38
|
+
# @option params [Object] 'count'
|
39
|
+
# Number of messages to return, between 1 and 1000.
|
40
|
+
#
|
41
|
+
# @see https://api.slack.com/methods/im.history
|
14
42
|
def im_history(params={})
|
15
|
-
|
43
|
+
raise ArgumentError.new("Required arguments 'channel' missing") if params['channel'].nil?
|
16
44
|
response = @session.do_get "#{SCOPE}.history", params
|
17
45
|
Slack::parse_response(response)
|
18
46
|
end
|
19
47
|
|
20
48
|
# Lists direct message channels for the calling user.
|
49
|
+
#
|
50
|
+
# @param [Hash] params
|
51
|
+
# API call arguments
|
52
|
+
#
|
53
|
+
# @see https://api.slack.com/methods/im.list
|
21
54
|
def im_list(params={})
|
22
55
|
response = @session.do_get "#{SCOPE}.list", params
|
23
56
|
Slack::parse_response(response)
|
24
57
|
end
|
25
58
|
|
26
59
|
# Sets the read cursor in a direct message channel.
|
60
|
+
#
|
61
|
+
# @param [Hash] params
|
62
|
+
# API call arguments
|
63
|
+
# @option params [im] 'channel'
|
64
|
+
# Direct message channel to set reading cursor in.
|
65
|
+
# @option params [timestamp] 'ts'
|
66
|
+
# Timestamp of the most recently seen message.
|
67
|
+
#
|
68
|
+
# @see https://api.slack.com/methods/im.mark
|
27
69
|
def im_mark(params={})
|
28
|
-
|
29
|
-
|
70
|
+
raise ArgumentError.new("Required arguments 'channel' missing") if params['channel'].nil?
|
71
|
+
raise ArgumentError.new("Required arguments 'ts' missing") if params['ts'].nil?
|
30
72
|
response = @session.do_get "#{SCOPE}.mark", params
|
31
73
|
Slack::parse_response(response)
|
32
74
|
end
|
33
75
|
|
34
76
|
# Opens a direct message channel.
|
77
|
+
#
|
78
|
+
# @param [Hash] params
|
79
|
+
# API call arguments
|
80
|
+
# @option params [user] 'user'
|
81
|
+
# User to open a direct message channel with.
|
82
|
+
#
|
83
|
+
# @see https://api.slack.com/methods/im.open
|
35
84
|
def im_open(params={})
|
36
|
-
|
85
|
+
raise ArgumentError.new("Required arguments 'user' missing") if params['user'].nil?
|
37
86
|
response = @session.do_get "#{SCOPE}.open", params
|
38
87
|
Slack::parse_response(response)
|
39
88
|
end
|
data/lib/slack/web/search.rb
CHANGED
@@ -1,25 +1,82 @@
|
|
1
|
+
# Copyright (c) 2015 Gustavo Bazan
|
2
|
+
# MIT License
|
3
|
+
|
1
4
|
module Slack
|
2
5
|
module Web
|
6
|
+
# Module for the search methods.
|
7
|
+
# Search your team's files and messages.
|
3
8
|
module Search
|
9
|
+
# Endpoint scope
|
4
10
|
SCOPE = "search"
|
5
11
|
|
6
12
|
# Searches for messages and files matching a query.
|
13
|
+
#
|
14
|
+
# @param [Hash] params
|
15
|
+
# API call arguments
|
16
|
+
# @option options [Object] 'query'
|
17
|
+
# Search query. May contains booleans, etc.
|
18
|
+
# @option options [Object] 'sort'
|
19
|
+
# Return matches sorted by either `score` or `timestamp`.
|
20
|
+
# @option options [Object] 'sort_dir'
|
21
|
+
# Change sort direction to ascending (`asc`) or descending (`desc`).
|
22
|
+
# @option options [Object] 'highlight'
|
23
|
+
# Pass a value of `1` to enable query highlight markers.
|
24
|
+
# @option params [Object] 'count'
|
25
|
+
# Number of items to return per page.
|
26
|
+
# @option params [Object] 'page'
|
27
|
+
# Page number of results to return.
|
28
|
+
#
|
29
|
+
# @see https://api.slack.com/methods/search.all
|
7
30
|
def search_all(params={})
|
8
|
-
|
31
|
+
raise ArgumentError.new("Required arguments 'query' missing") if params['query'].nil?
|
9
32
|
response = @session.do_get "#{SCOPE}.all", params
|
10
33
|
Slack::parse_response(response)
|
11
34
|
end
|
12
35
|
|
13
36
|
# Searches for files matching a query.
|
37
|
+
#
|
38
|
+
# @param [Hash] params
|
39
|
+
# API call arguments
|
40
|
+
# @option params [Object] 'query'
|
41
|
+
# Search query. May contains booleans, etc.
|
42
|
+
# @option params [Object] 'sort'
|
43
|
+
# Return matches sorted by either `score` or `timestamp`.
|
44
|
+
# @option params [Object] 'sort_dir'
|
45
|
+
# Change sort direction to ascending (`asc`) or descending (`desc`).
|
46
|
+
# @option params [Object] 'highlight'
|
47
|
+
# Pass a value of `1` to enable query highlight markers.
|
48
|
+
# @option params [Object] 'count'
|
49
|
+
# Number of items to return per page.
|
50
|
+
# @option params [Object] 'page'
|
51
|
+
# Page number of results to return.
|
52
|
+
#
|
53
|
+
# @see https://api.slack.com/methods/search.files
|
14
54
|
def search_files(params={})
|
15
|
-
|
55
|
+
raise ArgumentError.new("Required arguments 'query' missing") if params['query'].nil?
|
16
56
|
response = @session.do_get "#{SCOPE}.files", params
|
17
57
|
Slack::parse_response(response)
|
18
58
|
end
|
19
59
|
|
20
60
|
# Searches for messages matching a query.
|
61
|
+
#
|
62
|
+
# @param [Hash] params
|
63
|
+
# API call arguments
|
64
|
+
# @option params [Object] 'query'
|
65
|
+
# Search query. May contains booleans, etc.
|
66
|
+
# @option params [Object] 'sort'
|
67
|
+
# Return matches sorted by either `score` or `timestamp`.
|
68
|
+
# @option params [Object] 'sort_dir'
|
69
|
+
# Change sort direction to ascending (`asc`) or descending (`desc`).
|
70
|
+
# @option params [Object] 'highlight'
|
71
|
+
# Pass a value of `1` to enable query highlight markers.
|
72
|
+
# @option params [Object] 'count'
|
73
|
+
# Number of items to return per page.
|
74
|
+
# @option params [Object] 'page'
|
75
|
+
# Page number of results to return.
|
76
|
+
#
|
77
|
+
# @see https://api.slack.com/methods/search.messages
|
21
78
|
def search_messages(params={})
|
22
|
-
|
79
|
+
raise ArgumentError.new("Required arguments 'query' missing") if params['query'].nil?
|
23
80
|
response = @session.do_get "#{SCOPE}.messages", params
|
24
81
|
Slack::parse_response(response)
|
25
82
|
end
|
data/lib/slack/web/stars.rb
CHANGED
@@ -1,9 +1,25 @@
|
|
1
|
+
# Copyright (c) 2015 Gustavo Bazan
|
2
|
+
# MIT License
|
3
|
+
|
1
4
|
module Slack
|
2
5
|
module Web
|
6
|
+
# Module for the stars methods.
|
3
7
|
module Stars
|
8
|
+
# Endpoint scope
|
4
9
|
SCOPE = "stars"
|
5
10
|
|
6
11
|
# Lists stars for a user.
|
12
|
+
#
|
13
|
+
# @param [Hash] params
|
14
|
+
# API call arguments
|
15
|
+
# @option params [user] 'user'
|
16
|
+
# Show stars by this user. Defaults to the authed user.
|
17
|
+
# @option params [Object] 'count'
|
18
|
+
# Number of items to return per page.
|
19
|
+
# @option params [Object] 'page'
|
20
|
+
# Page number of results to return.
|
21
|
+
#
|
22
|
+
# @see https://api.slack.com/methods/stars.list
|
7
23
|
def stars_list(params={})
|
8
24
|
response = @session.do_get "#{SCOPE}.list", params
|
9
25
|
Slack::parse_response(response)
|
data/lib/slack/web/team.rb
CHANGED
@@ -1,9 +1,23 @@
|
|
1
|
+
# Copyright (c) 2015 Gustavo Bazan
|
2
|
+
# MIT License
|
3
|
+
|
1
4
|
module Slack
|
2
5
|
module Web
|
6
|
+
# Module for the teams methods.
|
3
7
|
module Team
|
8
|
+
# Endpoint scope
|
4
9
|
SCOPE = "team"
|
5
10
|
|
6
11
|
# Gets the access logs for a team.
|
12
|
+
#
|
13
|
+
# @param [Hash] params
|
14
|
+
# API call arguments
|
15
|
+
# @option params [Object] 'count'
|
16
|
+
# Number of items to return per page.
|
17
|
+
# @option params [Object] 'page'
|
18
|
+
# Page number of results to return.
|
19
|
+
#
|
20
|
+
# @see https://api.slack.com/methods/team.access_logs
|
7
21
|
def team_access_logs(params={})
|
8
22
|
response = @session.do_get "#{SCOPE}.accessLogs", params
|
9
23
|
Slack::parse_response(response)
|
data/lib/slack/web/users.rb
CHANGED
@@ -1,37 +1,74 @@
|
|
1
|
+
# Copyright (c) 2015 Gustavo Bazan
|
2
|
+
# MIT License
|
3
|
+
|
1
4
|
module Slack
|
2
5
|
module Web
|
6
|
+
# Module for the users methods.
|
7
|
+
# Get info on members of your Slack team.
|
3
8
|
module Users
|
9
|
+
# Endpoint scope
|
4
10
|
SCOPE = "users"
|
5
11
|
|
6
12
|
# Gets user presence information.
|
13
|
+
#
|
14
|
+
# @param [Hash] params
|
15
|
+
# API call arguments
|
16
|
+
# @option options [user] 'user'
|
17
|
+
# User to get presence info on. Defaults to the authed user.
|
18
|
+
#
|
19
|
+
# @see https://api.slack.com/methods/users.messages
|
7
20
|
def users_get_presence(params={})
|
8
|
-
|
21
|
+
raise ArgumentError.new("Required arguments :user missing") if params['user'].nil?
|
9
22
|
response = @session.do_get "#{SCOPE}.getPresence", params
|
10
23
|
Slack::parse_response(response)
|
11
24
|
end
|
12
25
|
|
13
26
|
# Gets information about a user.
|
27
|
+
#
|
28
|
+
# @param [Hash] params
|
29
|
+
# API call arguments
|
30
|
+
# @option options [user] 'user'
|
31
|
+
# User to get info on
|
32
|
+
#
|
33
|
+
# @see https://api.slack.com/methods/users.info
|
14
34
|
def users_info(params={})
|
15
|
-
|
35
|
+
raise ArgumentError.new("Required arguments 'user' missing") if params['user'].nil?
|
16
36
|
response = @session.do_get "#{SCOPE}.info", params
|
17
37
|
Slack::parse_response(response)
|
18
38
|
end
|
19
39
|
|
20
40
|
# Lists all users in a Slack team.
|
41
|
+
#
|
42
|
+
# @param [Hash] params
|
43
|
+
# API call arguments
|
44
|
+
#
|
45
|
+
# @see https://api.slack.com/methods/users.list
|
21
46
|
def users_list(params={})
|
22
47
|
response = @session.do_get "#{SCOPE}.list", params
|
23
48
|
Slack::parse_response(response)
|
24
49
|
end
|
25
50
|
|
26
51
|
# Marks a user as active.
|
52
|
+
#
|
53
|
+
# @param [Hash] params
|
54
|
+
# API call arguments
|
55
|
+
#
|
56
|
+
# @see https://api.slack.com/methods/users.setActive
|
27
57
|
def users_set_active(params={})
|
28
58
|
response = @session.do_get "#{SCOPE}.setActive", params
|
29
59
|
Slack::parse_response(response)
|
30
60
|
end
|
31
61
|
|
32
62
|
# Manually sets user presence.
|
63
|
+
#
|
64
|
+
# @param [Hash] params
|
65
|
+
# API call arguments
|
66
|
+
# @option options [Object] 'presence'
|
67
|
+
# Either `auto` or `away`
|
68
|
+
#
|
69
|
+
# @see https://api.slack.com/methods/users.setPresence
|
33
70
|
def users_set_presence(params={})
|
34
|
-
|
71
|
+
raise ArgumentError.new("Required arguments 'presence' missing") if params['presence'].nil?
|
35
72
|
response = @session.do_get "#{SCOPE}.setPresence", params
|
36
73
|
Slack::parse_response(response)
|
37
74
|
end
|
data/slack-api-wrapper.gemspec
CHANGED
@@ -24,4 +24,5 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_development_dependency "bundler", "~> 1.6"
|
25
25
|
spec.add_development_dependency "rake", '~> 0'
|
26
26
|
spec.add_development_dependency "rspec", '~> 3.2', '>= 3.2.0'
|
27
|
+
spec.add_development_dependency "yard", '~> 0.8.7', '>= 0.8.0'
|
27
28
|
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.6
|
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-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -58,6 +58,26 @@ dependencies:
|
|
58
58
|
- - ">="
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: 3.2.0
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: yard
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 0.8.7
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 0.8.0
|
71
|
+
type: :development
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - "~>"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.8.7
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 0.8.0
|
61
81
|
description: |2
|
62
82
|
A library that provides a plain function-call interface to the
|
63
83
|
Slack API web endpoints.
|
@@ -133,3 +153,4 @@ test_files:
|
|
133
153
|
- spec/slack/oauth2_spec.rb
|
134
154
|
- spec/slack_spec.rb
|
135
155
|
- spec/spec_helper.rb
|
156
|
+
has_rdoc:
|