Class: BoxView::Api::Document

Inherits:
Base
  • Object
show all
Includes:
Actions::Crudable, Actions::Findable, Actions::Listable
Defined in:
lib/box_view/api/document.rb

Instance Attribute Summary

Attributes inherited from Base

#session

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Actions::Crudable

#destroy, #update

Methods included from Actions::Listable

#list

Methods included from Actions::Findable

#find

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from BoxView::Api::Base

Class Method Details

.supported_filetype?(filetype) ⇒ Boolean

Returns:

  • (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_filetypesObject



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

Raises:

  • (ArgumentError)


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

Raises:

  • (NotImplementedError)


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