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
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copied from https://github.com/scoop/autotask_api/blob/master/lib/autotask_api/query_xml.rb
|
4
|
+
# Thank you for the great work.
|
5
|
+
|
6
|
+
module AutotaskRuby
|
7
|
+
class QueryXML
|
8
|
+
Condition = Struct.new(:field, :op, :expression)
|
9
|
+
attr_accessor :entity, :op, :field, :expression, :conditions
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
yield self
|
13
|
+
self.op ||= 'equals'
|
14
|
+
end
|
15
|
+
|
16
|
+
def add_condition(field, op, expression)
|
17
|
+
self.conditions ||= []
|
18
|
+
self.conditions << Condition.new(field, op, expression)
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_s
|
22
|
+
Nokogiri::XML::Builder.new do
|
23
|
+
sXML do
|
24
|
+
cdata(Nokogiri::XML::Builder.new do |xml|
|
25
|
+
xml.queryxml do
|
26
|
+
xml.entity entity
|
27
|
+
xml.query do
|
28
|
+
if field
|
29
|
+
xml.field field do
|
30
|
+
xml.expression expression, op: op
|
31
|
+
end
|
32
|
+
else
|
33
|
+
conditions.each do |condition|
|
34
|
+
xml.condition do
|
35
|
+
xml.field condition.field do
|
36
|
+
xml.expression condition.expression,
|
37
|
+
op: condition.op
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end.doc.root)
|
45
|
+
end
|
46
|
+
end.doc.root.to_xml
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -1,22 +1,22 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module AutotaskRuby
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
# Represents the Autotask Entity Resource
|
5
|
+
class Resource
|
6
|
+
include AutotaskRuby::Entity
|
7
|
+
include AutotaskRuby::Query
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
FIELDS = %i[id Email Email2 Email3 FirstName HomePhone Initials LastName LocationID MiddleName
|
10
|
+
MobilePhone OfficeExtension OfficePhone ResourceType Title UserName UserType Active].freeze
|
11
|
+
.each do |field|
|
12
|
+
attr_accessor :"#{field.to_s.underscore}"
|
13
|
+
end
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
15
|
+
def post_initialize
|
16
|
+
has_many :account_to_dos, foreign_key: 'AssignedToResourceID'
|
17
|
+
has_many :appointments, foreign_key: 'ResourceID'
|
18
|
+
has_many :tickets, foreign_key: 'AssignedResourceID'
|
19
|
+
has_many :tasks, foreign_key: 'AssignedResourceID'
|
21
20
|
end
|
21
|
+
end
|
22
22
|
end
|
@@ -1,28 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module AutotaskRuby
|
2
|
-
|
3
|
-
|
4
|
-
|
4
|
+
module Response
|
5
|
+
include Constants
|
6
|
+
attr_accessor :entity_type, :errors, :return_code, :entities
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
def initialize(client, response)
|
9
|
+
@client = client
|
10
|
+
@entities = []
|
11
|
+
@errors = response.xpath('//Autotask:Errors', Autotask: AutotaskRuby.configuration.namespace).text
|
12
|
+
@return_code = response.xpath('//Autotask:ReturnCode', Autotask: AutotaskRuby.configuration.namespace).text.to_i
|
13
|
+
@entity_type = response.xpath('//Autotask:EntityResultType', Autotask: AutotaskRuby.configuration.namespace).text.classify
|
14
|
+
parse_entities(response.xpath('//Autotask:Entity', Autotask: AutotaskRuby.configuration.namespace))
|
15
|
+
end
|
14
16
|
|
15
|
-
|
17
|
+
private
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
+
def parse_entities(results)
|
20
|
+
return [] if results.blank?
|
19
21
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
22
|
+
klass = ('AutotaskRuby::' + results.first.attribute('type').to_s).constantize
|
23
|
+
results.collect do |entity|
|
24
|
+
obj = klass.new(client: @client)
|
25
|
+
obj.build(entity)
|
26
|
+
@entities.push(obj)
|
27
|
+
end
|
27
28
|
end
|
29
|
+
end
|
28
30
|
end
|
@@ -1,24 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module AutotaskRuby
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
4
|
+
# Represents the Autotask Entity ServiceCall
|
5
|
+
class ServiceCall
|
6
|
+
include Entity
|
7
|
+
include Query
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
FIELDS = %i[id AccountID StartDateTime EndDateTime Description Complete CreateDateTime LastModifiedDateTime Duration Status].freeze
|
10
|
+
.each do |field|
|
11
|
+
attr_accessor :"#{field.to_s.underscore}"
|
12
|
+
end
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
# Returns the associated ResourceID.
|
15
|
+
def resource_id
|
16
|
+
service_call_ticket = find('ServiceCallTicket', 'ServiceCallId', id)
|
17
|
+
service_call_ticket_resource = find('ServiceCallTicketResource', 'ServiceCallTicketId', service_call_ticket.id)
|
18
|
+
service_call_ticket_resource.resource_id
|
19
|
+
end
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
21
|
+
# Returns the associated Resource
|
22
|
+
def resource
|
23
|
+
find('Resource', resource_id)
|
23
24
|
end
|
25
|
+
end
|
24
26
|
end
|
@@ -1,11 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module AutotaskRuby
|
2
|
-
|
3
|
-
|
4
|
-
|
4
|
+
# Represents the Autotask Entity ServiceCallTicket
|
5
|
+
class ServiceCallTicket
|
6
|
+
include Entity
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
8
|
+
FIELDS = %i[id ServiceCallID TicketID].freeze
|
9
|
+
.each do |field|
|
10
|
+
attr_accessor :"#{field.to_s.underscore}"
|
10
11
|
end
|
12
|
+
end
|
11
13
|
end
|
@@ -1,11 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module AutotaskRuby
|
2
|
-
|
3
|
-
|
4
|
-
|
4
|
+
# Represents the Autotask Entity ServiceCallTicketResource
|
5
|
+
class ServiceCallTicketResource
|
6
|
+
include Entity
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
8
|
+
FIELDS = %i[id ServiceCallTicketID ResourceID].freeze
|
9
|
+
.each do |field|
|
10
|
+
attr_accessor :"#{field.to_s.underscore}"
|
10
11
|
end
|
12
|
+
end
|
11
13
|
end
|
data/lib/autotask_ruby/task.rb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module AutotaskRuby
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
# Represents the Autotask Entity Task
|
5
|
+
class Task
|
6
|
+
include Entity
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
FIELDS = %i[id AllocationCodeID AssignedResourceID CreateDateTime DepartmentID Description EstimatedHours
|
9
|
+
LastActivityDateTime ProjectID Status TaskNumber TaskType Title ].freeze
|
10
|
+
.each do |field|
|
11
|
+
attr_accessor :"#{field.to_s.underscore}"
|
12
|
+
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
14
|
+
def post_initialize
|
15
|
+
belongs_to :resource
|
16
|
+
belongs_to :project
|
18
17
|
end
|
18
|
+
end
|
19
19
|
end
|
data/lib/autotask_ruby/ticket.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module AutotaskRuby
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
# Represents the Autotask Entity Ticket
|
5
|
+
class Ticket
|
6
|
+
include Entity
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
FIELDS = %i[id AccountID ContactID CreateDate Description DueDateTime LastActivityDate AssignedResourceID Status TicketNumber Title].freeze
|
9
|
+
.each do |field|
|
10
|
+
attr_accessor :"#{field.to_s.underscore}"
|
11
|
+
end
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
13
|
+
def post_initialize
|
14
|
+
belongs_to :account
|
15
|
+
belongs_to :contact
|
17
16
|
end
|
17
|
+
end
|
18
18
|
end
|
@@ -1,31 +1,34 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module AutotaskRuby
|
4
|
-
|
5
|
-
|
4
|
+
class ZoneInfo
|
5
|
+
attr_reader :raw_result
|
6
6
|
|
7
|
-
|
7
|
+
ENDPOINT = 'https://webservices.autotask.net/ATServices/1.5/atws.asmx'
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
def initialize(username)
|
10
|
+
@client = Savon.client(wsdl: './atws.wsdl', endpoint: ENDPOINT)
|
11
|
+
@raw_result = @client.call(:get_zone_info, message: {'UserName' => username})
|
12
|
+
@zone_info = @raw_result.body[:get_zone_info_response][:get_zone_info_result]
|
13
|
+
end
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
def error_code
|
16
|
+
@zone_info[:error_code].to_i
|
17
|
+
end
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
def web_url
|
20
|
+
@zone_info[:web_url]
|
21
|
+
end
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
def url
|
24
|
+
@zone_info[:url]
|
25
|
+
end
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
# @param [Object] method
|
28
|
+
# @param [Array] _args
|
29
|
+
# @return [Object]
|
30
|
+
def method_missing(method, *_args)
|
31
|
+
@zone_info[method]
|
30
32
|
end
|
33
|
+
end
|
31
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: autotask_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jared L Jennings
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -235,6 +235,7 @@ files:
|
|
235
235
|
- lib/autotask_ruby/project.rb
|
236
236
|
- lib/autotask_ruby/query.rb
|
237
237
|
- lib/autotask_ruby/query_response.rb
|
238
|
+
- lib/autotask_ruby/query_xml.rb
|
238
239
|
- lib/autotask_ruby/resource.rb
|
239
240
|
- lib/autotask_ruby/response.rb
|
240
241
|
- lib/autotask_ruby/service_call.rb
|
@@ -242,6 +243,7 @@ files:
|
|
242
243
|
- lib/autotask_ruby/service_call_ticket_resource.rb
|
243
244
|
- lib/autotask_ruby/task.rb
|
244
245
|
- lib/autotask_ruby/ticket.rb
|
246
|
+
- lib/autotask_ruby/update_response.rb
|
245
247
|
- lib/autotask_ruby/version.rb
|
246
248
|
- lib/autotask_ruby/zone_info.rb
|
247
249
|
homepage: https://github.com/trepidity/autotask_ruby
|
@@ -265,8 +267,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
265
267
|
- !ruby/object:Gem::Version
|
266
268
|
version: '0'
|
267
269
|
requirements: []
|
268
|
-
|
269
|
-
rubygems_version: 2.7.8
|
270
|
+
rubygems_version: 3.1.2
|
270
271
|
signing_key:
|
271
272
|
specification_version: 4
|
272
273
|
summary: A ruby client for the Autotask API
|