Module: Slack::Web::Api::Endpoints::Users

Included in:
Slack::Web::Api::Endpoints
Defined in:
lib/slack/web/api/endpoints/users.rb

Instance Method Summary collapse

Instance Method Details

#users_conversations(options = {}) ⇒ Object

List conversations the calling user may access.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :cursor (string)

    Paginate through collections of 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 for more detail.

  • :exclude_archived (boolean)

    Set to true to exclude archived channels from the list.

  • :limit (number)

    The maximum number of items to 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 with a max value of 999.

  • :team_id (string)

    encoded team id to list conversations in, required if org token is used.

  • :types (string)

    Mix and match channel types by providing a comma-separated list of any combination of public_channel, private_channel, mpim, im.

  • :user (user)

    Browse conversations by a specific user ID’s membership. Non-public channels are restricted to those where the calling user shares membership.

See Also:



26
27
28
29
30
31
32
33
34
35
# File 'lib/slack/web/api/endpoints/users.rb', line 26

def users_conversations(options = {})
  options = options.merge(user: users_id(options)['user']['id']) if options[:user]
  if block_given?
    Pagination::Cursor.new(self, :users_conversations, options).each do |page|
      yield page
    end
  else
    post('users.conversations', options)
  end
end

#users_deletePhoto(options = {}) ⇒ Object

Delete the user profile photo



42
43
44
# File 'lib/slack/web/api/endpoints/users.rb', line 42

def users_deletePhoto(options = {})
  post('users.deletePhoto', options)
end

#users_getPresence(options = {}) ⇒ Object

Gets user presence information.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :user (user)

    User to get presence info on. Defaults to the authed user.

See Also:



53
54
55
56
# File 'lib/slack/web/api/endpoints/users.rb', line 53

def users_getPresence(options = {})
  options = options.merge(user: users_id(options)['user']['id']) if options[:user]
  post('users.getPresence', options)
end

#users_identity(options = {}) ⇒ Object

Get a user’s identity.



63
64
65
# File 'lib/slack/web/api/endpoints/users.rb', line 63

def users_identity(options = {})
  post('users.identity', options)
end

#users_info(options = {}) ⇒ Object

Gets information about a user.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :user (user)

    User to get info on.

  • :include_locale (boolean)

    Set this to true to receive the locale for this user. Defaults to false.

Raises:

  • (ArgumentError)

See Also:



76
77
78
79
80
# File 'lib/slack/web/api/endpoints/users.rb', line 76

def users_info(options = {})
  raise ArgumentError, 'Required arguments :user missing' if options[:user].nil?
  options = options.merge(user: users_id(options)['user']['id']) if options[:user]
  post('users.info', options)
end

#users_list(options = {}) ⇒ Object

Lists all users in a Slack team.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :cursor (string)

    Paginate through collections of 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 for more detail.

  • :include_locale (boolean)

    Set this to true to receive the locale for users. Defaults to false.

  • :limit (number)

    The maximum number of items to 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.

  • :team_id (string)

    encoded team id to list users in, required if org token is used.

See Also:



95
96
97
98
99
100
101
102
103
# File 'lib/slack/web/api/endpoints/users.rb', line 95

def users_list(options = {})
  if block_given?
    Pagination::Cursor.new(self, :users_list, options).each do |page|
      yield page
    end
  else
    post('users.list', options)
  end
end

#users_lookupByEmail(options = {}) ⇒ Object

Find a user with an email address.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :email (string)

    An email address belonging to a user in the workspace.

Raises:

  • (ArgumentError)

See Also:



112
113
114
115
# File 'lib/slack/web/api/endpoints/users.rb', line 112

def users_lookupByEmail(options = {})
  raise ArgumentError, 'Required arguments :email missing' if options[:email].nil?
  post('users.lookupByEmail', options)
end

#users_setActive(options = {}) ⇒ Object

Marked a user as active. Deprecated and non-functional.



122
123
124
# File 'lib/slack/web/api/endpoints/users.rb', line 122

def users_setActive(options = {})
  post('users.setActive', options)
end

#users_setPhoto(options = {}) ⇒ Object

Set the user profile photo

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :crop_w (string)

    Width/height of crop box (always square).

  • :crop_x (string)

    X coordinate of top-left corner of crop box.

  • :crop_y (string)

    Y coordinate of top-left corner of crop box.

  • :image (Object)

    File contents via multipart/form-data.

See Also:



139
140
141
# File 'lib/slack/web/api/endpoints/users.rb', line 139

def users_setPhoto(options = {})
  post('users.setPhoto', options)
end

#users_setPresence(options = {}) ⇒ Object

Manually sets user presence.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :presence (enum)

    Either auto or away.

Raises:

  • (ArgumentError)

See Also:



150
151
152
153
# File 'lib/slack/web/api/endpoints/users.rb', line 150

def users_setPresence(options = {})
  raise ArgumentError, 'Required arguments :presence missing' if options[:presence].nil?
  post('users.setPresence', options)
end