algolia 2.0.0.pre.alpha.3 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +3 -0
  4. data/CHANGELOG.md +7 -0
  5. data/Gemfile +1 -1
  6. data/README.md +18 -10
  7. data/SECURITY.md +3 -0
  8. data/algolia.gemspec +9 -3
  9. data/lib/algolia.rb +1 -1
  10. data/lib/algolia/analytics_client.rb +1 -1
  11. data/lib/algolia/config/analytics_config.rb +2 -2
  12. data/lib/algolia/config/base_config.rb +43 -0
  13. data/lib/algolia/config/insights_config.rb +2 -2
  14. data/lib/algolia/config/recommendation_config.rb +2 -2
  15. data/lib/algolia/config/search_config.rb +2 -2
  16. data/lib/algolia/defaults.rb +2 -2
  17. data/lib/algolia/error.rb +1 -2
  18. data/lib/algolia/helpers.rb +3 -2
  19. data/lib/algolia/insights_client.rb +1 -1
  20. data/lib/algolia/iterators/object_iterator.rb +5 -4
  21. data/lib/algolia/iterators/paginator_iterator.rb +5 -3
  22. data/lib/algolia/recommendation_client.rb +1 -1
  23. data/lib/algolia/search_client.rb +1 -1
  24. data/lib/algolia/search_index.rb +37 -37
  25. data/lib/algolia/transport/transport.rb +4 -4
  26. data/lib/algolia/version.rb +1 -1
  27. data/sig/config/algolia_config.rbs +3 -3
  28. data/sig/config/analytics_config.rbs +1 -1
  29. data/sig/config/insights_config.rbs +1 -1
  30. data/sig/config/recommendation_config.rbs +1 -1
  31. data/sig/config/search_config.rbs +1 -1
  32. data/test/algolia/integration/analytics_client_test.rb +6 -6
  33. data/test/algolia/integration/insights_client_test.rb +11 -11
  34. data/test/algolia/integration/search_client_test.rb +20 -11
  35. data/test/algolia/unit/algolia_config_test.rb +16 -0
  36. data/test/algolia/unit/helpers_test.rb +18 -1
  37. data/test/algolia/unit/retry_strategy_test.rb +3 -3
  38. data/test/test_helper.rb +1 -1
  39. data/upgrade_guide.md +30 -22
  40. metadata +20 -14
  41. data/lib/algolia/config/algolia_config.rb +0 -40
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a37aa5b34c5719c6f15dae985448b1d4469c7617e5da569bb298531b459dcdc4
4
- data.tar.gz: d7c2a37e288cff749973b78dd9edc20f4611efe94bb36ede952450925b579976
3
+ metadata.gz: 555e432d41a84d3031f58dc7c74acf5297df48fe693fadf977c6b15547a82d6b
4
+ data.tar.gz: a3fbbc9ba6552b0b432a20e34cd5cf7a311f339c2df7f7a3c549ced84f409ba0
5
5
  SHA512:
6
- metadata.gz: 1b8fa3c17a15bb2249e21fa51376e41ff5f7f9de222c05d70b1e2bf289326e31f51c1c7c2b35abe7eefbcdf59f787c3c5822b84dcd11699d0931f5271d95f00d
7
- data.tar.gz: 523de843a4bb08fc9809768c29a4a1ec4393f6b7739c61e5739b429811ef79082a9b89718a7350e4fbfa6c666eab9249c9a96931a92b68dd9626de453b1015d7
6
+ metadata.gz: 757d57c2723f3f036bfb7faa38615fd751311e99b0a3f5e1b3c13087c53a9010af88c99a5412e31bb3e6d3cdb9201478d7100c71080b3fe948004170a870f875
7
+ data.tar.gz: ede51228b6bc2498b65434102f8b25b17d7db74ae74cd2b50a1ec7184f42692e4b24d94de8c621ec91a8192c924e71ac1067bfdde038a03936407f12147b6175
data/.gitignore CHANGED
@@ -35,4 +35,5 @@ pkg
35
35
  Gemfile.lock
36
36
  spec/integration_spec_conf.rb
37
37
  data.sqlite3
38
+
38
39
  debug.log
@@ -184,3 +184,6 @@ Style/HashTransformValues:
184
184
 
185
185
  Style/HashEachMethods:
186
186
  Enabled: true
187
+
188
+ Style/RedundantBegin:
189
+ Enabled: false
@@ -0,0 +1,7 @@
1
+ # ChangeLog
2
+
3
+ ## Unreleased
4
+
5
+ ## [2.0.0](https://github.com/algolia/algoliasearch-client-ruby/releases/tag/2.0.0) (2020-10-27)
6
+
7
+ * Initial release of v2
data/Gemfile CHANGED
@@ -9,7 +9,7 @@ gem 'minitest-ci'
9
9
 
10
10
  group :development do
11
11
  gem 'git-precommit'
12
- gem 'steep'
12
+ gem 'steep' if RUBY_VERSION >= '2.5'
13
13
  gem 'yard'
14
14
  end
15
15
 
data/README.md CHANGED
@@ -6,9 +6,9 @@
6
6
  <h4 align="center">The perfect starting point to integrate <a href="https://algolia.com" target="_blank">Algolia</a> within your Ruby project</h4>
7
7
 
8
8
  <p align="center">
9
- <a href="https://circleci.com/gh/algolia/algoliasearch-client-ruby/tree/release%2Fv2"><img src="https://circleci.com/gh/algolia/algoliasearch-client-ruby/tree/release%2Fv2.svg?style=shield" alt="CircleCI" /></a>
10
- <a href="https://rubygems.org/gems/algoliasearch"><img src="https://badge.fury.io/rb/algoliasearch.svg" alt="Gem Version"></a>
11
- <a href="https://rubygems.org/gems/algoliasearch"><img src="https://img.shields.io/badge/licence-MIT-blue.svg" alt="License"></a>
9
+ <a href="https://circleci.com/gh/algolia/algoliasearch-client-ruby"><img src="https://circleci.com/gh/algolia/algoliasearch-client-ruby/tree/release%2Fv2.svg?style=shield" alt="CircleCI" /></a>
10
+ <a href="https://rubygems.org/gems/algolia"><img src="https://badge.fury.io/rb/algoliasearch.svg" alt="Gem Version"></a>
11
+ <a href="https://rubygems.org/gems/algolia"><img src="https://img.shields.io/badge/licence-MIT-blue.svg" alt="License"></a>
12
12
  </p>
13
13
  </p>
14
14
 
@@ -18,39 +18,47 @@
18
18
  <a href="https://discourse.algolia.com" target="_blank">Community Forum</a> •
19
19
  <a href="http://stackoverflow.com/questions/tagged/algolia" target="_blank">Stack Overflow</a> •
20
20
  <a href="https://github.com/algolia/algoliasearch-client-ruby/issues" target="_blank">Report a bug</a> •
21
+ <a href="https://www.algolia.com/doc/api-client/troubleshooting/faq/ruby/" target="_blank">FAQ</a> •
21
22
  <a href="https://www.algolia.com/support" target="_blank">Support</a>
22
23
  </p>
23
24
 
24
25
  ## ✨ Features
25
26
 
26
27
  - Thin & minimal low-level HTTP client to interact with Algolia's API
27
- - Supports Ruby `^1.8.7`.
28
+ - Supports Ruby `^2.2`.
28
29
 
29
30
  ## 💡 Getting Started
30
31
 
31
32
  First, install Algolia Ruby API Client via the [RubyGems](https://rubygems.org/) package manager:
32
33
  ```bash
33
- gem install algoliasearch
34
+ gem install algolia
34
35
  ```
35
36
 
36
37
  Then, create objects on your index:
37
38
 
38
39
 
39
40
  ```ruby
40
- Algolia.init(application_id: 'YourApplicationID',
41
- api_key: 'YourAPIKey')
42
- index = Algolia::Index.new('your_index_name')
41
+ client = Algolia::Search::Client.create('YourApplicationID', 'YourAPIKey')
42
+ index = client.init_index('your_index_name')
43
43
 
44
- index.save_objects([objectID: 1, name: 'Foo'])
44
+ index.save_objects([objectID: 1, name: 'Foo'])
45
45
  ```
46
46
 
47
47
  Finally, you may begin searching a object using the `search` method:
48
48
  ```ruby
49
- objects = index.search('Fo')
49
+ objects = index.search('Foo')
50
50
  ```
51
51
 
52
52
  For full documentation, visit the **[Algolia Ruby API Client](https://www.algolia.com/doc/api-client/getting-started/install/ruby/)**.
53
53
 
54
+ ## ❓ Troubleshooting
55
+
56
+ Encountering an issue? Before reaching out to support, we recommend heading to our [FAQ](https://www.algolia.com/doc/api-client/troubleshooting/faq/ruby/) where you will find answers for the most common issues and gotchas with the client.
57
+
58
+ ## Upgrade from V1 to V2
59
+
60
+ If you were using the v1 and wish to update to v2, please follow our [Upgrade Guide](upgrade_guide.md)
61
+
54
62
  ## 📄 License
55
63
 
56
64
  Algolia Ruby API Client is an open-sourced software licensed under the [MIT license](LICENSE.md).
@@ -0,0 +1,3 @@
1
+ ## Reporting a Vulnerability
2
+
3
+ To report a security vulnerability, please use the [Algolia security email](security@algolia.com). Algolia will coordinate the fix and disclosure.
@@ -12,9 +12,15 @@ Gem::Specification.new do |spec|
12
12
 
13
13
  spec.date = Date.today
14
14
  spec.licenses = ['MIT']
15
- spec.summary = 'A simple Ruby client for the algolia.com REST API (alpha release)'
16
- spec.description = 'This is the alpha version of the upcoming v2 release of Algolia Client. Please keep on using the algoliasearch gem in the meantime.'
17
- spec.homepage = 'https://github.com/algolia/algoliasearch-client-ruby/tree/release/v2'
15
+ spec.summary = 'A simple Ruby client for the algolia.com REST API'
16
+ spec.description = 'A simple Ruby client for the algolia.com REST API'
17
+ spec.homepage = 'https://github.com/algolia/algoliasearch-client-ruby'
18
+
19
+ spec.metadata = {
20
+ 'bug_tracker_uri' => 'https://github.com/algolia/algoliasearch-client-ruby/issues',
21
+ 'documentation_uri' => 'https://www.algolia.com/doc/api-client/getting-started/install/ruby',
22
+ 'source_code_uri' => 'https://github.com/algolia/algoliasearch-client-ruby'
23
+ }
18
24
 
19
25
  # Specify which files should be added to the gem when it is released.
20
26
  # The `git ls-files -z` loads the files in the RubyGem
@@ -3,7 +3,7 @@ require 'algolia/helpers'
3
3
  require 'algolia/http/http_requester'
4
4
  require 'algolia/defaults'
5
5
  require 'algolia/user_agent'
6
- require 'algolia/config/algolia_config'
6
+ require 'algolia/config/base_config'
7
7
  require 'algolia/config/search_config'
8
8
  require 'algolia/config/analytics_config'
9
9
  require 'algolia/config/insights_config'
@@ -26,7 +26,7 @@ module Algolia
26
26
  # @return self
27
27
  #
28
28
  def self.create(app_id, api_key)
29
- config = Analytics::Config.new(app_id: app_id, api_key: api_key)
29
+ config = Analytics::Config.new(application_id: app_id, api_key: api_key)
30
30
  create_with_config(config)
31
31
  end
32
32
 
@@ -1,11 +1,11 @@
1
1
  module Algolia
2
2
  module Analytics
3
- class Config < AlgoliaConfig
3
+ class Config < BaseConfig
4
4
  attr_accessor :region, :default_hosts
5
5
 
6
6
  # Initialize a config
7
7
  #
8
- # @option options [String] :app_id
8
+ # @option options [String] :application_id
9
9
  # @option options [String] :api_key
10
10
  # @option options [String] :region
11
11
  #
@@ -0,0 +1,43 @@
1
+ require 'faraday'
2
+
3
+ module Algolia
4
+ class BaseConfig
5
+ attr_accessor :app_id, :api_key, :headers, :batch_size, :read_timeout, :write_timeout, :connect_timeout, :compression_type,
6
+ :symbolize_keys, :use_latest_settings
7
+
8
+ #
9
+ # @option options [String] :application_id
10
+ # @option options [String] :api_key
11
+ # @option options [Integer] :batch_size
12
+ # @option options [Integer] :read_timeout
13
+ # @option options [Integer] :write_timeout
14
+ # @option options [Integer] :connect_timeout
15
+ # @option options [Boolean] :symbolize_keys
16
+ #
17
+ def initialize(opts = {})
18
+ raise AlgoliaError, 'No Application ID provided, please set :application_id' unless opts.has_key?(:application_id)
19
+ raise AlgoliaError, 'No API key provided, please set :api_key' unless opts.has_key?(:api_key)
20
+
21
+ @app_id = opts[:application_id]
22
+ @api_key = opts[:api_key]
23
+
24
+ @headers = {
25
+ Defaults::HEADER_API_KEY => @api_key,
26
+ Defaults::HEADER_APP_ID => @app_id,
27
+ 'Content-Type' => 'application/json; charset=utf-8',
28
+ 'User-Agent' => UserAgent.value
29
+ }
30
+
31
+ @batch_size = opts[:batch_size] || Defaults::BATCH_SIZE
32
+ @read_timeout = opts[:read_timeout] || Defaults::READ_TIMEOUT
33
+ @write_timeout = opts[:write_timeout] || Defaults::WRITE_TIMEOUT
34
+ @connect_timeout = opts[:connect_timeout] || Defaults::CONNECT_TIMEOUT
35
+ @compression_type = opts[:compression_type] || Defaults::NONE_ENCODING
36
+ @symbolize_keys = opts.has_key?(:symbolize_keys) ? opts[:symbolize_keys] : true
37
+ end
38
+
39
+ def set_extra_header(key, value)
40
+ @headers[key] = value
41
+ end
42
+ end
43
+ end
@@ -1,11 +1,11 @@
1
1
  module Algolia
2
2
  module Insights
3
- class Config < AlgoliaConfig
3
+ class Config < BaseConfig
4
4
  attr_accessor :region, :default_hosts
5
5
 
6
6
  # Initialize a config
7
7
  #
8
- # @option options [String] :app_id
8
+ # @option options [String] :application_id
9
9
  # @option options [String] :api_key
10
10
  # @option options [String] :region
11
11
  #
@@ -1,11 +1,11 @@
1
1
  module Algolia
2
2
  module Recommendation
3
- class Config < AlgoliaConfig
3
+ class Config < BaseConfig
4
4
  attr_accessor :region, :default_hosts
5
5
 
6
6
  # Initialize a config
7
7
  #
8
- # @option options [String] :app_id
8
+ # @option options [String] :application_id
9
9
  # @option options [String] :api_key
10
10
  # @option options [String] :region
11
11
  #
@@ -5,13 +5,13 @@ require 'algolia/enums/call_type'
5
5
 
6
6
  module Algolia
7
7
  module Search
8
- class Config < AlgoliaConfig
8
+ class Config < BaseConfig
9
9
  include CallType
10
10
  attr_accessor :default_hosts
11
11
 
12
12
  # Initialize a config
13
13
  #
14
- # @option options [String] :app_id
14
+ # @option options [String] :application_id
15
15
  # @option options [String] :api_key
16
16
  # @option options [Hash] :custom_hosts
17
17
  #
@@ -24,8 +24,8 @@ module Defaults
24
24
 
25
25
  BATCH_SIZE = 1000
26
26
  CONNECT_TIMEOUT = 2
27
- READ_TIMEOUT = 30
28
- WRITE_TIMEOUT = 5
27
+ READ_TIMEOUT = 5
28
+ WRITE_TIMEOUT = 30
29
29
  USER_AGENT = "Algolia for Ruby (#{Algolia::VERSION}), Ruby (#{RUBY_VERSION})"
30
30
 
31
31
  WAIT_TASK_DEFAULT_TIME_BEFORE_RETRY = 100
@@ -17,8 +17,7 @@ module Algolia
17
17
  # which is also included in the response attribute.
18
18
  #
19
19
  class AlgoliaHttpError < AlgoliaError
20
- attr_accessor :code
21
- attr_accessor :message
20
+ attr_accessor :code, :message
22
21
 
23
22
  def initialize(code, message)
24
23
  self.code = code
@@ -52,7 +52,7 @@ module Helpers
52
52
 
53
53
  # Support to convert old settings to their new names
54
54
  #
55
- def deserialize_settings(data)
55
+ def deserialize_settings(data, symbolize_keys)
56
56
  settings = symbolize_hash(data)
57
57
  keys = {
58
58
  attributesToIndex: 'searchableAttributes',
@@ -62,7 +62,8 @@ module Helpers
62
62
 
63
63
  keys.each do |deprecated_key, current_key|
64
64
  if settings.has_key?(deprecated_key)
65
- settings[current_key.to_sym] = settings.delete(deprecated_key)
65
+ key = symbolize_keys ? current_key.to_sym : current_key.to_s
66
+ settings[key] = settings.delete(deprecated_key)
66
67
  end
67
68
  end
68
69
 
@@ -26,7 +26,7 @@ module Algolia
26
26
  # @return self
27
27
  #
28
28
  def self.create(app_id, api_key)
29
- config = Insights::Config.new(app_id: app_id, api_key: api_key)
29
+ config = Insights::Config.new(application_id: app_id, api_key: api_key)
30
30
  create_with_config(config)
31
31
  end
32
32
 
@@ -7,16 +7,17 @@ module Algolia
7
7
  data = {}
8
8
 
9
9
  if @response
10
- if @response[:hits].length
11
- @response[:hits].each do |hit|
10
+ parsed_response = symbolize_hash(@response)
11
+ if parsed_response[:hits].length
12
+ parsed_response[:hits].each do |hit|
12
13
  yield hit
13
14
  end
14
15
 
15
- if @response[:cursor].nil?
16
+ if parsed_response[:cursor].nil?
16
17
  @response = nil
17
18
  raise StopIteration
18
19
  else
19
- data[:cursor] = @response[:cursor]
20
+ data[:cursor] = parsed_response[:cursor]
20
21
  end
21
22
  end
22
23
  end
@@ -16,13 +16,15 @@ module Algolia
16
16
  def each
17
17
  loop do
18
18
  if @response
19
- if @response[:hits].length
20
- @response[:hits].each do |hit|
19
+ parsed_response = symbolize_hash(@response)
20
+ parsed_data = symbolize_hash(@data)
21
+ if parsed_response[:hits].length
22
+ parsed_response[:hits].each do |hit|
21
23
  hit.delete(:_highlightResult)
22
24
  yield hit
23
25
  end
24
26
 
25
- if @response[:nbHits] < @data[:hitsPerPage]
27
+ if parsed_response[:nbHits] < parsed_data[:hitsPerPage]
26
28
  @response = nil
27
29
  @data = {
28
30
  hitsPerPage: 1000,
@@ -24,7 +24,7 @@ module Algolia
24
24
  # @return self
25
25
  #
26
26
  def self.create(app_id, api_key)
27
- config = Recommendation::Config.new(app_id: app_id, api_key: api_key)
27
+ config = Recommendation::Config.new(application_id: app_id, api_key: api_key)
28
28
  create_with_config(config)
29
29
  end
30
30
 
@@ -32,7 +32,7 @@ module Algolia
32
32
  # @return self
33
33
  #
34
34
  def self.create(app_id, api_key)
35
- config = Search::Config.new(app_id: app_id, api_key: api_key)
35
+ config = Search::Config.new(application_id: app_id, api_key: api_key)
36
36
  create_with_config(config)
37
37
  end
38
38
 
@@ -5,16 +5,16 @@ module Algolia
5
5
  include CallType
6
6
  include Helpers
7
7
 
8
- attr_reader :index_name, :transporter, :config
8
+ attr_reader :name, :transporter, :config
9
9
 
10
10
  # Initialize an index
11
11
  #
12
- # @param index_name [String] name of the index
12
+ # @param name [String] name of the index
13
13
  # @param transporter [Object] transport object used for the connection
14
14
  # @param config [Config] a Config object which contains your APP_ID and API_KEY
15
15
  #
16
- def initialize(index_name, transporter, config)
17
- @index_name = index_name
16
+ def initialize(name, transporter, config)
17
+ @name = name
18
18
  @transporter = transporter
19
19
  @config = config
20
20
  end
@@ -47,7 +47,7 @@ module Algolia
47
47
  # @param opts [Hash] contains extra parameters to send with your query
48
48
  #
49
49
  def get_task_status(task_id, opts = {})
50
- res = @transporter.read(:GET, path_encode('/1/indexes/%s/task/%s', @index_name, task_id), {}, opts)
50
+ res = @transporter.read(:GET, path_encode('/1/indexes/%s/task/%s', @name, task_id), {}, opts)
51
51
  get_option(res, 'status')
52
52
  end
53
53
 
@@ -56,7 +56,7 @@ module Algolia
56
56
  # @param opts [Hash] contains extra parameters to send with your query
57
57
  #
58
58
  def clear_objects(opts = {})
59
- response = @transporter.write(:POST, path_encode('/1/indexes/%s/clear', @index_name), {}, opts)
59
+ response = @transporter.write(:POST, path_encode('/1/indexes/%s/clear', @name), {}, opts)
60
60
 
61
61
  IndexingResponse.new(self, response)
62
62
  end
@@ -75,7 +75,7 @@ module Algolia
75
75
  # @param opts [Hash] contains extra parameters to send with your query
76
76
  #
77
77
  def delete(opts = {})
78
- response = @transporter.write(:DELETE, path_encode('/1/indexes/%s', @index_name), opts)
78
+ response = @transporter.write(:DELETE, path_encode('/1/indexes/%s', @name), opts)
79
79
 
80
80
  IndexingResponse.new(self, response)
81
81
  end
@@ -115,7 +115,7 @@ module Algolia
115
115
  has_next_page = true
116
116
  while has_next_page
117
117
  request_options[:page] = page
118
- res = search(query, request_options)
118
+ res = symbolize_hash(search(query, request_options))
119
119
 
120
120
  res[:hits].each_with_index do |hit, i|
121
121
  if callback.call(hit)
@@ -154,7 +154,7 @@ module Algolia
154
154
  # @return [IndexingResponse]
155
155
  #
156
156
  def copy_to(name, opts = {})
157
- response = @transporter.write(:POST, path_encode('/1/indexes/%s/operation', @index_name), { operation: 'copy', destination: name }, opts)
157
+ response = @transporter.write(:POST, path_encode('/1/indexes/%s/operation', @name), { operation: 'copy', destination: name }, opts)
158
158
 
159
159
  IndexingResponse.new(self, response)
160
160
  end
@@ -167,7 +167,7 @@ module Algolia
167
167
  # @return [IndexingResponse]
168
168
  #
169
169
  def move_to(name, opts = {})
170
- response = @transporter.write(:POST, path_encode('/1/indexes/%s/operation', @index_name), { operation: 'move', destination: name }, opts)
170
+ response = @transporter.write(:POST, path_encode('/1/indexes/%s/operation', @name), { operation: 'move', destination: name }, opts)
171
171
 
172
172
  IndexingResponse.new(self, response)
173
173
  end
@@ -184,7 +184,7 @@ module Algolia
184
184
  # @return [Hash]
185
185
  #
186
186
  def get_object(object_id, opts = {})
187
- @transporter.read(:GET, path_encode('/1/indexes/%s/%s', @index_name, object_id), {}, opts)
187
+ @transporter.read(:GET, path_encode('/1/indexes/%s/%s', @name, object_id), {}, opts)
188
188
  end
189
189
 
190
190
  # Retrieve one or more objects in a single API call
@@ -201,7 +201,7 @@ module Algolia
201
201
 
202
202
  requests = []
203
203
  object_ids.each do |object_id|
204
- request = { indexName: @index_name, objectID: object_id.to_s }
204
+ request = { indexName: @name, objectID: object_id.to_s }
205
205
 
206
206
  if attributes_to_retrieve
207
207
  request[:attributesToRetrieve] = attributes_to_retrieve
@@ -381,7 +381,7 @@ module Algolia
381
381
  # @return [IndexingResponse]
382
382
  #
383
383
  def delete_by(filters, opts = {})
384
- response = @transporter.write(:POST, path_encode('/1/indexes/%s/deleteByQuery', @index_name), filters, opts)
384
+ response = @transporter.write(:POST, path_encode('/1/indexes/%s/deleteByQuery', @name), filters, opts)
385
385
 
386
386
  IndexingResponse.new(self, response)
387
387
  end
@@ -436,7 +436,7 @@ module Algolia
436
436
  # @return [Hash]
437
437
  #
438
438
  def get_rule(object_id, opts = {})
439
- @transporter.read(:GET, path_encode('/1/indexes/%s/rules/%s', @index_name, object_id), {}, opts)
439
+ @transporter.read(:GET, path_encode('/1/indexes/%s/rules/%s', @name, object_id), {}, opts)
440
440
  end
441
441
 
442
442
  # Create or update a rule
@@ -500,7 +500,7 @@ module Algolia
500
500
  get_object_id(rule)
501
501
  end
502
502
 
503
- response = @transporter.write(:POST, path_encode('/1/indexes/%s/rules/batch', @index_name) + handle_params({ forwardToReplicas: forward_to_replicas, clearExistingRules: clear_existing_rules }), rules, request_options)
503
+ response = @transporter.write(:POST, path_encode('/1/indexes/%s/rules/batch', @name) + handle_params({ forwardToReplicas: forward_to_replicas, clearExistingRules: clear_existing_rules }), rules, request_options)
504
504
 
505
505
  IndexingResponse.new(self, response)
506
506
  end
@@ -532,7 +532,7 @@ module Algolia
532
532
  request_options.delete(:forwardToReplicas)
533
533
  end
534
534
 
535
- response = @transporter.write(:POST, path_encode('1/indexes/%s/rules/clear', @index_name) + handle_params({ forwardToReplicas: forward_to_replicas }), '', request_options)
535
+ response = @transporter.write(:POST, path_encode('1/indexes/%s/rules/clear', @name) + handle_params({ forwardToReplicas: forward_to_replicas }), '', request_options)
536
536
 
537
537
  IndexingResponse.new(self, response)
538
538
  end
@@ -566,7 +566,7 @@ module Algolia
566
566
 
567
567
  response = @transporter.write(
568
568
  :DELETE,
569
- path_encode('1/indexes/%s/rules/%s', @index_name, object_id) + handle_params({ forwardToReplicas: forward_to_replicas }),
569
+ path_encode('1/indexes/%s/rules/%s', @name, object_id) + handle_params({ forwardToReplicas: forward_to_replicas }),
570
570
  '',
571
571
  request_options
572
572
  )
@@ -598,7 +598,7 @@ module Algolia
598
598
  # @return [Hash]
599
599
  #
600
600
  def get_synonym(object_id, opts = {})
601
- @transporter.read(:GET, path_encode('/1/indexes/%s/synonyms/%s', @index_name, object_id), {}, opts)
601
+ @transporter.read(:GET, path_encode('/1/indexes/%s/synonyms/%s', @name, object_id), {}, opts)
602
602
  end
603
603
 
604
604
  # Create a new synonym object or update the existing synonym object with the given object ID
@@ -666,7 +666,7 @@ module Algolia
666
666
  end
667
667
  response = @transporter.write(
668
668
  :POST,
669
- path_encode('/1/indexes/%s/synonyms/batch', @index_name) + handle_params({ forwardToReplicas: forward_to_replicas, replaceExistingSynonyms: replace_existing_synonyms }),
669
+ path_encode('/1/indexes/%s/synonyms/batch', @name) + handle_params({ forwardToReplicas: forward_to_replicas, replaceExistingSynonyms: replace_existing_synonyms }),
670
670
  synonyms,
671
671
  request_options
672
672
  )
@@ -703,7 +703,7 @@ module Algolia
703
703
  end
704
704
  response = @transporter.write(
705
705
  :POST,
706
- path_encode('1/indexes/%s/synonyms/clear', @index_name) + handle_params({ forwardToReplicas: forward_to_replicas }),
706
+ path_encode('1/indexes/%s/synonyms/clear', @name) + handle_params({ forwardToReplicas: forward_to_replicas }),
707
707
  '',
708
708
  request_options
709
709
  )
@@ -738,7 +738,7 @@ module Algolia
738
738
  end
739
739
  response = @transporter.write(
740
740
  :DELETE,
741
- path_encode('1/indexes/%s/synonyms/%s', @index_name, object_id) + handle_params({ forwardToReplicas: forward_to_replicas }),
741
+ path_encode('1/indexes/%s/synonyms/%s', @name, object_id) + handle_params({ forwardToReplicas: forward_to_replicas }),
742
742
  '',
743
743
  request_options
744
744
  )
@@ -769,9 +769,9 @@ module Algolia
769
769
  #
770
770
  def browse_objects(opts = {}, &block)
771
771
  if block_given?
772
- ObjectIterator.new(@transporter, @index_name, opts).each(&block)
772
+ ObjectIterator.new(@transporter, @name, opts).each(&block)
773
773
  else
774
- ObjectIterator.new(@transporter, @index_name, opts)
774
+ ObjectIterator.new(@transporter, @name, opts)
775
775
  end
776
776
  end
777
777
 
@@ -783,9 +783,9 @@ module Algolia
783
783
  #
784
784
  def browse_rules(opts = {}, &block)
785
785
  if block_given?
786
- RuleIterator.new(@transporter, @index_name, opts).each(&block)
786
+ RuleIterator.new(@transporter, @name, opts).each(&block)
787
787
  else
788
- RuleIterator.new(@transporter, @index_name, opts)
788
+ RuleIterator.new(@transporter, @name, opts)
789
789
  end
790
790
  end
791
791
 
@@ -797,9 +797,9 @@ module Algolia
797
797
  #
798
798
  def browse_synonyms(opts = {}, &block)
799
799
  if block_given?
800
- SynonymIterator.new(@transporter, @index_name, opts).each(&block)
800
+ SynonymIterator.new(@transporter, @name, opts).each(&block)
801
801
  else
802
- SynonymIterator.new(@transporter, @index_name, opts)
802
+ SynonymIterator.new(@transporter, @name, opts)
803
803
  end
804
804
  end
805
805
 
@@ -822,7 +822,7 @@ module Algolia
822
822
  request_options.delete(:safe)
823
823
  end
824
824
 
825
- tmp_index_name = @index_name + '_tmp_' + rand(10000000).to_s
825
+ tmp_index_name = @name + '_tmp_' + rand(10000000).to_s
826
826
  copy_to_response = copy_to(tmp_index_name, request_options.merge({ scope: %w(settings synonyms rules) }))
827
827
 
828
828
  if safe
@@ -839,7 +839,7 @@ module Algolia
839
839
  save_objects_response.wait
840
840
  end
841
841
 
842
- move_to_response = tmp_index.move_to(@index_name)
842
+ move_to_response = tmp_index.move_to(@name)
843
843
  if safe
844
844
  move_to_response.wait
845
845
  end
@@ -924,7 +924,7 @@ module Algolia
924
924
  # @return [Hash]
925
925
  #
926
926
  def search(query, opts = {})
927
- @transporter.read(:POST, path_encode('/1/indexes/%s/query', @index_name), { 'query': query.to_s }, opts)
927
+ @transporter.read(:POST, path_encode('/1/indexes/%s/query', @name), { 'query': query.to_s }, opts)
928
928
  end
929
929
 
930
930
  # Search for values of a given facet, optionally restricting the returned values to those contained
@@ -937,7 +937,7 @@ module Algolia
937
937
  # @return [Hash]
938
938
  #
939
939
  def search_for_facet_values(facet_name, facet_query, opts = {})
940
- @transporter.read(:POST, path_encode('/1/indexes/%s/facets/%s/query', @index_name, facet_name),
940
+ @transporter.read(:POST, path_encode('/1/indexes/%s/facets/%s/query', @name, facet_name),
941
941
  { 'facetQuery': facet_query }, opts)
942
942
  end
943
943
 
@@ -949,7 +949,7 @@ module Algolia
949
949
  # @return [Hash]
950
950
  #
951
951
  def search_synonyms(query, opts = {})
952
- @transporter.read(:POST, path_encode('/1/indexes/%s/synonyms/search', @index_name), { query: query.to_s }, opts)
952
+ @transporter.read(:POST, path_encode('/1/indexes/%s/synonyms/search', @name), { query: query.to_s }, opts)
953
953
  end
954
954
 
955
955
  # Search or browse all rules, optionally filtering them by type
@@ -960,7 +960,7 @@ module Algolia
960
960
  # @return [Hash]
961
961
  #
962
962
  def search_rules(query, opts = {})
963
- @transporter.read(:POST, path_encode('/1/indexes/%s/rules/search', @index_name), { query: query.to_s }, opts)
963
+ @transporter.read(:POST, path_encode('/1/indexes/%s/rules/search', @name), { query: query.to_s }, opts)
964
964
  end
965
965
 
966
966
  # # # # # # # # # # # # # # # # # # # # #
@@ -974,9 +974,9 @@ module Algolia
974
974
  # @return [Hash]
975
975
  #
976
976
  def get_settings(opts = {})
977
- response = @transporter.read(:GET, path_encode('/1/indexes/%s/settings', @index_name) + handle_params({ getVersion: 2 }), {}, opts)
977
+ response = @transporter.read(:GET, path_encode('/1/indexes/%s/settings', @name) + handle_params({ getVersion: 2 }), {}, opts)
978
978
 
979
- deserialize_settings(response)
979
+ deserialize_settings(response, @config.symbolize_keys)
980
980
  end
981
981
 
982
982
  # Update some index settings. Only specified settings are overridden
@@ -987,7 +987,7 @@ module Algolia
987
987
  # @return [IndexingResponse]
988
988
  #
989
989
  def set_settings(settings, opts = {})
990
- response = @transporter.write(:PUT, path_encode('/1/indexes/%s/settings', @index_name), settings, opts)
990
+ response = @transporter.write(:PUT, path_encode('/1/indexes/%s/settings', @name), settings, opts)
991
991
 
992
992
  IndexingResponse.new(self, response)
993
993
  end
@@ -1087,7 +1087,7 @@ module Algolia
1087
1087
  end
1088
1088
 
1089
1089
  def raw_batch(requests, opts)
1090
- @transporter.write(:POST, path_encode('/1/indexes/%s/batch', @index_name), { requests: requests }, opts)
1090
+ @transporter.write(:POST, path_encode('/1/indexes/%s/batch', @name), { requests: requests }, opts)
1091
1091
  end
1092
1092
  end
1093
1093
  end