Class: BoxView::Api::Document
Instance Attribute Summary
Attributes inherited from Base
#session
Class Method Summary
collapse
Instance Method Summary
collapse
#destroy, #update
#list
#find
Methods inherited from Base
#initialize
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]
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
|