algolia 2.2.0 → 2.2.1

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: 799e36b37cca18189b15d27f6b755904ef5c9707906258cfc3af51691a9af3a6
4
- data.tar.gz: a4235ea4599c928ac96eb9fc1243b8ccb915d2636d30282ff20d792bc7b1b174
3
+ metadata.gz: 6f4bd19a2458e131aa5492ad5aefb851d27f756e59e483b54e4bfd1c385fa851
4
+ data.tar.gz: 83fe8e73abb8ddff9aa52b8492a78d3fec616d598e56c2c79f6e6b57d678f457
5
5
  SHA512:
6
- metadata.gz: bff81541d4dd4392598eb229ee5e854e352988daa7af4892c07e94cd8574b0dab02e1d0a54aba710370775f521ef0338399a5c7876659b2be75d21e083eb4bfc
7
- data.tar.gz: 6549f6d062a2cecbe6521d7961563917d0a9ea9d660991f644ae00b0ef7772557eae5c416efd633544d81cac3d16a94ed5ba3633297710d553a571c85d746da7
6
+ metadata.gz: 9b45bc8ba4e45089de2ce90cf99e20cef6067c59738a88779d03fbe3c0bd88233304cd0296755cb029cb5610281b47dd09a69beb86034f7ba833bea2f6522501
7
+ data.tar.gz: e93d44ea2bfc529248f59996fcb72cb03cd3c578d847e6d6f6f1ec3c42552bebcf16007ff60e5a797c789ed9c5bf73436e8a807f7db581e1cdb5473331746ea5
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # ChangeLog
2
2
 
3
- ## [Unreleased](https://github.com/algolia/algoliasearch-client-ruby/compare/2.2.0..master)
3
+ ## [Unreleased](https://github.com/algolia/algoliasearch-client-ruby/compare/2.2.1..master)
4
+
5
+ ## [2.2.1](https://github.com/algolia/algoliasearch-client-ruby/compare/2.2.0...2.2.1) (2021-11-12)
6
+ ### Chore
7
+ - Deprecated `RecommendationClient` in favor of `PersonalizationClient` ([`#461`](https://github.com/algolia/algoliasearch-client-ruby/pull/461))
4
8
 
5
9
  ## [2.2.0](https://github.com/algolia/algoliasearch-client-ruby/compare/2.1.1...2.2.0) (2021-11-08)
6
10
  ### Added
@@ -0,0 +1,20 @@
1
+ module Algolia
2
+ module Personalization
3
+ class Config < BaseConfig
4
+ attr_accessor :region, :default_hosts
5
+
6
+ # Initialize a config
7
+ #
8
+ # @option options [String] :application_id
9
+ # @option options [String] :api_key
10
+ # @option options [String] :region
11
+ #
12
+ def initialize(opts = {})
13
+ super(opts)
14
+
15
+ @region = opts[:region] || 'us'
16
+ @default_hosts = [Transport::StatefulHost.new("personalization.#{region}.algolia.com")]
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,20 +1,7 @@
1
1
  module Algolia
2
2
  module Recommendation
3
- class Config < BaseConfig
4
- attr_accessor :region, :default_hosts
5
-
6
- # Initialize a config
7
- #
8
- # @option options [String] :application_id
9
- # @option options [String] :api_key
10
- # @option options [String] :region
11
- #
12
- def initialize(opts = {})
13
- super(opts)
14
-
15
- @region = opts[:region] || 'us'
16
- @default_hosts = [Transport::StatefulHost.new("recommendation.#{region}.algolia.com")]
17
- end
3
+ # <b>DEPRECATED:</b> Please use <tt>Algolia::Personalization::Config</tt> instead.
4
+ class Config < Algolia::Personalization::Config
18
5
  end
19
6
  end
20
7
  end
@@ -0,0 +1,60 @@
1
+ module Algolia
2
+ module Personalization
3
+ class Client
4
+ # Initializes the Personalization client
5
+ #
6
+ # @param personalization_config [Personalization::Config] a Personalization::Config object which contains your APP_ID and API_KEY
7
+ # @option adapter [Object] adapter object used for the connection
8
+ # @option logger [Object]
9
+ # @option http_requester [Object] http_requester object used for the connection
10
+ #
11
+ def initialize(personalization_config, opts = {})
12
+ @config = personalization_config
13
+ adapter = opts[:adapter] || Defaults::ADAPTER
14
+ logger = opts[:logger] || LoggerHelper.create('debug.log')
15
+ requester = opts[:http_requester] || Defaults::REQUESTER_CLASS.new(adapter, logger)
16
+ @transporter = Transport::Transport.new(@config, requester)
17
+ end
18
+
19
+ # Create a new client providing only app ID and API key
20
+ #
21
+ # @param app_id [String] Algolia application ID
22
+ # @param api_key [String] Algolia API key
23
+ #
24
+ # @return self
25
+ #
26
+ def self.create(app_id, api_key)
27
+ config = Personalization::Config.new(application_id: app_id, api_key: api_key)
28
+ create_with_config(config)
29
+ end
30
+
31
+ # Create a new client providing only an Personalization::Config object
32
+ #
33
+ # @param config [Personalization::Config]
34
+ #
35
+ # @return self
36
+ #
37
+ def self.create_with_config(config)
38
+ new(config)
39
+ end
40
+
41
+ # Set the personalization strategy.
42
+ #
43
+ # @param personalization_strategy [Hash] A strategy object.
44
+ #
45
+ # @return [Hash]
46
+ #
47
+ def set_personalization_strategy(personalization_strategy, opts = {})
48
+ @transporter.write(:POST, '1/strategies/personalization', personalization_strategy, opts)
49
+ end
50
+
51
+ # Get the personalization strategy.
52
+ #
53
+ # @return [Hash]
54
+ #
55
+ def get_personalization_strategy(opts = {})
56
+ @transporter.read(:GET, '1/strategies/personalization', {}, opts)
57
+ end
58
+ end
59
+ end
60
+ end
@@ -1,60 +1,7 @@
1
1
  module Algolia
2
2
  module Recommendation
3
- class Client
4
- # Initializes the Recommendation client
5
- #
6
- # @param recommendation_config [Recommendation::Config] a Recommendation::Config object which contains your APP_ID and API_KEY
7
- # @option adapter [Object] adapter object used for the connection
8
- # @option logger [Object]
9
- # @option http_requester [Object] http_requester object used for the connection
10
- #
11
- def initialize(recommendation_config, opts = {})
12
- @config = recommendation_config
13
- adapter = opts[:adapter] || Defaults::ADAPTER
14
- logger = opts[:logger] || LoggerHelper.create('debug.log')
15
- requester = opts[:http_requester] || Defaults::REQUESTER_CLASS.new(adapter, logger)
16
- @transporter = Transport::Transport.new(@config, requester)
17
- end
18
-
19
- # Create a new client providing only app ID and API key
20
- #
21
- # @param app_id [String] Algolia application ID
22
- # @param api_key [String] Algolia API key
23
- #
24
- # @return self
25
- #
26
- def self.create(app_id, api_key)
27
- config = Recommendation::Config.new(application_id: app_id, api_key: api_key)
28
- create_with_config(config)
29
- end
30
-
31
- # Create a new client providing only an Recommendation::Config object
32
- #
33
- # @param config [Recommendation::Config]
34
- #
35
- # @return self
36
- #
37
- def self.create_with_config(config)
38
- new(config)
39
- end
40
-
41
- # Set the personalization strategy.
42
- #
43
- # @param personalization_strategy [Hash] A strategy object.
44
- #
45
- # @return [Hash]
46
- #
47
- def set_personalization_strategy(personalization_strategy, opts = {})
48
- @transporter.write(:POST, '1/strategies/personalization', personalization_strategy, opts)
49
- end
50
-
51
- # Get the personalization strategy.
52
- #
53
- # @return [Hash]
54
- #
55
- def get_personalization_strategy(opts = {})
56
- @transporter.read(:GET, '1/strategies/personalization', {}, opts)
57
- end
3
+ # <b>DEPRECATED:</b> Please use <tt>Algolia::Personalization::Client</tt> instead.
4
+ class Client < Algolia::Personalization::Client
58
5
  end
59
6
  end
60
7
  end
@@ -1,3 +1,3 @@
1
1
  module Algolia
2
- VERSION = '2.2.0'.freeze
2
+ VERSION = '2.2.1'.freeze
3
3
  end
data/lib/algolia.rb CHANGED
@@ -8,6 +8,7 @@ require 'algolia/config/search_config'
8
8
  require 'algolia/config/analytics_config'
9
9
  require 'algolia/config/insights_config'
10
10
  require 'algolia/config/recommend_config'
11
+ require 'algolia/config/personalization_config'
11
12
  require 'algolia/config/recommendation_config'
12
13
  require 'algolia/enums/call_type'
13
14
  require 'algolia/enums/retry_outcome_type'
@@ -35,6 +36,7 @@ require 'algolia/search_client'
35
36
  require 'algolia/analytics_client'
36
37
  require 'algolia/insights_client'
37
38
  require 'algolia/recommend_client'
39
+ require 'algolia/personalization_client'
38
40
  require 'algolia/recommendation_client'
39
41
  require 'algolia/error'
40
42
  require 'algolia/search_index'
@@ -0,0 +1,30 @@
1
+ require_relative 'base_test'
2
+ require 'date'
3
+
4
+ class PersonalizationClientTest < BaseTest
5
+ describe 'Personalization client' do
6
+ def test_personalization_client
7
+ client = Algolia::Personalization::Client.create(APPLICATION_ID_1, ADMIN_KEY_1)
8
+ personalization_strategy = {
9
+ eventsScoring: [
10
+ { eventName: 'Add to cart', eventType: 'conversion', score: 50 },
11
+ { eventName: 'Purchase', eventType: 'conversion', score: 100 }
12
+ ],
13
+ facetsScoring: [
14
+ { facetName: 'brand', score: 100 },
15
+ { facetName: 'categories', score: 10 }
16
+ ],
17
+ personalizationImpact: 0
18
+ }
19
+
20
+ begin
21
+ client.set_personalization_strategy(personalization_strategy)
22
+ rescue Algolia::AlgoliaHttpError => e
23
+ raise e unless e.code == 429
24
+ end
25
+ response = client.get_personalization_strategy
26
+
27
+ assert_equal response, personalization_strategy
28
+ end
29
+ end
30
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: algolia
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Algolia
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-08 00:00:00.000000000 Z
11
+ date: 2021-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -218,6 +218,7 @@ files:
218
218
  - lib/algolia/config/analytics_config.rb
219
219
  - lib/algolia/config/base_config.rb
220
220
  - lib/algolia/config/insights_config.rb
221
+ - lib/algolia/config/personalization_config.rb
221
222
  - lib/algolia/config/recommend_config.rb
222
223
  - lib/algolia/config/recommendation_config.rb
223
224
  - lib/algolia/config/search_config.rb
@@ -235,6 +236,7 @@ files:
235
236
  - lib/algolia/iterators/rule_iterator.rb
236
237
  - lib/algolia/iterators/synonym_iterator.rb
237
238
  - lib/algolia/logger_helper.rb
239
+ - lib/algolia/personalization_client.rb
238
240
  - lib/algolia/recommend_client.rb
239
241
  - lib/algolia/recommendation_client.rb
240
242
  - lib/algolia/responses/add_api_key_response.rb
@@ -276,6 +278,7 @@ files:
276
278
  - test/algolia/integration/base_test.rb
277
279
  - test/algolia/integration/insights_client_test.rb
278
280
  - test/algolia/integration/mocks/mock_requester.rb
281
+ - test/algolia/integration/personalization_client_test.rb
279
282
  - test/algolia/integration/recommend_client_test.rb
280
283
  - test/algolia/integration/recommendation_client_test.rb
281
284
  - test/algolia/integration/search_client_test.rb
@@ -318,6 +321,7 @@ test_files:
318
321
  - test/algolia/integration/base_test.rb
319
322
  - test/algolia/integration/insights_client_test.rb
320
323
  - test/algolia/integration/mocks/mock_requester.rb
324
+ - test/algolia/integration/personalization_client_test.rb
321
325
  - test/algolia/integration/recommend_client_test.rb
322
326
  - test/algolia/integration/recommendation_client_test.rb
323
327
  - test/algolia/integration/search_client_test.rb