Class: SlackWebApi::AdminUsersController

Inherits:
BaseController show all
Defined in:
lib/slack_web_api/controllers/admin_users_controller.rb

Overview

AdminUsersController

Constant Summary

Constants inherited from BaseController

BaseController::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseController

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseController

#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters

Constructor Details

This class inherits a constructor from SlackWebApi::BaseController

Instance Method Details

#admin_users_assign(token, team_id, user_id, is_restricted: nil, is_ultra_restricted: nil, channel_ids: nil) ⇒ ApiResponse

Add an Enterprise user to a workspace. scope: admin.users:write workspace. the workspace. user should be added to the workspace as a guest. True if user should be added to the workspace as a single-channel guest. channel IDs to add user in the new workspace.

Parameters:

  • token (String)

    Required parameter: Authentication token. Requires

  • team_id (String)

    Required parameter: The ID (T1234) of the

  • user_id (String)

    Required parameter: The ID of the user to add to

  • is_restricted (TrueClass | FalseClass) (defaults to: nil)

    Optional parameter: True if

  • is_ultra_restricted (TrueClass | FalseClass) (defaults to: nil)

    Optional parameter:

  • channel_ids (String) (defaults to: nil)

    Optional parameter: Comma separated values of

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/slack_web_api/controllers/admin_users_controller.rb', line 23

def admin_users_assign(token,
                       team_id,
                       user_id,
                       is_restricted: nil,
                       is_ultra_restricted: nil,
                       channel_ids: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/admin.users.assign',
                                 Server::DEFAULT)
               .header_param(new_parameter(token, key: 'token')
                              .is_required(true))
               .form_param(new_parameter(team_id, key: 'team_id')
                            .is_required(true))
               .form_param(new_parameter(user_id, key: 'user_id')
                            .is_required(true))
               .form_param(new_parameter(is_restricted, key: 'is_restricted'))
               .form_param(new_parameter(is_ultra_restricted, key: 'is_ultra_restricted'))
               .form_param(new_parameter(channel_ids, key: 'channel_ids'))
               .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('slackAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(DefaultSuccessTemplate.method(:from_hash))
                .is_api_response(true)
                .local_error('default',
                             'Typical error response',
                             DefaultErrorTemplateException))
    .execute
end

#admin_users_invite(token, team_id, email, channel_ids, custom_message: nil, real_name: nil, resend: nil, is_restricted: nil, is_ultra_restricted: nil, guest_expiration_ts: nil) ⇒ ApiResponse

Invite a user to a workspace. scope: admin.users:write workspace. to invite. ‘channel_id`s for this user to join. At least one channel is required. send to the user in the invite email. invite to be resent in the future if a user has not signed up yet. (default: false) user a multi-channel guest user? (default: false) this user a single channel guest user? (default: false) guest account should be disabled. Only include this timestamp if you are inviting a guest user and you want their account to expire on a certain date.

Parameters:

  • token (String)

    Required parameter: Authentication token. Requires

  • team_id (String)

    Required parameter: The ID (T1234) of the

  • email (String)

    Required parameter: The email address of the person

  • channel_ids (String)

    Required parameter: A comma-separated list of

  • custom_message (String) (defaults to: nil)

    Optional parameter: An optional message to

  • real_name (String) (defaults to: nil)

    Optional parameter: Full name of the user.

  • resend (TrueClass | FalseClass) (defaults to: nil)

    Optional parameter: Allow this

  • is_restricted (TrueClass | FalseClass) (defaults to: nil)

    Optional parameter: Is this

  • is_ultra_restricted (TrueClass | FalseClass) (defaults to: nil)

    Optional parameter: Is

  • guest_expiration_ts (String) (defaults to: nil)

    Optional parameter: Timestamp when

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/slack_web_api/controllers/admin_users_controller.rb', line 79

def admin_users_invite(token,
                       team_id,
                       email,
                       channel_ids,
                       custom_message: nil,
                       real_name: nil,
                       resend: nil,
                       is_restricted: nil,
                       is_ultra_restricted: nil,
                       guest_expiration_ts: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/admin.users.invite',
                                 Server::DEFAULT)
               .header_param(new_parameter(token, key: 'token')
                              .is_required(true))
               .form_param(new_parameter(team_id, key: 'team_id')
                            .is_required(true))
               .form_param(new_parameter(email, key: 'email')
                            .is_required(true))
               .form_param(new_parameter(channel_ids, key: 'channel_ids')
                            .is_required(true))
               .form_param(new_parameter(custom_message, key: 'custom_message'))
               .form_param(new_parameter(real_name, key: 'real_name'))
               .form_param(new_parameter(resend, key: 'resend'))
               .form_param(new_parameter(is_restricted, key: 'is_restricted'))
               .form_param(new_parameter(is_ultra_restricted, key: 'is_ultra_restricted'))
               .form_param(new_parameter(guest_expiration_ts, key: 'guest_expiration_ts'))
               .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('slackAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(DefaultSuccessTemplate.method(:from_hash))
                .is_api_response(true)
                .local_error('default',
                             'Typical error response',
                             DefaultErrorTemplateException))
    .execute
end

#admin_users_list(token, team_id, cursor: nil, limit: nil) ⇒ ApiResponse

List users on a workspace scope: admin.users:read workspace. returned by the previous call to list items in the next page. retrieved per page

Parameters:

  • token (String)

    Required parameter: Authentication token. Requires

  • team_id (String)

    Required parameter: The ID (T1234) of the

  • cursor (String) (defaults to: nil)

    Optional parameter: Set cursor to next_cursor

  • limit (Integer) (defaults to: nil)

    Optional parameter: Limit for how many users to be

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/slack_web_api/controllers/admin_users_controller.rb', line 130

def admin_users_list(token,
                     team_id,
                     cursor: nil,
                     limit: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/admin.users.list',
                                 Server::DEFAULT)
               .header_param(new_parameter(token, key: 'token')
                              .is_required(true))
               .query_param(new_parameter(team_id, key: 'team_id')
                             .is_required(true))
               .header_param(new_parameter('application/x-www-form-urlencoded', key: 'Content-Type'))
               .query_param(new_parameter(cursor, key: 'cursor'))
               .query_param(new_parameter(limit, key: 'limit'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('slackAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(DefaultSuccessTemplate.method(:from_hash))
                .is_api_response(true)
                .local_error('default',
                             'Typical error response',
                             DefaultErrorTemplateException))
    .execute
end

#admin_users_remove(token, team_id, user_id) ⇒ ApiResponse

Remove a user from a workspace. scope: admin.users:write workspace. remove.

Parameters:

  • token (String)

    Required parameter: Authentication token. Requires

  • team_id (String)

    Required parameter: The ID (T1234) of the

  • user_id (String)

    Required parameter: The ID of the user to

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/slack_web_api/controllers/admin_users_controller.rb', line 165

def admin_users_remove(token,
                       team_id,
                       user_id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/admin.users.remove',
                                 Server::DEFAULT)
               .header_param(new_parameter(token, key: 'token')
                              .is_required(true))
               .form_param(new_parameter(team_id, key: 'team_id')
                            .is_required(true))
               .form_param(new_parameter(user_id, key: 'user_id')
                            .is_required(true))
               .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('slackAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(DefaultSuccessTemplate.method(:from_hash))
                .is_api_response(true)
                .local_error('default',
                             'Typical error response',
                             DefaultErrorTemplateException))
    .execute
end

#admin_users_set_admin(token, team_id, user_id) ⇒ ApiResponse

Set an existing guest, regular user, or owner to be an admin user. scope: admin.users:write workspace. designate as an admin.

Parameters:

  • token (String)

    Required parameter: Authentication token. Requires

  • team_id (String)

    Required parameter: The ID (T1234) of the

  • user_id (String)

    Required parameter: The ID of the user to

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
# File 'lib/slack_web_api/controllers/admin_users_controller.rb', line 199

def admin_users_set_admin(token,
                          team_id,
                          user_id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/admin.users.setAdmin',
                                 Server::DEFAULT)
               .header_param(new_parameter(token, key: 'token')
                              .is_required(true))
               .form_param(new_parameter(team_id, key: 'team_id')
                            .is_required(true))
               .form_param(new_parameter(user_id, key: 'user_id')
                            .is_required(true))
               .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('slackAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(DefaultSuccessTemplate.method(:from_hash))
                .is_api_response(true)
                .local_error('default',
                             'Typical error response',
                             DefaultErrorTemplateException))
    .execute
end

#admin_users_set_expiration(token, team_id, user_id, expiration_ts) ⇒ ApiResponse

Set an expiration for a guest user scope: admin.users:write workspace. expiration for. account should be disabled.

Parameters:

  • token (String)

    Required parameter: Authentication token. Requires

  • team_id (String)

    Required parameter: The ID (T1234) of the

  • user_id (String)

    Required parameter: The ID of the user to set an

  • expiration_ts (Integer)

    Required parameter: Timestamp when guest

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
# File 'lib/slack_web_api/controllers/admin_users_controller.rb', line 235

def admin_users_set_expiration(token,
                               team_id,
                               user_id,
                               expiration_ts)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/admin.users.setExpiration',
                                 Server::DEFAULT)
               .header_param(new_parameter(token, key: 'token')
                              .is_required(true))
               .form_param(new_parameter(team_id, key: 'team_id')
                            .is_required(true))
               .form_param(new_parameter(user_id, key: 'user_id')
                            .is_required(true))
               .form_param(new_parameter(expiration_ts, key: 'expiration_ts')
                            .is_required(true))
               .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('slackAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(DefaultSuccessTemplate.method(:from_hash))
                .is_api_response(true)
                .local_error('default',
                             'Typical error response',
                             DefaultErrorTemplateException))
    .execute
end

#admin_users_set_owner(token, team_id, user_id) ⇒ ApiResponse

Set an existing guest, regular user, or admin user to be a workspace owner. scope: admin.users:write workspace. owner.

Parameters:

  • token (String)

    Required parameter: Authentication token. Requires

  • team_id (String)

    Required parameter: The ID (T1234) of the

  • user_id (String)

    Required parameter: Id of the user to promote to

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
# File 'lib/slack_web_api/controllers/admin_users_controller.rb', line 273

def admin_users_set_owner(token,
                          team_id,
                          user_id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/admin.users.setOwner',
                                 Server::DEFAULT)
               .header_param(new_parameter(token, key: 'token')
                              .is_required(true))
               .form_param(new_parameter(team_id, key: 'team_id')
                            .is_required(true))
               .form_param(new_parameter(user_id, key: 'user_id')
                            .is_required(true))
               .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('slackAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(DefaultSuccessTemplate.method(:from_hash))
                .is_api_response(true)
                .local_error('default',
                             'Typical error response',
                             DefaultErrorTemplateException))
    .execute
end

#admin_users_set_regular(token, team_id, user_id) ⇒ ApiResponse

Set an existing guest user, admin user, or owner to be a regular user. scope: admin.users:write workspace. designate as a regular user.

Parameters:

  • token (String)

    Required parameter: Authentication token. Requires

  • team_id (String)

    Required parameter: The ID (T1234) of the

  • user_id (String)

    Required parameter: The ID of the user to

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
# File 'lib/slack_web_api/controllers/admin_users_controller.rb', line 307

def admin_users_set_regular(token,
                            team_id,
                            user_id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/admin.users.setRegular',
                                 Server::DEFAULT)
               .header_param(new_parameter(token, key: 'token')
                              .is_required(true))
               .form_param(new_parameter(team_id, key: 'team_id')
                            .is_required(true))
               .form_param(new_parameter(user_id, key: 'user_id')
                            .is_required(true))
               .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('slackAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(DefaultSuccessTemplate.method(:from_hash))
                .is_api_response(true)
                .local_error('default',
                             'Typical error response',
                             DefaultErrorTemplateException))
    .execute
end