Method: Crocodoc::Download.document

Defined in:
lib/crocodoc/download.rb

.document(uuid, is_pdf = false, is_annotated = false, filter = nil) ⇒ String

Download a document’s original file from Crocodoc. The file can optionally be downloaded as a PDF, as another filename, with annotations, and with filtered annotations.

Parameters:

  • uuid (String)

    The uuid of the file to download

  • is_pdf (Boolean) (defaults to: false)

    Should the file be downloaded as a PDF?

  • is_annotated (Boolean) (defaults to: false)

    Should the file be downloaded with annotations?

  • filter (String, Array<String>) (defaults to: nil)

    Which annotations should be included if any - this is usually a string, but could also be an array if it’s a comma-separated list of user IDs as the filter

Returns:

  • (String)

    The downloaded file contents as a string

Raises:

  • CrocodocError



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/crocodoc/download.rb', line 32

def self.document(uuid, is_pdf=false, is_annotated=false, filter=nil)
  get_params = {uuid: uuid}
  get_params['pdf'] = 'true' if is_pdf
  get_params['annotated'] = 'true' if is_annotated
  
  if filter
    filter = filter.join(',') if filter.is_a? Array
    get_params['filter'] = filter
  end
  
  Crocodoc._request(self.path, 'document', get_params, nil, false)
end