recombee_api_client 2.2.0 → 3.2.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.
@@ -0,0 +1,59 @@
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
+ #Gives the list of synonyms defined in the database.
11
+ class ListSearchSynonyms < ApiRequest
12
+ attr_reader :count, :offset
13
+ attr_accessor :timeout
14
+ attr_accessor :ensure_https
15
+
16
+ ##
17
+ #
18
+ # * *Optional arguments (given as hash optional)*
19
+ # - +count+ -> The number of synonyms to be listed.
20
+ # - +offset+ -> Specifies the number of synonyms to skip (ordered by `term`).
21
+ #
22
+ def initialize(optional = {})
23
+ optional = normalize_optional(optional)
24
+ @count = optional['count']
25
+ @offset = optional['offset']
26
+ @optional = optional
27
+ @timeout = 100000
28
+ @ensure_https = false
29
+ @optional.each do |par, _|
30
+ fail UnknownOptionalParameter.new(par) unless ["count","offset"].include? par
31
+ end
32
+ end
33
+
34
+ # HTTP method
35
+ def method
36
+ :get
37
+ end
38
+
39
+ # Values of body parameters as a Hash
40
+ def body_parameters
41
+ p = Hash.new
42
+ p
43
+ end
44
+
45
+ # Values of query parameters as a Hash.
46
+ # name of parameter => value of the parameter
47
+ def query_parameters
48
+ params = {}
49
+ params['count'] = @optional['count'] if @optional['count']
50
+ params['offset'] = @optional['offset'] if @optional['offset']
51
+ params
52
+ end
53
+
54
+ # Relative path to the endpoint
55
+ def path
56
+ "/{databaseId}/synonyms/items/"
57
+ end
58
+ end
59
+ end
@@ -9,10 +9,17 @@ module RecombeeApiClient
9
9
  ##
10
10
  #Recommends set of items that are somehow related to one given item, *X*. Typical scenario is when user *A* is viewing *X*. Then you may display items to the user that he might be also interested in. Recommend items to item request gives you Top-N such items, optionally taking the target user *A* into account.
11
11
  #
12
+ #The returned items are sorted by relevance (first item being the most relevant).
13
+ #
14
+ #Besides the recommended items, also a unique `recommId` is returned in the response. It can be used to:
15
+ #
16
+ #- Let Recombee know that this recommendation was successful (e.g. user clicked one of the recommended items). See [Reported metrics](https://docs.recombee.com/admin_ui.html#reported-metrics).
17
+ #- Get subsequent recommended items when the user scrolls down (*infinite scroll*) or goes to the next page. See [Recommend Next Items](https://docs.recombee.com/api.html#recommend-next-items).
18
+ #
12
19
  #It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters.
13
20
  #
14
21
  class RecommendItemsToItem < ApiRequest
15
- attr_reader :item_id, :target_user_id, :count, :user_impact, :filter, :booster, :cascade_create, :scenario, :return_properties, :included_properties, :diversity, :min_relevance, :rotation_rate, :rotation_time, :expert_settings
22
+ attr_reader :item_id, :target_user_id, :count, :scenario, :cascade_create, :return_properties, :included_properties, :filter, :booster, :logic, :user_impact, :diversity, :min_relevance, :rotation_rate, :rotation_time, :expert_settings, :return_ab_group
16
23
  attr_accessor :timeout
17
24
  attr_accessor :ensure_https
18
25
 
@@ -40,12 +47,13 @@ module RecombeeApiClient
40
47
  # - +count+ -> Number of items to be recommended (N for the top-N recommendation).
41
48
  #
42
49
  # * *Optional arguments (given as hash optional)*
43
- # - +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`.
50
+ # - +scenario+ -> Scenario defines a particular application of recommendations. It can be for example "homepage", "cart" or "emailing".
51
+ #
52
+ #You can set various settings to the [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). You can also see performance of each scenario in the Admin UI separately, so you can check how well each application performs.
53
+ #
54
+ #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
55
  #
45
- # - +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.
46
- # - +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.
47
56
  # - +cascadeCreate+ -> If item of given *itemId* or user of given *targetUserId* doesn't exist in the database, it creates the missing entity/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.
48
- # - +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.
49
57
  # - +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.
50
58
  #
51
59
  #Example response:
@@ -72,7 +80,8 @@ module RecombeeApiClient
72
80
  # "url": "myshop.com/mixer-42"
73
81
  # }
74
82
  # }
75
- # ]
83
+ # ],
84
+ # "numberNextRecommsCalls": 0
76
85
  # }
77
86
  #```
78
87
  #
@@ -98,13 +107,31 @@ module RecombeeApiClient
98
107
  # "price": 39
99
108
  # }
100
109
  # }
101
- # ]
110
+ # ],
111
+ # "numberNextRecommsCalls": 0
102
112
  # }
103
113
  #```
104
114
  #
115
+ # - +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.
116
+ #
117
+ #Filters can be also assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com).
118
+ #
119
+ # - +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.
120
+ #
121
+ #Boosters can be also assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com).
122
+ #
123
+ # - +logic+ -> Logic specifies particular behavior of the recommendation models. You can pick tailored logic for your domain and use case.
124
+ #See [this section](https://docs.recombee.com/recommendation_logics.html) for list of available logics and other details.
125
+ #
126
+ #The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
127
+ #
128
+ #Logic can be also set to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com).
129
+ #
130
+ # - +userImpact+ -> **Expert option** If *targetUserId* parameter is present, the recommendations are biased towards the given user. 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`.
131
+ #
105
132
  # - +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.
106
133
  #
107
- # - +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 relevancy, and may return less than *count* items when there is not enough data to fulfill it.
134
+ # - +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 relevance, and may return less than *count* items when there is not enough data to fulfill it.
108
135
  #
109
136
  # - +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.
110
137
  #
@@ -112,29 +139,33 @@ module RecombeeApiClient
112
139
  #
113
140
  # - +expertSettings+ -> Dictionary of custom options.
114
141
  #
142
+ # - +returnAbGroup+ -> If there is a custom AB-testing running, return name of group to which the request belongs.
143
+ #
115
144
  #
116
145
  def initialize(item_id, target_user_id, count, optional = {})
117
146
  @item_id = item_id
118
147
  @target_user_id = target_user_id
119
148
  @count = count
120
149
  optional = normalize_optional(optional)
121
- @user_impact = optional['userImpact']
122
- @filter = optional['filter']
123
- @booster = optional['booster']
124
- @cascade_create = optional['cascadeCreate']
125
150
  @scenario = optional['scenario']
151
+ @cascade_create = optional['cascadeCreate']
126
152
  @return_properties = optional['returnProperties']
127
153
  @included_properties = optional['includedProperties']
154
+ @filter = optional['filter']
155
+ @booster = optional['booster']
156
+ @logic = optional['logic']
157
+ @user_impact = optional['userImpact']
128
158
  @diversity = optional['diversity']
129
159
  @min_relevance = optional['minRelevance']
130
160
  @rotation_rate = optional['rotationRate']
131
161
  @rotation_time = optional['rotationTime']
132
162
  @expert_settings = optional['expertSettings']
163
+ @return_ab_group = optional['returnAbGroup']
133
164
  @optional = optional
134
165
  @timeout = 3000
135
166
  @ensure_https = false
136
167
  @optional.each do |par, _|
137
- fail UnknownOptionalParameter.new(par) unless ["userImpact","filter","booster","cascadeCreate","scenario","returnProperties","includedProperties","diversity","minRelevance","rotationRate","rotationTime","expertSettings"].include? par
168
+ fail UnknownOptionalParameter.new(par) unless ["scenario","cascadeCreate","returnProperties","includedProperties","filter","booster","logic","userImpact","diversity","minRelevance","rotationRate","rotationTime","expertSettings","returnAbGroup"].include? par
138
169
  end
139
170
  end
140
171
 
@@ -148,18 +179,20 @@ module RecombeeApiClient
148
179
  p = Hash.new
149
180
  p['targetUserId'] = @target_user_id
150
181
  p['count'] = @count
151
- p['userImpact'] = @optional['userImpact'] if @optional.include? 'userImpact'
152
- p['filter'] = @optional['filter'] if @optional.include? 'filter'
153
- p['booster'] = @optional['booster'] if @optional.include? 'booster'
154
- p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
155
182
  p['scenario'] = @optional['scenario'] if @optional.include? 'scenario'
183
+ p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
156
184
  p['returnProperties'] = @optional['returnProperties'] if @optional.include? 'returnProperties'
157
185
  p['includedProperties'] = @optional['includedProperties'] if @optional.include? 'includedProperties'
186
+ p['filter'] = @optional['filter'] if @optional.include? 'filter'
187
+ p['booster'] = @optional['booster'] if @optional.include? 'booster'
188
+ p['logic'] = @optional['logic'] if @optional.include? 'logic'
189
+ p['userImpact'] = @optional['userImpact'] if @optional.include? 'userImpact'
158
190
  p['diversity'] = @optional['diversity'] if @optional.include? 'diversity'
159
191
  p['minRelevance'] = @optional['minRelevance'] if @optional.include? 'minRelevance'
160
192
  p['rotationRate'] = @optional['rotationRate'] if @optional.include? 'rotationRate'
161
193
  p['rotationTime'] = @optional['rotationTime'] if @optional.include? 'rotationTime'
162
194
  p['expertSettings'] = @optional['expertSettings'] if @optional.include? 'expertSettings'
195
+ p['returnAbGroup'] = @optional['returnAbGroup'] if @optional.include? 'returnAbGroup'
163
196
  p
164
197
  end
165
198
 
@@ -9,23 +9,37 @@ module RecombeeApiClient
9
9
  ##
10
10
  #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.
11
11
  #
12
+ #The most typical use cases are recommendations at homepage, in some "Picked just for you" section or in email.
13
+ #
14
+ #The returned items are sorted by relevance (first item being the most relevant).
15
+ #
16
+ #Besides the recommended items, also a unique `recommId` is returned in the response. It can be used to:
17
+ #
18
+ #- Let Recombee know that this recommendation was successful (e.g. user clicked one of the recommended items). See [Reported metrics](https://docs.recombee.com/admin_ui.html#reported-metrics).
19
+ #- Get subsequent recommended items when the user scrolls down (*infinite scroll*) or goes to the next page. See [Recommend Next Items](https://docs.recombee.com/api.html#recommend-next-items).
20
+ #
12
21
  #It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters.
13
22
  #
14
23
  class RecommendItemsToUser < ApiRequest
15
- attr_reader :user_id, :count, :filter, :booster, :cascade_create, :scenario, :return_properties, :included_properties, :diversity, :min_relevance, :rotation_rate, :rotation_time, :expert_settings
24
+ attr_reader :user_id, :count, :scenario, :cascade_create, :return_properties, :included_properties, :filter, :booster, :logic, :diversity, :min_relevance, :rotation_rate, :rotation_time, :expert_settings, :return_ab_group
16
25
  attr_accessor :timeout
17
26
  attr_accessor :ensure_https
18
27
 
19
28
  ##
20
29
  # * *Required arguments*
21
- # - +user_id+ -> ID of the user for which personalized recommendations are to be generated.
30
+ # - +user_id+ -> ID of the user for whom personalized recommendations are to be generated.
22
31
  # - +count+ -> Number of items to be recommended (N for the top-N recommendation).
23
32
  #
33
+ #
24
34
  # * *Optional arguments (given as hash optional)*
25
- # - +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.
26
- # - +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.
35
+ # - +scenario+ -> Scenario defines a particular application of recommendations. It can be for example "homepage", "cart" or "emailing".
36
+ #
37
+ #You can set various settings to the [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). You can also see performance of each scenario in the Admin UI separately, so you can check how well each application performs.
38
+ #
39
+ #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.
40
+ #
27
41
  # - +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.
28
- # - +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.
42
+ #
29
43
  # - +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.
30
44
  #
31
45
  #Example response:
@@ -52,7 +66,8 @@ module RecombeeApiClient
52
66
  # "url": "myshop.com/mixer-42"
53
67
  # }
54
68
  # }
55
- # ]
69
+ # ],
70
+ # "numberNextRecommsCalls": 0
56
71
  # }
57
72
  #```
58
73
  #
@@ -78,13 +93,29 @@ module RecombeeApiClient
78
93
  # "price": 39
79
94
  # }
80
95
  # }
81
- # ]
96
+ # ],
97
+ # "numberNextRecommsCalls": 0
82
98
  # }
83
99
  #```
84
100
  #
101
+ # - +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.
102
+ #
103
+ #Filters can be also assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com).
104
+ #
105
+ # - +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.
106
+ #
107
+ #Boosters can be also assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com).
108
+ #
109
+ # - +logic+ -> Logic specifies particular behavior of the recommendation models. You can pick tailored logic for your domain and use case.
110
+ #See [this section](https://docs.recombee.com/recommendation_logics.html) for list of available logics and other details.
111
+ #
112
+ #The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
113
+ #
114
+ #Logic can be also set to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com).
115
+ #
85
116
  # - +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.
86
117
  #
87
- # - +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 relevancy, and may return less than *count* items when there is not enough data to fulfill it.
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.
88
119
  #
89
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`.
90
121
  #
@@ -92,27 +123,31 @@ module RecombeeApiClient
92
123
  #
93
124
  # - +expertSettings+ -> Dictionary of custom options.
94
125
  #
126
+ # - +returnAbGroup+ -> If there is a custom AB-testing running, return name of group to which the request belongs.
127
+ #
95
128
  #
96
129
  def initialize(user_id, count, optional = {})
97
130
  @user_id = user_id
98
131
  @count = count
99
132
  optional = normalize_optional(optional)
100
- @filter = optional['filter']
101
- @booster = optional['booster']
102
- @cascade_create = optional['cascadeCreate']
103
133
  @scenario = optional['scenario']
134
+ @cascade_create = optional['cascadeCreate']
104
135
  @return_properties = optional['returnProperties']
105
136
  @included_properties = optional['includedProperties']
137
+ @filter = optional['filter']
138
+ @booster = optional['booster']
139
+ @logic = optional['logic']
106
140
  @diversity = optional['diversity']
107
141
  @min_relevance = optional['minRelevance']
108
142
  @rotation_rate = optional['rotationRate']
109
143
  @rotation_time = optional['rotationTime']
110
144
  @expert_settings = optional['expertSettings']
145
+ @return_ab_group = optional['returnAbGroup']
111
146
  @optional = optional
112
147
  @timeout = 3000
113
148
  @ensure_https = false
114
149
  @optional.each do |par, _|
115
- fail UnknownOptionalParameter.new(par) unless ["filter","booster","cascadeCreate","scenario","returnProperties","includedProperties","diversity","minRelevance","rotationRate","rotationTime","expertSettings"].include? par
150
+ fail UnknownOptionalParameter.new(par) unless ["scenario","cascadeCreate","returnProperties","includedProperties","filter","booster","logic","diversity","minRelevance","rotationRate","rotationTime","expertSettings","returnAbGroup"].include? par
116
151
  end
117
152
  end
118
153
 
@@ -125,17 +160,19 @@ module RecombeeApiClient
125
160
  def body_parameters
126
161
  p = Hash.new
127
162
  p['count'] = @count
128
- p['filter'] = @optional['filter'] if @optional.include? 'filter'
129
- p['booster'] = @optional['booster'] if @optional.include? 'booster'
130
- p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
131
163
  p['scenario'] = @optional['scenario'] if @optional.include? 'scenario'
164
+ p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
132
165
  p['returnProperties'] = @optional['returnProperties'] if @optional.include? 'returnProperties'
133
166
  p['includedProperties'] = @optional['includedProperties'] if @optional.include? 'includedProperties'
167
+ p['filter'] = @optional['filter'] if @optional.include? 'filter'
168
+ p['booster'] = @optional['booster'] if @optional.include? 'booster'
169
+ p['logic'] = @optional['logic'] if @optional.include? 'logic'
134
170
  p['diversity'] = @optional['diversity'] if @optional.include? 'diversity'
135
171
  p['minRelevance'] = @optional['minRelevance'] if @optional.include? 'minRelevance'
136
172
  p['rotationRate'] = @optional['rotationRate'] if @optional.include? 'rotationRate'
137
173
  p['rotationTime'] = @optional['rotationTime'] if @optional.include? 'rotationTime'
138
174
  p['expertSettings'] = @optional['expertSettings'] if @optional.include? 'expertSettings'
175
+ p['returnAbGroup'] = @optional['returnAbGroup'] if @optional.include? 'returnAbGroup'
139
176
  p
140
177
  end
141
178
 
@@ -0,0 +1,69 @@
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
+ #Returns items that shall be shown to a user as next recommendations when the user e.g. scrolls the page down (*infinite scroll*) or goes to a next page.
11
+ #
12
+ #It accepts `recommId` of a base recommendation request (e.g. request from the first page) and number of items that shall be returned (`count`).
13
+ #The base request can be one of:
14
+ # - [Recommend items to item](https://docs.recombee.com/api.html#recommend-items-to-item)
15
+ # - [Recommend items to user](https://docs.recombee.com/api.html#recommend-items-to-user)
16
+ # - [Search items](https://docs.recombee.com/api.html#search-items)
17
+ #
18
+ #All the other parameters are inherited from the base request.
19
+ #
20
+ #*Recommend next items* can be called many times for a single `recommId` and each call returns different (previously not recommended) items.
21
+ #The number of *Recommend next items* calls performed so far is returned in the `numberNextRecommsCalls` field.
22
+ #
23
+ #*Recommend next items* can be requested up to 30 minutes after the base request or a previous *Recommend next items* call.
24
+ #
25
+ #For billing purposes, each call to *Recommend next items* is counted as a separate recommendation request.
26
+ #
27
+ class RecommendNextItems < ApiRequest
28
+ attr_reader :recomm_id, :count
29
+ attr_accessor :timeout
30
+ attr_accessor :ensure_https
31
+
32
+ ##
33
+ # * *Required arguments*
34
+ # - +recomm_id+ -> ID of the base recommendation request for which next recommendations should be returned
35
+ # - +count+ -> Number of items to be recommended
36
+ #
37
+ #
38
+ def initialize(recomm_id, count)
39
+ @recomm_id = recomm_id
40
+ @count = count
41
+ @timeout = 3000
42
+ @ensure_https = false
43
+ end
44
+
45
+ # HTTP method
46
+ def method
47
+ :post
48
+ end
49
+
50
+ # Values of body parameters as a Hash
51
+ def body_parameters
52
+ p = Hash.new
53
+ p['count'] = @count
54
+ p
55
+ end
56
+
57
+ # Values of query parameters as a Hash.
58
+ # name of parameter => value of the parameter
59
+ def query_parameters
60
+ params = {}
61
+ params
62
+ end
63
+
64
+ # Relative path to the endpoint
65
+ def path
66
+ "/{databaseId}/recomms/next/items/#{@recomm_id}"
67
+ end
68
+ end
69
+ end
@@ -11,8 +11,10 @@ module RecombeeApiClient
11
11
  #
12
12
  #It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters.
13
13
  #
14
+ #The returned users are sorted by predicted interest in the item (first user being the most interested).
15
+ #
14
16
  class RecommendUsersToItem < ApiRequest
15
- attr_reader :item_id, :count, :filter, :booster, :cascade_create, :scenario, :return_properties, :included_properties, :diversity, :expert_settings
17
+ attr_reader :item_id, :count, :scenario, :cascade_create, :return_properties, :included_properties, :filter, :booster, :logic, :diversity, :expert_settings, :return_ab_group
16
18
  attr_accessor :timeout
17
19
  attr_accessor :ensure_https
18
20
 
@@ -22,10 +24,13 @@ module RecombeeApiClient
22
24
  # - +count+ -> Number of items to be recommended (N for the top-N recommendation).
23
25
  #
24
26
  # * *Optional arguments (given as hash optional)*
25
- # - +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.
26
- # - +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.
27
+ # - +scenario+ -> Scenario defines a particular application of recommendations. It can be for example "homepage", "cart" or "emailing".
28
+ #
29
+ #You can set various settings to the [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). You can also see performance of each scenario in the Admin UI separately, so you can check how well each application performs.
30
+ #
31
+ #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
+ #
27
33
  # - +cascadeCreate+ -> If item of given *itemId* doesn't exist in the database, it creates the missing item.
28
- # - +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.
29
34
  # - +returnProperties+ -> With `returnProperties=true`, property values of the recommended users are returned along with their IDs in a JSON dictionary. The acquired property values can be used for easy displaying the recommended users.
30
35
  #
31
36
  #Example response:
@@ -48,7 +53,8 @@ module RecombeeApiClient
48
53
  # "sex": "M"
49
54
  # }
50
55
  # }
51
- # ]
56
+ # ],
57
+ # "numberNextRecommsCalls": 0
52
58
  # }
53
59
  #```
54
60
  #
@@ -72,32 +78,52 @@ module RecombeeApiClient
72
78
  # "country": "CAN"
73
79
  # }
74
80
  # }
75
- # ]
81
+ # ],
82
+ # "numberNextRecommsCalls": 0
76
83
  # }
77
84
  #```
78
85
  #
86
+ # - +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.
87
+ #
88
+ #Filters can be also assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com).
89
+ #
90
+ # - +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.
91
+ #
92
+ #Boosters can be also assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com).
93
+ #
94
+ # - +logic+ -> Logic specifies particular behavior of the recommendation models. You can pick tailored logic for your domain and use case.
95
+ #See [this section](https://docs.recombee.com/recommendation_logics.html) for list of available logics and other details.
96
+ #
97
+ #The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
98
+ #
99
+ #Logic can be also set to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com).
100
+ #
79
101
  # - +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.
80
102
  #
81
103
  # - +expertSettings+ -> Dictionary of custom options.
82
104
  #
105
+ # - +returnAbGroup+ -> If there is a custom AB-testing running, return name of group to which the request belongs.
106
+ #
83
107
  #
84
108
  def initialize(item_id, count, optional = {})
85
109
  @item_id = item_id
86
110
  @count = count
87
111
  optional = normalize_optional(optional)
88
- @filter = optional['filter']
89
- @booster = optional['booster']
90
- @cascade_create = optional['cascadeCreate']
91
112
  @scenario = optional['scenario']
113
+ @cascade_create = optional['cascadeCreate']
92
114
  @return_properties = optional['returnProperties']
93
115
  @included_properties = optional['includedProperties']
116
+ @filter = optional['filter']
117
+ @booster = optional['booster']
118
+ @logic = optional['logic']
94
119
  @diversity = optional['diversity']
95
120
  @expert_settings = optional['expertSettings']
121
+ @return_ab_group = optional['returnAbGroup']
96
122
  @optional = optional
97
123
  @timeout = 50000
98
124
  @ensure_https = false
99
125
  @optional.each do |par, _|
100
- fail UnknownOptionalParameter.new(par) unless ["filter","booster","cascadeCreate","scenario","returnProperties","includedProperties","diversity","expertSettings"].include? par
126
+ fail UnknownOptionalParameter.new(par) unless ["scenario","cascadeCreate","returnProperties","includedProperties","filter","booster","logic","diversity","expertSettings","returnAbGroup"].include? par
101
127
  end
102
128
  end
103
129
 
@@ -110,14 +136,16 @@ module RecombeeApiClient
110
136
  def body_parameters
111
137
  p = Hash.new
112
138
  p['count'] = @count
113
- p['filter'] = @optional['filter'] if @optional.include? 'filter'
114
- p['booster'] = @optional['booster'] if @optional.include? 'booster'
115
- p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
116
139
  p['scenario'] = @optional['scenario'] if @optional.include? 'scenario'
140
+ p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
117
141
  p['returnProperties'] = @optional['returnProperties'] if @optional.include? 'returnProperties'
118
142
  p['includedProperties'] = @optional['includedProperties'] if @optional.include? 'includedProperties'
143
+ p['filter'] = @optional['filter'] if @optional.include? 'filter'
144
+ p['booster'] = @optional['booster'] if @optional.include? 'booster'
145
+ p['logic'] = @optional['logic'] if @optional.include? 'logic'
119
146
  p['diversity'] = @optional['diversity'] if @optional.include? 'diversity'
120
147
  p['expertSettings'] = @optional['expertSettings'] if @optional.include? 'expertSettings'
148
+ p['returnAbGroup'] = @optional['returnAbGroup'] if @optional.include? 'returnAbGroup'
121
149
  p
122
150
  end
123
151