Module: FileboundClient::Endpoints::DocumentBinaryData

Defined in:
lib/filebound_client/endpoints/document_binary_data.rb

Overview

Module for DocumentBinaryData resource endpoint

Instance Method Summary collapse

Instance Method Details

#add_binary_data(extension, file_id, binary_data) ⇒ Hash

Adds binary data

Parameters:

  • extension (String)

    the file extension

  • file_id (int)

    the file id to add the binary data to

  • binary_data (String)

    the Base64 encoded binary data to add

Returns:

  • (Hash)

    the new document

Raises:

  • (FileboundClientException)


18
19
20
21
22
23
24
25
# File 'lib/filebound_client/endpoints/document_binary_data.rb', line 18

def add_binary_data(extension, file_id, binary_data)
  raise FileboundClientException.new('extension is required', 0) if extension.blank?
  # rubocop:disable Metrics/LineLength
  raise FileboundClientException.new('file_id is required and must be greater than 0 when adding binary data', 0) if file_id.blank? || file_id.zero?
  # rubocop:enable Metrics/LineLength
  raise FileboundClientException.new('binary_data is required', 0) if binary_data.blank?
  post('/documentBinaryData/0', nil, id: 0, extension: extension, fileId: file_id, documentToUpload: binary_data)
end

#add_to_indexing_queue(extension, binary_data, project_id = nil) ⇒ Hash

Adds binary data to the indexing queue

Parameters:

  • extension (String)

    the file extension

  • binary_data (String)

    the Base-64 encoded binary data to send to the indexing queue

  • project_id (int) (defaults to: nil)

    the optional project_id to assign the binary data to

Returns:

  • (Hash)

    the new document

Raises:

  • (FileboundClientException)


44
45
46
47
48
49
50
# File 'lib/filebound_client/endpoints/document_binary_data.rb', line 44

def add_to_indexing_queue(extension, binary_data, project_id = nil)
  raise FileboundClientException.new('extension is required', 0) if extension.blank?
  raise FileboundClientException.new('binary_data is required', 0) if binary_data.blank?
  body = { extension: extension, documentToUpload: binary_data }
  body[:projectId] = project_id unless project_id.blank?
  put('/documentBinaryData', nil, body)
end

#retrieve_binary_data(document_id, query_params = nil) ⇒ binary

Retrieves document binary data

Parameters:

  • document_id (int)

    the document key

  • query_params (Hash) (defaults to: nil)

    optional query parameters to pass to the request

Returns:

  • (binary)

    binary data for the document



9
10
11
# File 'lib/filebound_client/endpoints/document_binary_data.rb', line 9

def retrieve_binary_data(document_id, query_params = nil)
  get_binary("/documentBinaryData/#{document_id}", query_params)
end

#update_binary_data(document_id, extension, binary_data) ⇒ Hash

Updates binary data

Parameters:

  • document_id (int)

    the document key

  • extension (String)

    the file extension

  • binary_data (String)

    the Base64 encoded binary data to update

Returns:

  • (Hash)

    the updated document

Raises:

  • (FileboundClientException)


32
33
34
35
36
37
# File 'lib/filebound_client/endpoints/document_binary_data.rb', line 32

def update_binary_data(document_id, extension, binary_data)
  raise FileboundClientException.new('extension is required', 0) if extension.blank?
  raise FileboundClientException.new('binary_data is required', 0) if binary_data.blank?
  post("/documentBinaryData/#{document_id}", nil, id: document_id, extension: extension,
                                                  documentToUpload: binary_data)
end