Class: SysAid::Ticket

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTicket

Returns a new instance of Ticket.



12
13
14
# File 'lib/sysaid/ticket.rb', line 12

def initialize
  reset_all_attributes
end

Instance Attribute Details

#agreementObject

Returns the value of attribute agreement.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def agreement
  @agreement
end

#archiveObject

Returns the value of attribute archive.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def archive
  @archive
end

#assign_counterObject

Returns the value of attribute assign_counter.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def assign_counter
  @assign_counter
end

#assigned_groupObject

Returns the value of attribute assigned_group.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def assigned_group
  @assigned_group
end

#assigned_toObject

Returns the value of attribute assigned_to.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def assigned_to
  @assigned_to
end

#categoryObject

Returns the value of attribute category.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def category
  @category
end

#ccObject

Returns the value of attribute cc.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def cc
  @cc
end

#change_categoryObject

Returns the value of attribute change_category.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def change_category
  @change_category
end

#ciidObject

Returns the value of attribute ciid.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def ciid
  @ciid
end

#close_timeObject

Returns the value of attribute close_time.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def close_time
  @close_time
end

#closure_informationObject

Returns the value of attribute closure_information.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def closure_information
  @closure_information
end

#computer_idObject

Returns the value of attribute computer_id.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def computer_id
  @computer_id
end

#current_support_levelObject

Returns the value of attribute current_support_level.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def current_support_level
  @current_support_level
end

#cust_int1Object

Returns the value of attribute cust_int1.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def cust_int1
  @cust_int1
end

#cust_int2Object

Returns the value of attribute cust_int2.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def cust_int2
  @cust_int2
end

#cust_list1Object

Returns the value of attribute cust_list1.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def cust_list1
  @cust_list1
end

#cust_list2Object

Returns the value of attribute cust_list2.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def cust_list2
  @cust_list2
end

#cust_notesObject

Returns the value of attribute cust_notes.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def cust_notes
  @cust_notes
end

#cust_text1Object

Returns the value of attribute cust_text1.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def cust_text1
  @cust_text1
end

#cust_text2Object

Returns the value of attribute cust_text2.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def cust_text2
  @cust_text2
end

#descriptionObject

Returns the value of attribute description.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def description
  @description
end

#email_accountObject

Returns the value of attribute email_account.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def 
  @email_account
end

#escalationObject

Returns the value of attribute escalation.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def escalation
  @escalation
end

#followup_textObject

Returns the value of attribute followup_text.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def followup_text
  @followup_text
end

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def id
  @id
end

#impactObject

Returns the value of attribute impact.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def impact
  @impact
end

#insert_timeObject

Returns the value of attribute insert_time.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def insert_time
  @insert_time
end

#locationObject

Returns the value of attribute location.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def location
  @location
end

#max_support_levelObject

Returns the value of attribute max_support_level.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def max_support_level
  @max_support_level
end

#notesObject

Returns the value of attribute notes.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def notes
  @notes
end

Returns the value of attribute parent_link.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def parent_link
  @parent_link
end

#priorityObject

Returns the value of attribute priority.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def priority
  @priority
end

#project_idObject

Returns the value of attribute project_id.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def project_id
  @project_id
end

#reopen_counterObject

Returns the value of attribute reopen_counter.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def reopen_counter
  @reopen_counter
end

#request_userObject

Returns the value of attribute request_user.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def request_user
  @request_user
end

#resolutionObject

Returns the value of attribute resolution.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def resolution
  @resolution
end

#solutionObject

Returns the value of attribute solution.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def solution
  @solution
end

#sourceObject

Returns the value of attribute source.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def source
  @source
end

#sr_sub_typeObject

Returns the value of attribute sr_sub_type.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def sr_sub_type
  @sr_sub_type
end

#sr_typeObject

Returns the value of attribute sr_type.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def sr_type
  @sr_type
end

#statusObject

Returns the value of attribute status.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def status
  @status
end

#sub_categoryObject

Returns the value of attribute sub_category.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def sub_category
  @sub_category
end

#submit_userObject

Returns the value of attribute submit_user.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def submit_user
  @submit_user
end

#success_ratingObject

Returns the value of attribute success_rating.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def success_rating
  @success_rating
end

#task_idObject

Returns the value of attribute task_id.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def task_id
  @task_id
end

#third_level_categoryObject

Returns the value of attribute third_level_category.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def third_level_category
  @third_level_category
end

#titleObject

Returns the value of attribute title.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def title
  @title
end

#update_timeObject

Returns the value of attribute update_time.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def update_time
  @update_time
end

#update_userObject

Returns the value of attribute update_user.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def update_user
  @update_user
end

#urgencyObject

Returns the value of attribute urgency.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def urgency
  @urgency
end

#user_managerObject

Returns the value of attribute user_manager.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def user_manager
  @user_manager
end

#versionObject

Returns the value of attribute version.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def version
  @version
end

#workaroundObject

Returns the value of attribute workaround.



4
5
6
# File 'lib/sysaid/ticket.rb', line 4

def workaround
  @workaround
end

Class Method Details

.find_by_id(ticket_id) ⇒ Object



72
73
74
75
76
77
78
79
80
# File 'lib/sysaid/ticket.rb', line 72

def self.find_by_id(ticket_id)
  ticket = SysAid::Ticket.new

  ticket.id = ticket_id

  return nil unless ticket.refresh

  return ticket
end

Instance Method Details

#add_note(user, note, time = Time.now) ⇒ Object

Though the ‘notes’ field is merely an editable string, ‘add_note’ mimics the behavior of the SysAid web client.



98
99
100
101
102
103
104
105
106
107
# File 'lib/sysaid/ticket.rb', line 98

def add_note(user, note, time = Time.now)
  # NOTE: Notes are prepended.
  new_note = "#{user} (#{time.strftime("%-m/%-d/%y %I:%M %p")}):\n   #{note}"

  if self.notes
    self.notes = new_note + "\n=============================\n" + self.notes
  else
    self.notes = new_note
  end
end

#deleteObject

Deletes a ticket from the SysAid server

No return value as SysAid’s ‘delete’ call returns void. No idea why.

Example:

>> ticket_object.delete
=> true


135
136
137
138
139
140
141
# File 'lib/sysaid/ticket.rb', line 135

def delete
  SysAid.ensure_logged_in
  
  SysAid.call(:delete, message: to_xml(false))

  reset_all_attributes
end

#refreshObject

Loads the latest ticket information from the SysAid server



83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/sysaid/ticket.rb', line 83

def refresh
  SysAid.ensure_logged_in

  response = SysAid.call(:load_by_string_id, message: to_xml)

  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

#reset_all_attributesObject

Needed by both initialize and delete (to empty out the object when deleted)



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/sysaid/ticket.rb', line 17

def reset_all_attributes
  self.agreement = nil
  self.archive = nil
  self.assign_counter = nil
  self.assigned_group = nil
  self.assigned_to = nil
  self.ciid = nil
  self.category = nil
  self.cc = nil
  self.change_category = nil
  self.close_time = Date.new
  self.closure_information = nil
  self.computer_id = nil
  self.current_support_level = nil
  self.cust_int1 = nil
  self.cust_int2 = nil
  self.cust_list1 = nil
  self.cust_list2 = nil
  self.cust_notes = nil
  self.cust_text1 = nil
  self.cust_text2 = nil
  self.description = nil
  self. = nil
  self.escalation = nil
  self.followup_text = nil
  self.id = nil
  self.impact = nil
  self.insert_time = Date.new
  self.location = nil
  self.max_support_level = nil
  self.notes = nil
  self.parent_link = nil
  self.priority = nil
  self.project_id = nil
  self.reopen_counter = nil
  self.request_user = nil
  self.resolution = nil
  self.solution = nil
  self.source = nil
  self.sr_sub_type = nil
  self.sr_type = nil
  self.status = nil
  self.sub_category = nil
  self.success_rating = nil
  self.task_id = nil
  self.third_level_category = nil
  self.title = nil
  self.update_time = Date.new
  self.update_user = nil
  self.urgency = nil
  self.user_manager = nil
  self.version = nil
  self.workaround = nil
end

#saveObject

Saves a ticket back to the SysAid server

Example:

>> ticket_object.save
=> true


114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/sysaid/ticket.rb', line 114

def save
  SysAid.ensure_logged_in

  # Save it via the SOAP API
  response = SysAid.call(:save, message: to_xml(false))
  if response.to_hash[:save_response][:return]
    # In the case of a new ticket, the SysAid response will be the assigned ID
    self.id = response.to_hash[:save_response][:return] unless self.id
    return true
  else
    return false
  end
end