Class: Zendesk::Comment

Inherits:
Resource show all
Includes:
Constants
Defined in:
lib/zendesk/comment.rb

Constant Summary

Constants included from Constants

Zendesk::Constants::PRIORITY, Zendesk::Constants::RESTRICTION, Zendesk::Constants::ROLE, Zendesk::Constants::STATUS, Zendesk::Constants::TICKET_TYPE, Zendesk::Constants::VIA

Instance Method Summary collapse

Methods inherited from Resource

create, #load_data

Methods included from Properties

included

Constructor Details

#initialize(attrs = {}) ⇒ Comment

Returns a new instance of Comment.



9
10
11
12
13
# File 'lib/zendesk/comment.rb', line 9

def initialize(attrs = {})
  @ticket_id ||= attrs[:ticket_id] || attrs['ticket_id']
  @is_public ||= false
  super
end

Instance Method Details

#saveObject



19
20
21
22
23
24
25
26
27
# File 'lib/zendesk/comment.rb', line 19

def save
  begin
    response = Zendesk.resource["tickets/#{ticket_id}.xml"].put self.to_xml, :content_type => 'application/xml'
    return (200..300).include?(response.headers[:status].to_i)
  rescue Exception => e
    puts e.message
    return false
  end
end

#to_xmlObject



15
16
17
# File 'lib/zendesk/comment.rb', line 15

def to_xml    
  Zendesk.xml_out({:comment => { :value => value, :is_public => is_public }})
end