Module: S3Search::API::Documents

Included in:
Client
Defined in:
lib/s3search/api/documents.rb

Instance Method Summary collapse

Instance Method Details

#create(data) ⇒ 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})
end

#create_many(data) ⇒ 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})
  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 options={}
  options[:page] ||= 1
  options[:per_page] ||= 25
  response = _get("/v1/documents.json", options)
  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