Class: Connectwise::Ticket
- Inherits:
-
Object
- Object
- Connectwise::Ticket
- Includes:
- Model
- Defined in:
- lib/connectwise/ticket.rb
Instance Attribute Summary collapse
-
#board ⇒ Object
Returns the value of attribute board.
-
#closed_flag ⇒ Object
Returns the value of attribute closed_flag.
-
#company ⇒ Object
Returns the value of attribute company.
-
#company_id ⇒ Object
Returns the value of attribute company_id.
-
#id ⇒ Object
Returns the value of attribute id.
-
#impact ⇒ Object
Returns the value of attribute impact.
-
#member_id ⇒ Object
Returns the value of attribute member_id.
-
#member_rec_id ⇒ Object
Returns the value of attribute member_rec_id.
-
#notes ⇒ Object
Returns the value of attribute notes.
-
#priority ⇒ Object
Returns the value of attribute priority.
-
#problem_description ⇒ Object
Returns the value of attribute problem_description.
-
#remote_internal_company_name ⇒ Object
Returns the value of attribute remote_internal_company_name.
-
#resolution ⇒ Object
Returns the value of attribute resolution.
-
#severity ⇒ Object
Returns the value of attribute severity.
-
#site_name ⇒ Object
Returns the value of attribute site_name.
-
#source ⇒ Object
Returns the value of attribute source.
-
#status ⇒ Object
Returns the value of attribute status.
-
#status_name ⇒ Object
Returns the value of attribute status_name.
-
#summary ⇒ Object
Returns the value of attribute summary.
Class Method Summary collapse
-
.find(connection, id) ⇒ Object
TODO - The use of SrServiceRecid and TicketNumber instead of id - may want to configure these but this is so inconsistent for tickets that it may not be worth it unless other calls do the same thing.
- .parse(connection, params) ⇒ Object
Instance Method Summary collapse
Methods included from Model
#defined_attributes, included, #initialize, #persisted?, #to_h
Instance Attribute Details
#board ⇒ Object
Returns the value of attribute board.
7 8 9 |
# File 'lib/connectwise/ticket.rb', line 7 def board @board end |
#closed_flag ⇒ Object
Returns the value of attribute closed_flag.
7 8 9 |
# File 'lib/connectwise/ticket.rb', line 7 def closed_flag @closed_flag end |
#company ⇒ Object
Returns the value of attribute company.
7 8 9 |
# File 'lib/connectwise/ticket.rb', line 7 def company @company end |
#company_id ⇒ Object
Returns the value of attribute company_id.
7 8 9 |
# File 'lib/connectwise/ticket.rb', line 7 def company_id @company_id end |
#id ⇒ Object
Returns the value of attribute id.
7 8 9 |
# File 'lib/connectwise/ticket.rb', line 7 def id @id end |
#impact ⇒ Object
Returns the value of attribute impact.
7 8 9 |
# File 'lib/connectwise/ticket.rb', line 7 def impact @impact end |
#member_id ⇒ Object
Returns the value of attribute member_id.
7 8 9 |
# File 'lib/connectwise/ticket.rb', line 7 def member_id @member_id end |
#member_rec_id ⇒ Object
Returns the value of attribute member_rec_id.
7 8 9 |
# File 'lib/connectwise/ticket.rb', line 7 def member_rec_id @member_rec_id end |
#notes ⇒ Object
Returns the value of attribute notes.
7 8 9 |
# File 'lib/connectwise/ticket.rb', line 7 def notes @notes end |
#priority ⇒ Object
Returns the value of attribute priority.
7 8 9 |
# File 'lib/connectwise/ticket.rb', line 7 def priority @priority end |
#problem_description ⇒ Object
Returns the value of attribute problem_description.
7 8 9 |
# File 'lib/connectwise/ticket.rb', line 7 def problem_description @problem_description end |
#remote_internal_company_name ⇒ Object
Returns the value of attribute remote_internal_company_name.
7 8 9 |
# File 'lib/connectwise/ticket.rb', line 7 def remote_internal_company_name @remote_internal_company_name end |
#resolution ⇒ Object
Returns the value of attribute resolution.
7 8 9 |
# File 'lib/connectwise/ticket.rb', line 7 def resolution @resolution end |
#severity ⇒ Object
Returns the value of attribute severity.
7 8 9 |
# File 'lib/connectwise/ticket.rb', line 7 def severity @severity end |
#site_name ⇒ Object
Returns the value of attribute site_name.
7 8 9 |
# File 'lib/connectwise/ticket.rb', line 7 def site_name @site_name end |
#source ⇒ Object
Returns the value of attribute source.
7 8 9 |
# File 'lib/connectwise/ticket.rb', line 7 def source @source end |
#status ⇒ Object
Returns the value of attribute status.
7 8 9 |
# File 'lib/connectwise/ticket.rb', line 7 def status @status end |
#status_name ⇒ Object
Returns the value of attribute status_name.
7 8 9 |
# File 'lib/connectwise/ticket.rb', line 7 def status_name @status_name end |
#summary ⇒ Object
Returns the value of attribute summary.
7 8 9 |
# File 'lib/connectwise/ticket.rb', line 7 def summary @summary end |
Class Method Details
.find(connection, id) ⇒ Object
TODO - The use of SrServiceRecid and TicketNumber instead of id - may want to configure these but this is so inconsistent for tickets that it may not be worth it unless other calls do the same thing
11 12 13 14 15 16 17 18 19 |
# File 'lib/connectwise/ticket.rb', line 11 def self.find(connection, id) if (attrs = connection.call(cw_api_name, "get_#{cw_api_name}".to_sym, {ticketNumber: id})) self.new(connection, find_transform(attrs)) else fail RecordNotFound end rescue ConnectionError raise RecordNotFound end |
.parse(connection, params) ⇒ Object
21 22 23 24 25 |
# File 'lib/connectwise/ticket.rb', line 21 def self.parse(connection, params) resp = JSON.parse(params.keys.first) ticket_info = JSON.parse(resp['Entity']) self.new(connection, id: params[:id], summary: ticket_info['Summary'], closed_flag: ticket_info['ClosedFlag'], severity: ticket_info['Severity'], company_id: ticket_info['CompanyId'], member_id: ticket_info['memberId']) end |
Instance Method Details
#add_note(msg, **options) ⇒ Object
43 44 45 46 |
# File 'lib/connectwise/ticket.rb', line 43 def add_note(msg, **) note = TicketNote.new(connection, {note: msg, ticket: self}.merge()) note.save end |
#destroy ⇒ Object
38 39 40 41 |
# File 'lib/connectwise/ticket.rb', line 38 def destroy connection.call self.class.cw_api_name, "delete_#{self.class.cw_api_name}".to_sym, {ticketNumber: id} self end |
#save ⇒ Object
31 32 33 34 35 36 |
# File 'lib/connectwise/ticket.rb', line 31 def save return false unless @company attrs = {companyId: @company.company_id, 'serviceTicket' => to_cw_h} attrs = connection.call self.class.cw_api_name, "add_or_update_#{self.class.cw_api_name}_via_company_id".to_sym, attrs self.class.new(connection, self.class.save_transform(attrs)) end |