slack-api-wrapper 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 82f17a8e6d648e7e04b4e738de427049fb6c80c0
4
- data.tar.gz: 13a7ebe3f6728d354dad95647164ad92456b135c
3
+ metadata.gz: dedcbbf1b36c42b4eb57b2ed9ae32426db56e031
4
+ data.tar.gz: 72720e24918c02d42e573c659ca31e3540207a1f
5
5
  SHA512:
6
- metadata.gz: 1130982045e83c3cd01862e94bd4b79b5535f0c6691de714407e4b5002b83a853b67a2044360059e938e63d64d72ef5fe31dcce5cd94b4e3b77b44e3830b22bc
7
- data.tar.gz: d6d2f26145bae90283bb9c96dffbc9f22949362f1e49ddd6e3ade5e149290510fa26449ecb7cab48fbdf8b22537afc3eac8c3ecb452b39320a866b89ab710ac3
6
+ metadata.gz: 8795bfe54af70f6317508ece2bea2c0d2ea94feeb242f47ed6db8a82a95ac4563e2c3effeebc2d322d520d46455836c93fa4e4538154e773729969ee9596c9ef
7
+ data.tar.gz: b0de368f122442d43af86c55aab8372f7a73c20244a7b15348dce275623bfa566abd1ce5880a8fd08ad781fed113f625011e804dfa764201057d02c0aa1da3fc
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in slack.gemspec
3
+ # Specify your gem's dependencies in slack-api-wrapper.gemspec
4
4
  gemspec
@@ -8,11 +8,26 @@ require_relative "slack/session"
8
8
  require_relative "slack/oauth2"
9
9
  require_relative "slack/client"
10
10
 
11
- module Slack # :nodoc:
11
+ # Copyright (c) 2015 Gustavo Bazan
12
+ # MIT License
13
+ #
14
+ # The module that contains everything Slack-related:
15
+ #
16
+ # * {Slack::Client} is the class used to interact with the slack end points.
17
+ # * {Slack::Error} is raised when Slack encounters an error.
18
+ # * {Slack::Oauth2} handles oauth2 authentication.
19
+ #
20
+ module Slack
21
+ # Slack url
12
22
  WEB_SERVER = 'slack.com'
13
- API_SERVER = "#{WEB_SERVER}/api"
23
+ # Slack api path
24
+ API_SERVER = 'slack.com/api'
14
25
 
26
+ # Removes nil params
15
27
  #
28
+ # @param [Hash] params
29
+ # API call arguments
30
+ # @return [Hash]
16
31
  def self.clean_params(params)
17
32
  r = {}
18
33
  params.each do |k,v|
@@ -21,15 +36,24 @@ module Slack # :nodoc:
21
36
  r
22
37
  end
23
38
 
39
+ # Convert params to query string
24
40
  #
41
+ # @param [Hash] params
42
+ # API call arguments
43
+ # @return [String]
25
44
  def self.make_query_string(params)
26
45
  clean_params(params).collect {|k,v|
27
46
  CGI.escape(k) + "=" + CGI.escape(v)
28
47
  }.join("&")
29
48
  end
30
49
 
31
- #
32
- def self.do_http(uri, request) # :nodoc:
50
+ # Handle http requests
51
+ # @param [URI::HTTPS] uri
52
+ # API uri
53
+ # @param [Object] request
54
+ # request object
55
+ # @return [Net::HTTPResponse]
56
+ def self.do_http(uri, request)
33
57
 
34
58
  http = Net::HTTP.new(uri.host, uri.port)
35
59
 
@@ -47,7 +71,11 @@ module Slack # :nodoc:
47
71
 
48
72
  # Parse response. You probably shouldn't be calling this directly. This takes responses from the server
49
73
  # and parses them. It also checks for errors and raises exceptions with the appropriate messages.
50
- def self.parse_response(response, raw=false) # :nodoc:
74
+ # @param [Net::HTTPResponse] response
75
+ # @param [Boolean] raw if return raw data
76
+ # @raise [SlackError]
77
+ # @raise [SlackAuthError]
78
+ def self.parse_response(response, raw=false)
51
79
  if response.kind_of?(Net::HTTPServerError)
52
80
  raise SlackError.new("Slack Server Error: #{response} - #{response.body}", response)
53
81
  elsif response.kind_of?(Net::HTTPUnauthorized)
@@ -58,8 +86,10 @@ module Slack # :nodoc:
58
86
  rescue
59
87
  raise SlackError.new("Slack Server Error: body=#{response.body}", response)
60
88
  end
61
- unless d['ok'] == true
62
- raise SlackError.new(d['ok'], response)
89
+ if d['error']
90
+ raise SlackError.new(d['error'], response)
91
+ else
92
+ raise SlackError.new(response.body, response)
63
93
  end
64
94
  end
65
95
 
@@ -75,6 +105,9 @@ module Slack # :nodoc:
75
105
  # A string comparison function that is resistant to timing attacks. If you're comparing a
76
106
  # string you got from the outside world with a string that is supposed to be a secret, use
77
107
  # this function to check equality.
108
+ # @param [String] a
109
+ # @param [String] b
110
+ # @return [Boolean] whether the strings are equal
78
111
  def self.safe_string_equals(a, b)
79
112
  if a.length != b.length
80
113
  false
@@ -1,17 +1,19 @@
1
+ # Copyright (c) 2015 Gustavo Bazan
2
+ # MIT License
3
+
1
4
  require_relative 'session'
2
5
  require_relative 'web'
3
6
 
4
7
  module Slack
5
8
  # 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 SlackOAuth2Flow.
9
+ # first; you can get one using {Slack::OAuth2::Flow}.
7
10
  class Client
8
11
  include Web
9
12
 
10
- # Args:
11
- # * +oauth2_access_token+: Obtained via Slack::OAuth2::Flow.
13
+ # @param [String] oauth2_access_token user token
12
14
  def initialize(oauth2_access_token)
13
15
  if oauth2_access_token.is_a?(String)
14
- @session = OAuth2Session.new(oauth2_access_token)
16
+ @session = Session.new(oauth2_access_token)
15
17
  else
16
18
  raise ArgumentError.new("oauth2_access_token doesn't have a valid type")
17
19
  end
@@ -1,12 +1,23 @@
1
- # This is the usual error raised on any Slack related Errors
1
+ # Copyright (c) 2015 Gustavo Bazan
2
+ # MIT License
3
+
2
4
  module Slack
5
+ # This is the usual error raised on any Slack related Errors
6
+ # @!attribute http_response
7
+ # @return [Object] server response
8
+ # @!attribute error
9
+ # @return [String] the name of the error
3
10
  class Error < RuntimeError
11
+
4
12
  attr_accessor :http_response, :error
13
+
5
14
  def initialize(error, http_response=nil)
6
15
  @error = error
7
16
  @http_response = http_response
8
17
  end
9
18
 
19
+ # String representation
20
+ # @return [String]
10
21
  def to_s
11
22
  "#{error}"
12
23
  end
@@ -1,6 +1,10 @@
1
+ # Copyright (c) 2015 Gustavo Bazan
2
+ # MIT License
3
+
1
4
  require_relative 'oauth2/flow_base'
2
5
  require_relative 'oauth2/flow'
3
6
  module Slack
7
+ # Oauth2 authentication
4
8
  module Oauth2
5
9
  end
6
10
  end
@@ -1,20 +1,27 @@
1
+ # Copyright (c) 2015 Gustavo Bazan
2
+ # MIT License
3
+
1
4
  require 'securerandom'
2
5
 
3
6
  require_relative 'flow_base'
4
7
 
5
8
  module Slack
6
- module OAuth2
7
- # The standard OAuth 2 authorization helper. Use this if you're writing a web app.
9
+ module Oauth2
10
+ # The standard OAuth 2 authorization helper.
8
11
  class Flow < FlowBase
9
12
 
10
- # * consumer_key: Your Slack API app's "app key"
11
- # * consumer_secret: Your Slack API app's "app secret"
12
- # * redirect_uri: The URI that the Slack server will redirect the user to after the user
13
+ # @param [String] consumer_key
14
+ # Your Slack API app's "app key"
15
+ # @param [String] consumer_secret
16
+ # Your Slack API app's "app secret"
17
+ # @param [String] redirect_uri
18
+ # The URI that the Slack server will redirect the user to after the user
13
19
  # finishes authorizing your app. This URI must be HTTPs-based and pre-registered with
14
20
  # the Slack servers.
15
- # * session: A hash that represents the current web app session (will be used to save the CSRF
16
- # token)
17
- # * csrf_token_key: The key to use when storing the CSRF token in the session (for example,
21
+ # @param [Hash] session
22
+ # represents the current web app session (will be used to save the CSRF token)
23
+ # @param [Object] csrf_token_key
24
+ # The key to use when storing the CSRF token in the session (for example,
18
25
  # :slack_auth_csrf_token)
19
26
  def initialize(consumer_key, consumer_secret, redirect_uri, scope, team, session, csrf_token_session_key)
20
27
  super(consumer_key, consumer_secret, scope, team)
@@ -36,10 +43,11 @@ module Slack
36
43
  # you provided to the constructor. This CSRF token will be checked on finish() to prevent
37
44
  # request forgery.
38
45
  #
39
- # * url_state: Any data you would like to keep in the URL through the authorization
46
+ # @param [String] url_state
47
+ # Any data you would like to keep in the URL through the authorization
40
48
  # process. This exact value will be returned to you by finish().
41
49
  #
42
- # Returns the URL to redirect the user to.
50
+ # @return Returns the URL to redirect the user to.
43
51
  def start(url_state=nil)
44
52
  unless url_state.nil? or url_state.is_a?(String)
45
53
  raise ArgumentError, "url_state must be a String"
@@ -57,21 +65,23 @@ module Slack
57
65
  # Call this after the user has visited the authorize URL (see: start()), approved your app,
58
66
  # and was redirected to your redirect URI.
59
67
  #
60
- # * query_params: The query params on the GET request to your redirect URI.
68
+ # @param [Hash] query_params
69
+ # The query params on the GET request to your redirect URI.
61
70
  #
62
- # Returns a tuple of (access_token, scope, url_state). access_token can be used to
63
- # construct a SlackClient. scpe is the Slack scope the user that jsut approved
64
- # your app. url_state is the value you originally passed in to start().
71
+ # @return Returns a tuple of (access_token, scope, url_state). access_token can be used to
72
+ # construct a SlackClient. scpe is the Slack scope the user that jsut approved
73
+ # your app. url_state is the value you originally passed in to start().
65
74
  #
66
- # Can throw BadRequestError, BadStateError, CsrfError, NotApprovedError,
67
- # ProviderError.
75
+ # @raise [BadRequestError]
76
+ # @raise [BadStateError]
77
+ # @raise [CsrfError]
78
+ # @raise [NotApprovedError]
79
+ # @raise [ProviderError]
68
80
  def finish(query_params)
69
81
  csrf_token_from_session = @session[@csrf_token_session_key]
70
82
 
71
83
  # Check well-formedness of request.
72
84
 
73
- # Check well-formedness of request.
74
-
75
85
  state = query_params['state']
76
86
  if state.nil?
77
87
  raise BadRequestError.new("Missing query parameter 'state'.")
@@ -1,9 +1,12 @@
1
+ # Copyright (c) 2015 Gustavo Bazan
2
+ # MIT License
3
+
1
4
  require 'uri'
2
5
 
3
6
  module Slack
4
- module OAuth2
7
+ module Oauth2
5
8
  # Base class for the OAuth 2 authorization helpers.
6
- class FlowBase # :nodoc:
9
+ class FlowBase
7
10
  def initialize(consumer_key, consumer_secret, scope, team)
8
11
  unless consumer_key.is_a?(String)
9
12
  raise ArgumentError, "consumer_key must be a String, got #{consumer_key.inspect}"
@@ -1,7 +1,11 @@
1
+ # Copyright (c) 2015 Gustavo Bazan
2
+ # MIT License
3
+
1
4
  module Slack
2
5
 
3
- class OAuth2Session # :nodoc:
6
+ class Session # :nodoc:
4
7
 
8
+ # @param [String] oauth2_access_token user token
5
9
  def initialize(oauth2_access_token)
6
10
  unless oauth2_access_token.is_a?(String)
7
11
  raise "bad type for oauth2_access_token (expecting String)"
@@ -11,7 +15,7 @@ module Slack
11
15
 
12
16
  private
13
17
 
14
- def build_url(path)
18
+ def build_url(path) # :nodoc:
15
19
  host = Slack::WEB_SERVER
16
20
  full_path = "/api/#{path}"
17
21
  URI::HTTPS.build({host: host, path: full_path})
@@ -38,7 +42,7 @@ module Slack
38
42
  do_http(uri, Net::HTTP::Get.new(uri.request_uri))
39
43
  end
40
44
 
41
- def do_http_with_body(uri, request, body)
45
+ def do_http_with_body(uri, request, body) # :nodoc:
42
46
  if body != nil
43
47
  if body.is_a?(Hash)
44
48
  request.set_form_data(Slack::clean_params(body))
@@ -1,3 +1,7 @@
1
+ # Copyright (c) 2015 Gustavo Bazan
2
+ # MIT License
3
+
1
4
  module Slack
2
- VERSION = '0.0.5'
5
+ # The current version of the wrapper.
6
+ VERSION = '0.0.6'
3
7
  end
@@ -1,3 +1,7 @@
1
+ # Copyright (c) 2015 Gustavo Bazan
2
+ # MIT License
3
+
4
+ require_relative 'web/api'
1
5
  require_relative 'web/auth'
2
6
  require_relative 'web/channels'
3
7
  require_relative 'web/chat'
@@ -12,7 +16,9 @@ require_relative 'web/users'
12
16
  require_relative 'error'
13
17
 
14
18
  module Slack
19
+ # Web endpoints methods
15
20
  module Web
21
+ include Api
16
22
  include Auth
17
23
  include Channels
18
24
  include Chat
@@ -24,6 +30,5 @@ module Slack
24
30
  include Search
25
31
  include Team
26
32
  include Users
27
-
28
33
  end
29
34
  end
@@ -1,9 +1,23 @@
1
+ # Copyright (c) 2015 Gustavo Bazan
2
+ # MIT License
3
+
1
4
  module Slack
2
5
  module Web
3
- module Team
6
+ # Module for the api methods.
7
+ module Api
8
+ # Endpoint scope
4
9
  SCOPE = "api"
5
10
 
6
11
  # Checks API calling code.
12
+ #
13
+ # @param [Hash] params
14
+ # API call arguments
15
+ # @option params [Object] 'error'
16
+ # Error response to return
17
+ # @option params [Object] 'foo'
18
+ # example property to return
19
+ #
20
+ # @see https://api.slack.com/methods/api.test
7
21
  def api_test(params={})
8
22
  response = @session.do_get "#{SCOPE}.test", params
9
23
  Slack::parse_response(response)
@@ -1,8 +1,21 @@
1
+ # Copyright (c) 2015 Gustavo Bazan
2
+ # MIT License
3
+
1
4
  module Slack
2
5
  module Web
6
+ # Module for the auth methods.
3
7
  module Auth
8
+ # Endpoint scope
9
+ SCOPE = "auth"
10
+
11
+ # Checks authentication & identity.
12
+ #
13
+ # @param [Hash] params
14
+ # API call arguments
15
+ #
16
+ # @see https://api.slack.com/methods/auth.test
4
17
  def auth_test(params={})
5
- response = @session.do_get "auth.test", params
18
+ response = @session.do_get "#{SCOPE}.test", params
6
19
  Slack::parse_response(response)
7
20
  end
8
21
  end
@@ -1,107 +1,231 @@
1
+ # Copyright (c) 2015 Gustavo Bazan
2
+ # MIT License
3
+
1
4
  module Slack
2
5
  module Web
6
+ # Module for the channels methods.
7
+ # Get info on your team's Slack channels, create or archive channels,
8
+ # invite users, set the topic and purpose, and mark a channel as read.
3
9
  module Channels
10
+ # Endpoint scope
4
11
  SCOPE = "channels"
5
12
 
6
13
  # Archives a channel.
14
+ #
15
+ # @param [Hash] params
16
+ # API call arguments
17
+ # @option params [channel] 'channel'
18
+ # Channel to archive
19
+ #
20
+ # @see https://api.slack.com/methods/channels.archive
7
21
  def channels_archive(params = {})
8
- throw ArgumentError.new("Required arguments :channel missing") if params['channel'].nil?
22
+ raise ArgumentError.new("Required arguments 'channel' missing") if params['channel'].nil?
9
23
  response = @session.do_get "#{SCOPE}.archive", params
10
24
  Slack::parse_response(response)
11
25
  end
12
26
 
13
27
  # Creates a channel.
28
+ #
29
+ # @param [Hash] params
30
+ # API call arguments
31
+ # @option params [Object] 'name'
32
+ # Name of channel to create
33
+ #
34
+ # @see https://api.slack.com/methods/channels.create
14
35
  def channels_create(params = {})
15
- throw ArgumentError.new("Required arguments :name missing") if params['name'].nil?
36
+ raise ArgumentError.new("Required arguments 'name' missing") if params['name'].nil?
16
37
  response = @session.do_get "#{SCOPE}.create", params
17
38
  Slack::parse_response(response)
18
39
  end
19
40
 
20
41
  # Fetches history of messages and events from a channel.
42
+ #
43
+ # @param [Hash] params
44
+ # API call arguments
45
+ # @option params [channel] 'channel'
46
+ # Channel to fetch history for.
47
+ # @option params [timestamp] 'latest'
48
+ # Latest message timestamp to include in results.
49
+ # @option params [timestamp] 'oldest'
50
+ # Oldest message timestamp to include in results.
51
+ # @option params [Object] 'inclusive'
52
+ # Include messages with latest or oldest timestamp in results.
53
+ # @option params [Object] 'count'
54
+ # Number of messages to return, between 1 and 1000.
55
+ #
56
+ # @see https://api.slack.com/methods/channels.history
21
57
  def channels_history(params={})
22
- throw ArgumentError.new("Required arguments :channel missing") if params['channel'].nil?
58
+ raise ArgumentError.new("Required arguments 'channel' missing") if params['channel'].nil?
23
59
  response = @session.do_get "#{SCOPE}.history", params
24
60
  Slack::parse_response(response)
25
61
  end
26
62
 
27
63
  # Gets information about a channel.
64
+ #
65
+ # @param [Hash] params
66
+ # API call arguments
67
+ # @option params [channel] 'channel'
68
+ # Channel to get info on
69
+ #
70
+ # @see https://api.slack.com/methods/channels.info
28
71
  def channels_info(params={})
29
- throw ArgumentError.new("Required arguments :channel missing") if params['channel'].nil?
72
+ raise ArgumentError.new("Required arguments 'channel' missing") if params['channel'].nil?
30
73
  response = @session.do_get "#{SCOPE}.info", params
31
74
  Slack::parse_response(response)
32
75
  end
33
76
 
34
77
  # Invites a user to a channel.
78
+ #
79
+ # @param [Hash] params
80
+ # API call arguments
81
+ # @option params [channel] 'channel'
82
+ # Channel to invite user to.
83
+ # @option params [user] 'user'
84
+ # User to invite to channel.
85
+ #
86
+ # @see https://api.slack.com/methods/channels.invite
35
87
  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?
88
+ raise ArgumentError.new("Required arguments 'channel' missing") if params['channel'].nil?
89
+ raise ArgumentError.new("Required arguments 'user' missing") if params['user'].nil?
38
90
  response = @session.do_get "#{SCOPE}.invite", params
39
91
  Slack::parse_response(response)
40
92
  end
41
93
 
42
94
  # Joins a channel, creating it if needed.
95
+ #
96
+ # @param [Hash] params
97
+ # API call arguments
98
+ # @option params [Object] 'name'
99
+ # Name of channel to join
100
+ #
101
+ # @see https://api.slack.com/methods/channels.join
43
102
  def channels_join(params={})
44
- throw ArgumentError.new("Required arguments :name missing") if params['name'].nil?
103
+ raise ArgumentError.new("Required arguments 'name' missing") if params['name'].nil?
45
104
  response = @session.do_get "#{SCOPE}.join", params
46
105
  Slack::parse_response(response)
47
106
  end
48
107
 
49
108
  # Removes a user from a channel.
109
+ #
110
+ # @param [Hash] params
111
+ # API call arguments
112
+ # @option params [channel] 'channel'
113
+ # Channel to remove user from.
114
+ # @option params [user] 'user'
115
+ # User to remove from channel.
116
+ #
117
+ # @see https://api.slack.com/methods/channels.kick
50
118
  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?
119
+ raise ArgumentError.new("Required arguments 'channel' missing") if params['channel'].nil?
120
+ raise ArgumentError.new("Required arguments 'user' missing") if params['user'].nil?
53
121
  response = @session.do_get "#{SCOPE}.kick", params
54
122
  Slack::parse_response(response)
55
123
  end
56
124
 
57
125
  # Leaves a channel.
126
+ #
127
+ # @param [Hash] params
128
+ # API call arguments
129
+ # @option params [channel] 'channel'
130
+ # Channel to leave
131
+ # @see https://api.slack.com/methods/channels.leave
58
132
  def channels_leave(params={})
59
- throw ArgumentError.new("Required arguments :channel missing") if params['channel'].nil?
133
+ raise ArgumentError.new("Required arguments 'channel' missing") if params['channel'].nil?
60
134
  response = @session.do_get "#{SCOPE}.leave", params
61
135
  Slack::parse_response(response)
62
136
  end
63
137
 
64
138
  # Lists all channels in a Slack team.
139
+ #
140
+ # @param [Hash] params
141
+ # API call arguments
142
+ # @option params [Object] 'exclude_archived'
143
+ # Don't return archived channels.
144
+ #
145
+ # @see https://api.slack.com/methods/channels.list
65
146
  def channels_list(params={})
66
147
  response = @session.do_get "#{SCOPE}.list", params
67
148
  Slack::parse_response(response)
68
149
  end
69
150
 
70
151
  # Sets the read cursor in a channel.
152
+ #
153
+ # @param [Hash] params
154
+ # API call arguments
155
+ # @option params [channel] 'channel'
156
+ # Channel to set reading cursor in.
157
+ # @option params [timestamp] 'ts'
158
+ # Timestamp of the most recently seen message.
159
+ #
160
+ # @see https://api.slack.com/methods/channels.mark
71
161
  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?
162
+ raise ArgumentError.new("Required arguments 'channel' missing") if params['channel'].nil?
163
+ raise ArgumentError.new("Required arguments 'ts' missing") if params['ts'].nil?
74
164
  response = @session.do_get "#{SCOPE}.mark", params
75
165
  Slack::parse_response(response)
76
166
  end
77
167
 
78
168
  # Renames a channel.
169
+ #
170
+ # @param [Hash] params
171
+ # API call arguments
172
+ # @option params [channel] 'channel'
173
+ # Channel to rename
174
+ # @option params [Object] 'name'
175
+ # New name for channel.
176
+ #
177
+ # @see https://api.slack.com/methods/channels.rename
79
178
  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?
179
+ raise ArgumentError.new("Required arguments 'channel' missing") if params['channel'].nil?
180
+ raise ArgumentError.new("Required arguments 'name' missing") if params['name'].nil?
82
181
  response = @session.do_get "#{SCOPE}.rename", params
83
182
  Slack::parse_response(response)
84
183
  end
85
184
 
86
185
  # Sets the purpose for a channel.
186
+ #
187
+ # @param [Hash] params
188
+ # API call arguments
189
+ # @option params [channel] 'channel'
190
+ # Channel to set the purpose of
191
+ # @option params [Object] 'purpose'
192
+ # The new purpose
193
+ #
194
+ # @see https://api.slack.com/methods/channels.setPurpose
87
195
  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?
196
+ raise ArgumentError.new("Required arguments 'channel' missing") if params['channel'].nil?
197
+ raise ArgumentError.new("Required arguments 'purpose' missing") if params['purpose'].nil?
90
198
  response = @session.do_get "#{SCOPE}.setPurpose", params
91
199
  Slack::parse_response(response)
92
200
  end
93
201
 
94
202
  # Sets the topic for a channel.
203
+ #
204
+ # @param [Hash] params
205
+ # API call arguments
206
+ # @option params [channel] 'channel'
207
+ # Channel to set the topic of
208
+ # @option params [Object] 'topic'
209
+ # The new topic
210
+ # @raise [ArgumentError] if 'channel' or 'topic' are not present
211
+ # @see https://api.slack.com/methods/channels.setTopic
95
212
  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?
213
+ raise ArgumentError.new("Required arguments 'channel' missing") if params['channel'].nil?
214
+ raise ArgumentError.new("Required arguments 'topic' missing") if params['topic'].nil?
98
215
  response = @session.do_get "#{SCOPE}.setTopic", params
99
216
  Slack::parse_response(response)
100
217
  end
101
218
 
102
219
  # Unarchives a channel.
220
+ #
221
+ # @param [Hash] params
222
+ # API call arguments
223
+ # @option params [channel] 'channel'
224
+ # Channel to unarchive
225
+ # @raise [ArgumentError] if 'channel' is not present
226
+ # @see https://api.slack.com/methods/channels.unarchive
103
227
  def channels_unarchive(params={})
104
- throw ArgumentError.new("Required arguments :channel missing") if params['channel'].nil?
228
+ raise ArgumentError.new("Required arguments 'channel' missing") if params['channel'].nil?
105
229
  response = @session.do_get "#{SCOPE}.unarchive", params
106
230
  Slack::parse_response(response)
107
231
  end