Class: SlackWebApi::UsersController
- Inherits:
-
BaseController
- Object
- BaseController
- SlackWebApi::UsersController
- Defined in:
- lib/slack_web_api/controllers/users_controller.rb
Overview
UsersController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#users_conversations(token: nil, user: nil, types: nil, exclude_archived: nil, limit: nil, cursor: nil) ⇒ ApiResponse
List conversations the calling user may access.
-
#users_delete_photo(token) ⇒ ApiResponse
Delete the user profile photo scope:
users.profile:write. -
#users_get_presence(token, user: nil) ⇒ ApiResponse
Gets user presence information.
-
#users_identity(token: nil) ⇒ ApiResponse
Get a user’s identity.
-
#users_info(token, include_locale: nil, user: nil) ⇒ ApiResponse
Gets information about a user.
-
#users_list(token: nil, limit: nil, cursor: nil, include_locale: nil) ⇒ ApiResponse
Lists all users in a Slack team.
-
#users_lookup_by_email(token, email) ⇒ ApiResponse
Find a user with an email address.
-
#users_set_active(token) ⇒ ApiResponse
Marked a user as active.
-
#users_set_photo(token, crop_w: nil, crop_x: nil, crop_y: nil, image: nil) ⇒ ApiResponse
Set the user profile photo scope:
users.profile:write(always square) of crop box of crop boxmultipart/form-data. -
#users_set_presence(token, presence) ⇒ ApiResponse
Manually sets user presence.
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
#users_conversations(token: nil, user: nil, types: nil, exclude_archived: nil, limit: nil, cursor: nil) ⇒ ApiResponse
List conversations the calling user may access. scope: conversations:read specific user ID’s membership. Non-public channels are restricted to those where the calling user shares membership. providing a comma-separated list of any combination of public_channel, private_channel, mpim, im to true to exclude archived channels from the list return. Fewer than the requested number of items may be returned, even if the end of the list hasn’t been reached. Must be an integer no larger than 1000. data by setting the cursor parameter to a next_cursor attribute returned by a previous request’s response_metadata. Default value fetches the first “page” of the collection. See [pagination](/docs/pagination) for more detail.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/slack_web_api/controllers/users_controller.rb', line 30 def users_conversations(token: nil, user: nil, types: nil, exclude_archived: nil, limit: nil, cursor: nil) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/users.conversations', Server::DEFAULT) .header_param(new_parameter('application/x-www-form-urlencoded', key: 'Content-Type')) .query_param(new_parameter(token, key: 'token')) .query_param(new_parameter(user, key: 'user')) .query_param(new_parameter(types, key: 'types')) .query_param(new_parameter(exclude_archived, key: 'exclude_archived')) .query_param(new_parameter(limit, key: 'limit')) .query_param(new_parameter(cursor, key: 'cursor')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('slackAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(UsersConversationsSuccessSchema.method(:from_hash)) .is_api_response(true) .local_error('default', 'Typical error response', UsersConversationsErrorSchemaException)) .execute end |
#users_delete_photo(token) ⇒ ApiResponse
Delete the user profile photo scope: users.profile:write
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/slack_web_api/controllers/users_controller.rb', line 63 def users_delete_photo(token) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/users.deletePhoto', Server::DEFAULT) .form_param(new_parameter(token, key: 'token') .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(UsersDeletePhotoSchema.method(:from_hash)) .is_api_response(true) .local_error('default', 'Typical error response', UsersDeletePhotoErrorSchemaException)) .execute end |
#users_get_presence(token, user: nil) ⇒ ApiResponse
Gets user presence information. scope: users:read Defaults to the authed user.
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/slack_web_api/controllers/users_controller.rb', line 89 def users_get_presence(token, user: nil) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/users.getPresence', Server::DEFAULT) .query_param(new_parameter(token, key: 'token') .is_required(true)) .header_param(new_parameter('application/x-www-form-urlencoded', key: 'Content-Type')) .query_param(new_parameter(user, key: 'user')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('slackAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(ApiMethodUsersGetPresence.method(:from_hash)) .is_api_response(true) .local_error('default', 'Typical error response', UsersCountsErrorSchemaException)) .execute end |
#users_identity(token: nil) ⇒ ApiResponse
Get a user’s identity. scope: identity.basic
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/slack_web_api/controllers/users_controller.rb', line 115 def users_identity(token: nil) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/users.identity', Server::DEFAULT) .header_param(new_parameter('application/x-www-form-urlencoded', key: 'Content-Type')) .query_param(new_parameter(token, key: 'token')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('slackAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:dynamic_deserializer)) .is_api_response(true) .local_error('default', 'Typical error response', UsersIdentityErrorSchemaException)) .execute end |
#users_info(token, include_locale: nil, user: nil) ⇒ ApiResponse
Gets information about a user. scope: users:read this to true to receive the locale for this user. Defaults to false
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/slack_web_api/controllers/users_controller.rb', line 140 def users_info(token, include_locale: nil, user: nil) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/users.info', Server::DEFAULT) .query_param(new_parameter(token, key: 'token') .is_required(true)) .header_param(new_parameter('application/x-www-form-urlencoded', key: 'Content-Type')) .query_param(new_parameter(include_locale, key: 'include_locale')) .query_param(new_parameter(user, key: 'user')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('slackAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(UsersInfoSuccessSchema.method(:from_hash)) .is_api_response(true) .local_error('default', 'Typical error response', UsersInfoErrorSchemaException)) .execute end |
#users_list(token: nil, limit: nil, cursor: nil, include_locale: nil) ⇒ ApiResponse
Lists all users in a Slack team. scope: users:read return. Fewer than the requested number of items may be returned, even if the end of the users list hasn’t been reached. Providing no limit value will result in Slack attempting to deliver you the entire result set. If the collection is too large you may experience limit_required or HTTP 500 errors. data by setting the cursor parameter to a next_cursor attribute returned by a previous request’s response_metadata. Default value fetches the first “page” of the collection. See [pagination](/docs/pagination) for more detail. this to true to receive the locale for users. Defaults to false
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/slack_web_api/controllers/users_controller.rb', line 181 def users_list(token: nil, limit: nil, cursor: nil, include_locale: nil) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/users.list', Server::DEFAULT) .header_param(new_parameter('application/x-www-form-urlencoded', key: 'Content-Type')) .query_param(new_parameter(token, key: 'token')) .query_param(new_parameter(limit, key: 'limit')) .query_param(new_parameter(cursor, key: 'cursor')) .query_param(new_parameter(include_locale, key: 'include_locale')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('slackAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(UsersListSchema.method(:from_hash)) .is_api_response(true) .local_error('default', 'Typical error response', UsersListErrorSchemaException)) .execute end |
#users_lookup_by_email(token, email) ⇒ ApiResponse
Find a user with an email address. scope: users:read.email user in the workspace
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
# File 'lib/slack_web_api/controllers/users_controller.rb', line 212 def users_lookup_by_email(token, email) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/users.lookupByEmail', Server::DEFAULT) .query_param(new_parameter(token, key: 'token') .is_required(true)) .query_param(new_parameter(email, key: 'email') .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(UsersLookupByEmailSuccessSchema.method(:from_hash)) .is_api_response(true) .local_error('default', 'Typical error response', UsersLookupByEmailErrorSchemaException)) .execute end |
#users_set_active(token) ⇒ ApiResponse
Marked a user as active. Deprecated and non-functional. scope: users:write
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
# File 'lib/slack_web_api/controllers/users_controller.rb', line 239 def users_set_active(token) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/users.setActive', Server::DEFAULT) .header_param(new_parameter(token, key: 'token') .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(UsersSetActiveSchema.method(:from_hash)) .is_api_response(true) .local_error('default', 'Typical error response', UsersSetActiveErrorSchemaException)) .execute end |
#users_set_photo(token, crop_w: nil, crop_x: nil, crop_y: nil, image: nil) ⇒ ApiResponse
Set the user profile photo scope: users.profile:write (always square) of crop box of crop box multipart/form-data.
271 272 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/users_controller.rb', line 271 def users_set_photo(token, crop_w: nil, crop_x: nil, crop_y: nil, image: nil) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/users.setPhoto', Server::DEFAULT) .form_param(new_parameter(token, key: 'token') .is_required(true)) .form_param(new_parameter(crop_w, key: 'crop_w')) .form_param(new_parameter(crop_x, key: 'crop_x')) .form_param(new_parameter(crop_y, key: 'crop_y')) .form_param(new_parameter(image, key: 'image')) .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(UsersSetPhotoSchema.method(:from_hash)) .is_api_response(true) .local_error('default', 'Typical error response', UsersSetPhotoErrorSchemaException)) .execute end |
#users_set_presence(token, presence) ⇒ ApiResponse
Manually sets user presence. scope: users:write
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 |
# File 'lib/slack_web_api/controllers/users_controller.rb', line 304 def users_set_presence(token, presence) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/users.setPresence', Server::DEFAULT) .header_param(new_parameter(token, key: 'token') .is_required(true)) .form_param(new_parameter(presence, key: 'presence') .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(UsersSetPresenceSchema.method(:from_hash)) .is_api_response(true) .local_error('default', 'Typical error response', UsersSetPresenceErrorSchemaException)) .execute end |