lib/box/file.rb in box-api-0.1.9 vs lib/box/file.rb in box-api-0.2.0
- old
+ new
@@ -38,9 +38,40 @@
parent.delete_info('files')
self.class.new(api, parent, info)
end
+ # Get the comments left on this file.
+ #
+ # @return [Array] An array of {Comment}s.
+ def get_comments
+ comments = @api.get_comments(type, id)['comments']
+
+ comments = Comment.create(@api, comments['comment']) if comments
+
+ @data['comments'] = comments || Array.new
+ end
+
+ # Add a comment to the file.
+ #
+ # @return [Comment] The created comment.
+ def add_comment(message)
+ response = @api.add_comment(type, id, message)
+
+ Comment.create(@api, response['comment']).first
+ end
+
+ # Request the HTML embed code for this file.
+ #
+ # @param [Optional, Hash{:allow_download,:allow_print,:allow_share,
+ # :width,:height,:color => String}] options Options to use
+ # when generating the embed code.
+ # @return [String] HTML code to use to embed the file.
+ #
+ def embed_code(options = Hash.new)
+ @api.file_embed(id, options)['file_embed_html']
+ end
+
protected
# (see Item#get_info)
def get_info
@api.get_file_info(id)['info']