lib/nsicloudooo/client.rb in nsicloudooo-0.2.3 vs lib/nsicloudooo/client.rb in nsicloudooo-0.2.4
- old
+ new
@@ -14,20 +14,26 @@
# Send a document be granulated by a nsi.cloudooo node
#
# @param [Hash] options used to send a document to be graulated
# @option options [String] file the base64 encoded file to be granulated
+ # @option options [String] sam_uid the UID of a document at SAM
# @option options [String] filename the filename of the document
# @note the filename is very importante, the cloudooo node will convert the document based on its filename, if necessary
# @option options [String] doc_link link to the document that'll be granulated
# @note if provided both doc_link and file options, file will be ignored and the client will download the document instead
# @option options [String] callback a callback url to the file granulation
# @option options [String] verb the callback request verb, when not provided, nsi.cloudooo default to POST
#
# @example A simple granulation
# doc = Base64.encode64(File.new('document.odt', 'r').read)
# nsicloudooo.granulate(:file => doc, :filename => 'document.odt')
+ # @example Granulating from a SAM uid
+ # doc = Base64.encode64(File.new('document.odt', 'r').read)
+ # response = sam.store {:doc => doc, :granulated => false}
+ # doc_key = response["key"]
+ # nsicloudooo.granulate(:sam_uid => doc_key, :filename => 'document.odt')
# @example Downloading and granulating from web
# nsicloudooo.granulate(:doc_link => 'http://google.com/document.odt')
# @example Sending a callback url
# doc = Base64.encode64(File.new('document.odt', 'r').read)
# nsicloudooo.granulate(:file => doc, :filename => 'document.odt', :callback => 'http://google.com')
@@ -36,15 +42,18 @@
# doc = Base64.encode64(File.new('document.odt', 'r').read)
# nsicloudooo.granulate(:file => doc, :filename => 'document.odt', :callback => 'http://google.com', :verb => "PUT")
# nsicloudooo.granulate(:doc_link => 'http://google.com/document.odt', :callback => 'http://google.com', :verb => "PUT")
#
# @return [Hash] response
- # * "key" [String] the key to access the granulated document if the sam node it was stored
+ # * "doc_key" [String] the key to access the granulated document if the sam node it was stored
def granulate(options = {})
@request_data = Hash.new
if options[:doc_link]
insert_download_data options
+ elsif options[:sam_uid]
+ file_data = {:sam_uid => options[:sam_uid], :filename => options[:filename]}
+ @request_data.merge! file_data
else
file_data = {:doc => options[:file], :filename => options[:filename]}
@request_data.merge! file_data
end
insert_callback_data options
@@ -75,10 +84,10 @@
# @return [Hash] response
# * "images" [String] keys to the images grains of the document
# * "files" [String] keys to the files grains of the document
#
# @example
- # nsicloudooo.grains_kets_for("some key")
+ # nsicloudooo.grains_keys_for("some key")
def grains_keys_for(document_key)
request = prepare_request :GET, {:doc_key => document_key}.to_json
execute_request(request)
end