sirportly 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sirportly/data_objects/brand.rb +6 -0
- data/lib/sirportly/data_objects/customer.rb +7 -0
- data/lib/sirportly/data_objects/customer_contact_method.rb +4 -0
- data/lib/sirportly/data_objects/department.rb +6 -0
- data/lib/sirportly/data_objects/escalation_path.rb +6 -0
- data/lib/sirportly/data_objects/filter.rb +10 -0
- data/lib/sirportly/data_objects/priority.rb +5 -0
- data/lib/sirportly/data_objects/sla.rb +5 -0
- data/lib/sirportly/data_objects/status.rb +5 -0
- data/lib/sirportly/data_objects/team.rb +6 -0
- data/lib/sirportly/data_objects/ticket.rb +96 -0
- data/lib/sirportly/data_objects/ticket_update.rb +17 -0
- data/lib/sirportly/data_objects/user.rb +7 -0
- metadata +14 -1
@@ -0,0 +1,96 @@
|
|
1
|
+
module Sirportly
|
2
|
+
class Ticket < DataObject
|
3
|
+
self.collection_path = 'tickets/all'
|
4
|
+
self.member = {:path => 'tickets/ticket', :param => 'reference'}
|
5
|
+
self.maps = {'status' => 'Status', 'priority' => 'Priority', 'department' => 'Department', 'customer' => 'Customer', 'customer_contact_method' => 'CustomerContactMethod',
|
6
|
+
'team' => 'Team', 'user' => 'User', 'sla' => 'SLA', 'updates' => 'TicketUpdate'}
|
7
|
+
|
8
|
+
# Executes a macro on the ticket. Accepts the name of ID of the macro you wish to execute as a
|
9
|
+
# string or an integer.
|
10
|
+
def run_macro(name_or_id)
|
11
|
+
if req = client.request('tickets/macro', :ticket => @attributes['reference'], :macro => name_or_id.to_s)
|
12
|
+
set_attributes(req)
|
13
|
+
true
|
14
|
+
else
|
15
|
+
false
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# Updates ticket parameters. Accepts a hash with the parameters which you wish to update.
|
20
|
+
def update(params)
|
21
|
+
if req = client.request('tickets/update', format_params(params))
|
22
|
+
set_attributes(req)
|
23
|
+
true
|
24
|
+
else
|
25
|
+
false
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# Posts a new update to the ticket. Accepts a hash of parameters needed to create the update.
|
30
|
+
def post_update(params = {})
|
31
|
+
if req = client.request('tickets/post_update', format_params(params))
|
32
|
+
update = TicketUpdate.new(@client, req)
|
33
|
+
(@attributes['updates'] ||= []) << update
|
34
|
+
update
|
35
|
+
else
|
36
|
+
false
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Adds a follow up to the ticket
|
41
|
+
def add_follow_up(params = {})
|
42
|
+
if req = client.request('tickets/followup', format_params(params))
|
43
|
+
true
|
44
|
+
else
|
45
|
+
false
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# Creates a new ticket and returns a ticket object
|
50
|
+
def self.create(client, params = {})
|
51
|
+
if req = client.request('tickets/submit', format_params(params))
|
52
|
+
self.new(client, req)
|
53
|
+
else
|
54
|
+
false
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# Returns a DataSet containing tickets matching the passed query and page number.
|
59
|
+
def self.search(client, query, page = 1)
|
60
|
+
if req = client.request('tickets/search', :query => query, :page => page)
|
61
|
+
DataSet.new(client, req, self)
|
62
|
+
else
|
63
|
+
false
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# Returns tickets which match the passed filter
|
68
|
+
def self.filter(client, filter, options = {})
|
69
|
+
filter = filter.id if filter.is_a?(Sirportly::Filter)
|
70
|
+
options[:user] = options[:user].id if options[:user].is_a?(Sirportly::User)
|
71
|
+
if req = client.request('tickets/filter', options.merge({:filter => filter}))
|
72
|
+
DataSet.new(client, req, self)
|
73
|
+
else
|
74
|
+
false
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
private
|
79
|
+
|
80
|
+
def format_params(params)
|
81
|
+
self.class.format_params(params.merge({:ticket => @attributes['reference']}))
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.format_params(params)
|
85
|
+
params.inject({}) do |hash, (k,v)|
|
86
|
+
if v.kind_of?(Sirportly::DataObject) && v.attributes.keys.include?('id')
|
87
|
+
hash[k] = v.id
|
88
|
+
else
|
89
|
+
hash[k] = v
|
90
|
+
end
|
91
|
+
hash
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Sirportly
|
2
|
+
class TicketUpdate < DataObject
|
3
|
+
|
4
|
+
def author
|
5
|
+
if author = self.attributes['author']
|
6
|
+
if author.keys.include?('reference') && author.keys.include?('abbreviated_name') && author.keys.include?('pin')
|
7
|
+
Customer.new(author)
|
8
|
+
else
|
9
|
+
User.new(author)
|
10
|
+
end
|
11
|
+
else
|
12
|
+
nil
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sirportly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -20,6 +20,19 @@ files:
|
|
20
20
|
- lib/sirportly.rb
|
21
21
|
- lib/sirportly/client.rb
|
22
22
|
- lib/sirportly/data_object.rb
|
23
|
+
- lib/sirportly/data_objects/brand.rb
|
24
|
+
- lib/sirportly/data_objects/customer.rb
|
25
|
+
- lib/sirportly/data_objects/customer_contact_method.rb
|
26
|
+
- lib/sirportly/data_objects/department.rb
|
27
|
+
- lib/sirportly/data_objects/escalation_path.rb
|
28
|
+
- lib/sirportly/data_objects/filter.rb
|
29
|
+
- lib/sirportly/data_objects/priority.rb
|
30
|
+
- lib/sirportly/data_objects/sla.rb
|
31
|
+
- lib/sirportly/data_objects/status.rb
|
32
|
+
- lib/sirportly/data_objects/team.rb
|
33
|
+
- lib/sirportly/data_objects/ticket.rb
|
34
|
+
- lib/sirportly/data_objects/ticket_update.rb
|
35
|
+
- lib/sirportly/data_objects/user.rb
|
23
36
|
- lib/sirportly/data_set.rb
|
24
37
|
- lib/sirportly/request.rb
|
25
38
|
- lib/sirportly/spql_query.rb
|