Class: Insightly::Comment
Instance Method Summary
collapse
Methods inherited from ReadWrite
#post_collection, #put_collection, #to_json, #update_data
Methods inherited from Base
#==, all, api_field, build, #build, #config, custom_fields, date_to_insightly, #get_collection, #initialize, #process, #reload, #remote_data, #remote_id=, #remote_id?, #remote_id_field, #to_json, #url_base
Instance Method Details
#field_to_i(field) ⇒ Object
52
53
54
|
# File 'lib/insightly/comment.rb', line 52
def field_to_i(field)
@data[field] = @data[field].to_i if @data[field]
end
|
#load(id) ⇒ Object
43
44
45
|
# File 'lib/insightly/comment.rb', line 43
def load(id)
load_from_xml(get_collection("#{url_base}/#{id}", :xml_raw))
end
|
#load_from_xml(xml) ⇒ Object
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/insightly/comment.rb', line 18
def load_from_xml(xml)
result = Hash.from_xml(xml.to_str)
if result["Comment"]
@data = result["Comment"]
["COMMENT_ID", "OWNER_USER_ID"].each { |f| field_to_i(f) }
@data.delete("xmlns:xsi")
@data.delete('xmlns:xsd')
end
self
end
|
#remote_id ⇒ Object
14
15
16
|
# File 'lib/insightly/comment.rb', line 14
def remote_id
end
|
#save ⇒ Object
47
48
49
50
|
# File 'lib/insightly/comment.rb', line 47
def save
put_collection("#{url_base}", to_xml, :xml_raw)
self
end
|
#to_xml ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/insightly/comment.rb', line 29
def to_xml
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n <Comment xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n <COMMENT_ID>\#{comment_id}</COMMENT_ID>\n <BODY>\#{body}</BODY>\n <OWNER_USER_ID>\#{owner_user_id}</OWNER_USER_ID>\n <DATE_CREATED_UTC>\#{date_created_utc}</DATE_CREATED_UTC>\n <DATE_UPDATED_UTC>\#{date_updated_utc}</DATE_UPDATED_UTC>\n <FILE_ATTACHMENTS></FILE_ATTACHMENTS>\n </Comment>\n END_XML\nend\n"
|