Module: S3Search::API::Documents
- Included in:
- Client
- Defined in:
- lib/s3search/api/documents.rb
Instance Method Summary collapse
- #create(data, options = {}) ⇒ Object
- #create_many(data, options = {}) ⇒ Object
- #delete(id) ⇒ Object
- #get(id) ⇒ Object
- #get_all(options = {}) ⇒ Object
- #update(id, attributes) ⇒ Object
Instance Method Details
#create(data, options = {}) ⇒ Object
7 8 9 10 |
# File 'lib/s3search/api/documents.rb', line 7 def create data, ={} raise 'use create_many for multiple documents' if data.is_a?(Array) _post('/v1/documents.json', {data: data, options: }) end |
#create_many(data, options = {}) ⇒ Object
12 13 14 15 |
# File 'lib/s3search/api/documents.rb', line 12 def create_many data, ={} response = _post('/v1/documents.json', {data: [data].flatten}, options: ) response.results end |
#delete(id) ⇒ Object
17 18 19 |
# File 'lib/s3search/api/documents.rb', line 17 def delete id _delete "/v1/documents/#{id}.json" end |
#get(id) ⇒ Object
21 22 23 |
# File 'lib/s3search/api/documents.rb', line 21 def get id _get "/v1/documents/#{id}.json" end |
#get_all(options = {}) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/s3search/api/documents.rb', line 29 def get_all ={} [:page] ||= 1 [:per_page] ||= 25 response = _get("/v1/documents.json", ) S3Search::ResultPage.new(response, self) end |
#update(id, attributes) ⇒ Object
25 26 27 |
# File 'lib/s3search/api/documents.rb', line 25 def update id, attributes _put("/v1/documents/#{id}.json", {document: attributes}) end |