Class: SlackMsgr::Users

Inherits:
SlackMethod show all
Defined in:
lib/slack_msgr/users.rb

Overview

Handles all users functionality and methods corresponding with Slack API

Constant Summary collapse

USERS_METHODS =
{
  admin: 'admin',
  invite: 'invite'
}.freeze
REQUIRED_ARGUMENTS =
%i[email].freeze
PERMITTED_ARGUMENTS =
%i[
  token
  email
  channels
  real_name
  resend
  restricted
  ultra_restricted
  expiration_ts
].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(methods, opts) ⇒ Users

Returns a new instance of Users.



35
36
37
38
39
40
41
42
43
44
45
# 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

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



31
32
33
# File 'lib/slack_msgr/users.rb', line 31

def body
  @body
end

#methodObject (readonly)

Returns the value of attribute method.



31
32
33
# File 'lib/slack_msgr/users.rb', line 31

def method
  @method
end

#optsObject (readonly)

Returns the value of attribute opts.



31
32
33
# File 'lib/slack_msgr/users.rb', line 31

def opts
  @opts
end

Class Method Details

.call(method, opts = {}) ⇒ Object



25
26
27
28
# File 'lib/slack_msgr/users.rb', line 25

def call(method, opts = {})
  users = new(method, opts)
  send_legacy_request_to_slack(users)
end