algoliasearch 1.21.0 → 1.22.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 166a052570141d9782b6faed8c7b3731c2d4553d1628e3d7e903bb24edb276d1
4
- data.tar.gz: ccb0597728f4b692b8841594a8b42d83f839a22dd1f3abf03e1caf2d52fa266f
3
+ metadata.gz: 431002a3ec233966b7b7a0507662292938fd09cdbb62d1279d538d2da761ee6f
4
+ data.tar.gz: 6988bad4c248073ceee35d8ff9c447aeeb97c873e73b1ac41b4ab9b65099fd8c
5
5
  SHA512:
6
- metadata.gz: 2ed95969c8417cbd9fee0a89600965bf688d8536719ffea8481c31143796a2235b5e441392a69d8e75961e5c3dfabe34c9d6c75f12cdae8a7aac56d5e7327f2c
7
- data.tar.gz: b620520144dcf52e870bd07fa1d51a3f227f9cd83e815d183bec770471a56d066afc32e898317ad5e593b5eec10b70f5cbd78d9b04ae25e509d0092a235f0b9d
6
+ metadata.gz: 6bdc28f6b84c96088f0cddf1f071c68994291d5365a612b771426052b327bad8ff11b47682bc9fe150f6128c2144e699632c6c606fd08d836a7da889824a61b7
7
+ data.tar.gz: 1af3a1305da6856ccd56caaeeee126170205d244ba3a0026c50308d250f31e899609f1aab36b33a4970e6eec41f25b5014e9aea9c079e622576fb83b644997a6
@@ -1,3 +1,11 @@
1
+ ## [1.22.0](https://github.com/algolia/algoliasearch-client-ruby/releases/tag/1.22.0) (2018-05-30)
2
+
3
+ * Rename license file (#297)
4
+ * Fix release task (#294)
5
+ * Introduce multi cluster management (#285)
6
+ * Fix(browse): ensure cursor is passed in the body (#288)
7
+ * Chore(md): update contribution-related files (#293)
8
+
1
9
  ## [1.21.0](https://github.com/algolia/algoliasearch-client-ruby/releases/tag/1.21.0) (2018-05-24)
2
10
 
3
11
  * Fix(tests): fix warning for unspecified exception (#287)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- algoliasearch (1.21.0)
4
+ algoliasearch (1.22.0)
5
5
  httpclient (~> 2.8, >= 2.8.3)
6
6
  json (>= 1.5.1)
7
7
 
@@ -9,7 +9,7 @@ GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
11
  addressable (2.4.0)
12
- backports (3.11.2)
12
+ backports (3.11.1)
13
13
  coveralls (0.7.2)
14
14
  multi_json (~> 1.3)
15
15
  rest-client (= 1.6.7)
@@ -310,4 +310,4 @@ DEPENDENCIES
310
310
  webmock
311
311
 
312
312
  BUNDLED WITH
313
- 1.16.1
313
+ 1.16.2
@@ -1,7 +1,6 @@
1
- The MIT License (MIT)
1
+ MIT License
2
2
 
3
- Copyright (c) 2013 Algolia
4
- http://www.algolia.com/
3
+ Copyright (c) 2014-Present Algolia
5
4
 
6
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
7
6
  of this software and associated documentation files (the "Software"), to deal
@@ -10,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
9
  copies of the Software, and to permit persons to whom the Software is
11
10
  furnished to do so, subject to the following conditions:
12
11
 
13
- The above copyright notice and this permission notice shall be included in
14
- all copies or substantial portions of the Software.
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
15
14
 
16
15
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
16
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
17
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- THE SOFTWARE.
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/Rakefile CHANGED
@@ -35,7 +35,8 @@ RSpec::Core::RakeTask.new(:spec)
35
35
  task :default => :spec
36
36
 
37
37
  namespace :algolia do
38
- GIT_TAG_URL = 'https://github.com/algolia/algoliasearch-client-ruby/releases/tag/'
38
+ GEM_VERSION_FILE = File.expand_path('../lib/algolia/version.rb', __FILE__)
39
+ GIT_TAG_URL = 'https://github.com/algolia/algoliasearch-client-ruby/releases/tag/'
39
40
 
40
41
  def last_commit_date
41
42
  `git log -1 --date=short --format=%cd`.chomp
@@ -73,7 +74,8 @@ namespace :algolia do
73
74
 
74
75
  desc 'Bump gem version'
75
76
  task :semver, [:version] do |t, args|
76
- File.open(File.expand_path('../lib/algolia/version.rb', __FILE__), 'w') do |file|
77
+
78
+ File.open(GEM_VERSION_FILE, 'w') do |file|
77
79
  file.write <<~SEMVER
78
80
  module Algolia
79
81
  VERSION = "#{args[:version]}"
@@ -81,6 +83,10 @@ namespace :algolia do
81
83
  SEMVER
82
84
  end
83
85
 
86
+ # This force to reload the file with the newest version.
87
+ # Hence, `gemspec.version` invoked by Bundler later on will be correct.
88
+ load GEM_VERSION_FILE
89
+
84
90
  puts "Bumped gem version from #{latest_tag} to #{args[:version]}"
85
91
  end
86
92
 
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
28
28
 
29
29
  s.extra_rdoc_files = [
30
30
  "CHANGELOG.md",
31
- "LICENSE.txt",
31
+ "LICENSE",
32
32
  "README.md"
33
33
  ]
34
34
  s.files = [
@@ -37,7 +37,7 @@ Gem::Specification.new do |s|
37
37
  "CHANGELOG.md",
38
38
  "Gemfile",
39
39
  "Gemfile.lock",
40
- "LICENSE.txt",
40
+ "LICENSE",
41
41
  "README.md",
42
42
  "Rakefile",
43
43
  "algoliasearch.gemspec",
@@ -381,6 +381,45 @@ module Algolia
381
381
  end
382
382
 
383
383
  #
384
+ # Multicluster management
385
+ #
386
+ def list_clusters(request_options = {})
387
+ get(Protocol.clusters_uri, :read, request_options)
388
+ end
389
+
390
+ def list_user_ids(page = 0, hits_per_page = 20, request_options = {})
391
+ get(Protocol.list_ids_uri(page, hits_per_page), :read, request_options)
392
+ end
393
+
394
+ def get_top_user_ids(request_options = {})
395
+ get(Protocol.cluster_top_user_uri, :read, request_options)
396
+ end
397
+
398
+ def assign_user_id(user_id, cluster_name, request_options = {})
399
+ request_options = add_header_to_request_options(request_options, { :'X-Algolia-User-ID' => user_id})
400
+
401
+ body = { :cluster => cluster_name }
402
+ post(Protocol.cluster_mapping_uri, body.to_json, :write, request_options)
403
+ end
404
+
405
+ def get_user_id(user_id, request_options = {})
406
+ get(Protocol.cluster_mapping_uri(user_id), :read, request_options)
407
+ end
408
+
409
+ def remove_user_id(user_id, request_options = {})
410
+ request_options = add_header_to_request_options(request_options, { :'X-Algolia-User-ID' => user_id})
411
+
412
+ delete(Protocol.cluster_mapping_uri, :write, request_options)
413
+ end
414
+
415
+ def search_user_id(query, cluster_name = nil, page = nil, hits_per_page = nil, request_options = {})
416
+ body = { :query => query }
417
+ body[:clusterName] = cluster_name unless cluster_name.nil?
418
+ body[:page] = page unless page.nil?
419
+ body[:hitsPerPage] = hits_per_page unless hits_per_page.nil?
420
+ post(Protocol.search_user_id_uri, body.to_json, :read, request_options)
421
+ end
422
+
384
423
  # Perform an HTTP request for the given uri and method
385
424
  # with common basic response handling. Will raise a
386
425
  # AlgoliaProtocolError if the response has an error status code,
@@ -496,6 +535,20 @@ module Algolia
496
535
  return JSON.parse(response.content)
497
536
  end
498
537
 
538
+ def add_header_to_request_options(request_options, headers_to_add)
539
+ if !request_options['headers'].is_a?(Hash)
540
+ if request_options[:headers].is_a?(Hash)
541
+ request_options['headers'] = request_options[:headers]
542
+ request_options.delete(:headers)
543
+ else
544
+ request_options['headers'] = {}
545
+ end
546
+ end
547
+
548
+ request_options['headers'].merge!(headers_to_add)
549
+ request_options
550
+ end
551
+
499
552
  # Deprecated
500
553
  alias_method :list_user_keys, :list_api_keys
501
554
  alias_method :get_user_key, :get_api_key
@@ -228,7 +228,7 @@ module Algolia
228
228
  # @param request_options contains extra parameters to send with your query
229
229
  #
230
230
  def browse_from(cursor, hits_per_page = 1000, request_options = {})
231
- client.get(Protocol.browse_uri(name, { :cursor => cursor, :hitsPerPage => hits_per_page }), :read, request_options)
231
+ client.post(Protocol.browse_uri(name), { :cursor => cursor, :hitsPerPage => hits_per_page }.to_json, :read, request_options)
232
232
  end
233
233
 
234
234
  #
@@ -167,5 +167,27 @@ module Algolia
167
167
  "#{index_uri(index)}/deleteByQuery"
168
168
  end
169
169
 
170
+ def Protocol.clusters_uri
171
+ "/#{VERSION}/clusters"
172
+ end
173
+
174
+ def Protocol.cluster_mapping_uri(user_id = nil)
175
+ user_id = "/#{CGI.escape(user_id)}" if user_id
176
+
177
+ "/#{VERSION}/clusters/mapping" + user_id.to_s
178
+ end
179
+
180
+ def Protocol.list_ids_uri(page, hits_per_page)
181
+ Protocol.cluster_mapping_uri+"?page=#{CGI.escape(page.to_s)}&hitsPerPage=#{CGI.escape(hits_per_page.to_s)}"
182
+ end
183
+
184
+ def Protocol.cluster_top_user_uri
185
+ "/#{VERSION}/clusters/mapping/top"
186
+ end
187
+
188
+ def Protocol.search_user_id_uri
189
+ "/#{VERSION}/clusters/mapping/search"
190
+ end
191
+
170
192
  end
171
193
  end
@@ -1,3 +1,3 @@
1
1
  module Algolia
2
- VERSION = "1.21.0"
2
+ VERSION = "1.22.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: algoliasearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.21.0
4
+ version: 1.22.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Algolia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-24 00:00:00.000000000 Z
11
+ date: 2018-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient
@@ -92,7 +92,7 @@ executables: []
92
92
  extensions: []
93
93
  extra_rdoc_files:
94
94
  - CHANGELOG.md
95
- - LICENSE.txt
95
+ - LICENSE
96
96
  - README.md
97
97
  files:
98
98
  - ".rspec"
@@ -100,7 +100,7 @@ files:
100
100
  - CHANGELOG.md
101
101
  - Gemfile
102
102
  - Gemfile.lock
103
- - LICENSE.txt
103
+ - LICENSE
104
104
  - README.md
105
105
  - Rakefile
106
106
  - algoliasearch.gemspec
@@ -142,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
142
  version: '0'
143
143
  requirements: []
144
144
  rubyforge_project:
145
- rubygems_version: 2.7.6
145
+ rubygems_version: 2.7.3
146
146
  signing_key:
147
147
  specification_version: 4
148
148
  summary: A simple Ruby client for the algolia.com REST API