Class: SlackWebApi::UsersProfileController

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

Overview

UsersProfileController

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

#users_profile_get(token, include_labels: nil, user: nil) ⇒ ApiResponse

Retrieves a user’s profile information. scope: users.profile:read labels for each ID in custom profile fields for

Parameters:

  • token (String)

    Required parameter: Authentication token. Requires

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

    Optional parameter: Include

  • user (String) (defaults to: nil)

    Optional parameter: User to retrieve profile info

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/slack_web_api/controllers/users_profile_controller.rb', line 17

def users_profile_get(token,
                      include_labels: nil,
                      user: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/users.profile.get',
                                 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_labels, key: 'include_labels'))
               .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(UsersProfileGetSchema.method(:from_hash))
                .is_api_response(true)
                .local_error('default',
                             'Typical error response',
                             UsersProfileGetErrorSchemaException))
    .execute
end

#users_profile_set(token, name: nil, profile: nil, user: nil, value: nil) ⇒ ApiResponse

Set the profile information for a user. scope: users.profile:write Usable only if profile is not passed. presented as a URL-encoded JSON hash. At most 50 fields may be set. Each field name is limited to 255 characters. argument may only be specified by team admins on paid teams. Usable only if profile is not passed.

Parameters:

  • token (String)

    Required parameter: Authentication token. Requires

  • name (String) (defaults to: nil)

    Optional parameter: Name of a single key to set.

  • profile (String) (defaults to: nil)

    Optional parameter: Collection of key:value pairs

  • user (String) (defaults to: nil)

    Optional parameter: ID of user to change. This

  • value (String) (defaults to: nil)

    Optional parameter: Value to set a single key to.

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/slack_web_api/controllers/users_profile_controller.rb', line 54

def users_profile_set(token,
                      name: nil,
                      profile: nil,
                      user: nil,
                      value: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/users.profile.set',
                                 Server::DEFAULT)
               .header_param(new_parameter(token, key: 'token')
                              .is_required(true))
               .form_param(new_parameter(name, key: 'name'))
               .form_param(new_parameter(profile, key: 'profile'))
               .form_param(new_parameter(user, key: 'user'))
               .form_param(new_parameter(value, key: 'value'))
               .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(UsersProfileSetSchema.method(:from_hash))
                .is_api_response(true)
                .local_error('default',
                             'Typical error response',
                             UsersProfileSetErrorSchemaException))
    .execute
end