Class: Zendesk2::Ticket
- Inherits:
-
Object
- Object
- Zendesk2::Ticket
- Extended by:
- Attributes
- Includes:
- Model
- Defined in:
- lib/zendesk2/ticket.rb
Instance Attribute Summary
Attributes included from Model
Instance Method Summary collapse
-
#assignee_id ⇒ Integer
What agent is currently assigned to the ticket.
-
#audits ⇒ Zendesk2::TicketAudits
All audits for this ticket.
-
#brand_id ⇒ Integer
Enterprise only.
-
#collaborator_ids ⇒ Array
Who are currently CC’ed on the ticket.
-
#collaborators ⇒ Array<Zendesk2::User>
All users CCD on this ticket.
- #collaborators=(collaborators) ⇒ Object
-
#comment(text, options = {}) ⇒ Zendesk2::TicketComment
Adds a ticket comment.
-
#comments ⇒ Array<Zendesk2::TicketComment>
All comments for this ticket.
-
#created_at ⇒ Time
When this record was created.
-
#custom_fields ⇒ Array
The custom fields of the ticket.
-
#description ⇒ String
The first comment on the ticket.
- #destroy! ⇒ Object
-
#due_at ⇒ Time
If this is a ticket of type “task” it has a due date.
-
#external_id ⇒ String
A unique external id, you can use this to link Zendesk tickets to local records.
-
#forum_topic_id ⇒ Integer
The topic this ticket originated from, if any.
-
#group_id ⇒ Integer
The group this ticket is assigned to.
-
#has_incidents ⇒ Boolean
Is true of this ticket has been marked as a problem, false otherwise.
-
#id ⇒ Integer
Automatically assigned when creating tickets.
-
#metrics ⇒ Zendesk2::TicketMetric
Metrics for this ticket.
-
#organization ⇒ Zendesk2::Organization
Organization assigned to ticket.
-
#organization_id ⇒ Integer
The organization of the requester.
-
#priority ⇒ String
Priority, defines the urgency with which the ticket should be addressed: “urgent”, “high”, “normal”, “low”.
-
#problem_id ⇒ Integer
The problem this incident is linked to, if any.
-
#recipient ⇒ String
The original recipient e-mail address of the ticket.
-
#requester ⇒ Zendesk2::User
User that requested the ticket.
-
#requester_id ⇒ Integer
The user who requested this ticket.
-
#satisfaction_rating ⇒ Hash
The satisfaction rating of the ticket, if it exists.
- #save! ⇒ Object
-
#sharing_agreement_ids ⇒ Array
The ids of the sharing agreements used for this ticket.
-
#status ⇒ String
The state of the ticket, “new”, “open”, “pending”, “hold”, “solved”, “closed”.
-
#subject ⇒ String
The value of the subject field for this ticket.
-
#submitter ⇒ Zendesk2::User
User that submitted the ticket.
-
#submitter_id ⇒ Integer
The user who submitted the ticket; this is the currently authenticated API user.
-
#tags ⇒ Array
The array of tags applied to this ticket.
-
#ticket_form_id ⇒ Integer
Enterprise only.
-
#type ⇒ String
The type of this ticket, i.e.
-
#updated_at ⇒ Time
When this record last got updated.
-
#url ⇒ String
The API url of this ticket.
-
#via ⇒ Hash
This object explains how the ticket was created.
Methods included from Attributes
assoc_accessor, assoc_reader, assoc_writer
Methods included from Model
#destroy, #destroyed?, #missing_attributes, #save, #update!
Instance Method Details
#assignee_id ⇒ Integer
Returns What agent is currently assigned to the ticket.
10 |
# File 'lib/zendesk2/ticket.rb', line 10 attribute :assignee_id, type: :integer |
#audits ⇒ Zendesk2::TicketAudits
Returns all audits for this ticket.
123 124 125 |
# File 'lib/zendesk2/ticket.rb', line 123 def audits cistern.ticket_audits(ticket_id: identity).all end |
#brand_id ⇒ Integer
Returns Enterprise only. The id of the brand this ticket is associated with.
63 |
# File 'lib/zendesk2/ticket.rb', line 63 attribute :brand_id |
#collaborator_ids ⇒ Array
Returns Who are currently CC’ed on the ticket.
12 |
# File 'lib/zendesk2/ticket.rb', line 12 attribute :collaborator_ids, type: :array |
#collaborators ⇒ Array<Zendesk2::User>
Returns All users CCD on this ticket.
138 139 140 |
# File 'lib/zendesk2/ticket.rb', line 138 def collaborators (collaborator_ids || []).map { |id| cistern.users.get(id) } end |
#collaborators=(collaborators) ⇒ Object
142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/zendesk2/ticket.rb', line 142 def collaborators=(collaborators) collaborators = [collaborators] unless collaborators.is_a?(Array) value = collaborators.map do |collaborator| case collaborator when Zendesk2::User collaborator.identity else collaborator end end attributes[:collaborators] = value end |
#comment(text, options = {}) ⇒ Zendesk2::TicketComment
Adds a ticket comment
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/zendesk2/ticket.rb', line 105 def comment(text, = {}) requires :identity [:public] = true if [:public].nil? comment = Zendesk2.stringify_keys().merge('body' => text) cistern.ticket_comments.new( cistern.update_ticket( 'ticket' => { 'id' => identity, 'comment' => comment, } ).body['audit']['events'].first ) end |
#comments ⇒ Array<Zendesk2::TicketComment>
Returns all comments for this ticket.
133 134 135 |
# File 'lib/zendesk2/ticket.rb', line 133 def comments cistern.ticket_comments(ticket_id: identity).all end |
#created_at ⇒ Time
Returns When this record was created.
14 |
# File 'lib/zendesk2/ticket.rb', line 14 attribute :created_at, type: :time |
#custom_fields ⇒ Array
Returns The custom fields of the ticket.
16 |
# File 'lib/zendesk2/ticket.rb', line 16 attribute :custom_fields, type: :array |
#description ⇒ String
Returns The first comment on the ticket.
18 |
# File 'lib/zendesk2/ticket.rb', line 18 attribute :description, type: :string |
#destroy! ⇒ Object
92 93 94 95 96 |
# File 'lib/zendesk2/ticket.rb', line 92 def destroy! requires :identity cistern.destroy_ticket('ticket' => { 'id' => identity }) end |
#due_at ⇒ Time
Returns If this is a ticket of type “task” it has a due date. Due date format uses ISO 8601 format.
20 |
# File 'lib/zendesk2/ticket.rb', line 20 attribute :due_at, type: :time |
#external_id ⇒ String
Returns A unique external id, you can use this to link Zendesk tickets to local records.
22 |
# File 'lib/zendesk2/ticket.rb', line 22 attribute :external_id, type: :string |
#forum_topic_id ⇒ Integer
Returns The topic this ticket originated from, if any.
24 |
# File 'lib/zendesk2/ticket.rb', line 24 attribute :forum_topic_id, type: :integer |
#group_id ⇒ Integer
Returns The group this ticket is assigned to.
26 |
# File 'lib/zendesk2/ticket.rb', line 26 attribute :group_id, type: :integer |
#has_incidents ⇒ Boolean
Returns Is true of this ticket has been marked as a problem, false otherwise.
28 |
# File 'lib/zendesk2/ticket.rb', line 28 attribute :has_incidents, type: :boolean |
#id ⇒ Integer
Returns Automatically assigned when creating tickets.
8 |
# File 'lib/zendesk2/ticket.rb', line 8 identity :id, type: :integer |
#metrics ⇒ Zendesk2::TicketMetric
Returns metrics for this ticket.
128 129 130 |
# File 'lib/zendesk2/ticket.rb', line 128 def metrics Zendesk2::TicketMetric.new(cistern.get_ticket_metric('ticket_id' => identity).body['ticket_metric']) end |
#organization ⇒ Zendesk2::Organization
Returns organization assigned to ticket.
66 |
# File 'lib/zendesk2/ticket.rb', line 66 assoc_reader :organization |
#organization_id ⇒ Integer
Returns The organization of the requester.
30 |
# File 'lib/zendesk2/ticket.rb', line 30 attribute :organization_id, type: :integer |
#priority ⇒ String
Returns Priority, defines the urgency with which the ticket should be addressed: “urgent”, “high”, “normal”, “low”.
33 |
# File 'lib/zendesk2/ticket.rb', line 33 attribute :priority, type: :string |
#problem_id ⇒ Integer
Returns The problem this incident is linked to, if any.
35 |
# File 'lib/zendesk2/ticket.rb', line 35 attribute :problem_id, type: :integer |
#recipient ⇒ String
Returns The original recipient e-mail address of the ticket.
37 |
# File 'lib/zendesk2/ticket.rb', line 37 attribute :recipient, type: :string |
#requester ⇒ Zendesk2::User
Returns user that requested the ticket.
68 |
# File 'lib/zendesk2/ticket.rb', line 68 assoc_accessor :requester, collection: :users |
#requester_id ⇒ Integer
Returns The user who requested this ticket.
39 |
# File 'lib/zendesk2/ticket.rb', line 39 attribute :requester_id, type: :integer |
#satisfaction_rating ⇒ Hash
Returns The satisfaction rating of the ticket, if it exists.
41 |
# File 'lib/zendesk2/ticket.rb', line 41 attribute :satisfaction_rating |
#save! ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/zendesk2/ticket.rb', line 72 def save! data = if new_record? requires :subject, :description create_attributes = attributes.dup with_requester = (@requester || nil) && Zendesk2.stringify_keys(@requester) with_requester && create_attributes['requester'] = with_requester cistern.create_ticket('ticket' => create_attributes).body['ticket'] else requires :identity cistern.update_ticket('ticket' => attributes).body['ticket'] end merge_attributes(data) end |
#sharing_agreement_ids ⇒ Array
Returns The ids of the sharing agreements used for this ticket.
43 |
# File 'lib/zendesk2/ticket.rb', line 43 attribute :sharing_agreement_ids, type: :array |
#status ⇒ String
Returns The state of the ticket, “new”, “open”, “pending”, “hold”, “solved”, “closed”.
45 |
# File 'lib/zendesk2/ticket.rb', line 45 attribute :status, type: :string |
#subject ⇒ String
Returns The value of the subject field for this ticket.
47 |
# File 'lib/zendesk2/ticket.rb', line 47 attribute :subject, type: :string |
#submitter ⇒ Zendesk2::User
Returns user that submitted the ticket.
70 |
# File 'lib/zendesk2/ticket.rb', line 70 assoc_reader :submitter, collection: :users |
#submitter_id ⇒ Integer
Returns The user who submitted the ticket; this is the currently authenticated API user.
49 |
# File 'lib/zendesk2/ticket.rb', line 49 attribute :submitter_id, type: :integer |
#tags ⇒ Array
Returns The array of tags applied to this ticket.
51 |
# File 'lib/zendesk2/ticket.rb', line 51 attribute :tags, type: :array |
#ticket_form_id ⇒ Integer
Returns Enterprise only. The id of the ticket form to render for the ticket.
61 |
# File 'lib/zendesk2/ticket.rb', line 61 attribute :ticket_form_id |
#type ⇒ String
Returns The type of this ticket, i.e. “problem”, “incident”, “question” or “task”.
53 |
# File 'lib/zendesk2/ticket.rb', line 53 attribute :type, type: :string |
#updated_at ⇒ Time
Returns When this record last got updated.
55 |
# File 'lib/zendesk2/ticket.rb', line 55 attribute :updated_at, type: :time |
#url ⇒ String
Returns The API url of this ticket.
57 |
# File 'lib/zendesk2/ticket.rb', line 57 attribute :url, type: :string |
#via ⇒ Hash
Returns This object explains how the ticket was created.
59 |
# File 'lib/zendesk2/ticket.rb', line 59 attribute :via |