class SlackMsgr::Users

Handles all users functionality and methods corresponding with Slack API

Constants

PERMITTED_ARGUMENTS
REQUIRED_ARGUMENTS
USERS_METHODS

Attributes

body[R]
method[R]
opts[R]

Public Class Methods

call(method, opts = {}) click to toggle source
# File lib/slack_msgr/users.rb, line 25
def call(method, opts = {})
  users = new(method, opts)
  send_legacy_request_to_slack(users)
end
new(methods, opts) click to toggle source
# File lib/slack_msgr/users.rb, line 35
def initialize(methods, opts)
  users_method = methods.map do |method|
    ErrorHandling.raise(:unknown_method, method: method) unless USERS_METHODS[method]

    USERS_METHODS[method]
  end.join('.')

  @method = "users.#{users_method}"
  @opts   = opts
  @body   = sanitize_body
end

Private Instance Methods

req_args_missing?() click to toggle source
# File lib/slack_msgr/users.rb, line 58
def req_args_missing?
  !(REQUIRED_ARGUMENTS - opts.keys).empty?
end
sanitize_body() click to toggle source
# File lib/slack_msgr/users.rb, line 49
def sanitize_body
  ErrorHandling.raise(:req_args_missing, req_args: REQUIRED_ARGUMENTS, method: method) if req_args_missing?

  opts.merge!(token).keys.each_with_object({}) do |key, body|
    body[key] ||= opts[key] if PERMITTED_ARGUMENTS.include?(key)
    body
  end
end
token() click to toggle source
# File lib/slack_msgr/users.rb, line 62
def token
  { token: SlackMsgr.configuration.legacy_token }
end