Class: SysAid::Activity
- Inherits:
-
Object
- Object
- SysAid::Activity
- Defined in:
- lib/sysaid/activity.rb
Instance Attribute Summary collapse
-
#ciid ⇒ Object
Returns the value of attribute ciid.
-
#cust_int1 ⇒ Object
Returns the value of attribute cust_int1.
-
#cust_int2 ⇒ Object
Returns the value of attribute cust_int2.
-
#cust_int3 ⇒ Object
Returns the value of attribute cust_int3.
-
#cust_int4 ⇒ Object
Returns the value of attribute cust_int4.
-
#cust_list1 ⇒ Object
Returns the value of attribute cust_list1.
-
#cust_list2 ⇒ Object
Returns the value of attribute cust_list2.
-
#description ⇒ Object
Returns the value of attribute description.
-
#from_time ⇒ Object
Returns the value of attribute from_time.
-
#id ⇒ Object
Returns the value of attribute id.
-
#sr_id ⇒ Object
Returns the value of attribute sr_id.
-
#to_time ⇒ Object
Returns the value of attribute to_time.
-
#user ⇒ Object
Returns the value of attribute user.
Class Method Summary collapse
-
.find_by_id(activity_id) ⇒ Object
Returns a specific Activity based on an Activity ID.
-
.find_by_ticket_id(ticket_id) ⇒ Object
Returns an array of Activity IDs based on ticket_id.
Instance Method Summary collapse
-
#delete ⇒ Object
Deletes an activity from the SysAid server.
-
#initialize ⇒ Activity
constructor
A new instance of Activity.
-
#refresh ⇒ Object
Loads the latest ticket information from the SysAid server.
-
#reset_all_attributes ⇒ Object
Needed by both initialize and delete (to empty out the object when deleted).
-
#save ⇒ Object
Saves an activity back to the SysAid server.
Constructor Details
#initialize ⇒ Activity
Returns a new instance of Activity.
6 7 8 |
# File 'lib/sysaid/activity.rb', line 6 def initialize reset_all_attributes end |
Instance Attribute Details
#ciid ⇒ Object
Returns the value of attribute ciid.
4 5 6 |
# File 'lib/sysaid/activity.rb', line 4 def ciid @ciid end |
#cust_int1 ⇒ Object
Returns the value of attribute cust_int1.
4 5 6 |
# File 'lib/sysaid/activity.rb', line 4 def cust_int1 @cust_int1 end |
#cust_int2 ⇒ Object
Returns the value of attribute cust_int2.
4 5 6 |
# File 'lib/sysaid/activity.rb', line 4 def cust_int2 @cust_int2 end |
#cust_int3 ⇒ Object
Returns the value of attribute cust_int3.
4 5 6 |
# File 'lib/sysaid/activity.rb', line 4 def cust_int3 @cust_int3 end |
#cust_int4 ⇒ Object
Returns the value of attribute cust_int4.
4 5 6 |
# File 'lib/sysaid/activity.rb', line 4 def cust_int4 @cust_int4 end |
#cust_list1 ⇒ Object
Returns the value of attribute cust_list1.
4 5 6 |
# File 'lib/sysaid/activity.rb', line 4 def cust_list1 @cust_list1 end |
#cust_list2 ⇒ Object
Returns the value of attribute cust_list2.
4 5 6 |
# File 'lib/sysaid/activity.rb', line 4 def cust_list2 @cust_list2 end |
#description ⇒ Object
Returns the value of attribute description.
4 5 6 |
# File 'lib/sysaid/activity.rb', line 4 def description @description end |
#from_time ⇒ Object
Returns the value of attribute from_time.
4 5 6 |
# File 'lib/sysaid/activity.rb', line 4 def from_time @from_time end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/sysaid/activity.rb', line 4 def id @id end |
#sr_id ⇒ Object
Returns the value of attribute sr_id.
4 5 6 |
# File 'lib/sysaid/activity.rb', line 4 def sr_id @sr_id end |
#to_time ⇒ Object
Returns the value of attribute to_time.
4 5 6 |
# File 'lib/sysaid/activity.rb', line 4 def to_time @to_time end |
#user ⇒ Object
Returns the value of attribute user.
4 5 6 |
# File 'lib/sysaid/activity.rb', line 4 def user @user end |
Class Method Details
.find_by_id(activity_id) ⇒ Object
Returns a specific Activity based on an Activity ID
42 43 44 45 46 47 48 49 50 |
# File 'lib/sysaid/activity.rb', line 42 def self.find_by_id(activity_id) activity = SysAid::Activity.new activity.id = activity_id return nil unless activity.refresh return activity end |
.find_by_ticket_id(ticket_id) ⇒ Object
Returns an array of Activity IDs based on ticket_id. Returns false on error.
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/sysaid/activity.rb', line 29 def self.find_by_ticket_id(ticket_id) SysAid.ensure_logged_in response = SysAid.call(:execute_select_query, message: sql_query(" service_req_id = #{ticket_id}")) if response.to_hash[:execute_select_query_response][:return] return response.to_hash[:execute_select_query_response][:return] end return false end |
Instance Method Details
#delete ⇒ Object
Deletes an activity from the SysAid server
No return value as SysAid’s ‘delete’ call returns void. No idea why.
Example:
>> activity_object.delete
=> true
92 93 94 95 96 97 98 |
# File 'lib/sysaid/activity.rb', line 92 def delete SysAid.ensure_logged_in SysAid.call(:delete, message: to_xml(false)) reset_all_attributes end |
#refresh ⇒ Object
Loads the latest ticket information from the SysAid server
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/sysaid/activity.rb', line 53 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_attributes ⇒ Object
Needed by both initialize and delete (to empty out the object when deleted)
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/sysaid/activity.rb', line 11 def reset_all_attributes self.ciid = nil self.cust_int1 = nil self.cust_int2 = nil self.cust_int3 = nil self.cust_int4 = nil self.cust_list1 = nil self.cust_list2 = nil self.description = nil self.from_time = Date.new self.id = nil self.sr_id = nil self.to_time = Date.new self.user = nil end |
#save ⇒ Object
Saves an activity back to the SysAid server
Example:
>> activity_object.save
=> true
71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/sysaid/activity.rb', line 71 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 new activities, 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 |