class SysAid::Activity
Attributes
ciid[RW]
cust_int1[RW]
cust_int2[RW]
cust_int3[RW]
cust_int4[RW]
cust_list1[RW]
cust_list2[RW]
description[RW]
from_time[RW]
id[RW]
sr_id[RW]
to_time[RW]
user[RW]
Public Class Methods
find_by_id(activity_id)
click to toggle source
find_by_ticket_id(ticket_id)
click to toggle source
Returns an array of Activity
IDs based on ticket_id. Returns false on error.
# 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
new()
click to toggle source
# File lib/sysaid/activity.rb, line 6 def initialize reset_all_attributes end
Private Class Methods
sql_query(query)
click to toggle source
# File lib/sysaid/activity.rb, line 102 def self.sql_query(query) builder = Builder::XmlMarkup.new builder.sessionId(SysAid.session_id) xml = builder.apiSysObj('xsi:type' => "tns:apiServiceRequestActivity") xml = builder.condition(query) xml end
Public Instance Methods
delete()
click to toggle source
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
# 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()
click to toggle source
Loads the latest ticket information from the SysAid
server
# 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()
click to toggle source
Needed by both initialize and delete (to empty out the object when deleted)
# 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()
click to toggle source
Saves an activity back to the SysAid
server
Example:
>> activity_object.save => true
# 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
Private Instance Methods
set_self_from_response(response)
click to toggle source
Update instance variables to match what is in response
# File lib/sysaid/activity.rb, line 136 def set_self_from_response(response) self.ciid = response[:ci_id] self.cust_int1 = response[:cust_int1] self.cust_int2 = response[:cust_int2] self.cust_int3 = response[:cust_int3] self.cust_int4 = response[:cust_int4] self.cust_list1 = response[:cust_list1] self.cust_list2 = response[:cust_list2] self.description = response[:description] self.from_time = response[:from_time] self.id = response[:id] self.sr_id = response[:sr_id] self.to_time = response[:to_time] self.user = response[:user] end
to_xml(include_id = true)
click to toggle source
# File lib/sysaid/activity.rb, line 111 def to_xml(include_id = true) builder = Builder::XmlMarkup.new builder.sessionId(SysAid.session_id) xml = builder.apiSysObj('xsi:type' => "tns:apiServiceRequestActivity") { |b| b.CIId(self.ciid, 'xsi:type' => 'xsd:int') b.custInt1(self.cust_int1, 'xsi:type' => 'xsd:int') b.custInt2(self.cust_int2, 'xsi:type' => 'xsd:int') b.custInt3(self.cust_int3, 'xsi:type' => 'xsd:int') b.custInt4(self.cust_int4, 'xsi:type' => 'xsd:int') b.custList1(self.cust_list1, 'xsi:type' => 'xsd:int') b.custList2(self.cust_list2, 'xsi:type' => 'xsd:int') b.description(self.description, 'xsi:type' => 'xsd:string') b.fromTime(self.from_time.rfc3339, 'xsi:type' => 'xsd:dateTime') b.id(self.id, 'xsi:type' => 'xsd:int') b.srID(self.sr_id, 'xsi:type' => 'xsd:int') b.toTime(self.to_time.rfc3339, 'xsi:type' => 'xsd:dateTime') b.user(self.user, 'xsi:type' => 'xsd:string') } xml = builder.id(self.id) if include_id xml end