recombee_api_client 3.2.0 → 4.0.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: 993911797068c239b3eb1ed0bff4f115049a3a7c5c25cc10ee2e7606fabaecc5
4
- data.tar.gz: 9759c4ad279ea317cbdf0d6b3ac93eee89761010b1d8aded8cdd946f9dc0e793
3
+ metadata.gz: ddc59d0fe517546ea3c3e201f4ba31fdab38fee38ef7ab2780a226744d94ed8a
4
+ data.tar.gz: 2afe45ef3d9540eb9a1c112152b33a2559d8be9dd49bc613904020ee648e300a
5
5
  SHA512:
6
- metadata.gz: 7a5cccd32d72f4ec654b3ffc9c8f9d0f50e90618b104afc7618e24cf40f0ad9ceaf14b18031d7e8c4ef1ac05027a7857a592e3fc18fded5a7a2f1b27b80f9225
7
- data.tar.gz: 8a68e11edd23890854ec6248994d77e4f494fd19b881d798eb7f916b0823b77987695ad0c439594fdadc82c7f229cda3128ce6d3dfecdd17162e38654d1f3200
6
+ metadata.gz: 4550dea796a247b45f3e80c840b876dec5065835f9127ad5f991440256e512dbd40c9d1c95675c7d3d4fe8700d5851201c278193ed561d2d28414b660b111d30
7
+ data.tar.gz: efa14da6a11f0fa00490e38cf22f0e9bdf741e7a331ef69a9b609ef683c28b2f7c07afb70548d07077e8b366ca968f2592290249591b28f1d8f0320136b54f49
data/README.md CHANGED
@@ -29,7 +29,7 @@ Or install it yourself as:
29
29
  require 'recombee_api_client'
30
30
  include RecombeeApiClient
31
31
 
32
- client = RecombeeClient('--my-database-id--', '--db-private-token--')
32
+ client = RecombeeClient('--my-database-id--', '--db-private-token--', {:region => 'us-west'})
33
33
 
34
34
  # Generate some random purchases of items by users
35
35
  NUM = 100
@@ -76,7 +76,7 @@ include RecombeeApiClient
76
76
  NUM = 100
77
77
  PROBABILITY_PURCHASED = 0.1
78
78
 
79
- client = RecombeeClient('--my-database-id--', '--db-private-token--')
79
+ client = RecombeeClient('--my-database-id--', '--db-private-token--', {:region => 'ap-se'})
80
80
  client.send(ResetDatabase.new) # Clear everything from the database (asynchronous)
81
81
 
82
82
  # We will use computers as items in this example
@@ -11,7 +11,7 @@ module RecombeeApiClient
11
11
  #
12
12
  #If there are any *purchases*, *ratings*, *bookmarks*, *cart additions* or *detail views* of the item present in the database, they will be deleted in cascade as well. Also, if the item is present in some *series*, it will be removed from all the *series* where present.
13
13
  #
14
- #If an item becomes obsolete/no longer available, it is often meaningful to keep it in the catalog (along with all the interaction data, which are very useful), and only exclude the item from recommendations. In such a case, use [ReQL filter](https://docs.recombee.com/reql.html) instead of deleting the item completely.
14
+ #If an item becomes obsolete/no longer available, it is meaningful to keep it in the catalog (along with all the interaction data, which are very useful), and **only exclude the item from recommendations**. In such a case, use [ReQL filter](https://docs.recombee.com/reql.html) instead of deleting the item completely.
15
15
  #
16
16
  class DeleteItem < ApiRequest
17
17
  attr_reader :item_id
@@ -0,0 +1,52 @@
1
+ #
2
+ # This file is auto-generated, do not edit
3
+ #
4
+
5
+ module RecombeeApiClient
6
+ require_relative 'request'
7
+ require_relative '../errors'
8
+
9
+ ##
10
+ #Delete all the items that pass the filter.
11
+ #
12
+ #If an item becomes obsolete/no longer available, it is meaningful to **keep it in the catalog** (along with all the interaction data, which are very useful), and **only exclude the item from recommendations**. In such a case, use [ReQL filter](https://docs.recombee.com/reql.html) instead of deleting the item completely.
13
+ class DeleteMoreItems < ApiRequest
14
+ attr_reader :filter
15
+ attr_accessor :timeout
16
+ attr_accessor :ensure_https
17
+
18
+ ##
19
+ # * *Required arguments*
20
+ # - +filter+ -> A [ReQL](https://docs.recombee.com/reql.html) expression, which return `true` for the items that shall be updated.
21
+ #
22
+ def initialize(filter)
23
+ @filter = filter
24
+ @timeout = 1000
25
+ @ensure_https = false
26
+ end
27
+
28
+ # HTTP method
29
+ def method
30
+ :delete
31
+ end
32
+
33
+ # Values of body parameters as a Hash
34
+ def body_parameters
35
+ p = Hash.new
36
+ p['filter'] = @filter
37
+ p
38
+ end
39
+
40
+ # Values of query parameters as a Hash.
41
+ # name of parameter => value of the parameter
42
+ def query_parameters
43
+ params = {}
44
+ params
45
+ end
46
+
47
+ # Relative path to the endpoint
48
+ def path
49
+ "/{databaseId}/more-items/"
50
+ end
51
+ end
52
+ end
@@ -18,7 +18,7 @@ module RecombeeApiClient
18
18
 
19
19
  ##
20
20
  # * *Required arguments*
21
- # - +user_id+ -> ID of the user to be added.
21
+ # - +user_id+ -> ID of the user to be deleted.
22
22
  #
23
23
  def initialize(user_id)
24
24
  @user_id = user_id
@@ -117,7 +117,7 @@ module RecombeeApiClient
117
117
  #
118
118
  # - +minRelevance+ -> **Expert option** Specifies the threshold of how much relevant must the recommended items be to the user. Possible values one of: "low", "medium", "high". The default value is "low", meaning that the system attempts to recommend number of items equal to *count* at any cost. If there are not enough data (such as interactions or item properties), this may even lead to bestseller-based recommendations to be appended to reach the full *count*. This behavior may be suppressed by using "medium" or "high" values. In such case, the system only recommends items of at least the requested relevance, and may return less than *count* items when there is not enough data to fulfill it.
119
119
  #
120
- # - +rotationRate+ -> **Expert option** If your users browse the system in real-time, it may easily happen that you wish to offer them recommendations multiple times. Here comes the question: how much should the recommendations change? Should they remain the same, or should they rotate? Recombee API allows you to control this per-request in backward fashion. You may penalize an item for being recommended in the near past. For the specific user, `rotationRate=1` means maximal rotation, `rotationRate=0` means absolutely no rotation. You may also use, for example `rotationRate=0.2` for only slight rotation of recommended items. Default: `0.1`.
120
+ # - +rotationRate+ -> **Expert option** If your users browse the system in real-time, it may easily happen that you wish to offer them recommendations multiple times. Here comes the question: how much should the recommendations change? Should they remain the same, or should they rotate? Recombee API allows you to control this per-request in backward fashion. You may penalize an item for being recommended in the near past. For the specific user, `rotationRate=1` means maximal rotation, `rotationRate=0` means absolutely no rotation. You may also use, for example `rotationRate=0.2` for only slight rotation of recommended items. Default: `0`.
121
121
  #
122
122
  # - +rotationTime+ -> **Expert option** Taking *rotationRate* into account, specifies how long time it takes to an item to recover from the penalization. For example, `rotationTime=7200.0` means that items recommended less than 2 hours ago are penalized. Default: `7200.0`.
123
123
  #
@@ -0,0 +1,63 @@
1
+ #
2
+ # This file is auto-generated, do not edit
3
+ #
4
+
5
+ module RecombeeApiClient
6
+ require_relative 'request'
7
+ require_relative '../errors'
8
+
9
+ ##
10
+ #Update (some) property values of all the items that pass the filter.
11
+ #
12
+ #Example: *Setting all the items that are older than a week as unavailable*
13
+ #
14
+ # ```
15
+ # {
16
+ # "filter": "'releaseDate' < now() - 7*24*3600",
17
+ # "changes": {"available": false}
18
+ # }
19
+ # ```
20
+ #
21
+ class UpdateMoreItems < ApiRequest
22
+ attr_reader :filter, :changes
23
+ attr_accessor :timeout
24
+ attr_accessor :ensure_https
25
+
26
+ ##
27
+ # * *Required arguments*
28
+ # - +filter+ -> A [ReQL](https://docs.recombee.com/reql.html) expression, which return `true` for the items that shall be updated.
29
+ # - +changes+ -> A dictionary where the keys are properties which shall be updated.
30
+ #
31
+ def initialize(filter, changes)
32
+ @filter = filter
33
+ @changes = changes
34
+ @timeout = 1000
35
+ @ensure_https = false
36
+ end
37
+
38
+ # HTTP method
39
+ def method
40
+ :post
41
+ end
42
+
43
+ # Values of body parameters as a Hash
44
+ def body_parameters
45
+ p = Hash.new
46
+ p['filter'] = @filter
47
+ p['changes'] = @changes
48
+ p
49
+ end
50
+
51
+ # Values of query parameters as a Hash.
52
+ # name of parameter => value of the parameter
53
+ def query_parameters
54
+ params = {}
55
+ params
56
+ end
57
+
58
+ # Relative path to the endpoint
59
+ def path
60
+ "/{databaseId}/more-items/"
61
+ end
62
+ end
63
+ end
@@ -1,3 +1,3 @@
1
1
  module RecombeeApiClient
2
- VERSION = '3.2.0'
2
+ VERSION = '4.0.0'
3
3
  end
@@ -18,19 +18,16 @@ module RecombeeApiClient
18
18
  include HTTParty
19
19
 
20
20
  BATCH_MAX_SIZE = 10000
21
- USER_AGENT = {'User-Agent' => 'recombee-ruby-api-client/3.2.0'}
21
+ USER_AGENT = {'User-Agent' => 'recombee-ruby-api-client/4.0.0'}
22
22
 
23
23
  ##
24
24
  # - +account+ -> Name of your account at Recombee
25
25
  # - +token+ -> Secret token obtained from Recombee for signing requests
26
- # - +protocol+ -> Default protocol for sending requests. Possible values: 'http', 'https'.
27
- def initialize(account, token, protocol = 'https', options = {})
26
+ def initialize(account, token, options = {})
28
27
  @account = account
29
28
  @token = token
30
- @protocol = protocol
31
- @base_uri = ENV['RAPI_URI'] if ENV.key? 'RAPI_URI'
32
- @base_uri||= options[:base_uri]
33
- @base_uri||= 'rapi.recombee.com'
29
+ @protocol = options[:protocol] || 'https'
30
+ @base_uri = get_base_uri(options)
34
31
  end
35
32
 
36
33
  ##
@@ -42,7 +39,7 @@ module RecombeeApiClient
42
39
  timeout = request.timeout / 1000
43
40
  uri = process_request_uri(request)
44
41
  uri = sign_url(uri)
45
- protocol = request.ensure_https ? 'https' : @protocol
42
+ protocol = request.ensure_https ? 'https' : @protocol.to_s
46
43
  uri = protocol + '://' + @base_uri + uri
47
44
  # puts uri
48
45
  begin
@@ -63,10 +60,33 @@ module RecombeeApiClient
63
60
 
64
61
  private
65
62
 
63
+ def get_regional_base_uri(region)
64
+ uri = {
65
+ 'ap-se' => 'rapi-ap-se.recombee.com',
66
+ 'ca-east' => 'rapi-ca-east.recombee.com',
67
+ 'eu-west' => 'rapi-eu-west.recombee.com',
68
+ 'us-west' => 'rapi-us-west.recombee.com'
69
+ }[region.to_s.gsub('_', '-').downcase]
70
+ raise ArgumentError.new("Region \"#{region}\" is unknown. You may need to update the version of the SDK.") if uri == nil
71
+ uri
72
+ end
73
+
74
+ def get_base_uri(options)
75
+ base_uri = ENV['RAPI_URI']
76
+ base_uri ||= options[:base_uri]
77
+
78
+ if options.key? :region
79
+ raise ArgumentError.new(':base_uri and :region cannot be specified at the same time') if base_uri
80
+ base_uri = get_regional_base_uri(options[:region])
81
+ end
82
+ base_uri||= 'rapi.recombee.com'
83
+ base_uri
84
+ end
85
+
66
86
  def put(request, uri, timeout)
67
87
  response = self.class.put(uri, body: request.body_parameters.to_json,
68
- headers: { 'Content-Type' => 'application/json' }.merge(USER_AGENT),
69
- timeout: timeout)
88
+ headers: { 'Content-Type' => 'application/json' }.merge(USER_AGENT),
89
+ timeout: timeout)
70
90
  check_errors(response, request)
71
91
  response.body
72
92
  end
@@ -78,10 +98,9 @@ module RecombeeApiClient
78
98
  end
79
99
 
80
100
  def post(request, uri, timeout)
81
- # pass arguments in body
82
101
  response = self.class.post(uri, body: request.body_parameters.to_json,
83
- headers: { 'Content-Type' => 'application/json' }.merge(USER_AGENT),
84
- timeout: timeout)
102
+ headers: { 'Content-Type' => 'application/json' }.merge(USER_AGENT),
103
+ timeout: timeout)
85
104
  check_errors(response, request)
86
105
  begin
87
106
  return JSON.parse(response.body)
@@ -91,9 +110,15 @@ module RecombeeApiClient
91
110
  end
92
111
 
93
112
  def delete(request, uri, timeout)
94
- response = self.class.delete(uri, timeout: timeout, headers: USER_AGENT)
113
+ response = self.class.delete(uri, body: request.body_parameters.to_json,
114
+ headers: { 'Content-Type' => 'application/json' }.merge(USER_AGENT),
115
+ timeout: timeout)
95
116
  check_errors(response, request)
96
- response.body
117
+ begin
118
+ return JSON.parse(response.body)
119
+ rescue JSON::ParserError
120
+ return response.body
121
+ end
97
122
  end
98
123
 
99
124
  def check_errors(response, request)
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.add_dependency 'multi_json'
21
21
  spec.add_dependency 'httparty'
22
22
 
23
- spec.add_development_dependency 'bundler', '~> 1.10'
24
- spec.add_development_dependency 'rake', '~> 10.0'
23
+ spec.add_development_dependency 'bundler', '~> 2.2.10'
24
+ spec.add_development_dependency 'rake', '~> 12.3.3'
25
25
  spec.add_development_dependency 'rspec'
26
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recombee_api_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ondřej Fiedler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-17 00:00:00.000000000 Z
11
+ date: 2022-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -44,28 +44,28 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.10'
47
+ version: 2.2.10
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.10'
54
+ version: 2.2.10
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '10.0'
61
+ version: 12.3.3
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '10.0'
68
+ version: 12.3.3
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -112,6 +112,7 @@ files:
112
112
  - lib/recombee_api_client/api/delete_group.rb
113
113
  - lib/recombee_api_client/api/delete_item.rb
114
114
  - lib/recombee_api_client/api/delete_item_property.rb
115
+ - lib/recombee_api_client/api/delete_more_items.rb
115
116
  - lib/recombee_api_client/api/delete_purchase.rb
116
117
  - lib/recombee_api_client/api/delete_rating.rb
117
118
  - lib/recombee_api_client/api/delete_search_synonym.rb
@@ -126,7 +127,6 @@ files:
126
127
  - lib/recombee_api_client/api/hash_normalizer.rb
127
128
  - lib/recombee_api_client/api/insert_to_group.rb
128
129
  - lib/recombee_api_client/api/insert_to_series.rb
129
- - lib/recombee_api_client/api/item_based_recommendation.rb
130
130
  - lib/recombee_api_client/api/list_group_items.rb
131
131
  - lib/recombee_api_client/api/list_groups.rb
132
132
  - lib/recombee_api_client/api/list_item_bookmarks.rb
@@ -163,7 +163,7 @@ files:
163
163
  - lib/recombee_api_client/api/set_user_values.rb
164
164
  - lib/recombee_api_client/api/set_values.rb
165
165
  - lib/recombee_api_client/api/set_view_portion.rb
166
- - lib/recombee_api_client/api/user_based_recommendation.rb
166
+ - lib/recombee_api_client/api/update_more_items.rb
167
167
  - lib/recombee_api_client/errors.rb
168
168
  - lib/recombee_api_client/version.rb
169
169
  - recombee_api_client.gemspec
@@ -1,159 +0,0 @@
1
- #
2
- # This file is auto-generated, do not edit
3
- #
4
-
5
- module RecombeeApiClient
6
- require_relative 'request'
7
- require_relative '../errors'
8
-
9
- ##
10
- #Deprecated since version 2.0.0. Use RecommendItemsToItem request instead.
11
- #
12
- #Recommends set of items that are somehow related to one given item, *X*. Typical scenario for using item-based recommendation is when user *A* is viewing *X*. Then you may display items to the user that he might be also interested in. Item-recommendation request gives you Top-N such items, optionally taking the target user *A* into account.
13
- #
14
- # It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters.
15
- #
16
- class ItemBasedRecommendation < ApiRequest
17
- attr_reader :item_id, :count, :target_user_id, :user_impact, :filter, :booster, :allow_nonexistent, :cascade_create, :scenario, :return_properties, :included_properties, :diversity, :min_relevance, :rotation_rate, :rotation_time, :expert_settings
18
- attr_accessor :timeout
19
- attr_accessor :ensure_https
20
-
21
- ##
22
- # * *Required arguments*
23
- # - +item_id+ -> ID of the item for which the recommendations are to be generated.
24
- # - +count+ -> Number of items to be recommended (N for the top-N recommendation).
25
- #
26
- # * *Optional arguments (given as hash optional)*
27
- # - +targetUserId+ -> ID of the user who will see the recommendations.
28
- #
29
- #Specifying the *targetUserId* is beneficial because:
30
- #
31
- #* It makes the recommendations personalized
32
- #* Allows the calculation of Actions and Conversions in the graphical user interface,
33
- # as Recombee can pair the user who got recommendations and who afterwards viewed/purchased an item.
34
- #
35
- #For the above reasons, we encourage you to set the *targetUserId* even for anonymous/unregistered users (i.e. use their session ID).
36
- #
37
- # - +userImpact+ -> If *targetUserId* parameter is present, the recommendations are biased towards the user given. Using *userImpact*, you may control this bias. For an extreme case of `userImpact=0.0`, the interactions made by the user are not taken into account at all (with the exception of history-based blacklisting), for `userImpact=1.0`, you'll get user-based recommendation. The default value is `0`.
38
- #
39
- # - +filter+ -> Boolean-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to filter recommended items based on the values of their attributes.
40
- # - +booster+ -> Number-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to boost recommendation rate of some items based on the values of their attributes.
41
- # - +allowNonexistent+ -> Instead of causing HTTP 404 error, returns some (non-personalized) recommendations if either item of given *itemId* or user of given *targetUserId* does not exist in the database. It creates neither of the missing entities in the database.
42
- # - +cascadeCreate+ -> If item of given *itemId* or user of given *targetUserId* doesn't exist in the database, it creates the missing enity/entities and returns some (non-personalized) recommendations. This allows for example rotations in the following recommendations for the user of given *targetUserId*, as the user will be already known to the system.
43
- # - +scenario+ -> Scenario defines a particular application of recommendations. It can be for example "homepage", "cart" or "emailing". You can see each scenario in the UI separately, so you can check how well each application performs. The AI which optimizes models in order to get the best results may optimize different scenarios separately, or even use different models in each of the scenarios.
44
- # - +returnProperties+ -> With `returnProperties=true`, property values of the recommended items are returned along with their IDs in a JSON dictionary. The acquired property values can be used for easy displaying of the recommended items to the user.
45
- #
46
- #Example response:
47
- #```
48
- # [
49
- # {
50
- # "itemId": "tv-178",
51
- # "description": "4K TV with 3D feature",
52
- # "categories": ["Electronics", "Televisions"],
53
- # "price": 342,
54
- # "url": "myshop.com/tv-178"
55
- # },
56
- # {
57
- # "itemId": "mixer-42",
58
- # "description": "Stainless Steel Mixer",
59
- # "categories": ["Home & Kitchen"],
60
- # "price": 39,
61
- # "url": "myshop.com/mixer-42"
62
- # }
63
- # ]
64
- #```
65
- #
66
- # - +includedProperties+ -> Allows to specify, which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list.
67
- #
68
- #Example response for `includedProperties=description,price`:
69
- #```
70
- # [
71
- # {
72
- # "itemId": "tv-178",
73
- # "description": "4K TV with 3D feature",
74
- # "price": 342
75
- # },
76
- # {
77
- # "itemId": "mixer-42",
78
- # "description": "Stainless Steel Mixer",
79
- # "price": 39
80
- # }
81
- # ]
82
- #```
83
- #
84
- # - +diversity+ -> **Expert option** Real number from [0.0, 1.0] which determines how much mutually dissimilar should the recommended items be. The default value is 0.0, i.e., no diversification. Value 1.0 means maximal diversification.
85
- #
86
- # - +minRelevance+ -> **Expert option** If the *targetUserId* is provided: Specifies the threshold of how much relevant must the recommended items be to the user. Possible values one of: "low", "medium", "high". The default value is "low", meaning that the system attempts to recommend number of items equal to *count* at any cost. If there are not enough data (such as interactions or item properties), this may even lead to bestseller-based recommendations to be appended to reach the full *count*. This behavior may be suppressed by using "medium" or "high" values. In such case, the system only recommends items of at least the requested qualit, and may return less than *count* items when there is not enough data to fulfill it.
87
- #
88
- # - +rotationRate+ -> **Expert option** If the *targetUserId* is provided: If your users browse the system in real-time, it may easily happen that you wish to offer them recommendations multiple times. Here comes the question: how much should the recommendations change? Should they remain the same, or should they rotate? Recombee API allows you to control this per-request in backward fashion. You may penalize an item for being recommended in the near past. For the specific user, `rotationRate=1` means maximal rotation, `rotationRate=0` means absolutely no rotation. You may also use, for example `rotationRate=0.2` for only slight rotation of recommended items. Default: `0.01`.
89
- #
90
- # - +rotationTime+ -> **Expert option** If the *targetUserId* is provided: Taking *rotationRate* into account, specifies how long time it takes to an item to recover from the penalization. For example, `rotationTime=7200.0` means that items recommended less than 2 hours ago are penalized. Default: `7200.0`.
91
- #
92
- # - +expertSettings+ -> Dictionary of custom options.
93
- #
94
- #
95
- def initialize(item_id, count, optional = {})
96
- @item_id = item_id
97
- @count = count
98
- optional = normalize_optional(optional)
99
- @target_user_id = optional['targetUserId']
100
- @user_impact = optional['userImpact']
101
- @filter = optional['filter']
102
- @booster = optional['booster']
103
- @allow_nonexistent = optional['allowNonexistent']
104
- @cascade_create = optional['cascadeCreate']
105
- @scenario = optional['scenario']
106
- @return_properties = optional['returnProperties']
107
- @included_properties = optional['includedProperties']
108
- @diversity = optional['diversity']
109
- @min_relevance = optional['minRelevance']
110
- @rotation_rate = optional['rotationRate']
111
- @rotation_time = optional['rotationTime']
112
- @expert_settings = optional['expertSettings']
113
- @optional = optional
114
- @timeout = 3000
115
- @ensure_https = false
116
- @optional.each do |par, _|
117
- fail UnknownOptionalParameter.new(par) unless ["targetUserId","userImpact","filter","booster","allowNonexistent","cascadeCreate","scenario","returnProperties","includedProperties","diversity","minRelevance","rotationRate","rotationTime","expertSettings"].include? par
118
- end
119
- end
120
-
121
- # HTTP method
122
- def method
123
- :post
124
- end
125
-
126
- # Values of body parameters as a Hash
127
- def body_parameters
128
- p = Hash.new
129
- p['count'] = @count
130
- p['targetUserId'] = @optional['targetUserId'] if @optional.include? 'targetUserId'
131
- p['userImpact'] = @optional['userImpact'] if @optional.include? 'userImpact'
132
- p['filter'] = @optional['filter'] if @optional.include? 'filter'
133
- p['booster'] = @optional['booster'] if @optional.include? 'booster'
134
- p['allowNonexistent'] = @optional['allowNonexistent'] if @optional.include? 'allowNonexistent'
135
- p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
136
- p['scenario'] = @optional['scenario'] if @optional.include? 'scenario'
137
- p['returnProperties'] = @optional['returnProperties'] if @optional.include? 'returnProperties'
138
- p['includedProperties'] = @optional['includedProperties'] if @optional.include? 'includedProperties'
139
- p['diversity'] = @optional['diversity'] if @optional.include? 'diversity'
140
- p['minRelevance'] = @optional['minRelevance'] if @optional.include? 'minRelevance'
141
- p['rotationRate'] = @optional['rotationRate'] if @optional.include? 'rotationRate'
142
- p['rotationTime'] = @optional['rotationTime'] if @optional.include? 'rotationTime'
143
- p['expertSettings'] = @optional['expertSettings'] if @optional.include? 'expertSettings'
144
- p
145
- end
146
-
147
- # Values of query parameters as a Hash.
148
- # name of parameter => value of the parameter
149
- def query_parameters
150
- params = {}
151
- params
152
- end
153
-
154
- # Relative path to the endpoint
155
- def path
156
- "/{databaseId}/items/#{@item_id}/recomms/"
157
- end
158
- end
159
- end
@@ -1,143 +0,0 @@
1
- #
2
- # This file is auto-generated, do not edit
3
- #
4
-
5
- module RecombeeApiClient
6
- require_relative 'request'
7
- require_relative '../errors'
8
-
9
- ##
10
- #Deprecated since version 2.0.0. Use RecommendItemsToUser request instead.
11
- #
12
- #Based on user's past interactions (purchases, ratings, etc.) with the items, recommends top-N items that are most likely to be of high value for a given user.
13
- #
14
- #It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters.
15
- #
16
- class UserBasedRecommendation < ApiRequest
17
- attr_reader :user_id, :count, :filter, :booster, :allow_nonexistent, :cascade_create, :scenario, :return_properties, :included_properties, :diversity, :min_relevance, :rotation_rate, :rotation_time, :expert_settings
18
- attr_accessor :timeout
19
- attr_accessor :ensure_https
20
-
21
- ##
22
- # * *Required arguments*
23
- # - +user_id+ -> ID of the user for whom the personalized recommendations are to be generated.
24
- # - +count+ -> Number of items to be recommended (N for the top-N recommendation).
25
- #
26
- # * *Optional arguments (given as hash optional)*
27
- # - +filter+ -> Boolean-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to filter recommended items based on the values of their attributes.
28
- # - +booster+ -> Number-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to boost recommendation rate of some items based on the values of their attributes.
29
- # - +allowNonexistent+ -> If the user does not exist in the database, returns a list of non-personalized recommendations instead of causing HTTP 404 error. It doesn't create the user in the database.
30
- # - +cascadeCreate+ -> If the user does not exist in the database, returns a list of non-personalized recommendations and creates the user in the database. This allows for example rotations in the following recommendations for that user, as the user will be already known to the system.
31
- # - +scenario+ -> Scenario defines a particular application of recommendations. It can be for example "homepage", "cart" or "emailing". You can see each scenario in the UI separately, so you can check how well each application performs. The AI which optimizes models in order to get the best results may optimize different scenarios separately, or even use different models in each of the scenarios.
32
- # - +returnProperties+ -> With `returnProperties=true`, property values of the recommended items are returned along with their IDs in a JSON dictionary. The acquired property values can be used for easy displaying of the recommended items to the user.
33
- #
34
- #Example response:
35
- #```
36
- # [
37
- # {
38
- # "itemId": "tv-178",
39
- # "description": "4K TV with 3D feature",
40
- # "categories": ["Electronics", "Televisions"],
41
- # "price": 342,
42
- # "url": "myshop.com/tv-178"
43
- # },
44
- # {
45
- # "itemId": "mixer-42",
46
- # "description": "Stainless Steel Mixer",
47
- # "categories": ["Home & Kitchen"],
48
- # "price": 39,
49
- # "url": "myshop.com/mixer-42"
50
- # }
51
- # ]
52
- #```
53
- #
54
- # - +includedProperties+ -> Allows to specify, which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list.
55
- #
56
- #Example response for `includedProperties=description,price`:
57
- #```
58
- # [
59
- # {
60
- # "itemId": "tv-178",
61
- # "description": "4K TV with 3D feature",
62
- # "price": 342
63
- # },
64
- # {
65
- # "itemId": "mixer-42",
66
- # "description": "Stainless Steel Mixer",
67
- # "price": 39
68
- # }
69
- # ]
70
- #```
71
- #
72
- # - +diversity+ -> **Expert option** Real number from [0.0, 1.0] which determines how much mutually dissimilar should the recommended items be. The default value is 0.0, i.e., no diversification. Value 1.0 means maximal diversification.
73
- #
74
- # - +minRelevance+ -> **Expert option** Specifies the threshold of how much relevant must the recommended items be to the user. Possible values one of: "low", "medium", "high". The default value is "low", meaning that the system attempts to recommend number of items equal to *count* at any cost. If there are not enough data (such as interactions or item properties), this may even lead to bestseller-based recommendations to be appended to reach the full *count*. This behavior may be suppressed by using "medium" or "high" values. In such case, the system only recommends items of at least the requested qualit, and may return less than *count* items when there is not enough data to fulfill it.
75
- #
76
- # - +rotationRate+ -> **Expert option** If your users browse the system in real-time, it may easily happen that you wish to offer them recommendations multiple times. Here comes the question: how much should the recommendations change? Should they remain the same, or should they rotate? Recombee API allows you to control this per-request in backward fashion. You may penalize an item for being recommended in the near past. For the specific user, `rotationRate=1` means maximal rotation, `rotationRate=0` means absolutely no rotation. You may also use, for example `rotationRate=0.2` for only slight rotation of recommended items. Default: `0.1`.
77
- #
78
- # - +rotationTime+ -> **Expert option** Taking *rotationRate* into account, specifies how long time it takes to an item to recover from the penalization. For example, `rotationTime=7200.0` means that items recommended less than 2 hours ago are penalized. Default: `7200.0`.
79
- #
80
- # - +expertSettings+ -> Dictionary of custom options.
81
- #
82
- #
83
- def initialize(user_id, count, optional = {})
84
- @user_id = user_id
85
- @count = count
86
- optional = normalize_optional(optional)
87
- @filter = optional['filter']
88
- @booster = optional['booster']
89
- @allow_nonexistent = optional['allowNonexistent']
90
- @cascade_create = optional['cascadeCreate']
91
- @scenario = optional['scenario']
92
- @return_properties = optional['returnProperties']
93
- @included_properties = optional['includedProperties']
94
- @diversity = optional['diversity']
95
- @min_relevance = optional['minRelevance']
96
- @rotation_rate = optional['rotationRate']
97
- @rotation_time = optional['rotationTime']
98
- @expert_settings = optional['expertSettings']
99
- @optional = optional
100
- @timeout = 3000
101
- @ensure_https = false
102
- @optional.each do |par, _|
103
- fail UnknownOptionalParameter.new(par) unless ["filter","booster","allowNonexistent","cascadeCreate","scenario","returnProperties","includedProperties","diversity","minRelevance","rotationRate","rotationTime","expertSettings"].include? par
104
- end
105
- end
106
-
107
- # HTTP method
108
- def method
109
- :post
110
- end
111
-
112
- # Values of body parameters as a Hash
113
- def body_parameters
114
- p = Hash.new
115
- p['count'] = @count
116
- p['filter'] = @optional['filter'] if @optional.include? 'filter'
117
- p['booster'] = @optional['booster'] if @optional.include? 'booster'
118
- p['allowNonexistent'] = @optional['allowNonexistent'] if @optional.include? 'allowNonexistent'
119
- p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
120
- p['scenario'] = @optional['scenario'] if @optional.include? 'scenario'
121
- p['returnProperties'] = @optional['returnProperties'] if @optional.include? 'returnProperties'
122
- p['includedProperties'] = @optional['includedProperties'] if @optional.include? 'includedProperties'
123
- p['diversity'] = @optional['diversity'] if @optional.include? 'diversity'
124
- p['minRelevance'] = @optional['minRelevance'] if @optional.include? 'minRelevance'
125
- p['rotationRate'] = @optional['rotationRate'] if @optional.include? 'rotationRate'
126
- p['rotationTime'] = @optional['rotationTime'] if @optional.include? 'rotationTime'
127
- p['expertSettings'] = @optional['expertSettings'] if @optional.include? 'expertSettings'
128
- p
129
- end
130
-
131
- # Values of query parameters as a Hash.
132
- # name of parameter => value of the parameter
133
- def query_parameters
134
- params = {}
135
- params
136
- end
137
-
138
- # Relative path to the endpoint
139
- def path
140
- "/{databaseId}/users/#{@user_id}/recomms/"
141
- end
142
- end
143
- end