Class: Connectwise::TicketNote

Inherits:
Object
  • Object
show all
Includes:
Model
Defined in:
lib/connectwise/ticket_note.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Model

#defined_attributes, #destroy, included, #persisted?, #to_cw_h, #to_h

Constructor Details

#initialize(connection, **attributes) ⇒ TicketNote

Returns a new instance of TicketNote.



24
25
26
27
# File 'lib/connectwise/ticket_note.rb', line 24

def initialize(connection, **attributes)
  @ticket = attributes.delete(:ticket)
  super(connection, attributes)
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/connectwise/ticket_note.rb', line 5

def id
  @id
end

#is_part_of_detail_descriptionObject

Returns the value of attribute is_part_of_detail_description.



5
6
7
# File 'lib/connectwise/ticket_note.rb', line 5

def is_part_of_detail_description
  @is_part_of_detail_description
end

#is_part_of_internal_analysisObject

Returns the value of attribute is_part_of_internal_analysis.



5
6
7
# File 'lib/connectwise/ticket_note.rb', line 5

def is_part_of_internal_analysis
  @is_part_of_internal_analysis
end

#is_part_of_resolutionObject

Returns the value of attribute is_part_of_resolution.



5
6
7
# File 'lib/connectwise/ticket_note.rb', line 5

def is_part_of_resolution
  @is_part_of_resolution
end

#noteObject

Returns the value of attribute note.



5
6
7
# File 'lib/connectwise/ticket_note.rb', line 5

def note
  @note
end

#note_textObject

Returns the value of attribute note_text.



5
6
7
# File 'lib/connectwise/ticket_note.rb', line 5

def note_text
  @note_text
end

Class Method Details

.cw_api_nameObject



7
8
9
# File 'lib/connectwise/ticket_note.rb', line 7

def self.cw_api_name
  :service_ticket
end

.transform(attrs) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/connectwise/ticket_note.rb', line 11

def self.transform(attrs)
  type = attrs.delete(:type)
  attrs[:note_text] ||= attrs.delete(:note)
  if type == :internal
    attrs[:is_part_of_internal_analysis] = true
  elsif type == :resolution
    attrs[:is_part_of_resolution] = true
  else
    attrs[:is_part_of_detail_description] = true
  end
  attrs
end

Instance Method Details

#external?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/connectwise/ticket_note.rb', line 34

def external?
  !!is_part_of_detail_description
end

#internal?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/connectwise/ticket_note.rb', line 38

def internal?
  !!is_part_of_internal_analysis
end

#resolution?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/connectwise/ticket_note.rb', line 42

def resolution?
  !!is_part_of_resolution
end

#saveObject



29
30
31
32
# File 'lib/connectwise/ticket_note.rb', line 29

def save
  attrs = connection.call self.class.cw_api_name, "update_#{self.class.cw_model_name}".to_sym, {'note' => to_cw_h, 'srServiceRecid' => @ticket.id}
  self.class.new(connection, self.class.save_transform(attrs))
end