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

This method helps answer questions like:

  • Which conversations am I a member of?

  • Which public channels is my bot user in?

  • Do I have any direct messages open with my friend Suzy?

  • Is my bot a member of any private channels?

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :cursor (Object)

    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 (Object)

    Set to true to exclude archived channels from the list.

  • :limit (Object)

    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 no larger than 1000.

  • :types (Object)

    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:



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

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

This method allows the user to delete their profile image. It will clear whatever image is currently set.



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

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

#users_getPresence(options = {}) ⇒ Object

This method lets you find out information about a user’s presence. Consult the presence documentation for more details.

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:



55
56
57
58
59
# File 'lib/slack/web/api/endpoints/users.rb', line 55

def users_getPresence(options = {})
  throw ArgumentError.new('Required arguments :user missing') if options[:user].nil?
  options = options.merge(user: users_id(options)['user']['id']) if options[:user]
  post('users.getPresence', options)
end

#users_identity(options = {}) ⇒ Object

After your Slack app is awarded an identity token through Sign in with Slack, use this method to retrieve a user’s identity.



66
67
68
# File 'lib/slack/web/api/endpoints/users.rb', line 66

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

#users_info(options = {}) ⇒ Object

This method returns information about a member of a workspace.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :user (user)

    User to get info on.

  • :include_locale (Object)

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

See Also:



79
80
81
82
83
# File 'lib/slack/web/api/endpoints/users.rb', line 79

def users_info(options = {})
  throw ArgumentError.new('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

This method returns a list of all users in the workspace. This includes deleted/deactivated users.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :cursor (Object)

    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 (Object)

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

  • :limit (Object)

    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.

See Also:



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

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

Retrieve a single user by looking them up by their registered email address. Requires users:read.email.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :email (Object)

    An email address belonging to a user in the workspace.

See Also:



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

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

#users_setActive(options = {}) ⇒ Object

This method is no longer functional and the behavior it controlled is no longer offered. The method will no longer exist beginning May 8, 2018.



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

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

#users_setPhoto(options = {}) ⇒ Object

This method allows the user to set their profile image. The caller can pass image data via image.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :image (Object)

    File contents via multipart/form-data.

  • :crop_w (Object)

    Width/height of crop box (always square).

  • :crop_x (Object)

    X coordinate of top-left corner of crop box.

  • :crop_y (Object)

    Y coordinate of top-left corner of crop box.

See Also:



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

def users_setPhoto(options = {})
  throw ArgumentError.new('Required arguments :image missing') if options[:image].nil?
  post('users.setPhoto', options)
end

#users_setPresence(options = {}) ⇒ Object

This method lets you set the calling user’s manual presence. Consult the presence documentation for more details.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :presence (Object)

    Either auto or away.

See Also:



153
154
155
156
# File 'lib/slack/web/api/endpoints/users.rb', line 153

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