dblock/slack-ruby-client

View on GitHub
lib/slack/web/api/endpoints/users.rb

Summary

Maintainability
A
1 hr
Test Coverage
# frozen_string_literal: true
# This file was auto-generated by lib/tasks/web.rake

module Slack
  module Web
    module Api
      module Endpoints
        module Users
          #
          # List conversations the calling user may access.
          #
          # @option options [string] :cursor
          #   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.
          # @option options [boolean] :exclude_archived
          #   Set to true to exclude archived channels from the list.
          # @option options [number] :limit
          #   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.
          # @option options [string] :team_id
          #   encoded team id to list conversations in, required if org token is used.
          # @option options [string] :types
          #   Mix and match channel types by providing a comma-separated list of any combination of public_channel, private_channel, mpim, im.
          # @option options [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 https://api.slack.com/methods/users.conversations
          # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/users/users.conversations.json
          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

          #
          # Delete the user profile photo
          #
          # @see https://api.slack.com/methods/users.deletePhoto
          # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/users/users.deletePhoto.json
          def users_deletePhoto(options = {})
            post('users.deletePhoto', options)
          end

          #
          # Gets user presence information.
          #
          # @option options [user] :user
          #   User to get presence info on. Defaults to the authed user.
          # @see https://api.slack.com/methods/users.getPresence
          # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/users/users.getPresence.json
          def users_getPresence(options = {})
            options = options.merge(user: users_id(options)['user']['id']) if options[:user]
            post('users.getPresence', options)
          end

          #
          # Get a user's identity.
          #
          # @see https://api.slack.com/methods/users.identity
          # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/users/users.identity.json
          def users_identity(options = {})
            post('users.identity', options)
          end

          #
          # Gets information about a user.
          #
          # @option options [user] :user
          #   User to get info on.
          # @option options [boolean] :include_locale
          #   Set this to true to receive the locale for this user. Defaults to false.
          # @see https://api.slack.com/methods/users.info
          # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/users/users.info.json
          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

          #
          # Lists all users in a Slack team.
          #
          # @option options [string] :cursor
          #   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.
          # @option options [boolean] :include_locale
          #   Set this to true to receive the locale for users. Defaults to false.
          # @option options [number] :limit
          #   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.
          # @option options [string] :team_id
          #   encoded team id to list users in, required if org token is used.
          # @see https://api.slack.com/methods/users.list
          # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/users/users.list.json
          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

          #
          # Find a user with an email address.
          #
          # @option options [string] :email
          #   An email address belonging to a user in the workspace.
          # @see https://api.slack.com/methods/users.lookupByEmail
          # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/users/users.lookupByEmail.json
          def users_lookupByEmail(options = {})
            raise ArgumentError, 'Required arguments :email missing' if options[:email].nil?
            post('users.lookupByEmail', options)
          end

          #
          # Marked a user as active. Deprecated and non-functional.
          #
          # @see https://api.slack.com/methods/users.setActive
          # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/users/users.setActive.json
          def users_setActive(options = {})
            post('users.setActive', options)
          end

          #
          # Set the user profile photo
          #
          # @option options [string] :crop_w
          #   Width/height of crop box (always square).
          # @option options [string] :crop_x
          #   X coordinate of top-left corner of crop box.
          # @option options [string] :crop_y
          #   Y coordinate of top-left corner of crop box.
          # @option options [Object] :image
          #   File contents via multipart/form-data.
          # @see https://api.slack.com/methods/users.setPhoto
          # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/users/users.setPhoto.json
          def users_setPhoto(options = {})
            post('users.setPhoto', options)
          end

          #
          # Manually sets user presence.
          #
          # @option options [string] :presence
          #   Either auto or away.
          # @see https://api.slack.com/methods/users.setPresence
          # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/users/users.setPresence.json
          def users_setPresence(options = {})
            raise ArgumentError, 'Required arguments :presence missing' if options[:presence].nil?
            post('users.setPresence', options)
          end
        end
      end
    end
  end
end