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