lib/xeroizer/models/attachment.rb in xeroizer-2.15.9 vs lib/xeroizer/models/attachment.rb in xeroizer-2.16.0
- old
+ new
@@ -2,41 +2,43 @@
module Record
class AttachmentModel < BaseModel
module Extensions
- def attach_data(id, filename, data, content_type = "application/octet-stream")
- application.Attachment.attach_data(url, id, filename, data, content_type)
+ def attach_data(id, filename, data, content_type = "application/octet-stream", options = {})
+ application.Attachment.attach_data(url, id, filename, data, content_type, options)
end
- def attach_file(id, filename, path, content_type = "application/octet-stream")
- application.Attachment.attach_file(url, id, filename, path, content_type)
+ def attach_file(id, filename, path, content_type = "application/octet-stream", options = {})
+ application.Attachment.attach_file(url, id, filename, path, content_type, options)
end
def attachments(id)
application.Attachment.attachments_for(url, id)
end
end
set_permissions :read
- def attach_data(url, id, filename, data, content_type)
+ def attach_data(url, id, filename, data, content_type, options = {})
+ options = { include_online: false }.merge(options)
+
response_xml = @application.http_put(@application.client,
"#{url}/#{CGI.escape(id)}/Attachments/#{CGI.escape(filename)}",
data,
- :raw_body => true, :content_type => content_type
+ :raw_body => true, :content_type => content_type, "IncludeOnline" => options[:include_online]
)
response = parse_response(response_xml)
if (response_items = response.response_items) && response_items.size > 0
response_items.size == 1 ? response_items.first : response_items
else
response
end
end
- def attach_file(url, id, filename, path, content_type)
- attach_data(url, id, filename, File.read(path), content_type)
+ def attach_file(url, id, filename, path, content_type, options = {})
+ attach_data(url, id, filename, File.read(path), content_type, options)
end
def attachments_for(url, id)
response_xml = @application.http_get(@application.client,
"#{url}/#{CGI.escape(id)}/Attachments")
@@ -52,16 +54,16 @@
end
class Attachment < Base
module Extensions
- def attach_file(filename, path, content_type = "application/octet-stream")
- parent.attach_file(id, filename, path, content_type)
+ def attach_file(filename, path, content_type = "application/octet-stream", options = {})
+ parent.attach_file(id, filename, path, content_type, options)
end
- def attach_data(filename, data, content_type = "application/octet-stream")
- parent.attach_data(id, filename, data, content_type)
+ def attach_data(filename, data, content_type = "application/octet-stream", options = {})
+ parent.attach_data(id, filename, data, content_type, options)
end
def attachments
parent.attachments(id)
end
@@ -88,6 +90,6 @@
end
end
end
-end
+end
\ No newline at end of file