Class: SysAid::User

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username = nil) ⇒ User

Creates a SysAid::User object

Example:

>> SysAid::User.new
=> SysAid::User

Arguments:

username: (SysAid username, optional)


15
16
17
# File 'lib/sysaid/user.rb', line 15

def initialize(username = nil)
  self.username = username
end

Instance Attribute Details

#adminObject

Returns the value of attribute admin.



2
3
4
# File 'lib/sysaid/user.rb', line 2

def admin
  @admin
end

#agreementObject

Returns the value of attribute agreement.



2
3
4
# File 'lib/sysaid/user.rb', line 2

def agreement
  @agreement
end

#buildingObject

Returns the value of attribute building.



2
3
4
# File 'lib/sysaid/user.rb', line 2

def building
  @building
end

#car_numberObject

Returns the value of attribute car_number.



2
3
4
# File 'lib/sysaid/user.rb', line 2

def car_number
  @car_number
end

#cellphoneObject

Returns the value of attribute cellphone.



2
3
4
# File 'lib/sysaid/user.rb', line 2

def cellphone
  @cellphone
end

#companyObject

Returns the value of attribute company.



2
3
4
# File 'lib/sysaid/user.rb', line 2

def company
  @company
end

#cubicObject

Returns the value of attribute cubic.



2
3
4
# File 'lib/sysaid/user.rb', line 2

def cubic
  @cubic
end

#cust_int1Object

Returns the value of attribute cust_int1.



2
3
4
# File 'lib/sysaid/user.rb', line 2

def cust_int1
  @cust_int1
end

#cust_int2Object

Returns the value of attribute cust_int2.



2
3
4
# File 'lib/sysaid/user.rb', line 2

def cust_int2
  @cust_int2
end

#cust_list1Object

Returns the value of attribute cust_list1.



2
3
4
# File 'lib/sysaid/user.rb', line 2

def cust_list1
  @cust_list1
end

#cust_list2Object

Returns the value of attribute cust_list2.



2
3
4
# File 'lib/sysaid/user.rb', line 2

def cust_list2
  @cust_list2
end

#cust_notesObject

Returns the value of attribute cust_notes.



2
3
4
# File 'lib/sysaid/user.rb', line 2

def cust_notes
  @cust_notes
end

#cust_text1Object

Returns the value of attribute cust_text1.



2
3
4
# File 'lib/sysaid/user.rb', line 2

def cust_text1
  @cust_text1
end

#cust_text2Object

Returns the value of attribute cust_text2.



2
3
4
# File 'lib/sysaid/user.rb', line 2

def cust_text2
  @cust_text2
end

#departmentObject

Returns the value of attribute department.



2
3
4
# File 'lib/sysaid/user.rb', line 2

def department
  @department
end

#disableObject

Returns the value of attribute disable.



2
3
4
# File 'lib/sysaid/user.rb', line 2

def disable
  @disable
end

#display_nameObject

Returns the value of attribute display_name.



2
3
4
# File 'lib/sysaid/user.rb', line 2

def display_name
  @display_name
end

#emailObject

Returns the value of attribute email.



2
3
4
# File 'lib/sysaid/user.rb', line 2

def email
  @email
end

#email_notificationsObject

Returns the value of attribute email_notifications.



2
3
4
# File 'lib/sysaid/user.rb', line 2

def email_notifications
  @email_notifications
end

#enable_login_to_eupObject

Returns the value of attribute enable_login_to_eup.



2
3
4
# File 'lib/sysaid/user.rb', line 2

def 
  @enable_login_to_eup
end

#first_nameObject

Returns the value of attribute first_name.



2
3
4
# File 'lib/sysaid/user.rb', line 2

def first_name
  @first_name
end

#floorObject

Returns the value of attribute floor.



2
3
4
# File 'lib/sysaid/user.rb', line 2

def floor
  @floor
end

#last_nameObject

Returns the value of attribute last_name.



2
3
4
# File 'lib/sysaid/user.rb', line 2

def last_name
  @last_name
end

#locationObject

Returns the value of attribute location.



2
3
4
# File 'lib/sysaid/user.rb', line 2

def location
  @location
end

#login_domainObject

Returns the value of attribute login_domain.



2
3
4
# File 'lib/sysaid/user.rb', line 2

def 
  @login_domain
end

#login_userObject

Returns the value of attribute login_user.



2
3
4
# File 'lib/sysaid/user.rb', line 2

def 
  @login_user
end

#managerObject

Returns the value of attribute manager.



2
3
4
# File 'lib/sysaid/user.rb', line 2

def manager
  @manager
end

#notesObject

Returns the value of attribute notes.



2
3
4
# File 'lib/sysaid/user.rb', line 2

def notes
  @notes
end

#phoneObject

Returns the value of attribute phone.



2
3
4
# File 'lib/sysaid/user.rb', line 2

def phone
  @phone
end

#secondary_emailObject

Returns the value of attribute secondary_email.



2
3
4
# File 'lib/sysaid/user.rb', line 2

def secondary_email
  @secondary_email
end

#smsObject

Returns the value of attribute sms.



2
3
4
# File 'lib/sysaid/user.rb', line 2

def sms
  @sms
end

#user_manager_nameObject

Returns the value of attribute user_manager_name.



2
3
4
# File 'lib/sysaid/user.rb', line 2

def user_manager_name
  @user_manager_name
end

#usernameObject

Returns the value of attribute username.



2
3
4
# File 'lib/sysaid/user.rb', line 2

def username
  @username
end

Class Method Details

.find_by_username(username) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/sysaid/user.rb', line 19

def self.find_by_username(username)
  user = SysAid::User.new(username)

  return nil unless user.refresh

  return user
end

Instance Method Details

#deleteObject

Deletes a user from the SysAid server

Example:

>> user_object.delete
=> nil


62
63
64
65
66
# File 'lib/sysaid/user.rb', line 62

def delete
  SysAid.ensure_logged_in

  SysAid.call(:delete, message: to_xml(false).to_s )
end

#refreshObject

Loads the latest user information from the SysAid server



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/sysaid/user.rb', line 28

def refresh
  SysAid.ensure_logged_in

  response = SysAid.call(:load_by_string_id, message: to_xml.to_s )
  if response.to_hash[:load_by_string_id_response][:return]
    set_self_from_response(response.to_hash[:load_by_string_id_response][:return])
    return true
  end

  return false
end

#saveObject

Saves a user back to the SysAid server

Example:

>> user_object.save
=> true


45
46
47
48
49
50
51
52
53
54
55
# File 'lib/sysaid/user.rb', line 45

def save
  SysAid.ensure_logged_in

  # Save it via the SOAP API
  response = SysAid.call(:save, message: to_xml(false).to_s )
  if response.to_hash[:save_response][:return]
    return true
  else
    return false
  end
end