zendesk2 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -115,9 +115,14 @@ class Zendesk2::Client::Ticket < Zendesk2::Model
115
115
  self.connection.ticket_audits(ticket_id: self.identity).all
116
116
  end
117
117
 
118
- # @return [Array<Zendesk2::Client::AuditEvent>] audit events of type 'Comment'
118
+ # @return [Zendesk2::Client::TicketMetric] metrics for this ticket
119
+ def metrics
120
+ Zendesk2::Client::TicketMetric.new(self.connection.get_ticket_metric("ticket_id" => self.identity).body["ticket_metric"])
121
+ end
122
+
123
+ # @return [Array<Zendesk2::Client::TicketComment>] all comments for this ticket
119
124
  def comments
120
- audits.map{|audit| audit.events.select{|e| e.type == "Comment"}}.flatten
125
+ self.connection.ticket_comments(ticket_id: self.identity).all
121
126
  end
122
127
 
123
128
  private
@@ -0,0 +1,23 @@
1
+ class Zendesk2::Client::TicketComments < Zendesk2::Collection
2
+
3
+ model Zendesk2::Client::TicketComment
4
+
5
+ attribute :ticket_id, type: :integer
6
+
7
+ self.collection_method = :get_ticket_comments
8
+ self.collection_root = "comments"
9
+
10
+ def ticket
11
+ self.connection.tickets.get(self.ticket_id)
12
+ end
13
+
14
+ def all(params={})
15
+ requires :ticket_id
16
+
17
+ body = connection.send(collection_method, {"ticket_id" => self.ticket_id}.merge(params)).body
18
+
19
+ collection = self.clone.load(body[collection_root])
20
+ collection.merge_attributes(Cistern::Hash.slice(body, "count", "next_page", "previous_page"))
21
+ collection
22
+ end
23
+ end
@@ -0,0 +1,54 @@
1
+ class Zendesk2::Client::TicketMetric < Cistern::Model
2
+ extend Zendesk2::Attributes
3
+
4
+ # @return [Integer] Automatically assigned
5
+ identity :id, type: :integer
6
+ # @return [Integer] The ID of the associated ticket
7
+ attribute :ticket_id, type: :integer
8
+ # @return [Time] The time the audit was created
9
+ attribute :created_at, type: :time
10
+ # @return [Time] The time the audit was last updated
11
+ attribute :updated_at, type: :time
12
+
13
+ # @return [Integer] Number of groups this ticket passed through
14
+ attribute :group_stations, type: :integer
15
+ # @return [Integer] Number of assignees this ticket had
16
+ attribute :assignee_stations, type: :integer
17
+ # @return [Integer] Total number of times the ticket was reopened
18
+ attribute :reopens, type: :integer
19
+ # @return [Integer] Total number of times ticket was replied to
20
+ attribute :replies, type: :integer
21
+
22
+ # @return [Time] When the assignee last updated the ticket
23
+ attribute :assignee_updated_at, type: :time
24
+ # @return [Time] When the requester last updated the ticket
25
+ attribute :requester_updated_at, type: :time
26
+ # @return [Time] When the status was last updated
27
+ attribute :status_updated_at, type: :time
28
+ # @return [Time] When the ticket was initially assigned
29
+ attribute :initially_assigned_at, type: :time
30
+ # @return [Time] When the ticket was last assigned
31
+ attribute :assigned_at, type: :time
32
+ # @return [Time] When the ticket was solved
33
+ attribute :solved_at, type: :time
34
+ # @return [Time] When the latest comment was added
35
+ attribute :latest_comment_added_at, type: :time
36
+
37
+ # @return [Hash] Number of minutes to the first resolution time inside and out of business hours
38
+ attribute :first_resolution_time_in_minutes
39
+ # @return [Hash] Number of minutes to the first reply inside and out of business hours
40
+ attribute :reply_time_in_minutes
41
+ # @return [Hash] Number of minutes to the full resolution inside and out of business hours
42
+ attribute :full_resolution_time_in_minutes
43
+ # @return [Hash] Number of minutes the agent spent waiting inside and out of business hours
44
+ attribute :agent_wait_time_in_minutes
45
+ # @return [Hash] Number of minutes the requester spent waiting inside and out of business hours
46
+ attribute :requester_wait_time_in_minutes
47
+
48
+ def ticket
49
+ requires :ticket_id
50
+
51
+ self.connection.tickets.get(self.ticket_id)
52
+ end
53
+
54
+ end
@@ -0,0 +1,10 @@
1
+ class Zendesk2::Client::TicketMetrics < Zendesk2::Collection
2
+ model Zendesk2::Client::TicketMetric
3
+
4
+ attribute :ticket_id, type: :integer
5
+
6
+ self.collection_method = :get_ticket_metrics
7
+ self.collection_root = "ticket_metrics"
8
+ self.model_method = :get_ticket_metric
9
+ self.model_root = "ticket_metric"
10
+ end
@@ -0,0 +1,22 @@
1
+ class Zendesk2::Client
2
+ class Real
3
+ def get_ticket_comments(params={})
4
+ ticket_id = params["ticket_id"]
5
+ request(
6
+ :method => :get,
7
+ :path => "/tickets/#{ticket_id}/comments.json"
8
+ )
9
+ end
10
+ end # Real
11
+
12
+ class Mock
13
+ def get_ticket_comments(params={})
14
+ ticket_id = params["ticket_id"]
15
+
16
+ page(params,
17
+ :ticket_comments,
18
+ "/tickets/#{ticket_id}/comments.json",
19
+ "comments")
20
+ end
21
+ end # Mock
22
+ end
@@ -0,0 +1,43 @@
1
+ class Zendesk2::Client
2
+ class Real
3
+ def get_ticket_metric(params={})
4
+ id = params["id"]
5
+ ticket_id = params["ticket_id"]
6
+ if id
7
+ request(
8
+ :method => :get,
9
+ :path => "/ticket_metrics/#{id}.json"
10
+ )
11
+ else
12
+ request(
13
+ :method => :get,
14
+ :path => "/tickets/#{ticket_id}/metrics.json"
15
+ )
16
+ end
17
+ end
18
+ end # Real
19
+
20
+ class Mock
21
+ def get_ticket_metric(params={})
22
+ id = params["id"]
23
+ ticket_id = params["ticket_id"]
24
+
25
+ path = "/tickets_metrics/#{id}.json"
26
+
27
+ if body = self.data[:ticket_metrics][id]
28
+ response(
29
+ :path => path,
30
+ :body => {
31
+ "ticket_metric" => body
32
+ },
33
+ )
34
+ else
35
+ response(
36
+ :path => path,
37
+ :status => 404,
38
+ :body => {"error" => "RecordNotFound", "description" => "Not found"},
39
+ )
40
+ end
41
+ end
42
+ end # Mock
43
+ end
@@ -0,0 +1,22 @@
1
+ class Zendesk2::Client
2
+ class Real
3
+ def get_ticket_metrics(params={})
4
+ page_params = Zendesk2.paging_parameters(params)
5
+
6
+ request(
7
+ :params => page_params,
8
+ :method => :get,
9
+ :path => "/ticket_metrics.json",
10
+ )
11
+ end
12
+ end # Real
13
+
14
+ class Mock
15
+ def get_ticket_metrics(params={})
16
+ page(params,
17
+ :ticket_metrics,
18
+ "/ticket_metrics.json",
19
+ "metrics")
20
+ end
21
+ end
22
+ end
@@ -18,6 +18,18 @@ class Zendesk2::Client
18
18
  body = self.data[:tickets][ticket_id].merge!(params)
19
19
 
20
20
  if comment = params["comment"]
21
+ comment_id = self.class.new_id
22
+ comment_data = self.data[:ticket_comments][comment_id] = {
23
+ "id" => comment_id,
24
+ "type" => "Comment",
25
+ "author_id" => current_user["id"],
26
+ "body" => comment["body"],
27
+ "html_body" => "<p>#{comment["body"]}</p>",
28
+ "public" => comment["public"].nil? ? true : comment["public"],
29
+ "trusted" => comment["trusted"].nil? ? true : comment["trusted"],
30
+ "attachments" => comment["attachments"] || [],
31
+ }
32
+
21
33
  audit_id = self.class.new_id
22
34
  self.data[:ticket_audits][audit_id] = {
23
35
  "id" => audit_id,
@@ -42,16 +54,7 @@ class Zendesk2::Client
42
54
  },
43
55
  "custom" => {},
44
56
  },
45
- "events" => [
46
- "id" => self.class.new_id,
47
- "type" => "Comment",
48
- "author_id" => current_user["id"],
49
- "body" => comment["body"],
50
- "html_body" => "<p>#{comment["body"]}</p>",
51
- "public" => comment["public"].nil? ? true : comment["public"],
52
- "trusted" => comment["trusted"].nil? ? true : comment["trusted"],
53
- "attachments" => comment["attachments"] || [],
54
- ]
57
+ "events" => [comment_data]
55
58
  }
56
59
  end
57
60
 
@@ -11,7 +11,9 @@ class Zendesk2::Client < Cistern::Service
11
11
  collection :groups
12
12
  collection :organizations
13
13
  collection :ticket_audits
14
+ collection :ticket_metrics
14
15
  collection :tickets
16
+ collection :ticket_comments
15
17
  collection :topic_comments
16
18
  collection :topics
17
19
  collection :users
@@ -22,6 +24,7 @@ class Zendesk2::Client < Cistern::Service
22
24
  model :organization
23
25
  model :ticket
24
26
  model :ticket_audit
27
+ model :ticket_metric
25
28
  model :ticket_change
26
29
  model :ticket_comment
27
30
  model :ticket_comment_privacy_change
@@ -70,6 +73,9 @@ class Zendesk2::Client < Cistern::Service
70
73
  request :get_ticket
71
74
  request :get_ticket_audit
72
75
  request :get_ticket_audits
76
+ request :get_ticket_comments
77
+ request :get_ticket_metric
78
+ request :get_ticket_metrics
73
79
  request :get_tickets
74
80
  request :get_topic
75
81
  request :get_topic_comment
@@ -171,6 +177,8 @@ class Zendesk2::Client < Cistern::Service
171
177
  :identities => {},
172
178
  :organizations => {},
173
179
  :ticket_audits => {},
180
+ :ticket_comments => {},
181
+ :ticket_metrics => {},
174
182
  :tickets => {},
175
183
  :topic_comments => {},
176
184
  :topics => {},
@@ -1,3 +1,3 @@
1
1
  module Zendesk2
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zendesk2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-29 00:00:00.000000000 Z
12
+ date: 2013-11-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: addressable
@@ -125,7 +125,10 @@ files:
125
125
  - lib/zendesk2/client/models/ticket_change.rb
126
126
  - lib/zendesk2/client/models/ticket_comment.rb
127
127
  - lib/zendesk2/client/models/ticket_comment_privacy_change.rb
128
+ - lib/zendesk2/client/models/ticket_comments.rb
128
129
  - lib/zendesk2/client/models/ticket_create.rb
130
+ - lib/zendesk2/client/models/ticket_metric.rb
131
+ - lib/zendesk2/client/models/ticket_metrics.rb
129
132
  - lib/zendesk2/client/models/ticket_notification.rb
130
133
  - lib/zendesk2/client/models/ticket_voice_comment.rb
131
134
  - lib/zendesk2/client/models/tickets.rb
@@ -174,6 +177,9 @@ files:
174
177
  - lib/zendesk2/client/requests/get_ticket.rb
175
178
  - lib/zendesk2/client/requests/get_ticket_audit.rb
176
179
  - lib/zendesk2/client/requests/get_ticket_audits.rb
180
+ - lib/zendesk2/client/requests/get_ticket_comments.rb
181
+ - lib/zendesk2/client/requests/get_ticket_metric.rb
182
+ - lib/zendesk2/client/requests/get_ticket_metrics.rb
177
183
  - lib/zendesk2/client/requests/get_tickets.rb
178
184
  - lib/zendesk2/client/requests/get_topic.rb
179
185
  - lib/zendesk2/client/requests/get_topic_comment.rb
@@ -254,3 +260,4 @@ test_files:
254
260
  - spec/topics_spec.rb
255
261
  - spec/user_identities_spec.rb
256
262
  - spec/users_spec.rb
263
+ has_rdoc: