Module: FileboundClient::Endpoints::Documents

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

Overview

Module for Documents resource endpoint

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object

This will call macros to create resource methods on the fly



6
7
8
9
10
11
# File 'lib/filebound_client/endpoints/documents.rb', line 6

def self.included(klass)
  klass.instance_eval do
    allow_new :document
    allow_all :documents
  end
end

Instance Method Details

#document(document_id, query_params = nil) ⇒ Hash

Retrieves a single document

Parameters:

  • document_id (int)

    the document key

Returns:

  • (Hash)

    the document hash



16
17
18
# File 'lib/filebound_client/endpoints/documents.rb', line 16

def document(document_id, query_params = nil)
  get("/documents/#{document_id}", query_params)
end

#document_add(document) ⇒ Hash

Adds a document

Parameters:

  • document (Hash)

    the document hash to add

Returns:

  • (Hash)

    the newly added document hash

Raises:

  • (FileboundClientException)


89
90
91
92
# File 'lib/filebound_client/endpoints/documents.rb', line 89

def document_add(document)
  raise FileboundClientException.new('File Id is required', 0) unless document && document[:fileId].positive?
  put("/documents/#{document[:fileId]}", nil, document)
end

#document_add_comment(document_id, comment_data, query_params = nil) ⇒ Hash

Adds a comment to document

Parameters:

  • document_id (int)

    the document key

  • comment_data (Hash)

    the comment to add

Returns:

  • (Hash)

    the newly added document comment hash



112
113
114
# File 'lib/filebound_client/endpoints/documents.rb', line 112

def document_add_comment(document_id, comment_data, query_params = nil)
  put("/documents/#{document_id}/comments", nil, comment_data)
end

#document_add_eformdata(document_id, eform_data) ⇒ Hash

Adds eform data to document

Parameters:

  • document_id (int)

    the document key

  • eform_data (Hash)

    the eform data hash to add

Returns:

  • (Hash)

    the newly added eform data hash



48
49
50
# File 'lib/filebound_client/endpoints/documents.rb', line 48

def document_add_eformdata(document_id, eform_data)
  put("/documents/#{document_id}/eformdata", nil, eform_data)
end

#document_add_eformdetail(document_id, eform_detail) ⇒ Hash

Adds eform detail to document

Parameters:

  • document_id (int)

    the document key

  • eform_detail (Hash)

    the eform detail to add

Returns:

  • (Hash)

    the newly added eform detail hash



56
57
58
# File 'lib/filebound_client/endpoints/documents.rb', line 56

def document_add_eformdetail(document_id, eform_detail)
  put("/documents/#{document_id}/eformdetail", nil, eform_detail)
end

#document_comments(document_id, query_params = nil) ⇒ Object

Returns the document comments for the supplied document key

Parameters:

  • document_id (int)

    the document key

  • query_params (Hash) (defaults to: nil)

    the additional query params to send in the request



104
105
106
# File 'lib/filebound_client/endpoints/documents.rb', line 104

def document_comments(document_id, query_params = nil)
  get("/documents/#{document_id}/comments", query_params)
end

#document_delete(document_id, query_params = nil) ⇒ bool

Delete a document

Parameters:

  • document_id (int)

    the document key

Returns:

  • (bool)

    true if document was deleted successfully



97
98
99
# File 'lib/filebound_client/endpoints/documents.rb', line 97

def document_delete(document_id, query_params = nil)
  delete("/documents/#{document_id}")
end

#document_eform_data(document_id, query_params = nil) ⇒ Hash

Returns the eform data for the document key

Parameters:

  • document_id (int)

    the document key

  • query_params (Hash) (defaults to: nil)

    the additional query params to send in the request

Returns:

  • (Hash)

    the EFormData hash



24
25
26
# File 'lib/filebound_client/endpoints/documents.rb', line 24

def document_eform_data(document_id, query_params = nil)
  get("/documents/#{document_id}/eformdata", query_params)
end

#document_eform_detail(document_id, query_params = nil) ⇒ Hash

Returns the eform detail for the document key

Parameters:

  • document_id (int)

    the document key

  • query_params (Hash) (defaults to: nil)

    the additional query params to send in the request

Returns:

  • (Hash)

    the EFormDetail hash



32
33
34
# File 'lib/filebound_client/endpoints/documents.rb', line 32

def document_eform_detail(document_id, query_params = nil)
  get("/documents/#{document_id}/eformdetail", query_params)
end

#document_rendition(document_id, query_params = nil) ⇒ String

Returns a rendition for the document key

Parameters:

  • document_id (int)

    the document key

  • query_params (Hash) (defaults to: nil)

    the additional query params to send in the request (optional: page(int))

Returns:

  • (String)

    rendition for the document



40
41
42
# File 'lib/filebound_client/endpoints/documents.rb', line 40

def document_rendition(document_id, query_params = nil)
  get("/documents/#{document_id}/rendition", query_params)
end

#document_update(document, query_params = nil) ⇒ int

Updates a document

Parameters:

  • document (Hash)

    the document hash to update

  • query_params (Hash) (defaults to: nil)

    additional query parameters to pass to the request (optional: setBinaryData(bool))

Returns:

  • (int)

    the document id that was updated



82
83
84
# File 'lib/filebound_client/endpoints/documents.rb', line 82

def document_update(document, query_params = nil)
  post("/documents/#{document[:id]}", query_params, document)
end

#document_update_eformdata(document_id, eform_data, query_params = nil) ⇒ Hash

Updates eform data for the document

Parameters:

  • document_id (int)

    the document key

  • eform_data (Hash)

    the eform data hash to update

  • query_params (Hash) (defaults to: nil)

    additional query parameters to pass to the request (optional: deleteNonMatches(bool))

Returns:

  • (Hash)

    the updated eform data hash



65
66
67
# File 'lib/filebound_client/endpoints/documents.rb', line 65

def document_update_eformdata(document_id, eform_data, query_params = nil)
  post("/documents/#{document_id}/eformdata", query_params, eform_data)
end

#document_update_eformdetail(document_id, eform_detail, query_params = nil) ⇒ Hash

Updates eform detail for the document

Parameters:

  • document_id (int)

    the document key

  • eform_detail (Hash)

    the eform detail hash to update

  • query_params (Hash) (defaults to: nil)

    additional query parameters to pass to the request (optional: deleteNonMatches(bool))

Returns:

  • (Hash)

    the updated eform detail hash



74
75
76
# File 'lib/filebound_client/endpoints/documents.rb', line 74

def document_update_eformdetail(document_id, eform_detail, query_params = nil)
  put("/documents/#{document_id}/eformdetail", query_params, eform_detail)
end