Class: Documents
Instance Method Summary
collapse
#delete_resource, #get_resource, #initialize, #parse_response, #patch_resource, #post_resource, #post_resource_with_string_result, #put_resource, #return_uri
Methods inherited from CheckValues
#check_boolean, #check_int, #check_json, #check_string
Constructor Details
This class inherits a constructor from ChinoBaseAPI
Instance Method Details
#create_document(schema_id, content) ⇒ Object
1055
1056
1057
1058
1059
1060
1061
1062
|
# File 'lib/chino_ruby.rb', line 1055
def create_document(schema_id, content)
check_string(schema_id)
check_json(content)
data = {"content": content}.to_json
document = Document.new
document.from_json(post_resource("/schemas/#{schema_id}/documents", data).to_json, true)
document
end
|
#delete_document(document_id, force) ⇒ Object
1077
1078
1079
1080
1081
|
# File 'lib/chino_ruby.rb', line 1077
def delete_document(document_id, force)
check_string(document_id)
check_boolean(force)
delete_resource("/documents/#{document_id}", force)
end
|
#get_document(document_id) ⇒ Object
1021
1022
1023
1024
1025
1026
|
# File 'lib/chino_ruby.rb', line 1021
def get_document(document_id)
check_string(document_id)
d = Document.new
d.from_json(get_resource("/documents/#{document_id}").to_json, true)
d
end
|
#list_documents(schema_id, full_document, limit = nil, offset = nil) ⇒ Object
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
|
# File 'lib/chino_ruby.rb', line 1028
def list_documents(schema_id, full_document, limit=nil, offset=nil)
check_string(schema_id)
check_boolean(full_document)
docs = GetDocumentsResponse.new
if limit==nil && offset==nil
if full_document
docs.from_json(get_resource("/schemas/#{schema_id}/documents", ChinoRuby::QUERY_DEFAULT_LIMIT, 0, true).to_json)
else
docs.from_json(get_resource("/schemas/#{schema_id}/documents", ChinoRuby::QUERY_DEFAULT_LIMIT, 0).to_json)
end
else
if full_document
docs.from_json(get_resource("/schemas/#{schema_id}/documents", limit, offset, true).to_json)
else
docs.from_json(get_resource("/schemas/#{schema_id}/documents", limit, offset).to_json)
end
end
ds = docs.documents
docs.documents = []
ds.each do |d|
doc = Document.new
doc.from_json(d.to_json)
docs.documents.push(doc)
end
docs
end
|
#update_document(document_id, content, is_active = nil) ⇒ Object
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
|
# File 'lib/chino_ruby.rb', line 1064
def update_document(document_id, content, is_active=nil)
check_string(document_id)
check_json(content)
if is_active.nil?
data = {"content": content}.to_json
else
data = {"content": content, "is_active": is_active}.to_json
end
document = Document.new
document.from_json(put_resource("/documents/#{document_id}", data).to_json, true)
document
end
|