Class: AdobeConnect::User

Inherits:
Base
  • Object
show all
Defined in:
lib/adobe_connect/user.rb

Overview

Public: Represents a user in a Connect environment.

Instance Attribute Summary collapse

Attributes inherited from Base

#errors, #id, #service

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#ac_obj_node_name, #ac_obj_type, config, create, #delete, #delete_method_prefix, #method_prefix, #permissions_update, #save, #save_errors, #set_attrs, #update_attributes

Constructor Details

#initializeUser

Returns a new instance of User.



8
9
10
11
12
# File 'lib/adobe_connect/user.rb', line 8

def initialize(*)
  super
  # Silence a warning about uninitialized instance variable.
  @username = nil
end

Instance Attribute Details

#emailObject

Returns the value of attribute email.



5
6
7
# File 'lib/adobe_connect/user.rb', line 5

def email
  @email
end

#first_nameObject

Returns the value of attribute first_name.



5
6
7
# File 'lib/adobe_connect/user.rb', line 5

def first_name
  @first_name
end

#last_nameObject

Returns the value of attribute last_name.



5
6
7
# File 'lib/adobe_connect/user.rb', line 5

def last_name
  @last_name
end

#send_emailObject

Returns the value of attribute send_email.



5
6
7
# File 'lib/adobe_connect/user.rb', line 5

def send_email
  @send_email
end

#usernameObject

Public: Getter for the Connect user’s username. If no username is

given, use the email.

Returns a username string.



46
47
48
# File 'lib/adobe_connect/user.rb', line 46

def username
  @username || email
end

#uuidObject

Returns the value of attribute uuid.



5
6
7
# File 'lib/adobe_connect/user.rb', line 5

def uuid
  @uuid
end

Class Method Details

.find(user_options) ⇒ Object

Public: Find the given app user on the Connect server.

app_user - Generic user options (see #initialize for required

attributes).

Returns an AdobeConnect::User or nil.



63
64
65
66
67
68
69
70
71
# File 'lib/adobe_connect/user.rb', line 63

def self.find(user_options)
  user     = AdobeConnect::User.new(user_options)
  response = user.service.principal_list(:filter_login => user.username)

  if principal = response.at_xpath('//principal')
    user.instance_variable_set(:@id, principal.attr('principal-id'))
    user
  end
end

Instance Method Details

#attrsObject

user_options - A hash with the following keys:

first_name - User's first name.
last_name  - User's last name.
email      - The email address for the user.
username   - The login for the connect user.
uuid       - A unique identifier for this user (used to
             generate a password).
send_email - The server sends a welcome e-mail with login information
             to the user’s e-mail address.


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/adobe_connect/user.rb', line 26

def attrs
  atrs = { :first_name => first_name,
    :last_name => last_name, :login => username,
    :email => email, :has_children => 0 }
  atrs[:send_email] = send_email unless send_email.nil?
  if !self.id.nil?
    atrs.merge!(:principal_id => self.id)
  else
    atrs.merge!(
      :password => password,
      :type => 'user'
    )
  end
  atrs
end

#passwordObject

Public: Generate a password for this connect user.

Returns a password string.



53
54
55
# File 'lib/adobe_connect/user.rb', line 53

def password
  Digest::MD5.hexdigest(uuid)[0..9]
end