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

#custInt1Object

Returns the value of attribute custInt1.



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

def custInt1
  @custInt1
end

#custInt2Object

Returns the value of attribute custInt2.



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

def custInt2
  @custInt2
end

#custList1Object

Returns the value of attribute custList1.



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

def custList1
  @custList1
end

#custList2Object

Returns the value of attribute custList2.



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

def custList2
  @custList2
end

#custNotesObject

Returns the value of attribute custNotes.



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

def custNotes
  @custNotes
end

#custText1Object

Returns the value of attribute custText1.



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

def custText1
  @custText1
end

#custText2Object

Returns the value of attribute custText2.



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

def custText2
  @custText2
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

#emailNotificationsObject

Returns the value of attribute emailNotifications.



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

def emailNotifications
  @emailNotifications
end

#enableLoginToEupObject

Returns the value of attribute enableLoginToEup.



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

def enableLoginToEup
  @enableLoginToEup
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

#loginDomainObject

Returns the value of attribute loginDomain.



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

def loginDomain
  @loginDomain
end

#loginUserObject

Returns the value of attribute loginUser.



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

def loginUser
  @loginUser
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

#secondaryEmailObject

Returns the value of attribute secondaryEmail.



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

def secondaryEmail
  @secondaryEmail
end

#smsObject

Returns the value of attribute sms.



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

def sms
  @sms
end

#userManagerNameObject

Returns the value of attribute userManagerName.



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

def userManagerName
  @userManagerName
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 ticket from the SysAid server

Example:

>> ticket_object.delete
=> true


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

def delete
  response = SysAid.client.call(:delete, message: to_xml(false).to_s )
  
  #response.to_hash[:delete_response]
  
  # The SysAid API doesn't return anything on delete.
  # Think about that for a minute.
end

#refreshObject

Loads the latest user information from the SysAid server



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

def refresh
  response = SysAid.client.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


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

def save
  if SysAid.logged_in? == false
    raise "You must log in before creating or saving a user."
  end
  
  # Save it via the SOAP API
  response = SysAid.client.call(:save, message: to_xml(false).to_s )
  if response.to_hash[:save_response][:return]
    return true
  else
    return false
  end
end