recombee_api_client 2.1.0 → 3.1.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,178 @@
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
+ #Full-text personalized search. The results are based on the provided `searchQuery` and also on the user's past interactions (purchases, ratings, etc.) with the items (items more suitable for the user are preferred in the results).
11
+ #
12
+ #All the string and set item properties are indexed by the search engine.
13
+ #
14
+ #This endpoint should be used in a search box at your website/app. It can be called multiple times as the user is typing the query in order to get the most viable suggestions based on current state of the query, or once after submitting the whole query.
15
+ #
16
+ #The returned items are sorted by relevance (first item being the most relevant).
17
+ #
18
+ #Besides the recommended items, also a unique `recommId` is returned in the response. It can be used to:
19
+ #
20
+ #- Let Recombee know that this search was successful (e.g. user clicked one of the recommended items). See [Reported metrics](https://docs.recombee.com/admin_ui.html#reported-metrics).
21
+ #- Get subsequent search results when the user scrolls down or goes to the next page. See [Recommend Next Items](https://docs.recombee.com/api.html#recommend-next-items).
22
+ #
23
+ #It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters.
24
+ #
25
+ class SearchItems < ApiRequest
26
+ attr_reader :user_id, :search_query, :count, :scenario, :cascade_create, :return_properties, :included_properties, :filter, :booster, :logic, :expert_settings, :return_ab_group
27
+ attr_accessor :timeout
28
+ attr_accessor :ensure_https
29
+
30
+ ##
31
+ # * *Required arguments*
32
+ # - +user_id+ -> ID of the user for whom personalized search will be performed.
33
+ # - +search_query+ -> Search query provided by the user. It is used for the full-text search.
34
+ # - +count+ -> Number of items to be returned (N for the top-N results).
35
+ #
36
+ # * *Optional arguments (given as hash optional)*
37
+ # - +scenario+ -> Scenario defines a particular search field in your user interface.
38
+ #
39
+ #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 field performs.
40
+ #
41
+ #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
+ #
43
+ # - +cascadeCreate+ -> If the user does not exist in the database, returns a list of non-personalized search results 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.
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
+ # "recommId": "ce52ada4-e4d9-4885-943c-407db2dee837",
50
+ # "recomms":
51
+ # [
52
+ # {
53
+ # "id": "tv-178",
54
+ # "values": {
55
+ # "description": "4K TV with 3D feature",
56
+ # "categories": ["Electronics", "Televisions"],
57
+ # "price": 342,
58
+ # "url": "myshop.com/tv-178"
59
+ # }
60
+ # },
61
+ # {
62
+ # "id": "mixer-42",
63
+ # "values": {
64
+ # "description": "Stainless Steel Mixer",
65
+ # "categories": ["Home & Kitchen"],
66
+ # "price": 39,
67
+ # "url": "myshop.com/mixer-42"
68
+ # }
69
+ # }
70
+ # ],
71
+ # "numberNextRecommsCalls": 0
72
+ # }
73
+ #```
74
+ #
75
+ # - +includedProperties+ -> Allows to specify, which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list.
76
+ #
77
+ #Example response for `includedProperties=description,price`:
78
+ #```
79
+ # {
80
+ # "recommId": "a86ee8d5-cd8e-46d1-886c-8b3771d0520b",
81
+ # "recomms":
82
+ # [
83
+ # {
84
+ # "id": "tv-178",
85
+ # "values": {
86
+ # "description": "4K TV with 3D feature",
87
+ # "price": 342
88
+ # }
89
+ # },
90
+ # {
91
+ # "id": "mixer-42",
92
+ # "values": {
93
+ # "description": "Stainless Steel Mixer",
94
+ # "price": 39
95
+ # }
96
+ # }
97
+ # ],
98
+ # "numberNextRecommsCalls": 0
99
+ # }
100
+ #```
101
+ #
102
+ # - +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.
103
+ #
104
+ #Filters can be also assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com).
105
+ #
106
+ # - +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.
107
+ #
108
+ #Boosters can be also assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com).
109
+ #
110
+ # - +logic+ -> Logic specifies particular behavior of the recommendation models. You can pick tailored logic for your domain and use case.
111
+ #See [this section](https://docs.recombee.com/recommendation_logics.html) for list of available logics and other details.
112
+ #
113
+ #The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
114
+ #
115
+ #Logic can be also set to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com).
116
+ #
117
+ # - +expertSettings+ -> Dictionary of custom options.
118
+ #
119
+ # - +returnAbGroup+ -> If there is a custom AB-testing running, return name of group to which the request belongs.
120
+ #
121
+ #
122
+ def initialize(user_id, search_query, count, optional = {})
123
+ @user_id = user_id
124
+ @search_query = search_query
125
+ @count = count
126
+ optional = normalize_optional(optional)
127
+ @scenario = optional['scenario']
128
+ @cascade_create = optional['cascadeCreate']
129
+ @return_properties = optional['returnProperties']
130
+ @included_properties = optional['includedProperties']
131
+ @filter = optional['filter']
132
+ @booster = optional['booster']
133
+ @logic = optional['logic']
134
+ @expert_settings = optional['expertSettings']
135
+ @return_ab_group = optional['returnAbGroup']
136
+ @optional = optional
137
+ @timeout = 3000
138
+ @ensure_https = false
139
+ @optional.each do |par, _|
140
+ fail UnknownOptionalParameter.new(par) unless ["scenario","cascadeCreate","returnProperties","includedProperties","filter","booster","logic","expertSettings","returnAbGroup"].include? par
141
+ end
142
+ end
143
+
144
+ # HTTP method
145
+ def method
146
+ :post
147
+ end
148
+
149
+ # Values of body parameters as a Hash
150
+ def body_parameters
151
+ p = Hash.new
152
+ p['searchQuery'] = @search_query
153
+ p['count'] = @count
154
+ p['scenario'] = @optional['scenario'] if @optional.include? 'scenario'
155
+ p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
156
+ p['returnProperties'] = @optional['returnProperties'] if @optional.include? 'returnProperties'
157
+ p['includedProperties'] = @optional['includedProperties'] if @optional.include? 'includedProperties'
158
+ p['filter'] = @optional['filter'] if @optional.include? 'filter'
159
+ p['booster'] = @optional['booster'] if @optional.include? 'booster'
160
+ p['logic'] = @optional['logic'] if @optional.include? 'logic'
161
+ p['expertSettings'] = @optional['expertSettings'] if @optional.include? 'expertSettings'
162
+ p['returnAbGroup'] = @optional['returnAbGroup'] if @optional.include? 'returnAbGroup'
163
+ p
164
+ end
165
+
166
+ # Values of query parameters as a Hash.
167
+ # name of parameter => value of the parameter
168
+ def query_parameters
169
+ params = {}
170
+ params
171
+ end
172
+
173
+ # Relative path to the endpoint
174
+ def path
175
+ "/{databaseId}/search/users/#{@user_id}/items/"
176
+ end
177
+ end
178
+ end
@@ -11,7 +11,7 @@ module RecombeeApiClient
11
11
  #If you send new request with the same (`userId`, `itemId`, `sessionId`), the portion gets updated.
12
12
  #
13
13
  class SetViewPortion < ApiRequest
14
- attr_reader :user_id, :item_id, :portion, :session_id, :timestamp, :cascade_create
14
+ attr_reader :user_id, :item_id, :portion, :session_id, :timestamp, :cascade_create, :recomm_id, :additional_data
15
15
  attr_accessor :timeout
16
16
  attr_accessor :ensure_https
17
17
 
@@ -25,6 +25,8 @@ module RecombeeApiClient
25
25
  # - +sessionId+ -> ID of session in which the user viewed the item. Default is `null` (`None`, `nil`, `NULL` etc. depending on language).
26
26
  # - +timestamp+ -> UTC timestamp of the rating as ISO8601-1 pattern or UTC epoch time. The default value is the current time.
27
27
  # - +cascadeCreate+ -> Sets whether the given user/item should be created if not present in the database.
28
+ # - +recommId+ -> If this view portion is based on a recommendation request, `recommId` is the id of the clicked recommendation.
29
+ # - +additionalData+ -> A dictionary of additional data for the interaction.
28
30
  #
29
31
  def initialize(user_id, item_id, portion, optional = {})
30
32
  @user_id = user_id
@@ -34,11 +36,13 @@ module RecombeeApiClient
34
36
  @session_id = optional['sessionId']
35
37
  @timestamp = optional['timestamp']
36
38
  @cascade_create = optional['cascadeCreate']
39
+ @recomm_id = optional['recommId']
40
+ @additional_data = optional['additionalData']
37
41
  @optional = optional
38
42
  @timeout = 1000
39
43
  @ensure_https = false
40
44
  @optional.each do |par, _|
41
- fail UnknownOptionalParameter.new(par) unless ["sessionId","timestamp","cascadeCreate"].include? par
45
+ fail UnknownOptionalParameter.new(par) unless ["sessionId","timestamp","cascadeCreate","recommId","additionalData"].include? par
42
46
  end
43
47
  end
44
48
 
@@ -56,6 +60,8 @@ module RecombeeApiClient
56
60
  p['sessionId'] = @optional['sessionId'] if @optional.include? 'sessionId'
57
61
  p['timestamp'] = @optional['timestamp'] if @optional.include? 'timestamp'
58
62
  p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
63
+ p['recommId'] = @optional['recommId'] if @optional.include? 'recommId'
64
+ p['additionalData'] = @optional['additionalData'] if @optional.include? 'additionalData'
59
65
  p
60
66
  end
61
67
 
@@ -20,7 +20,7 @@ module RecombeeApiClient
20
20
 
21
21
  ##
22
22
  # * *Required arguments*
23
- # - +user_id+ -> ID of the user for which the personalized recommendations are to be generated.
23
+ # - +user_id+ -> ID of the user for whom the personalized recommendations are to be generated.
24
24
  # - +count+ -> Number of items to be recommended (N for the top-N recommendation).
25
25
  #
26
26
  # * *Optional arguments (given as hash optional)*
@@ -1,3 +1,3 @@
1
1
  module RecombeeApiClient
2
- VERSION = '2.1.0'
2
+ VERSION = '3.1.0'
3
3
  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: 2.1.0
4
+ version: 3.1.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: 2018-04-05 00:00:00.000000000 Z
11
+ date: 2021-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -147,12 +147,14 @@ files:
147
147
  - lib/recombee_api_client/api/merge_users.rb
148
148
  - lib/recombee_api_client/api/recommend_items_to_item.rb
149
149
  - lib/recombee_api_client/api/recommend_items_to_user.rb
150
+ - lib/recombee_api_client/api/recommend_next_items.rb
150
151
  - lib/recombee_api_client/api/recommend_users_to_item.rb
151
152
  - lib/recombee_api_client/api/recommend_users_to_user.rb
152
153
  - lib/recombee_api_client/api/remove_from_group.rb
153
154
  - lib/recombee_api_client/api/remove_from_series.rb
154
155
  - lib/recombee_api_client/api/request.rb
155
156
  - lib/recombee_api_client/api/reset_database.rb
157
+ - lib/recombee_api_client/api/search_items.rb
156
158
  - lib/recombee_api_client/api/set_item_values.rb
157
159
  - lib/recombee_api_client/api/set_user_values.rb
158
160
  - lib/recombee_api_client/api/set_values.rb
@@ -180,8 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
182
  - !ruby/object:Gem::Version
181
183
  version: '0'
182
184
  requirements: []
183
- rubyforge_project:
184
- rubygems_version: 2.6.11
185
+ rubygems_version: 3.1.2
185
186
  signing_key:
186
187
  specification_version: 4
187
188
  summary: Client for Recombee recommendation API