autotask_ruby 0.1.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -2
- data/.ruby-version +2 -1
- data/Gemfile.lock +64 -66
- data/lib/autotask_ruby.rb +3 -0
- data/lib/autotask_ruby/account.rb +7 -8
- data/lib/autotask_ruby/account_to_do.rb +22 -13
- data/lib/autotask_ruby/action_type.rb +7 -7
- data/lib/autotask_ruby/appointment.rb +10 -13
- data/lib/autotask_ruby/association.rb +35 -33
- data/lib/autotask_ruby/client.rb +97 -79
- data/lib/autotask_ruby/configuration.rb +18 -18
- data/lib/autotask_ruby/constants.rb +3 -3
- data/lib/autotask_ruby/contact.rb +16 -17
- data/lib/autotask_ruby/create_response.rb +5 -3
- data/lib/autotask_ruby/delete_response.rb +5 -3
- data/lib/autotask_ruby/entity.rb +107 -108
- data/lib/autotask_ruby/fields.rb +11 -11
- data/lib/autotask_ruby/project.rb +12 -13
- data/lib/autotask_ruby/query.rb +15 -15
- data/lib/autotask_ruby/query_response.rb +4 -4
- data/lib/autotask_ruby/query_xml.rb +49 -0
- data/lib/autotask_ruby/resource.rb +15 -15
- data/lib/autotask_ruby/response.rb +23 -21
- data/lib/autotask_ruby/service_call.rb +20 -18
- data/lib/autotask_ruby/service_call_ticket.rb +9 -7
- data/lib/autotask_ruby/service_call_ticket_resource.rb +9 -7
- data/lib/autotask_ruby/task.rb +12 -12
- data/lib/autotask_ruby/ticket.rb +11 -11
- data/lib/autotask_ruby/update_response.rb +7 -0
- data/lib/autotask_ruby/version.rb +1 -1
- data/lib/autotask_ruby/zone_info.rb +23 -20
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 508e05d8468713f8dd50ce98719c0b1ff139a0935459be0cc0ed08fffc14451b
|
4
|
+
data.tar.gz: '09592b92714f90db2f070fa5487eed58853418b55ff3df40c8f257508573780f'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41947b77a8ed8f45bdbe1ae1b37ced6da2938180373913fc6ef5c2beb93e523cd4ef18655b431a3deeb4f6a61fe27a488cd9cd75ec7c5d081ec383e552502fbb
|
7
|
+
data.tar.gz: 63ce5fe9e0eb34f7fde68233fc4d413fee9b90c40493c9971b5c97e289fcb63fabd45a8f3be87a52e6cdffa31d9186ccf4b1a0f4534340f31729924b69dc5ab2
|
data/.rubocop.yml
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
ruby-2.
|
1
|
+
ruby-2.6.4
|
2
|
+
|
data/Gemfile.lock
CHANGED
@@ -2,35 +2,36 @@ PATH
|
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
4
|
autotask_ruby (0.1.0)
|
5
|
-
activesupport
|
6
|
-
savon
|
5
|
+
activesupport
|
6
|
+
savon
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activesupport (
|
11
|
+
activesupport (6.0.2.1)
|
12
12
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
13
|
i18n (>= 0.7, < 2)
|
14
14
|
minitest (~> 5.1)
|
15
15
|
tzinfo (~> 1.1)
|
16
|
-
|
17
|
-
|
16
|
+
zeitwerk (~> 2.2)
|
17
|
+
addressable (2.7.0)
|
18
|
+
public_suffix (>= 2.0.2, < 5.0)
|
18
19
|
akami (1.3.1)
|
19
20
|
gyoku (>= 0.4.0)
|
20
21
|
nokogiri
|
21
22
|
ast (2.4.0)
|
22
23
|
awesome_print (1.8.0)
|
23
|
-
builder (3.2.
|
24
|
-
byebug (
|
24
|
+
builder (3.2.4)
|
25
|
+
byebug (11.1.1)
|
25
26
|
coderay (1.1.2)
|
26
|
-
concurrent-ruby (1.1.
|
27
|
+
concurrent-ruby (1.1.5)
|
27
28
|
crack (0.4.3)
|
28
29
|
safe_yaml (~> 1.0.0)
|
29
30
|
diff-lcs (1.3)
|
30
|
-
dotenv (2.5
|
31
|
-
ffi (1.
|
31
|
+
dotenv (2.7.5)
|
32
|
+
ffi (1.12.2)
|
32
33
|
formatador (0.2.5)
|
33
|
-
guard (2.
|
34
|
+
guard (2.16.1)
|
34
35
|
formatador (>= 0.2.4)
|
35
36
|
listen (>= 2.7, < 4.0)
|
36
37
|
lumberjack (>= 1.0.12, < 2.0)
|
@@ -46,68 +47,64 @@ GEM
|
|
46
47
|
rspec (>= 2.99.0, < 4.0)
|
47
48
|
gyoku (1.3.1)
|
48
49
|
builder (>= 2.1.2)
|
49
|
-
hashdiff (0.
|
50
|
+
hashdiff (1.0.0)
|
50
51
|
httpi (2.4.4)
|
51
52
|
rack
|
52
53
|
socksify
|
53
|
-
i18n (1.
|
54
|
+
i18n (1.8.2)
|
54
55
|
concurrent-ruby (~> 1.0)
|
55
|
-
jaro_winkler (1.5.
|
56
|
-
listen (3.1
|
57
|
-
rb-fsevent (~> 0.
|
58
|
-
rb-inotify (~> 0.9, >= 0.9.
|
59
|
-
|
60
|
-
lumberjack (1.0.13)
|
56
|
+
jaro_winkler (1.5.4)
|
57
|
+
listen (3.2.1)
|
58
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
59
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
60
|
+
lumberjack (1.2.4)
|
61
61
|
method_source (0.9.2)
|
62
62
|
mini_portile2 (2.4.0)
|
63
|
-
minitest (5.
|
63
|
+
minitest (5.14.0)
|
64
64
|
nenv (0.3.0)
|
65
|
-
nokogiri (1.
|
65
|
+
nokogiri (1.10.7)
|
66
66
|
mini_portile2 (~> 2.4.0)
|
67
67
|
nori (2.6.0)
|
68
|
-
notiffany (0.1.
|
68
|
+
notiffany (0.1.3)
|
69
69
|
nenv (~> 0.1)
|
70
70
|
shellany (~> 0.0)
|
71
|
-
parallel (1.
|
72
|
-
parser (2.
|
71
|
+
parallel (1.19.1)
|
72
|
+
parser (2.7.0.2)
|
73
73
|
ast (~> 2.4.0)
|
74
|
-
powerpack (0.1.2)
|
75
74
|
pry (0.12.2)
|
76
75
|
coderay (~> 1.1.0)
|
77
76
|
method_source (~> 0.9.0)
|
78
|
-
public_suffix (
|
79
|
-
rack (2.
|
77
|
+
public_suffix (4.0.3)
|
78
|
+
rack (2.2.1)
|
80
79
|
rainbow (3.0.0)
|
81
|
-
rake (
|
80
|
+
rake (13.0.1)
|
82
81
|
rb-fsevent (0.10.3)
|
83
|
-
rb-inotify (0.10.
|
82
|
+
rb-inotify (0.10.1)
|
84
83
|
ffi (~> 1.0)
|
85
|
-
rspec (3.
|
86
|
-
rspec-core (~> 3.
|
87
|
-
rspec-expectations (~> 3.
|
88
|
-
rspec-mocks (~> 3.
|
89
|
-
rspec-core (3.
|
90
|
-
rspec-support (~> 3.
|
91
|
-
rspec-expectations (3.
|
84
|
+
rspec (3.9.0)
|
85
|
+
rspec-core (~> 3.9.0)
|
86
|
+
rspec-expectations (~> 3.9.0)
|
87
|
+
rspec-mocks (~> 3.9.0)
|
88
|
+
rspec-core (3.9.1)
|
89
|
+
rspec-support (~> 3.9.1)
|
90
|
+
rspec-expectations (3.9.0)
|
92
91
|
diff-lcs (>= 1.2.0, < 2.0)
|
93
|
-
rspec-support (~> 3.
|
94
|
-
rspec-mocks (3.
|
92
|
+
rspec-support (~> 3.9.0)
|
93
|
+
rspec-mocks (3.9.1)
|
95
94
|
diff-lcs (>= 1.2.0, < 2.0)
|
96
|
-
rspec-support (~> 3.
|
97
|
-
rspec-support (3.
|
98
|
-
rubocop (0.
|
95
|
+
rspec-support (~> 3.9.0)
|
96
|
+
rspec-support (3.9.2)
|
97
|
+
rubocop (0.79.0)
|
99
98
|
jaro_winkler (~> 1.5.1)
|
100
99
|
parallel (~> 1.10)
|
101
|
-
parser (>= 2.
|
102
|
-
powerpack (~> 0.1)
|
100
|
+
parser (>= 2.7.0.1)
|
103
101
|
rainbow (>= 2.2.2, < 4.0)
|
104
102
|
ruby-progressbar (~> 1.7)
|
105
|
-
unicode-display_width (
|
106
|
-
rubocop-rspec (1.
|
107
|
-
rubocop (>= 0.
|
108
|
-
ruby-progressbar (1.10.
|
109
|
-
|
110
|
-
safe_yaml (1.0.4)
|
103
|
+
unicode-display_width (>= 1.4.0, < 1.7)
|
104
|
+
rubocop-rspec (1.37.1)
|
105
|
+
rubocop (>= 0.68.1)
|
106
|
+
ruby-progressbar (1.10.1)
|
107
|
+
safe_yaml (1.0.5)
|
111
108
|
savon (2.12.0)
|
112
109
|
akami (~> 1.2)
|
113
110
|
builder (>= 2.1.2)
|
@@ -118,35 +115,36 @@ GEM
|
|
118
115
|
wasabi (~> 3.4)
|
119
116
|
shellany (0.0.1)
|
120
117
|
socksify (1.7.1)
|
121
|
-
thor (0.
|
118
|
+
thor (1.0.1)
|
122
119
|
thread_safe (0.3.6)
|
123
|
-
tzinfo (1.2.
|
120
|
+
tzinfo (1.2.6)
|
124
121
|
thread_safe (~> 0.1)
|
125
|
-
unicode-display_width (1.
|
122
|
+
unicode-display_width (1.6.1)
|
126
123
|
wasabi (3.5.0)
|
127
124
|
httpi (~> 2.0)
|
128
125
|
nokogiri (>= 1.4.2)
|
129
|
-
webmock (3.
|
126
|
+
webmock (3.8.1)
|
130
127
|
addressable (>= 2.3.6)
|
131
128
|
crack (>= 0.3.2)
|
132
|
-
hashdiff
|
129
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
130
|
+
zeitwerk (2.2.2)
|
133
131
|
|
134
132
|
PLATFORMS
|
135
133
|
ruby
|
136
134
|
|
137
135
|
DEPENDENCIES
|
138
136
|
autotask_ruby!
|
139
|
-
awesome_print
|
140
|
-
bundler
|
141
|
-
byebug
|
142
|
-
dotenv
|
143
|
-
guard
|
144
|
-
guard-rspec
|
145
|
-
rake
|
146
|
-
rspec
|
147
|
-
rubocop
|
148
|
-
rubocop-rspec
|
149
|
-
webmock
|
137
|
+
awesome_print
|
138
|
+
bundler
|
139
|
+
byebug
|
140
|
+
dotenv
|
141
|
+
guard
|
142
|
+
guard-rspec
|
143
|
+
rake
|
144
|
+
rspec
|
145
|
+
rubocop
|
146
|
+
rubocop-rspec
|
147
|
+
webmock
|
150
148
|
|
151
149
|
BUNDLED WITH
|
152
|
-
1.
|
150
|
+
2.1.2
|
data/lib/autotask_ruby.rb
CHANGED
@@ -9,11 +9,13 @@ require 'nokogiri'
|
|
9
9
|
require 'autotask_ruby/configuration'
|
10
10
|
require 'autotask_ruby/constants'
|
11
11
|
require 'autotask_ruby/query'
|
12
|
+
require 'autotask_ruby/query_xml'
|
12
13
|
require 'autotask_ruby/association'
|
13
14
|
require 'autotask_ruby/response'
|
14
15
|
require 'autotask_ruby/query_response'
|
15
16
|
require 'autotask_ruby/create_response'
|
16
17
|
require 'autotask_ruby/delete_response'
|
18
|
+
require 'autotask_ruby/update_response'
|
17
19
|
require 'autotask_ruby/zone_info'
|
18
20
|
require 'autotask_ruby/entity'
|
19
21
|
require 'autotask_ruby/client'
|
@@ -22,6 +24,7 @@ require 'autotask_ruby/account'
|
|
22
24
|
require 'autotask_ruby/contact'
|
23
25
|
require 'autotask_ruby/account_to_do'
|
24
26
|
require 'autotask_ruby/appointment'
|
27
|
+
require 'autotask_ruby/action_type'
|
25
28
|
require 'autotask_ruby/task'
|
26
29
|
require 'autotask_ruby/ticket'
|
27
30
|
require 'autotask_ruby/project'
|
@@ -1,14 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module AutotaskRuby
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
FIELDS = %i[id Address1 City Country CreateDate AccountName AccountNumber Phone PostalCode State Active].freeze
|
9
|
-
.each do |field|
|
10
|
-
self.attr_accessor :"#{field.to_s.underscore}"
|
11
|
-
end
|
4
|
+
# Represents the Autotask Account Entity
|
5
|
+
class Account
|
6
|
+
include Entity
|
12
7
|
|
8
|
+
FIELDS = %i[id Address1 City Country CreateDate AccountName AccountNumber Phone PostalCode State Active].freeze
|
9
|
+
.each do |field|
|
10
|
+
attr_accessor :"#{field.to_s.underscore}"
|
13
11
|
end
|
12
|
+
end
|
14
13
|
end
|
@@ -1,20 +1,29 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module AutotaskRuby
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
# Represents the Autotask AccountToDo entity
|
5
|
+
class AccountToDo
|
6
|
+
include AutotaskRuby::Entity
|
7
|
+
include AutotaskRuby::Query
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
FIELDS = %i[id AccountID ContactID ActivityDescription StartDateTime EndDateTime
|
10
|
+
AssignedToResourceID CreateDateTime LastModifiedDate ActionType].freeze
|
11
|
+
.each do |field|
|
12
|
+
attr_accessor :"#{field.to_s.underscore}"
|
13
|
+
end
|
14
|
+
|
15
|
+
def post_initialize
|
16
|
+
belongs_to :resource
|
17
|
+
belongs_to :account
|
18
|
+
end
|
14
19
|
|
15
|
-
|
16
|
-
|
17
|
-
belongs_to :account
|
18
|
-
end
|
20
|
+
def contact
|
21
|
+
find('Contact', contact_id)
|
19
22
|
end
|
23
|
+
|
24
|
+
def action
|
25
|
+
find('ActionType', action_type)
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
20
29
|
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module AutotaskRuby
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
# Represents the Autotask Entity Action Type
|
5
|
+
class ActionType
|
6
|
+
include Entity
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
end
|
8
|
+
FIELDS = %i[id Name View Active SystemActionType].freeze
|
9
|
+
.each do |field|
|
10
|
+
attr_accessor :"#{field.to_s.underscore}"
|
12
11
|
end
|
12
|
+
end
|
13
13
|
end
|
@@ -1,20 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module AutotaskRuby
|
4
|
+
# Represents an AutoTask Appointment Entity
|
5
|
+
class Appointment
|
6
|
+
include Entity
|
4
7
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
FIELDS = %i[id Title Description ResourceID StartDateTime EndDateTime CreateDateTime UpdateDateTime].freeze
|
10
|
-
.each do |field|
|
11
|
-
self.attr_accessor :"#{field.to_s.underscore}"
|
12
|
-
end
|
13
|
-
|
14
|
-
def post_initialize
|
15
|
-
belongs_to :resource
|
16
|
-
end
|
17
|
-
|
8
|
+
FIELDS = %i[id Title Description ResourceID StartDateTime EndDateTime CreateDateTime UpdateDateTime].freeze
|
9
|
+
.each do |field|
|
10
|
+
attr_accessor :"#{field.to_s.underscore}"
|
18
11
|
end
|
19
12
|
|
13
|
+
def post_initialize
|
14
|
+
belongs_to :resource
|
15
|
+
end
|
16
|
+
end
|
20
17
|
end
|
@@ -1,38 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module AutotaskRuby
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
4
|
+
# handles loading associated entities.
|
5
|
+
module Association
|
6
|
+
# loads parent entity.
|
7
|
+
# Thanks to scoop for this example.
|
8
|
+
def belongs_to(name, options = {})
|
9
|
+
name = name.to_s
|
10
|
+
klass = (options[:class_name] || name).to_s.classify.to_s
|
11
|
+
foreign_key = name.foreign_key
|
12
|
+
define_singleton_method(name) do
|
13
|
+
find(klass, send(foreign_key))
|
14
|
+
end
|
15
|
+
end
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
17
|
+
# Example, an appointment can have one contact.
|
18
|
+
# Thanks to scoop for this example.
|
19
|
+
def has_one(name, options = {})
|
20
|
+
name = name.to_s
|
21
|
+
options.reverse_merge! foreign_key: to_s.foreign_key.camelize
|
22
|
+
klass = (options[:class_name] || name).to_s.classify.to_s
|
23
|
+
define_singleton_method(name) do
|
24
|
+
find(klass, options[:foreign_key], id).first
|
25
|
+
end
|
26
|
+
end
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
28
|
+
# loads child entities.
|
29
|
+
# Example: A project can have many tasks.
|
30
|
+
# Thanks to scoop for this example.
|
31
|
+
def has_many(name, options = {})
|
32
|
+
name = name.to_s
|
33
|
+
options.reverse_merge! foreign_key: to_s.foreign_key.camelize
|
34
|
+
klass = (options[:class_name] || name).to_s.classify.to_s
|
35
|
+
define_singleton_method(name) do
|
36
|
+
query(klass, options[:foreign_key], id)
|
37
|
+
end
|
37
38
|
end
|
39
|
+
end
|
38
40
|
end
|
data/lib/autotask_ruby/client.rb
CHANGED
@@ -4,88 +4,106 @@ require 'autotask_ruby/version'
|
|
4
4
|
require 'autotask_ruby/resource'
|
5
5
|
|
6
6
|
module AutotaskRuby
|
7
|
+
# the primary client that interfaces with the SOAP Client that will interface with AutoTask.
|
8
|
+
class Client
|
9
|
+
attr_accessor :soap_client, :headers, :logger
|
7
10
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
@headers = {
|
16
|
-
'tns:AutotaskIntegrations' =>
|
17
|
-
{
|
18
|
-
'tns:IntegrationCode' => integration_code
|
19
|
-
}
|
11
|
+
def initialize(options = {})
|
12
|
+
@version = options[:version] || AutotaskRuby.configuration.version
|
13
|
+
integration_code = options[:integration_code] || AutotaskRuby.configuration.integration_code
|
14
|
+
@headers = {
|
15
|
+
'tns:AutotaskIntegrations' =>
|
16
|
+
{
|
17
|
+
'tns:IntegrationCode' => integration_code
|
20
18
|
}
|
19
|
+
}
|
21
20
|
|
22
|
-
|
23
|
-
|
24
|
-
@host = options[:host] || 'webservices.autotask.net'
|
25
|
-
@endpoint = options[:endpoint] || "https://#{@host}/ATServices/#{@version}/atws.asmx"
|
26
|
-
|
27
|
-
# Override optional Savon attributes
|
28
|
-
savon_options = {}
|
29
|
-
%w[read_timeout open_timeout proxy raise_errors log_level basic_auth log raise_errors].each do |prop|
|
30
|
-
key = prop.to_sym
|
31
|
-
savon_options[key] = options[key] if options.key?(key)
|
32
|
-
end
|
33
|
-
|
34
|
-
@soap_client = Savon.client({
|
35
|
-
wsdl: './atws.wsdl',
|
36
|
-
soap_header: @headers,
|
37
|
-
namespaces: { xmlns: AutotaskRuby.configuration.namespace },
|
38
|
-
logger: Logger.new($stdout),
|
39
|
-
raise_errors: false,
|
40
|
-
log: true,
|
41
|
-
endpoint: @endpoint,
|
42
|
-
ssl_version: @ssl_version # Sets ssl_version for HTTPI adapter
|
43
|
-
}.update(savon_options))
|
44
|
-
end
|
45
|
-
|
46
|
-
# Public: Get the names of all wsdl operations.
|
47
|
-
# List all available operations from the atws.wsdl
|
48
|
-
def operations
|
49
|
-
@soap_client.operations
|
50
|
-
end
|
51
|
-
|
52
|
-
# @param entity, id
|
53
|
-
# pass in the entity_type, I.E. AccountToDo, Resource, etc. and the ID of the entity.
|
54
|
-
# @return Entity
|
55
|
-
# Returns a single Entity if a match was found.
|
56
|
-
# Returns nil if no match is found.
|
57
|
-
def find(entity, id)
|
58
|
-
response = query(entity.to_s, id)
|
59
|
-
|
60
|
-
return nil if response.entities.empty?
|
61
|
-
|
62
|
-
response.entities.first
|
63
|
-
end
|
64
|
-
|
65
|
-
# @param entity_type and value
|
66
|
-
# Other parameters, are optional.
|
67
|
-
# full set of parameters include entity_type, field, operation, value.
|
68
|
-
# Queries the Autotask QUERY API. Returns a QueryResponse result set.
|
69
|
-
# @return AutotaskRuby::Response.
|
70
|
-
def query(entity_type, field = 'id', operation = 'equals', value)
|
71
|
-
result = @soap_client.call(:query, message: "<sXML><![CDATA[<queryxml><entity>#{entity_type}</entity><query><field>#{field}<expression op=\"#{operation}\">#{value}</expression></field></query></queryxml>]]></sXML>")
|
72
|
-
AutotaskRuby::QueryResponse.new(self, result)
|
73
|
-
end
|
74
|
-
|
75
|
-
# @param entity_type
|
76
|
-
# include the entity type. ServiceCall, Appointment, etc.
|
77
|
-
# @param ids
|
78
|
-
# One or more entity ID's that should be deleted.
|
79
|
-
# @return
|
80
|
-
# AutotaskRuby::DeleteResponse
|
81
|
-
def delete(entity_type, *ids)
|
82
|
-
entities = ++''
|
83
|
-
ids.each do |id|
|
84
|
-
entities << "<Entity xsi:type=\"#{entity_type}\"><id xsi:type=\"xsd:int\">#{id}</id></Entity>"
|
85
|
-
end
|
86
|
-
resp = @soap_client.call(:delete, message: "<Entities>#{entities.to_s}</Entities>")
|
87
|
-
AutotaskRuby::DeleteResponse.new(@client, resp)
|
88
|
-
end
|
21
|
+
@ssl_version = options[:ssl_version] || :TLSv1_2
|
89
22
|
|
23
|
+
@host = options[:host] || 'webservices.autotask.net'
|
24
|
+
@endpoint = options[:endpoint] || "https://#{@host}/ATServices/#{@version}/atws.asmx"
|
25
|
+
|
26
|
+
# Override optional Savon attributes
|
27
|
+
savon_options = {}
|
28
|
+
%w[read_timeout open_timeout proxy raise_errors log_level basic_auth log raise_errors].each do |prop|
|
29
|
+
key = prop.to_sym
|
30
|
+
savon_options[key] = options[key] if options.key?(key)
|
31
|
+
end
|
32
|
+
|
33
|
+
@soap_client = Savon.client({
|
34
|
+
wsdl: './atws.wsdl',
|
35
|
+
soap_header: @headers,
|
36
|
+
namespaces: { xmlns: AutotaskRuby.configuration.namespace },
|
37
|
+
logger: Logger.new($stdout),
|
38
|
+
raise_errors: false,
|
39
|
+
log: true,
|
40
|
+
endpoint: @endpoint,
|
41
|
+
ssl_version: @ssl_version # Sets ssl_version for HTTPI adapter
|
42
|
+
}.update(savon_options))
|
43
|
+
end
|
44
|
+
|
45
|
+
# Public: Get the names of all wsdl operations.
|
46
|
+
# List all available operations from the atws.wsdl
|
47
|
+
def operations
|
48
|
+
@soap_client.operations
|
49
|
+
end
|
50
|
+
|
51
|
+
# @param entity, id
|
52
|
+
# pass in the entity_type, I.E. AccountToDo, Resource, etc. and the ID of the entity.
|
53
|
+
# @return Entity
|
54
|
+
# Returns a single Entity if a match was found.
|
55
|
+
# Returns nil if no match is found.
|
56
|
+
def find(entity, id)
|
57
|
+
response = query(entity.to_s, id)
|
58
|
+
|
59
|
+
return nil if response.entities.empty?
|
60
|
+
|
61
|
+
response.entities.first
|
62
|
+
end
|
63
|
+
|
64
|
+
# @param entity_type and value
|
65
|
+
# Other parameters, are optional.
|
66
|
+
# full set of parameters include entity_type, field, operation, value.
|
67
|
+
# Queries the Autotask QUERY API. Returns a QueryResponse result set.
|
68
|
+
# @return AutotaskRuby::Response.
|
69
|
+
def query(entity_type, field = 'id', operation = 'equals', value)
|
70
|
+
result = @soap_client.call(:query, message: "<sXML><![CDATA[<queryxml><entity>#{entity_type}</entity><query><field>#{field}<expression op=\"#{operation}\">#{value}</expression></field></query></queryxml>]]></sXML>")
|
71
|
+
AutotaskRuby::QueryResponse.new(self, result)
|
72
|
+
end
|
73
|
+
|
74
|
+
# @param entity_type
|
75
|
+
# include the entity type. ServiceCall, Appointment, etc.
|
76
|
+
# @param ids
|
77
|
+
# One or more entity ID's that should be deleted.
|
78
|
+
# @return
|
79
|
+
# AutotaskRuby::DeleteResponse
|
80
|
+
def delete(entity_type, *ids)
|
81
|
+
entities = ++''
|
82
|
+
ids.each do |id|
|
83
|
+
entities << "<Entity xsi:type=\"#{entity_type}\"><id xsi:type=\"xsd:int\">#{id}</id></Entity>"
|
84
|
+
end
|
85
|
+
resp = @soap_client.call(:delete, message: "<Entities>#{entities}</Entities>")
|
86
|
+
AutotaskRuby::DeleteResponse.new(@client, resp)
|
87
|
+
end
|
88
|
+
|
89
|
+
def query_for(message)
|
90
|
+
result = @soap_client.call(:query, message: message)
|
91
|
+
AutotaskRuby::QueryResponse.new(self, result)
|
92
|
+
end
|
93
|
+
|
94
|
+
# updates the entity in the AutoTask API.
|
95
|
+
# All fields are iterated and this builds the XML message that is sent to AutoTask.
|
96
|
+
# Any field that is not filled out will be sent as empty. This means that it will wipe
|
97
|
+
# any value that AutoTask has for that field.
|
98
|
+
def update(entity_xml)
|
99
|
+
result = @soap_client.call(:update, message: "<Entities>#{entity_xml}</Entities>")
|
100
|
+
UpdateResponse.new(@client, result)
|
101
|
+
end
|
102
|
+
|
103
|
+
# creates an entity in AutoTask.
|
104
|
+
def create(entity_xml)
|
105
|
+
result = @soap_client.call(:create, message: "<Entities>#{entity_xml}</Entities>")
|
106
|
+
CreateResponse.new(@client, result)
|
90
107
|
end
|
108
|
+
end
|
91
109
|
end
|