zendesk2 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/zendesk2/client/models/audit_event.rb +19 -22
- data/lib/zendesk2/client/models/organization.rb +1 -1
- data/lib/zendesk2/client/models/ticket_audit.rb +1 -1
- data/lib/zendesk2/client/models/ticket_change.rb +13 -0
- data/lib/zendesk2/client/models/ticket_comment.rb +26 -0
- data/lib/zendesk2/client/models/ticket_comment_privacy_change.rb +19 -0
- data/lib/zendesk2/client/models/ticket_create.rb +11 -0
- data/lib/zendesk2/client/models/ticket_notification.rb +15 -0
- data/lib/zendesk2/client/models/ticket_voice_comment.rb +36 -0
- data/lib/zendesk2/client/models/user.rb +2 -1
- data/lib/zendesk2/client.rb +8 -1
- data/lib/zendesk2/model.rb +1 -1
- data/lib/zendesk2/version.rb +1 -1
- data/spec/tickets_spec.rb +2 -0
- metadata +13 -8
@@ -1,33 +1,30 @@
|
|
1
|
+
# @abstract subclass and implement audit event specific attributes
|
1
2
|
class Zendesk2::Client::AuditEvent < Cistern::Model
|
2
3
|
extend Zendesk2::Attributes
|
3
4
|
extend Forwardable
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
6
|
+
def self.all
|
7
|
+
@all ||= []
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.inherited(klass)
|
11
|
+
all << klass
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.for(attributes)
|
15
|
+
event_class = "Zendesk2::Client::Ticket#{attributes["type"]}"
|
16
|
+
if klass = all.find{|k| k.name == event_class}
|
17
|
+
klass.new(attributes)
|
18
|
+
else # handle unrecognized audit events
|
19
|
+
attributes.reject{|k,v| k == :connection}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# @return [String] has the event value
|
8
24
|
attribute :type, type: :string
|
9
|
-
# @return [String] The actual comment made by the author
|
10
|
-
attribute :body, type: :string
|
11
|
-
# @return [String] The actual comment made by the author formatted to HTML
|
12
|
-
attribute :html_body, type: :string
|
13
|
-
# @return [Boolean] If this is a public comment or an internal agents only note
|
14
|
-
attribute :public, type: :boolean
|
15
|
-
# @return [Boolean] If this comment is trusted or marked as being potentially fraudulent
|
16
|
-
attribute :trusted, type: :boolean
|
17
|
-
# @return [Integer] The id of the author of this comment
|
18
|
-
attribute :author_id, type: :integer
|
19
|
-
# @return [Array] The attachments on this comment as Attachment objects
|
20
|
-
attribute :attachments, type: :array
|
21
25
|
|
22
26
|
# @return [Zendesk2::Client::TicketAudit] audit that includes this event
|
23
27
|
attr_accessor :ticket_audit
|
24
28
|
|
25
29
|
def_delegators :ticket_audit, :created_at
|
26
|
-
|
27
|
-
# @return [Zendesk2::Client::User] event author
|
28
|
-
def author
|
29
|
-
requires :author_id
|
30
|
-
|
31
|
-
self.connection.users.get(self.author_id)
|
32
|
-
end
|
33
30
|
end
|
@@ -6,7 +6,7 @@ class Zendesk2::Client::Organization < Zendesk2::Model
|
|
6
6
|
attribute :created_at, type: :time
|
7
7
|
attribute :details, type: :string
|
8
8
|
attribute :domain_names, type: :array
|
9
|
-
attribute :external_id, type: :
|
9
|
+
attribute :external_id, type: :string
|
10
10
|
attribute :group_id, type: :integer
|
11
11
|
attribute :shared_comments, type: :boolean
|
12
12
|
attribute :shared_tickets, type: :boolean
|
@@ -23,6 +23,6 @@ class Zendesk2::Client::TicketAudit < Cistern::Model
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def events
|
26
|
-
(self.attributes[:events] || []).map{|ae|
|
26
|
+
(self.attributes[:events] || []).map{|ae| Zendesk2::Client::AuditEvent.for(ae.merge(ticket_audit: self, connection: self.connection))}
|
27
27
|
end
|
28
28
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class Zendesk2::Client
|
2
|
+
class TicketChange < AuditEvent
|
3
|
+
# @return [Integer] Automatically assigned when creating events
|
4
|
+
identity :id, type: :integer
|
5
|
+
|
6
|
+
# @return [String] The name of the field that was changed
|
7
|
+
attribute :field_name, type: :string
|
8
|
+
# @return [String] The name of the field that was changed
|
9
|
+
attribute :value, type: :string
|
10
|
+
# @return [Array] The previous value of the field that was changed
|
11
|
+
attribute :previous_value, type: :array, parser: lambda{|v, _| [*v]}
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class Zendesk2::Client
|
2
|
+
class TicketComment < AuditEvent
|
3
|
+
# @return [Integer] Automatically assigned when creating events
|
4
|
+
identity :id, type: :integer
|
5
|
+
|
6
|
+
# @return [String] The actual comment made by the author
|
7
|
+
attribute :body, type: :string
|
8
|
+
# @return [String] The actual comment made by the author formatted to HTML
|
9
|
+
attribute :html_body, type: :string
|
10
|
+
# @return [Boolean] If this is a public comment or an internal agents only note
|
11
|
+
attribute :public, type: :boolea
|
12
|
+
# @return [Boolean] If this comment is trusted or marked as being potentially fraudulent
|
13
|
+
attribute :trusted, type: :boolean
|
14
|
+
# @return [Integer] The id of the author of this comment
|
15
|
+
attribute :author_id, type: :integer
|
16
|
+
# @return [Array] The attachments on this comment as Attachment objects
|
17
|
+
attribute :attachments, type: :array
|
18
|
+
|
19
|
+
# @return [Zendesk2::Client::User] event author
|
20
|
+
def author
|
21
|
+
requires :author_id
|
22
|
+
|
23
|
+
self.connection.users.get(self.author_id)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Zendesk2::Client
|
2
|
+
class TicketCommentPrivacyChange < AuditEvent
|
3
|
+
|
4
|
+
# @return [integer] Automatically assigned when creating events
|
5
|
+
identity :id, type: :integer
|
6
|
+
|
7
|
+
# @return [Integer] The id if the comment that changed privacy
|
8
|
+
attribute :comment_id, type: :integer
|
9
|
+
# @return [Boolean] Tells if the comment was made public or private
|
10
|
+
attribute :public, type: :boolean
|
11
|
+
|
12
|
+
# @return [Zendesk2::Client::TicketComment] ticket comment pertaining to this privacy change
|
13
|
+
def comment
|
14
|
+
requires :comment_id
|
15
|
+
|
16
|
+
self.connection.ticket_comments.get(self.comment_id)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class Zendesk2::Client
|
2
|
+
class TicketCreate < AuditEvent
|
3
|
+
# @return [integer] Automatically assigned when creating events
|
4
|
+
identity :id, type: :integer
|
5
|
+
|
6
|
+
# @return [string] The name of the field that was set
|
7
|
+
attribute :field_name, type: :string
|
8
|
+
# @return [Array] The value of the field that was set
|
9
|
+
attribute :value, parser: lambda{|v, _| [*v]}
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class Zendesk2::Client
|
2
|
+
class TicketNotification < AuditEvent
|
3
|
+
# @return [Integer] Automatically assigned when creating events
|
4
|
+
identity :id, type: :integer
|
5
|
+
|
6
|
+
# @return [String] The message sent to the recipients
|
7
|
+
attribute :body, type: :string
|
8
|
+
# @return [Array] A array of simple object holding the ids and names of the recipients of this notification
|
9
|
+
attribute :recipients, type: :array
|
10
|
+
# @return [String] The subject of the message sent to the recipients
|
11
|
+
attribute :subject, type: :string
|
12
|
+
# @return [Hash] A reference to the trigger that created this notification
|
13
|
+
attribute :via
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
class Zendesk2::Client
|
2
|
+
class TicketVoiceComment < AuditEvent
|
3
|
+
# @return [integer] Automatically assigned when creating events
|
4
|
+
identity :id, type: :integer
|
5
|
+
|
6
|
+
# @return [Array] The attachments on this comment as Attachment objects
|
7
|
+
attribute :attachments, type: :array
|
8
|
+
# @return [Integer] The id of the author of this comment
|
9
|
+
attribute :author_id, type: :integer
|
10
|
+
# @return [String] The actual comment made by the author
|
11
|
+
attribute :body, type: :string
|
12
|
+
# @return [String] A hash of properties about the call
|
13
|
+
attribute :data, type: :string
|
14
|
+
# @return [String] A formatted version of the phone number which dialed the call
|
15
|
+
attribute :formatted_from, type: :string
|
16
|
+
# @return [String] A formatted version of the phone number which answered the call
|
17
|
+
attribute :formatted_to, type: :string
|
18
|
+
# @return [String] The actual comment made by the author formatted to HTML
|
19
|
+
attribute :html_body, type: :string
|
20
|
+
# @return [Boolean] If this is a public comment or an internal agents only note
|
21
|
+
attribute :public, type: :boolean
|
22
|
+
# @return [Boolean] If true, the ticket requester can see this comment
|
23
|
+
attribute :public, type: :boolean
|
24
|
+
# @return [Boolean] If this comment is trusted or marked as being potentially fraudulent
|
25
|
+
attribute :trusted, type: :boolean
|
26
|
+
# @return [String] Has the value VoiceComment
|
27
|
+
attribute :type, type: :string
|
28
|
+
|
29
|
+
# @return [Zendesk2::Client::User] event author
|
30
|
+
def author
|
31
|
+
requires :author_id
|
32
|
+
|
33
|
+
self.connection.users.get(self.author_id)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -119,13 +119,14 @@ class Zendesk2::Client::User < Zendesk2::Model
|
|
119
119
|
end
|
120
120
|
|
121
121
|
# @return [Zendesk2::Client::Tickets] tickets this user requested
|
122
|
-
def
|
122
|
+
def tickets
|
123
123
|
requires :identity
|
124
124
|
|
125
125
|
data = connection.get_requested_tickets("id" => self.identity).body["tickets"]
|
126
126
|
|
127
127
|
connection.tickets.load(data)
|
128
128
|
end
|
129
|
+
alias requested_tickets tickets
|
129
130
|
|
130
131
|
# @return [Zendesk2::Client::Tickets] tickets this user is CC'eD
|
131
132
|
def ccd_tickets
|
data/lib/zendesk2/client.rb
CHANGED
@@ -4,6 +4,8 @@ class Zendesk2::Client < Cistern::Service
|
|
4
4
|
model_path "zendesk2/client/models"
|
5
5
|
request_path "zendesk2/client/requests"
|
6
6
|
|
7
|
+
require 'zendesk2/client/models/audit_event' # so special
|
8
|
+
|
7
9
|
collection :categories
|
8
10
|
collection :forums
|
9
11
|
collection :groups
|
@@ -14,13 +16,18 @@ class Zendesk2::Client < Cistern::Service
|
|
14
16
|
collection :topics
|
15
17
|
collection :users
|
16
18
|
collection :user_identities
|
17
|
-
model :audit_event
|
18
19
|
model :category
|
19
20
|
model :forum
|
20
21
|
model :group
|
21
22
|
model :organization
|
22
23
|
model :ticket
|
23
24
|
model :ticket_audit
|
25
|
+
model :ticket_change
|
26
|
+
model :ticket_comment
|
27
|
+
model :ticket_comment_privacy_change
|
28
|
+
model :ticket_create
|
29
|
+
model :ticket_notification
|
30
|
+
model :ticket_voice_comment
|
24
31
|
model :topic
|
25
32
|
model :topic_comment
|
26
33
|
model :user
|
data/lib/zendesk2/model.rb
CHANGED
data/lib/zendesk2/version.rb
CHANGED
data/spec/tickets_spec.rb
CHANGED
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.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,17 +9,17 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-02-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cistern
|
16
|
-
prerelease: false
|
17
16
|
requirement: !ruby/object:Gem::Requirement
|
18
17
|
requirements:
|
19
18
|
- - ~>
|
20
19
|
- !ruby/object:Gem::Version
|
21
20
|
version: 0.2.0
|
22
21
|
none: false
|
22
|
+
prerelease: false
|
23
23
|
type: :runtime
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
@@ -29,13 +29,13 @@ dependencies:
|
|
29
29
|
none: false
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: faraday
|
32
|
-
prerelease: false
|
33
32
|
requirement: !ruby/object:Gem::Requirement
|
34
33
|
requirements:
|
35
34
|
- - ! '>='
|
36
35
|
- !ruby/object:Gem::Version
|
37
36
|
version: '0'
|
38
37
|
none: false
|
38
|
+
prerelease: false
|
39
39
|
type: :runtime
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
41
|
requirements:
|
@@ -45,13 +45,13 @@ dependencies:
|
|
45
45
|
none: false
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: faraday_middleware
|
48
|
-
prerelease: false
|
49
48
|
requirement: !ruby/object:Gem::Requirement
|
50
49
|
requirements:
|
51
50
|
- - ! '>='
|
52
51
|
- !ruby/object:Gem::Version
|
53
52
|
version: '0'
|
54
53
|
none: false
|
54
|
+
prerelease: false
|
55
55
|
type: :runtime
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
@@ -61,13 +61,13 @@ dependencies:
|
|
61
61
|
none: false
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: addressable
|
64
|
-
prerelease: false
|
65
64
|
requirement: !ruby/object:Gem::Requirement
|
66
65
|
requirements:
|
67
66
|
- - ! '>='
|
68
67
|
- !ruby/object:Gem::Version
|
69
68
|
version: '0'
|
70
69
|
none: false
|
70
|
+
prerelease: false
|
71
71
|
type: :runtime
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
@@ -105,6 +105,12 @@ files:
|
|
105
105
|
- lib/zendesk2/client/models/ticket.rb
|
106
106
|
- lib/zendesk2/client/models/ticket_audit.rb
|
107
107
|
- lib/zendesk2/client/models/ticket_audits.rb
|
108
|
+
- lib/zendesk2/client/models/ticket_change.rb
|
109
|
+
- lib/zendesk2/client/models/ticket_comment.rb
|
110
|
+
- lib/zendesk2/client/models/ticket_comment_privacy_change.rb
|
111
|
+
- lib/zendesk2/client/models/ticket_create.rb
|
112
|
+
- lib/zendesk2/client/models/ticket_notification.rb
|
113
|
+
- lib/zendesk2/client/models/ticket_voice_comment.rb
|
108
114
|
- lib/zendesk2/client/models/tickets.rb
|
109
115
|
- lib/zendesk2/client/models/topic.rb
|
110
116
|
- lib/zendesk2/client/models/topic_comment.rb
|
@@ -210,7 +216,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
210
216
|
none: false
|
211
217
|
requirements: []
|
212
218
|
rubyforge_project:
|
213
|
-
rubygems_version: 1.8.
|
219
|
+
rubygems_version: 1.8.25
|
214
220
|
signing_key:
|
215
221
|
specification_version: 3
|
216
222
|
summary: Zendesk V2 API client
|
@@ -227,4 +233,3 @@ test_files:
|
|
227
233
|
- spec/topics_spec.rb
|
228
234
|
- spec/user_identities_spec.rb
|
229
235
|
- spec/users_spec.rb
|
230
|
-
has_rdoc:
|