Class: MeiliSearch::HTTPRequest

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/meilisearch/http_request.rb

Direct Known Subclasses

Client, Index

Instance Method Summary collapse

Constructor Details

#initialize(url, api_key = nil, options = {}) ⇒ HTTPRequest

Returns a new instance of HTTPRequest.



10
11
12
13
14
15
16
17
18
# File 'lib/meilisearch/http_request.rb', line 10

def initialize(url, api_key = nil, options = {})
  @base_url = url
  @api_key = api_key
  @options = options
  @headers = {
    'Content-Type' => 'application/json',
    'X-Meili-API-Key' => api_key
  }.compact
end

Instance Method Details

#http_delete(relative_path = '') ⇒ Object



46
47
48
49
50
51
# File 'lib/meilisearch/http_request.rb', line 46

def http_delete(relative_path = '')
  send_request(
    proc { |path, config| self.class.delete(path, config) },
    relative_path
  )
end

#http_get(relative_path = '', query_params = {}) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/meilisearch/http_request.rb', line 20

def http_get(relative_path = '', query_params = {})
  send_request(
    proc { |path, config| self.class.get(path, config) },
    relative_path,
    query_params
  )
end

#http_post(relative_path = '', body = nil, query_params = nil) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/meilisearch/http_request.rb', line 28

def http_post(relative_path = '', body = nil, query_params = nil)
  send_request(
    proc { |path, config| self.class.post(path, config) },
    relative_path,
    query_params,
    body
  )
end

#http_put(relative_path = '', body = nil, query_params = nil) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/meilisearch/http_request.rb', line 37

def http_put(relative_path = '', body = nil, query_params = nil)
  send_request(
    proc { |path, config| self.class.put(path, config) },
    relative_path,
    query_params,
    body
  )
end