sirportly 1.1.1 → 1.1.2

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.
@@ -0,0 +1,6 @@
1
+ module Sirportly
2
+ class Brand < DataObject
3
+ self.collection_path = 'objects/brands'
4
+ self.maps = {'departments' => "Department"}
5
+ end
6
+ end
@@ -0,0 +1,7 @@
1
+ module Sirportly
2
+ class Customer < DataObject
3
+ self.collection_path = 'customers/all'
4
+ self.member = {:path => 'customers/info', :param => 'customer'}
5
+ self.maps = {'contact_methods' => 'CustomerContactMethod'}
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ module Sirportly
2
+ class CustomerContactMethod < DataObject
3
+ end
4
+ end
@@ -0,0 +1,6 @@
1
+ module Sirportly
2
+ class Department < DataObject
3
+ self.collection_path = 'objects/departments'
4
+ self.maps = {'brand' => 'Brand', 'escalation_path' => 'EscalationPath'}
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Sirportly
2
+ class EscalationPath < DataObject
3
+ self.collection_path = 'objects/escalation_paths'
4
+ self.maps = {'teams' => 'Team'}
5
+ end
6
+ end
@@ -0,0 +1,10 @@
1
+ module Sirportly
2
+ class Filter < DataObject
3
+ self.collection_path = 'objects/filters'
4
+
5
+ def tickets(options = {})
6
+ Ticket.filter(@client, self, options)
7
+ end
8
+
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ module Sirportly
2
+ class Priority < DataObject
3
+ self.collection_path = 'objects/priorities'
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Sirportly
2
+ class SLA < DataObject
3
+ self.collection_path = 'objects/slas'
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Sirportly
2
+ class Status < DataObject
3
+ self.collection_path = 'objects/statuses'
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ module Sirportly
2
+ class Team < DataObject
3
+ self.collection_path = 'objects/teams'
4
+ self.maps = {'users' => 'User'}
5
+ end
6
+ end
@@ -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
@@ -0,0 +1,7 @@
1
+ module Sirportly
2
+ class User < DataObject
3
+ self.collection_path = 'users/all'
4
+ self.member = {:path => 'users/info', :param => 'user'}
5
+ self.maps = {'teams' => 'Team'}
6
+ end
7
+ 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.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