Class: MeiliSearch::HTTPRequest
- Inherits:
-
Object
- Object
- MeiliSearch::HTTPRequest
- Includes:
- HTTParty
- Defined in:
- lib/meilisearch/http_request.rb
Instance Method Summary collapse
- #http_delete(relative_path = '') ⇒ Object
- #http_get(relative_path = '', query_params = {}) ⇒ Object
- #http_post(relative_path = '', body = nil, query_params = nil) ⇒ Object
- #http_put(relative_path = '', body = nil, query_params = nil) ⇒ Object
-
#initialize(url, api_key = nil) ⇒ HTTPRequest
constructor
A new instance of HTTPRequest.
Constructor Details
#initialize(url, api_key = nil) ⇒ HTTPRequest
Returns a new instance of HTTPRequest.
10 11 12 13 14 15 16 17 |
# File 'lib/meilisearch/http_request.rb', line 10 def initialize(url, api_key = nil) @base_url = url @api_key = api_key @headers = { 'Content-Type' => 'application/json', 'X-Meili-API-Key' => api_key }.compact end |
Instance Method Details
#http_delete(relative_path = '') ⇒ Object
45 46 47 48 49 50 |
# File 'lib/meilisearch/http_request.rb', line 45 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
19 20 21 22 23 24 25 |
# File 'lib/meilisearch/http_request.rb', line 19 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
27 28 29 30 31 32 33 34 |
# File 'lib/meilisearch/http_request.rb', line 27 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
36 37 38 39 40 41 42 43 |
# File 'lib/meilisearch/http_request.rb', line 36 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 |