algoliasearch 1.23.1 → 1.23.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a37af52a9b4457ecc7382c387715b670cc722ef038539414ed035cb533ccebd1
4
- data.tar.gz: 435c56716df669bc3d7316905389fc8c60d628870a7305de51950b1af4982f06
3
+ metadata.gz: 898fdf039d30438b0bccedd74cef5c7a4b665d92c351f63ce779db7be8b29256
4
+ data.tar.gz: 7ccdd7ccd3ebddb4f7ab10aaa4ce2d403e55e1032e16f4864b6a3802857e2809
5
5
  SHA512:
6
- metadata.gz: 7eb808a327e3dd9d666c859b9a256ce7a85adbc1da3644ef7f58080cb94c7a7a3c3b08d3f8224b746d89f87311c0ce0216b4b246ed406437bf543e03f45183e5
7
- data.tar.gz: b6fb46016a1241e96575b036f878f704d8c705a3d6b17bfbafb801b258a80b0ddbf767b105ad3f91dab54f84b4c13a2f1746b729f05924bf0e6a74e23c8f74c4
6
+ metadata.gz: a1046362fa13b0646f799eeeb26bf1dbef4f0de91433a7a882aa59f65637b6501f488dbfca44b745fb4164e388c09f65185c100bdc4f792c46f095233cd433c8
7
+ data.tar.gz: e390cc59d90d8685801bd359b5c5a2721040f1a733ab54eb9202fa8f38995e7e43151f48d994deacaf22fdd4d004537c038b92c83872f9e4359d848260e6d1de
@@ -1,11 +1,7 @@
1
- ## [1.23.1](https://github.com/algolia/algoliasearch-client-ruby/releases/tag/1.23.1) (2018-06-19)
1
+ ## [1.23.2](https://github.com/algolia/algoliasearch-client-ruby/releases/tag/1.23.2) (2018-06-19)
2
2
 
3
3
  * Fix(analytics): gem without new analytics class (#306)
4
4
 
5
- ## [1.23.1](https://github.com/algolia/algoliasearch-client-ruby/releases/tag/1.23.1) (2018-06-19)
6
-
7
- * Fix(analytics): gem without new analytics class
8
-
9
5
  ## [1.23.0](https://github.com/algolia/algoliasearch-client-ruby/releases/tag/1.23.0) (2018-06-19)
10
6
 
11
7
  * Feat(analytics): introduce new analytics class
@@ -42,6 +42,7 @@ Gem::Specification.new do |s|
42
42
  "Rakefile",
43
43
  "algoliasearch.gemspec",
44
44
  "contacts.json",
45
+ "lib/algolia/analytics.rb",
45
46
  "lib/algolia/client.rb",
46
47
  "lib/algolia/error.rb",
47
48
  "lib/algolia/index.rb",
@@ -0,0 +1,75 @@
1
+ module Algolia
2
+
3
+ class Analytics
4
+ attr_reader :ssl, :ssl_version, :headers
5
+ API_URL='https://analytics.algolia.com'
6
+
7
+ def initialize(client, params)
8
+ @client = client
9
+ @headers = params[:headers]
10
+ end
11
+
12
+ def get_ab_tests(params = {})
13
+ params = {
14
+ :offset => 0,
15
+ :limit => 10,
16
+ }.merge(params)
17
+
18
+ perform_request(:GET, Protocol.ab_tests_uri, params)
19
+ end
20
+
21
+ def get_ab_test(ab_test_id)
22
+ raise ArgumentError.new('ab_test_id cannot be empty') if ab_test_id.nil? || ab_test_id == ''
23
+
24
+ perform_request(:GET, Protocol.ab_tests_uri(ab_test_id))
25
+ end
26
+
27
+ def add_ab_test(ab_test)
28
+ perform_request(:POST, Protocol.ab_tests_uri, {}, ab_test.to_json)
29
+ end
30
+
31
+ def stop_ab_test(ab_test_id)
32
+ raise ArgumentError.new('ab_test_id cannot be empty') if ab_test_id.nil? || ab_test_id == ''
33
+
34
+ perform_request(:POST, Protocol.ab_tests_stop_uri(ab_test_id))
35
+ end
36
+
37
+ def delete_ab_test(ab_test_id)
38
+ raise ArgumentError.new('ab_test_id cannot be empty') if ab_test_id.nil? || ab_test_id == ''
39
+
40
+ perform_request(:DELETE, Protocol.ab_tests_uri(ab_test_id))
41
+ end
42
+
43
+ def wait_task(index_name, taskID, time_before_retry = WAIT_TASK_DEFAULT_TIME_BEFORE_RETRY, request_options = {})
44
+ @client.wait_task(index_name, taskID, time_before_retry, request_options)
45
+ end
46
+
47
+ private
48
+
49
+ def perform_request(method, url, params = {}, data = {})
50
+ http = HTTPClient.new
51
+
52
+ url = API_URL + url
53
+
54
+ encoded_params = Hash[params.map { |k, v| [k.to_s, v.is_a?(Array) ? v.to_json : v] }]
55
+ url << "?" + Protocol.to_query(encoded_params)
56
+
57
+ response = case method
58
+ when :GET
59
+ http.get(url, { :header => @headers })
60
+ when :POST
61
+ http.post(url, { :body => data, :header => @headers })
62
+ when :DELETE
63
+ http.delete(url, { :header => @headers })
64
+ end
65
+
66
+ if response.code / 100 != 2
67
+ raise AlgoliaProtocolError.new(response.code, "Cannot #{method} to #{url}: #{response.content}")
68
+ end
69
+
70
+ JSON.parse(response.content)
71
+ end
72
+
73
+ end
74
+
75
+ end
@@ -1,3 +1,3 @@
1
1
  module Algolia
2
- VERSION = "1.23.1"
2
+ VERSION = "1.23.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: algoliasearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.23.1
4
+ version: 1.23.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Algolia
@@ -105,6 +105,7 @@ files:
105
105
  - Rakefile
106
106
  - algoliasearch.gemspec
107
107
  - contacts.json
108
+ - lib/algolia/analytics.rb
108
109
  - lib/algolia/client.rb
109
110
  - lib/algolia/error.rb
110
111
  - lib/algolia/index.rb