sysaid 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sysaid.rb +23 -3
- data/lib/sysaid/activity.rb +7 -3
- data/lib/sysaid/project.rb +6 -8
- data/lib/sysaid/task.rb +7 -3
- data/lib/sysaid/ticket.rb +5 -3
- data/lib/sysaid/user.rb +5 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 460f0f1788540fb09584b9ca8ad7e4b4b1f4d537
|
4
|
+
data.tar.gz: 5a87c4b7a050a490d7cbac924b0c53ad373cd1de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33f5eacb540eeea650be02df36458053e68d91a758e60cbbb43e5ca4e1e9efbce6e7843fc82d335b5fb1a9da24f665d8a6b16956d3dd232f877a8326bbeb6440
|
7
|
+
data.tar.gz: 45d33c447041f8c82dbca8435df74f63390ca9cf57062ee1d58351f5dc65eb82cd1e8ce854b5b0f40f3b501572f598ed43a6df033b1a301a8bf55ecb2f2d0e7c
|
data/lib/sysaid.rb
CHANGED
@@ -7,7 +7,7 @@ end
|
|
7
7
|
# The main SysAid class
|
8
8
|
class SysAid
|
9
9
|
@@logged_in = false
|
10
|
-
@@server_settings = {}
|
10
|
+
@@server_settings = { account: nil, username: nil, password: nil, wsdl_uri: nil, debug: false }
|
11
11
|
|
12
12
|
# Accessor for internal SysaidApiService object.
|
13
13
|
# Used by SysAid::Ticket
|
@@ -26,6 +26,20 @@ class SysAid
|
|
26
26
|
def self.server_settings
|
27
27
|
@@server_settings
|
28
28
|
end
|
29
|
+
def self.server_settings=(server_settings)
|
30
|
+
@@server_settings = server_settings
|
31
|
+
# If they don't pass in debug, set it to false to maintain default settings
|
32
|
+
@@server_settings[:debug] = false if server_settings[:debug].nil?
|
33
|
+
end
|
34
|
+
|
35
|
+
# The SysAid API isn't clear on what creates an API timeout. It's possible to login
|
36
|
+
# and make SOAP calls many minutes later but the API _seems_ to timeout at some point.
|
37
|
+
# With the exception of the added delay, there's no harm in simply logging in over and
|
38
|
+
# over with each call, so we do this in ensure_logged_in until we can get a better answer
|
39
|
+
# on what we can do with the SysAid API to _actually_ ensure we're logged in.
|
40
|
+
def self.ensure_logged_in
|
41
|
+
self.login unless self.logged_in?
|
42
|
+
end
|
29
43
|
|
30
44
|
# Returns true if logged into SysAid server
|
31
45
|
# Note: By design, logged_in? will try to log in if it isn't already
|
@@ -34,6 +48,8 @@ class SysAid
|
|
34
48
|
# >> SysAid.logged_in?
|
35
49
|
# => true
|
36
50
|
def self.logged_in?
|
51
|
+
puts "SysAid.logged_in? called" if @@server_settings[:debug]
|
52
|
+
|
37
53
|
# Until official word comes from the company, we're going to login every time
|
38
54
|
# to avoid a problem with undetected timeouts.
|
39
55
|
#if @@logged_in == false
|
@@ -50,10 +66,14 @@ class SysAid
|
|
50
66
|
# self.login does not require credentials be passed every time.
|
51
67
|
# SysAid sometimes times out the session and we can simply call 'login' again with the
|
52
68
|
# saved credentials to get around the timeout.
|
53
|
-
def self.login(account = nil, username = nil, password = nil, wsdl_uri = nil, debug =
|
69
|
+
def self.login(account = nil, username = nil, password = nil, wsdl_uri = nil, debug = nil)
|
70
|
+
puts "SysAid.login" if @@server_settings[:debug]
|
71
|
+
|
54
72
|
if account and username and password and wsdl_uri
|
55
73
|
# Save server settings in case we need to log in again later
|
56
|
-
@@server_settings = { :account => account, :username => username, :password => password, :wsdl_uri => wsdl_uri
|
74
|
+
@@server_settings = { :account => account, :username => username, :password => password, :wsdl_uri => wsdl_uri }
|
75
|
+
# 'debug' parameter cannot default to false else it would override default, so use nil and check
|
76
|
+
@@server_settings[:debug] = debug if debug != nil
|
57
77
|
end
|
58
78
|
|
59
79
|
begin
|
data/lib/sysaid/activity.rb
CHANGED
@@ -27,6 +27,8 @@ class SysAid::Activity
|
|
27
27
|
# Returns an array of Activity IDs based on ticket_id.
|
28
28
|
# Returns false on error.
|
29
29
|
def self.find_by_ticket_id(ticket_id)
|
30
|
+
SysAid.ensure_logged_in
|
31
|
+
|
30
32
|
response = SysAid.client.call(:execute_select_query, message: sql_query(" service_req_id = #{ticket_id}"))
|
31
33
|
|
32
34
|
if response.to_hash[:execute_select_query_response][:return]
|
@@ -49,6 +51,8 @@ class SysAid::Activity
|
|
49
51
|
|
50
52
|
# Loads the latest ticket information from the SysAid server
|
51
53
|
def refresh
|
54
|
+
SysAid.ensure_logged_in
|
55
|
+
|
52
56
|
response = SysAid.client.call(:load_by_string_id, message: to_xml)
|
53
57
|
|
54
58
|
if response.to_hash[:load_by_string_id_response][:return]
|
@@ -65,9 +69,7 @@ class SysAid::Activity
|
|
65
69
|
# >> activity_object.save
|
66
70
|
# => true
|
67
71
|
def save
|
68
|
-
|
69
|
-
raise "You must log in before creating or saving an activity."
|
70
|
-
end
|
72
|
+
SysAid.ensure_logged_in
|
71
73
|
|
72
74
|
# Save it via the SOAP API
|
73
75
|
response = SysAid.client.call(:save, message: to_xml(false))
|
@@ -88,6 +90,8 @@ class SysAid::Activity
|
|
88
90
|
# >> activity_object.delete
|
89
91
|
# => true
|
90
92
|
def delete
|
93
|
+
SysAid.ensure_logged_in
|
94
|
+
|
91
95
|
SysAid.client.call(:delete, message: to_xml(false))
|
92
96
|
|
93
97
|
reset_all_attributes
|
data/lib/sysaid/project.rb
CHANGED
@@ -22,6 +22,8 @@ class SysAid::Project
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def self.find_by_query(query)
|
25
|
+
SysAid.ensure_logged_in
|
26
|
+
|
25
27
|
response = SysAid.client.call(:execute_select_query, message: sql_query(query))
|
26
28
|
|
27
29
|
if response.to_hash[:execute_select_query_response][:return]
|
@@ -33,6 +35,8 @@ class SysAid::Project
|
|
33
35
|
|
34
36
|
# Loads the latest project information from the SysAid server
|
35
37
|
def refresh
|
38
|
+
SysAid.ensure_logged_in
|
39
|
+
|
36
40
|
response = SysAid.client.call(:load_by_string_id, message: to_xml)
|
37
41
|
|
38
42
|
if response.to_hash[:load_by_string_id_response][:return]
|
@@ -49,9 +53,7 @@ class SysAid::Project
|
|
49
53
|
# >> project_object.save
|
50
54
|
# => true
|
51
55
|
def save
|
52
|
-
|
53
|
-
raise "You must log in before creating or saving a project."
|
54
|
-
end
|
56
|
+
SysAid.ensure_logged_in
|
55
57
|
|
56
58
|
# Save it via the SOAP API
|
57
59
|
response = SysAid.client.call(:save, message: to_xml(false))
|
@@ -70,6 +72,7 @@ class SysAid::Project
|
|
70
72
|
# >> project_object.delete
|
71
73
|
# => true
|
72
74
|
def delete
|
75
|
+
SysAid.ensure_logged_in
|
73
76
|
SysAid.client.call(:delete, message: to_xml(false))
|
74
77
|
end
|
75
78
|
|
@@ -92,8 +95,6 @@ class SysAid::Project
|
|
92
95
|
b.assignedGroup(self.assigned_group, 'xsi:type' => 'xsd:string')
|
93
96
|
b.category(self.category, 'xsi:type' => 'xsd:int')
|
94
97
|
b.company(self.company, 'xsi:type' => 'xsd:int')
|
95
|
-
#b.custDate1(self.cust_date1.rfc3339, 'xsi:type' => 'xsd:dateTime')
|
96
|
-
#b.custDate2(self.cust_date2.rfc3339, 'xsi:type' => 'xsd:dateTime')
|
97
98
|
b.custInt1(self.cust_int1, 'xsi:type' => 'xsd:int')
|
98
99
|
b.custInt2(self.cust_int2, 'xsi:type' => 'xsd:int')
|
99
100
|
b.custList1(self.cust_list1, 'xsi:type' => 'xsd:int')
|
@@ -102,7 +103,6 @@ class SysAid::Project
|
|
102
103
|
b.custText1(self.cust_text1, 'xsi:type' => 'xsd:string')
|
103
104
|
b.custText2(self.cust_text2, 'xsi:type' => 'xsd:string')
|
104
105
|
b.customDateFields
|
105
|
-
#b.customFields
|
106
106
|
b.description(self.description, 'xsi:type' => 'xsd:string')
|
107
107
|
b.endTime(self.end_time.rfc3339, 'xsi:type' => 'xsd:dateTime')
|
108
108
|
b.id(self.id, 'xsi:type' => 'xsd:int')
|
@@ -127,8 +127,6 @@ class SysAid::Project
|
|
127
127
|
self.assigned_group = response[:assign_group]
|
128
128
|
self.category = response[:category]
|
129
129
|
self.company = response[:company]
|
130
|
-
#self.cust_date1 = response[:cust_date1]
|
131
|
-
#self.cust_date2 = response[:cust_date2]
|
132
130
|
self.cust_int1 = response[:cust_int1]
|
133
131
|
self.cust_int2 = response[:cust_int2]
|
134
132
|
self.cust_list1 = response[:cust_list1]
|
data/lib/sysaid/task.rb
CHANGED
@@ -22,6 +22,8 @@ class SysAid::Task
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def self.find_by_project_id(project_id)
|
25
|
+
SysAid.ensure_logged_in
|
26
|
+
|
25
27
|
response = SysAid.client.call(:execute_select_query, message: sql_query(project_id))
|
26
28
|
|
27
29
|
if response.to_hash[:execute_select_query_response][:return]
|
@@ -33,6 +35,8 @@ class SysAid::Task
|
|
33
35
|
|
34
36
|
# Loads the latest task information from the SysAid server
|
35
37
|
def refresh
|
38
|
+
SysAid.ensure_logged_in
|
39
|
+
|
36
40
|
response = SysAid.client.call(:load_by_string_id, message: to_xml)
|
37
41
|
|
38
42
|
if response.to_hash[:load_by_string_id_response][:return]
|
@@ -49,9 +53,7 @@ class SysAid::Task
|
|
49
53
|
# >> task_object.save
|
50
54
|
# => true
|
51
55
|
def save
|
52
|
-
|
53
|
-
raise "You must log in before creating or saving a task."
|
54
|
-
end
|
56
|
+
SysAid.ensure_logged_in
|
55
57
|
|
56
58
|
# Save it via the SOAP API
|
57
59
|
response = SysAid.client.call(:save, message: to_xml(false))
|
@@ -70,6 +72,8 @@ class SysAid::Task
|
|
70
72
|
# >> task_object.delete
|
71
73
|
# => true
|
72
74
|
def delete
|
75
|
+
SysAid.ensure_logged_in
|
76
|
+
|
73
77
|
SysAid.client.call(:delete, message: to_xml(false))
|
74
78
|
end
|
75
79
|
|
data/lib/sysaid/ticket.rb
CHANGED
@@ -81,6 +81,8 @@ class SysAid::Ticket
|
|
81
81
|
|
82
82
|
# Loads the latest ticket information from the SysAid server
|
83
83
|
def refresh
|
84
|
+
SysAid.ensure_logged_in
|
85
|
+
|
84
86
|
response = SysAid.client.call(:load_by_string_id, message: to_xml)
|
85
87
|
|
86
88
|
if response.to_hash[:load_by_string_id_response][:return]
|
@@ -110,9 +112,7 @@ class SysAid::Ticket
|
|
110
112
|
# >> ticket_object.save
|
111
113
|
# => true
|
112
114
|
def save
|
113
|
-
|
114
|
-
raise "You must log in before creating or saving a ticket."
|
115
|
-
end
|
115
|
+
SysAid.ensure_logged_in
|
116
116
|
|
117
117
|
# Save it via the SOAP API
|
118
118
|
response = SysAid.client.call(:save, message: to_xml(false))
|
@@ -133,6 +133,8 @@ class SysAid::Ticket
|
|
133
133
|
# >> ticket_object.delete
|
134
134
|
# => true
|
135
135
|
def delete
|
136
|
+
SysAid.ensure_logged_in
|
137
|
+
|
136
138
|
SysAid.client.call(:delete, message: to_xml(false))
|
137
139
|
|
138
140
|
reset_all_attributes
|
data/lib/sysaid/user.rb
CHANGED
@@ -27,6 +27,8 @@ class SysAid::User
|
|
27
27
|
# Loads the latest user information from the SysAid server
|
28
28
|
def refresh
|
29
29
|
begin
|
30
|
+
SysAid.ensure_logged_in
|
31
|
+
|
30
32
|
response = SysAid.client.call(:load_by_string_id, message: to_xml.to_s )
|
31
33
|
if response.to_hash[:load_by_string_id_response][:return]
|
32
34
|
set_self_from_response(response.to_hash[:load_by_string_id_response][:return])
|
@@ -45,9 +47,7 @@ class SysAid::User
|
|
45
47
|
# >> user_object.save
|
46
48
|
# => true
|
47
49
|
def save
|
48
|
-
|
49
|
-
raise "You must log in before creating or saving a user."
|
50
|
-
end
|
50
|
+
SysAid.ensure_logged_in
|
51
51
|
|
52
52
|
# Save it via the SOAP API
|
53
53
|
response = SysAid.client.call(:save, message: to_xml(false).to_s )
|
@@ -64,6 +64,8 @@ class SysAid::User
|
|
64
64
|
# >> user_object.delete
|
65
65
|
# => nil
|
66
66
|
def delete
|
67
|
+
SysAid.ensure_logged_in
|
68
|
+
|
67
69
|
SysAid.client.call(:delete, message: to_xml(false).to_s )
|
68
70
|
end
|
69
71
|
|
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.3.
|
4
|
+
version: 0.3.2
|
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-02-
|
11
|
+
date: 2014-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: savon
|