-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
begin modeling specific audit events
* updates #15 ~feature
- Loading branch information
Showing
11 changed files
with
151 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,30 @@ | ||
# @abstract subclass and implement audit event specific attributes | ||
class Zendesk2::Client::AuditEvent < Cistern::Model | ||
extend Zendesk2::Attributes | ||
extend Forwardable | ||
|
||
# @return [Integer] Automatically assigned when creating events | ||
identity :id, type: :integer | ||
# @return [String] Has the value Comment | ||
def self.all | ||
@all ||= [] | ||
end | ||
|
||
def self.inherited(klass) | ||
all << klass | ||
end | ||
|
||
def self.for(attributes) | ||
event_class = "Zendesk2::Client::Ticket#{attributes["type"]}" | ||
if klass = all.find{|k| k.name == event_class} | ||
klass.new(attributes) | ||
else # handle unrecognized audit events | ||
attributes.reject{|k,v| k == :connection} | ||
end | ||
end | ||
|
||
# @return [String] has the event value | ||
attribute :type, type: :string | ||
# @return [String] The actual comment made by the author | ||
attribute :body, type: :string | ||
# @return [String] The actual comment made by the author formatted to HTML | ||
attribute :html_body, type: :string | ||
# @return [Boolean] If this is a public comment or an internal agents only note | ||
attribute :public, type: :boolean | ||
# @return [Boolean] If this comment is trusted or marked as being potentially fraudulent | ||
attribute :trusted, type: :boolean | ||
# @return [Integer] The id of the author of this comment | ||
attribute :author_id, type: :integer | ||
# @return [Array] The attachments on this comment as Attachment objects | ||
attribute :attachments, type: :array | ||
|
||
# @return [Zendesk2::Client::TicketAudit] audit that includes this event | ||
attr_accessor :ticket_audit | ||
|
||
def_delegators :ticket_audit, :created_at | ||
|
||
# @return [Zendesk2::Client::User] event author | ||
def author | ||
requires :author_id | ||
|
||
self.connection.users.get(self.author_id) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class Zendesk2::Client | ||
class TicketChange < AuditEvent | ||
# @return [Integer] Automatically assigned when creating events | ||
identity :id, type: :integer | ||
|
||
# @return [String] The name of the field that was changed | ||
attribute :field_name, type: :string | ||
# @return [String] The name of the field that was changed | ||
attribute :value, type: :string | ||
# @return [Array] The previous value of the field that was changed | ||
attribute :previous_value, type: :array, parser: lambda{|v, _| [*v]} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
class Zendesk2::Client | ||
class TicketComment < AuditEvent | ||
# @return [Integer] Automatically assigned when creating events | ||
identity :id, type: :integer | ||
|
||
# @return [String] The actual comment made by the author | ||
attribute :body, type: :string | ||
# @return [String] The actual comment made by the author formatted to HTML | ||
attribute :html_body, type: :string | ||
# @return [Boolean] If this is a public comment or an internal agents only note | ||
attribute :public, type: :boolea | ||
# @return [Boolean] If this comment is trusted or marked as being potentially fraudulent | ||
attribute :trusted, type: :boolean | ||
# @return [Integer] The id of the author of this comment | ||
attribute :author_id, type: :integer | ||
# @return [Array] The attachments on this comment as Attachment objects | ||
attribute :attachments, type: :array | ||
|
||
# @return [Zendesk2::Client::User] event author | ||
def author | ||
requires :author_id | ||
|
||
self.connection.users.get(self.author_id) | ||
end | ||
end | ||
end |
19 changes: 19 additions & 0 deletions
19
lib/zendesk2/client/models/ticket_comment_privacy_change.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class Zendesk2::Client | ||
class TicketCommentPrivacyChange < AuditEvent | ||
|
||
# @return [integer] Automatically assigned when creating events | ||
identity :id, type: :integer | ||
|
||
# @return [Integer] The id if the comment that changed privacy | ||
attribute :comment_id, type: :integer | ||
# @return [Boolean] Tells if the comment was made public or private | ||
attribute :public, type: :boolean | ||
|
||
# @return [Zendesk2::Client::TicketComment] ticket comment pertaining to this privacy change | ||
def comment | ||
requires :comment_id | ||
|
||
self.connection.ticket_comments.get(self.comment_id) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class Zendesk2::Client | ||
class TicketCreate < AuditEvent | ||
# @return [integer] Automatically assigned when creating events | ||
identity :id, type: :integer | ||
|
||
# @return [string] The name of the field that was set | ||
attribute :field_name, type: :string | ||
# @return [Array] The value of the field that was set | ||
attribute :value, parser: lambda{|v, _| [*v]} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class Zendesk2::Client | ||
class TicketNotification < AuditEvent | ||
# @return [Integer] Automatically assigned when creating events | ||
identity :id, type: :integer | ||
|
||
# @return [String] The message sent to the recipients | ||
attribute :body, type: :string | ||
# @return [Array] A array of simple object holding the ids and names of the recipients of this notification | ||
attribute :recipients, type: :array | ||
# @return [String] The subject of the message sent to the recipients | ||
attribute :subject, type: :string | ||
# @return [Hash] A reference to the trigger that created this notification | ||
attribute :via | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
class Zendesk2::Client | ||
class TicketVoiceComment < AuditEvent | ||
# @return [integer] Automatically assigned when creating events | ||
identity :id, type: :integer | ||
|
||
# @return [Array] The attachments on this comment as Attachment objects | ||
attribute :attachments, type: :array | ||
# @return [Integer] The id of the author of this comment | ||
attribute :author_id, type: :integer | ||
# @return [String] The actual comment made by the author | ||
attribute :body, type: :string | ||
# @return [String] A hash of properties about the call | ||
attribute :data, type: :string | ||
# @return [String] A formatted version of the phone number which dialed the call | ||
attribute :formatted_from, type: :string | ||
# @return [String] A formatted version of the phone number which answered the call | ||
attribute :formatted_to, type: :string | ||
# @return [String] The actual comment made by the author formatted to HTML | ||
attribute :html_body, type: :string | ||
# @return [Boolean] If this is a public comment or an internal agents only note | ||
attribute :public, type: :boolean | ||
# @return [Boolean] If true, the ticket requester can see this comment | ||
attribute :public, type: :boolean | ||
# @return [Boolean] If this comment is trusted or marked as being potentially fraudulent | ||
attribute :trusted, type: :boolean | ||
# @return [String] Has the value VoiceComment | ||
attribute :type, type: :string | ||
|
||
# @return [Zendesk2::Client::User] event author | ||
def author | ||
requires :author_id | ||
|
||
self.connection.users.get(self.author_id) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters