Module: Algolia::Protocol
- Defined in:
- lib/algolia/protocol.rb
Overview
A module which encapsulates the specifics of Algolia’s REST API.
Constant Summary collapse
- VERSION =
The version of the REST API implemented by this module.
1
- HEADER_APP_ID =
The HTTP header used for passing your application ID to the Algolia API.
"X-Algolia-Application-Id"
- HEADER_API_KEY =
The HTTP header used for passing your API key to the Algolia API.
"X-Algolia-API-Key"
- HEADER_FORWARDED_IP =
"X-Forwarded-For"
- HEADER_FORWARDED_API_KEY =
"X-Forwarded-API-Key"
- ERROR_TIMEOUT =
HTTP ERROR CODES
124
- ERROR_UNAVAILABLE =
503
Class Method Summary collapse
- .batch_uri(index) ⇒ Object
- .browse_uri(index, params = {}) ⇒ Object
- .clear_uri(index) ⇒ Object
- .index_key_uri(index, key) ⇒ Object
- .index_keys_uri(index) ⇒ Object
- .index_operation_uri(index) ⇒ Object
-
.index_uri(index) ⇒ Object
Construct a uri referencing a given Algolia index.
-
.indexes_uri ⇒ Object
Construct a uri to list available indexes.
- .key_uri(key) ⇒ Object
- .keys_uri ⇒ Object
- .logs(offset, length) ⇒ Object
- .object_uri(index, object_id, params = {}) ⇒ Object
- .partial_object_uri(index, object_id) ⇒ Object
- .search_uri(index, query, params = {}) ⇒ Object
- .settings_uri(index) ⇒ Object
- .task_uri(index, task_id) ⇒ Object
Class Method Details
.batch_uri(index) ⇒ Object
46 47 48 |
# File 'lib/algolia/protocol.rb', line 46 def Protocol.batch_uri(index) "/#{VERSION}/indexes/#{index}/batch" end |
.browse_uri(index, params = {}) ⇒ Object
68 69 70 71 |
# File 'lib/algolia/protocol.rb', line 68 def Protocol.browse_uri(index, params = {}) params = params.nil? || params.size == 0 ? "" : "?#{to_query(params)}" "#{index_uri(index)}/browse#{params}" end |
.clear_uri(index) ⇒ Object
81 82 83 |
# File 'lib/algolia/protocol.rb', line 81 def Protocol.clear_uri(index) "#{index_uri(index)}/clear" end |
.index_key_uri(index, key) ⇒ Object
97 98 99 |
# File 'lib/algolia/protocol.rb', line 97 def Protocol.index_key_uri(index, key) "#{index_uri(index)}/keys/#{key}" end |
.index_keys_uri(index) ⇒ Object
101 102 103 |
# File 'lib/algolia/protocol.rb', line 101 def Protocol.index_keys_uri(index) "#{index_uri(index)}/keys" end |
.index_operation_uri(index) ⇒ Object
50 51 52 |
# File 'lib/algolia/protocol.rb', line 50 def Protocol.index_operation_uri(index) "/#{VERSION}/indexes/#{index}/operation" end |
.index_uri(index) ⇒ Object
Construct a uri referencing a given Algolia index
42 43 44 |
# File 'lib/algolia/protocol.rb', line 42 def Protocol.index_uri(index) "/#{VERSION}/indexes/#{index}" end |
.indexes_uri ⇒ Object
Construct a uri to list available indexes
37 38 39 |
# File 'lib/algolia/protocol.rb', line 37 def Protocol.indexes_uri "/#{VERSION}/indexes" end |
.key_uri(key) ⇒ Object
93 94 95 |
# File 'lib/algolia/protocol.rb', line 93 def Protocol.key_uri(key) "/#{VERSION}/keys/#{key}" end |
.keys_uri ⇒ Object
89 90 91 |
# File 'lib/algolia/protocol.rb', line 89 def Protocol.keys_uri "/#{VERSION}/keys" end |
.logs(offset, length) ⇒ Object
85 86 87 |
# File 'lib/algolia/protocol.rb', line 85 def Protocol.logs(offset, length) "/#{VERSION}/logs?offset=#{offset}&length=#{length}" end |
.object_uri(index, object_id, params = {}) ⇒ Object
58 59 60 61 |
# File 'lib/algolia/protocol.rb', line 58 def Protocol.object_uri(index, object_id, params = {}) params = params.nil? || params.size == 0 ? "" : "?#{to_query(params)}" "#{index_uri(index)}/#{object_id}#{params}" end |
.partial_object_uri(index, object_id) ⇒ Object
73 74 75 |
# File 'lib/algolia/protocol.rb', line 73 def Protocol.partial_object_uri(index, object_id) "#{index_uri(index)}/#{object_id}/partial" end |
.search_uri(index, query, params = {}) ⇒ Object
63 64 65 66 |
# File 'lib/algolia/protocol.rb', line 63 def Protocol.search_uri(index, query, params = {}) params = params.nil? || params.size == 0 ? "" : "&#{to_query(params)}" "#{index_uri(index)}?query=#{CGI.escape(query)}&#{params}" end |
.settings_uri(index) ⇒ Object
77 78 79 |
# File 'lib/algolia/protocol.rb', line 77 def Protocol.settings_uri(index) "#{index_uri(index)}/settings" end |
.task_uri(index, task_id) ⇒ Object
54 55 56 |
# File 'lib/algolia/protocol.rb', line 54 def Protocol.task_uri(index, task_id) "#{index_uri(index)}/task/#{task_id}" end |