Class: Insightly::Comment
Constant Summary
collapse
- URL_BASE =
"Comments"
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, #get_collection, #initialize, #process, #reload, #remote_data, #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
42
43
44
45
|
# File 'lib/insightly/comment.rb', line 42
def load(id)
load_from_xml(get_collection("#{url_base}/#{id}", :xml_raw))
end
|
#load_from_xml(xml) ⇒ Object
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/insightly/comment.rb', line 17
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
13
14
15
|
# File 'lib/insightly/comment.rb', line 13
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
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/insightly/comment.rb', line 28
def to_xml
<<-END_XML
<?xml version="1.0" encoding="utf-8"?>
<Comment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<COMMENT_ID>#{}</COMMENT_ID>
<BODY>#{body}</BODY>
<OWNER_USER_ID>#{owner_user_id}</OWNER_USER_ID>
<DATE_CREATED_UTC>#{date_created_utc}</DATE_CREATED_UTC>
<DATE_UPDATED_UTC>#{date_updated_utc}</DATE_UPDATED_UTC>
<FILE_ATTACHMENTS></FILE_ATTACHMENTS>
</Comment>
END_XML
end
|