module Ohmage::API::Document

Public Instance Methods

document_contents(params = {}) click to toggle source

ohmage document/read/contents call @see github.com/ohmage/server/wiki/Document-Manipulation#documentUpdate @returns [Binary File] from raw HTTP Response Body.

# File lib/ohmage/document.rb, line 57
def document_contents(params = {})
  request = Ohmage::Request.new(self, :post, 'document/read/contents', params)
  request.perform
end
document_create(params = {}) click to toggle source

ohmage document/create call @see github.com/ohmage/server/wiki/Document-Manipulation#documentCreate @returns [Ohmage::Document object]

# File lib/ohmage/document.rb, line 23
def document_create(params = {})
  params[:document] = HTTP::FormData::File.new(params[:document])
  # catch lack of document_name param, since we can just append the filename we have!
  request = Ohmage::Request.new(self, :post, 'document/create', params)
  request.perform
  document_read(document_name_search: params[:document_name])
end
document_delete(params = {}) click to toggle source

ohmage document/delete call @see github.com/ohmage/server/wiki/Document-Manipulation#documentDelete @returns string with success/fail

# File lib/ohmage/document.rb, line 47
def document_delete(params = {})
  request = Ohmage::Request.new(self, :post, 'document/delete', params)
  request.perform
end
document_read(params = {}) click to toggle source

ohmage document/read call @see github.com/ohmage/server/wiki/Document-Manipulation#document-information-read @returns [Array: Ohmage::Document objects] matching criteria and output format

# File lib/ohmage/document.rb, line 8
def document_read(params = {})
  request = Ohmage::Request.new(self, :post, 'document/read', params)
  # TODO: make a utility to abstract creation of array of base objects
  t = []
  request.perform[:data].each do |k, v|
    t << Ohmage::Document.new(k => v)
  end
  t
end
document_update(params = {}) click to toggle source

ohmage document/update call @see github.com/ohmage/server/wiki/Document-Manipulation#documentUpdate @returns nil, can’t be sure we can search for the updated file.

# File lib/ohmage/document.rb, line 36
def document_update(params = {})
  params[:document] = HTTP::FormData::File.new(params[:document]) if params[:document]
  request = Ohmage::Request.new(self, :post, 'document/update', params)
  request.perform
end