Class: BoxView::Api::Document
- Includes:
- Actions::Crudable, Actions::Findable, Actions::Listable
- Defined in:
- lib/box_view/api/document.rb
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
- #content(id, extension = nil) ⇒ Object
- #create(*args) ⇒ Object
- #thumbnail(id, width, height) ⇒ Object
- #upload(url, name) ⇒ Object
Methods included from Actions::Crudable
Methods included from Actions::Listable
Methods included from Actions::Findable
Methods inherited from Base
Constructor Details
This class inherits a constructor from BoxView::Api::Base
Class Method Details
.supported_filetype?(filetype) ⇒ Boolean
13 14 15 |
# File 'lib/box_view/api/document.rb', line 13 def self.supported_filetype?(filetype) supported_filetypes.include?(filetype.to_sym) end |
.supported_filetypes ⇒ Object
9 10 11 |
# File 'lib/box_view/api/document.rb', line 9 def self.supported_filetypes [:pdf, :doc, :docx, :ppt, :pptx, :xls, :xlsx, :txt, :py, :js, :xml, :html, :css, :md, :pl, :c, :m] end |
Instance Method Details
#content(id, extension = nil) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/box_view/api/document.rb', line 29 def content(id, extension=nil) supported_extensions = %w(zip pdf) raise ArgumentError.new("Unsupported content extension #{extension}. Must use one of #{supported_extensions} or nil.") unless supported_extensions.include?(extension) || extension.nil? extension = ".#{extension}" if extension session.get("#{endpoint_url}/#{id}/content#{extension}", {}, false) end |
#create(*args) ⇒ Object
17 18 19 |
# File 'lib/box_view/api/document.rb', line 17 def create(*args) raise NotImplementedError end |
#thumbnail(id, width, height) ⇒ Object
25 26 27 |
# File 'lib/box_view/api/document.rb', line 25 def thumbnail(id, width, height) session.get("#{endpoint_url}/#{id}/thumbnail", { width: width, height: height }, false) end |
#upload(url, name) ⇒ Object
21 22 23 |
# File 'lib/box_view/api/document.rb', line 21 def upload(url, name) data_item(session.post(endpoint_url, { url: url, name: name }.to_json), session) end |