sysaid 0.2.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/sysaid.rb +1 -0
- data/lib/sysaid/activity.rb +148 -0
- data/lib/sysaid/ticket.rb +58 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0bc7dbae6cf5ac0e3a514cf8316b1c5aebd16a9e
|
4
|
+
data.tar.gz: babb7c8076094240eaa4bd1d18eb621ef0e7e46f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9fc827b98fe2ac91bad360001165d9971c15d157ae723ddc9fb293333634432c03e172b951f5087e9c1c8ba4cb32cfe875f1e40624dee3600a6a5c43438e977a
|
7
|
+
data.tar.gz: a67f7d7288856fdc424e9f7ab4d68e8daa14a7a795569152d641e63acd014219eb0f36386d1daed61392cc0fd78fc72ef572f964307d5a70e6c01f4e5d07a64b
|
data/lib/sysaid.rb
CHANGED
@@ -0,0 +1,148 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
3
|
+
class SysAid::Activity
|
4
|
+
attr_accessor :ciid, :cust_int1, :cust_int2, :cust_int3, :cust_int4, :cust_list1, :cust_list2, :description, :from_time,
|
5
|
+
:id, :sr_id, :to_time, :user
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
reset_all_attributes
|
9
|
+
end
|
10
|
+
|
11
|
+
# Needed by both initialize and delete (to empty out the object when deleted)
|
12
|
+
def reset_all_attributes
|
13
|
+
self.ciid = nil
|
14
|
+
self.cust_int1 = nil
|
15
|
+
self.cust_int2 = nil
|
16
|
+
self.cust_int3 = nil
|
17
|
+
self.cust_int4 = nil
|
18
|
+
self.cust_list1 = nil
|
19
|
+
self.cust_list2 = nil
|
20
|
+
self.description = nil
|
21
|
+
self.from_time = Date.new
|
22
|
+
self.id = nil
|
23
|
+
self.sr_id = nil
|
24
|
+
self.to_time = Date.new
|
25
|
+
self.user = nil
|
26
|
+
end
|
27
|
+
|
28
|
+
# Returns an array of Activity IDs based on ticket_id.
|
29
|
+
# Returns false on error.
|
30
|
+
def self.find_by_ticket_id(ticket_id)
|
31
|
+
response = SysAid.client.call(:execute_select_query, message: sql_query(" service_req_id = #{ticket_id}"))
|
32
|
+
|
33
|
+
if response.to_hash[:execute_select_query_response][:return]
|
34
|
+
return response.to_hash[:execute_select_query_response][:return]
|
35
|
+
end
|
36
|
+
|
37
|
+
return false
|
38
|
+
end
|
39
|
+
|
40
|
+
# Returns a specific Activity based on an Activity ID
|
41
|
+
def self.find_by_id(activity_id)
|
42
|
+
activity = SysAid::Activity.new
|
43
|
+
|
44
|
+
activity.id = activity_id
|
45
|
+
|
46
|
+
return nil unless activity.refresh
|
47
|
+
|
48
|
+
return activity
|
49
|
+
end
|
50
|
+
|
51
|
+
# Loads the latest ticket information from the SysAid server
|
52
|
+
def refresh
|
53
|
+
response = SysAid.client.call(:load_by_string_id, message: to_xml)
|
54
|
+
|
55
|
+
if response.to_hash[:load_by_string_id_response][:return]
|
56
|
+
set_self_from_response(response.to_hash[:load_by_string_id_response][:return])
|
57
|
+
return true
|
58
|
+
end
|
59
|
+
|
60
|
+
return false
|
61
|
+
end
|
62
|
+
|
63
|
+
# Saves an activity back to the SysAid server
|
64
|
+
#
|
65
|
+
# Example:
|
66
|
+
# >> activity_object.save
|
67
|
+
# => true
|
68
|
+
def save
|
69
|
+
if SysAid.logged_in? == false
|
70
|
+
raise "You must log in before creating or saving an activity."
|
71
|
+
end
|
72
|
+
|
73
|
+
# Save it via the SOAP API
|
74
|
+
response = SysAid.client.call(:save, message: to_xml(false))
|
75
|
+
if response.to_hash[:save_response][:return]
|
76
|
+
# In the case of new activities, the SysAid response will be the assigned ID
|
77
|
+
self.id = response.to_hash[:save_response][:return] unless self.id
|
78
|
+
return true
|
79
|
+
else
|
80
|
+
return false
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
# Deletes an activity from the SysAid server
|
85
|
+
#
|
86
|
+
# No return value as SysAid's 'delete' call returns void. No idea why.
|
87
|
+
#
|
88
|
+
# Example:
|
89
|
+
# >> activity_object.delete
|
90
|
+
# => true
|
91
|
+
def delete
|
92
|
+
SysAid.client.call(:delete, message: to_xml(false))
|
93
|
+
|
94
|
+
reset_all_attributes
|
95
|
+
end
|
96
|
+
|
97
|
+
private
|
98
|
+
|
99
|
+
def self.sql_query(query)
|
100
|
+
builder = Builder::XmlMarkup.new
|
101
|
+
|
102
|
+
builder.sessionId(SysAid.session_id)
|
103
|
+
xml = builder.apiSysObj('xsi:type' => "tns:apiServiceRequestActivity")
|
104
|
+
xml = builder.condition(query)
|
105
|
+
xml
|
106
|
+
end
|
107
|
+
|
108
|
+
def to_xml(include_id = true)
|
109
|
+
builder = Builder::XmlMarkup.new
|
110
|
+
|
111
|
+
builder.sessionId(SysAid.session_id)
|
112
|
+
xml = builder.apiSysObj('xsi:type' => "tns:apiServiceRequestActivity") { |b|
|
113
|
+
b.CIId(self.ciid, 'xsi:type' => 'xsd:int')
|
114
|
+
b.custInt1(self.cust_int1, 'xsi:type' => 'xsd:int')
|
115
|
+
b.custInt2(self.cust_int2, 'xsi:type' => 'xsd:int')
|
116
|
+
b.custInt3(self.cust_int3, 'xsi:type' => 'xsd:int')
|
117
|
+
b.custInt4(self.cust_int4, 'xsi:type' => 'xsd:int')
|
118
|
+
b.custList1(self.cust_list1, 'xsi:type' => 'xsd:int')
|
119
|
+
b.custList2(self.cust_list2, 'xsi:type' => 'xsd:int')
|
120
|
+
b.description(self.description, 'xsi:type' => 'xsd:string')
|
121
|
+
b.fromTime(self.from_time.rfc3339, 'xsi:type' => 'xsd:dateTime')
|
122
|
+
b.id(self.id, 'xsi:type' => 'xsd:int')
|
123
|
+
b.srID(self.sr_id, 'xsi:type' => 'xsd:int')
|
124
|
+
b.toTime(self.to_time.rfc3339, 'xsi:type' => 'xsd:dateTime')
|
125
|
+
b.user(self.user, 'xsi:type' => 'xsd:string')
|
126
|
+
}
|
127
|
+
xml = builder.id(self.id) if include_id
|
128
|
+
|
129
|
+
xml
|
130
|
+
end
|
131
|
+
|
132
|
+
# Update instance variables to match what is in response
|
133
|
+
def set_self_from_response(response)
|
134
|
+
self.ciid = response[:ci_id]
|
135
|
+
self.cust_int1 = response[:cust_int1]
|
136
|
+
self.cust_int2 = response[:cust_int2]
|
137
|
+
self.cust_int3 = response[:cust_int3]
|
138
|
+
self.cust_int4 = response[:cust_int4]
|
139
|
+
self.cust_list1 = response[:cust_list1]
|
140
|
+
self.cust_list2 = response[:cust_list2]
|
141
|
+
self.description = response[:description]
|
142
|
+
self.from_time = response[:from_time]
|
143
|
+
self.id = response[:id]
|
144
|
+
self.sr_id = response[:sr_id]
|
145
|
+
self.to_time = response[:to_time]
|
146
|
+
self.user = response[:user]
|
147
|
+
end
|
148
|
+
end
|
data/lib/sysaid/ticket.rb
CHANGED
@@ -10,9 +10,63 @@ class SysAid::Ticket
|
|
10
10
|
:update_time, :update_user, :user_manager, :workaround, :insert_time, :followup_text, :email_account
|
11
11
|
|
12
12
|
def initialize
|
13
|
+
reset_all_attributes
|
14
|
+
end
|
15
|
+
|
16
|
+
# Needed by both initialize and delete (to empty out the object when deleted)
|
17
|
+
def reset_all_attributes
|
18
|
+
self.agreement = nil
|
19
|
+
self.archive = nil
|
20
|
+
self.assign_counter = nil
|
21
|
+
self.assigned_group = nil
|
22
|
+
self.assigned_to = nil
|
23
|
+
self.ciid = nil
|
24
|
+
self.category = nil
|
25
|
+
self.cc = nil
|
26
|
+
self.change_category = nil
|
13
27
|
self.close_time = Date.new
|
28
|
+
self.closure_information = nil
|
29
|
+
self.computer_id = nil
|
30
|
+
self.current_support_level = nil
|
31
|
+
self.cust_int1 = nil
|
32
|
+
self.cust_int2 = nil
|
33
|
+
self.cust_list1 = nil
|
34
|
+
self.cust_list2 = nil
|
35
|
+
self.cust_notes = nil
|
36
|
+
self.cust_text1 = nil
|
37
|
+
self.cust_text2 = nil
|
38
|
+
self.description = nil
|
39
|
+
self.email_account = nil
|
40
|
+
self.escalation = nil
|
41
|
+
self.followup_text = nil
|
42
|
+
self.id = nil
|
43
|
+
self.impact = nil
|
14
44
|
self.insert_time = Date.new
|
45
|
+
self.location = nil
|
46
|
+
self.max_support_level = nil
|
47
|
+
self.notes = nil
|
48
|
+
self.parent_link = nil
|
49
|
+
self.priority = nil
|
50
|
+
self.project_id = nil
|
51
|
+
self.reopen_counter = nil
|
52
|
+
self.request_user = nil
|
53
|
+
self.resolution = nil
|
54
|
+
self.solution = nil
|
55
|
+
self.source = nil
|
56
|
+
self.sr_sub_type = nil
|
57
|
+
self.sr_type = nil
|
58
|
+
self.status = nil
|
59
|
+
self.sub_category = nil
|
60
|
+
self.success_rating = nil
|
61
|
+
self.task_id = nil
|
62
|
+
self.third_level_category = nil
|
63
|
+
self.title = nil
|
15
64
|
self.update_time = Date.new
|
65
|
+
self.update_user = nil
|
66
|
+
self.urgency = nil
|
67
|
+
self.user_manager = nil
|
68
|
+
self.version = nil
|
69
|
+
self.workaround = nil
|
16
70
|
end
|
17
71
|
|
18
72
|
def self.find_by_id(ticket_id)
|
@@ -63,6 +117,8 @@ class SysAid::Ticket
|
|
63
117
|
# Save it via the SOAP API
|
64
118
|
response = SysAid.client.call(:save, message: to_xml(false))
|
65
119
|
if response.to_hash[:save_response][:return]
|
120
|
+
# In the case of a new ticket, the SysAid response will be the assigned ID
|
121
|
+
self.id = response.to_hash[:save_response][:return] unless self.id
|
66
122
|
return true
|
67
123
|
else
|
68
124
|
return false
|
@@ -78,6 +134,8 @@ class SysAid::Ticket
|
|
78
134
|
# => true
|
79
135
|
def delete
|
80
136
|
SysAid.client.call(:delete, message: to_xml(false))
|
137
|
+
|
138
|
+
reset_all_attributes
|
81
139
|
end
|
82
140
|
|
83
141
|
private
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sysaid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christopher Thielen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: savon
|
@@ -37,6 +37,7 @@ extensions: []
|
|
37
37
|
extra_rdoc_files: []
|
38
38
|
files:
|
39
39
|
- lib/sysaid.rb
|
40
|
+
- lib/sysaid/activity.rb
|
40
41
|
- lib/sysaid/project.rb
|
41
42
|
- lib/sysaid/task.rb
|
42
43
|
- lib/sysaid/ticket.rb
|