recombee_api_client 5.1.0 → 6.0.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.
- checksums.yaml +4 -4
- data/lib/recombee_api_client/api/add_bookmark.rb +26 -26
- data/lib/recombee_api_client/api/add_cart_addition.rb +28 -28
- data/lib/recombee_api_client/api/add_detail_view.rb +32 -28
- data/lib/recombee_api_client/api/add_item.rb +15 -18
- data/lib/recombee_api_client/api/add_item_property.rb +34 -35
- data/lib/recombee_api_client/api/add_manual_reql_segment.rb +26 -27
- data/lib/recombee_api_client/api/add_purchase.rb +29 -29
- data/lib/recombee_api_client/api/add_rating.rb +27 -27
- data/lib/recombee_api_client/api/add_search_synonym.rb +29 -30
- data/lib/recombee_api_client/api/add_series.rb +20 -21
- data/lib/recombee_api_client/api/add_user.rb +14 -17
- data/lib/recombee_api_client/api/add_user_property.rb +30 -31
- data/lib/recombee_api_client/api/batch.rb +12 -16
- data/lib/recombee_api_client/api/composite_recommendation.rb +132 -0
- data/lib/recombee_api_client/api/create_auto_reql_segmentation.rb +29 -30
- data/lib/recombee_api_client/api/create_manual_reql_segmentation.rb +27 -28
- data/lib/recombee_api_client/api/create_property_based_segmentation.rb +30 -31
- data/lib/recombee_api_client/api/delete_all_search_synonyms.rb +15 -19
- data/lib/recombee_api_client/api/delete_bookmark.rb +21 -22
- data/lib/recombee_api_client/api/delete_cart_addition.rb +21 -22
- data/lib/recombee_api_client/api/delete_detail_view.rb +21 -22
- data/lib/recombee_api_client/api/delete_item.rb +16 -19
- data/lib/recombee_api_client/api/delete_item_property.rb +15 -18
- data/lib/recombee_api_client/api/delete_manual_reql_segment.rb +16 -19
- data/lib/recombee_api_client/api/delete_more_items.rb +18 -19
- data/lib/recombee_api_client/api/delete_purchase.rb +21 -22
- data/lib/recombee_api_client/api/delete_rating.rb +21 -22
- data/lib/recombee_api_client/api/delete_search_synonym.rb +15 -18
- data/lib/recombee_api_client/api/delete_segmentation.rb +15 -18
- data/lib/recombee_api_client/api/delete_series.rb +21 -22
- data/lib/recombee_api_client/api/delete_user.rb +15 -18
- data/lib/recombee_api_client/api/delete_user_property.rb +15 -18
- data/lib/recombee_api_client/api/delete_view_portion.rb +21 -22
- data/lib/recombee_api_client/api/get_item_property_info.rb +14 -17
- data/lib/recombee_api_client/api/get_item_values.rb +15 -18
- data/lib/recombee_api_client/api/get_segmentation.rb +15 -18
- data/lib/recombee_api_client/api/get_user_property_info.rb +15 -18
- data/lib/recombee_api_client/api/get_user_values.rb +15 -18
- data/lib/recombee_api_client/api/insert_to_series.rb +23 -24
- data/lib/recombee_api_client/api/list_item_bookmarks.rb +16 -19
- data/lib/recombee_api_client/api/list_item_cart_additions.rb +16 -19
- data/lib/recombee_api_client/api/list_item_detail_views.rb +16 -19
- data/lib/recombee_api_client/api/list_item_properties.rb +15 -19
- data/lib/recombee_api_client/api/list_item_purchases.rb +16 -19
- data/lib/recombee_api_client/api/list_item_ratings.rb +16 -19
- data/lib/recombee_api_client/api/list_item_view_portions.rb +16 -19
- data/lib/recombee_api_client/api/list_items.rb +62 -62
- data/lib/recombee_api_client/api/list_scenarios.rb +15 -19
- data/lib/recombee_api_client/api/list_search_synonyms.rb +20 -21
- data/lib/recombee_api_client/api/list_segmentations.rb +16 -17
- data/lib/recombee_api_client/api/list_series.rb +15 -19
- data/lib/recombee_api_client/api/list_series_items.rb +15 -18
- data/lib/recombee_api_client/api/list_user_bookmarks.rb +15 -18
- data/lib/recombee_api_client/api/list_user_cart_additions.rb +15 -18
- data/lib/recombee_api_client/api/list_user_detail_views.rb +15 -18
- data/lib/recombee_api_client/api/list_user_properties.rb +15 -19
- data/lib/recombee_api_client/api/list_user_purchases.rb +15 -18
- data/lib/recombee_api_client/api/list_user_ratings.rb +15 -18
- data/lib/recombee_api_client/api/list_user_view_portions.rb +15 -18
- data/lib/recombee_api_client/api/list_users.rb +56 -56
- data/lib/recombee_api_client/api/merge_users.rb +24 -25
- data/lib/recombee_api_client/api/recommend_item_segments_to_item.rb +69 -68
- data/lib/recombee_api_client/api/recommend_item_segments_to_item_segment.rb +70 -69
- data/lib/recombee_api_client/api/recommend_item_segments_to_user.rb +51 -50
- data/lib/recombee_api_client/api/recommend_items_to_item.rb +185 -139
- data/lib/recombee_api_client/api/recommend_items_to_item_segment.rb +181 -138
- data/lib/recombee_api_client/api/recommend_items_to_user.rb +165 -122
- data/lib/recombee_api_client/api/recommend_next_items.rb +24 -25
- data/lib/recombee_api_client/api/recommend_users_to_item.rb +151 -105
- data/lib/recombee_api_client/api/recommend_users_to_user.rb +154 -111
- data/lib/recombee_api_client/api/remove_from_series.rb +17 -18
- data/lib/recombee_api_client/api/request.rb +1 -1
- data/lib/recombee_api_client/api/reset_database.rb +15 -19
- data/lib/recombee_api_client/api/search_item_segments.rb +52 -51
- data/lib/recombee_api_client/api/search_items.rb +157 -114
- data/lib/recombee_api_client/api/set_item_values.rb +28 -29
- data/lib/recombee_api_client/api/set_user_values.rb +21 -22
- data/lib/recombee_api_client/api/set_values.rb +28 -28
- data/lib/recombee_api_client/api/set_view_portion.rb +37 -30
- data/lib/recombee_api_client/api/update_auto_reql_segmentation.rb +26 -27
- data/lib/recombee_api_client/api/update_manual_reql_segment.rb +25 -26
- data/lib/recombee_api_client/api/update_manual_reql_segmentation.rb +24 -25
- data/lib/recombee_api_client/api/update_more_items.rb +19 -20
- data/lib/recombee_api_client/api/update_property_based_segmentation.rb +26 -27
- data/lib/recombee_api_client/errors.rb +2 -5
- data/lib/recombee_api_client/inputs/composite_recommendation_stage_parameters.rb +240 -0
- data/lib/recombee_api_client/inputs/input.rb +9 -0
- data/lib/recombee_api_client/inputs/logic.rb +45 -0
- data/lib/recombee_api_client/utils/hash_normalizer.rb +21 -0
- data/lib/recombee_api_client/version.rb +1 -1
- data/lib/recombee_api_client.rb +40 -35
- data/recombee_api_client.gemspec +2 -3
- metadata +14 -10
- data/lib/recombee_api_client/api/hash_normalizer.rb +0 -21
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
module RecombeeApiClient
|
|
6
6
|
require_relative 'request'
|
|
7
7
|
require_relative '../errors'
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
##
|
|
10
|
-
#Updates (some) property values of all the items that pass the filter.
|
|
10
|
+
# Updates (some) property values of all the items that pass the filter.
|
|
11
11
|
#
|
|
12
|
-
#Example: *Setting all the items that are older than a week as unavailable*
|
|
12
|
+
# Example: *Setting all the items that are older than a week as unavailable*
|
|
13
13
|
#
|
|
14
14
|
# ```json
|
|
15
15
|
# {
|
|
@@ -20,44 +20,43 @@ module RecombeeApiClient
|
|
|
20
20
|
#
|
|
21
21
|
class UpdateMoreItems < ApiRequest
|
|
22
22
|
attr_reader :filter, :changes
|
|
23
|
-
attr_accessor :timeout
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
#
|
|
23
|
+
attr_accessor :timeout, :ensure_https
|
|
24
|
+
|
|
25
|
+
##
|
|
26
|
+
# * *Required arguments*
|
|
27
|
+
# - +filter+ -> A [ReQL](https://docs.recombee.com/reql) expression, which returns `true` for the items that shall be updated.
|
|
28
|
+
# - +changes+ -> A dictionary where the keys are properties that shall be updated.
|
|
29
|
+
#
|
|
31
30
|
def initialize(filter, changes)
|
|
32
31
|
@filter = filter
|
|
33
32
|
@changes = changes
|
|
34
|
-
@timeout =
|
|
33
|
+
@timeout = 100_000
|
|
35
34
|
@ensure_https = false
|
|
36
35
|
end
|
|
37
|
-
|
|
36
|
+
|
|
38
37
|
# HTTP method
|
|
39
38
|
def method
|
|
40
39
|
:post
|
|
41
40
|
end
|
|
42
|
-
|
|
41
|
+
|
|
43
42
|
# Values of body parameters as a Hash
|
|
44
43
|
def body_parameters
|
|
45
|
-
p =
|
|
44
|
+
p = {}
|
|
46
45
|
p['filter'] = @filter
|
|
47
46
|
p['changes'] = @changes
|
|
47
|
+
|
|
48
48
|
p
|
|
49
49
|
end
|
|
50
|
-
|
|
50
|
+
|
|
51
51
|
# Values of query parameters as a Hash.
|
|
52
52
|
# name of parameter => value of the parameter
|
|
53
53
|
def query_parameters
|
|
54
|
-
|
|
55
|
-
params
|
|
54
|
+
{}
|
|
56
55
|
end
|
|
57
|
-
|
|
56
|
+
|
|
58
57
|
# Relative path to the endpoint
|
|
59
58
|
def path
|
|
60
|
-
|
|
59
|
+
'/{databaseId}/more-items/'
|
|
61
60
|
end
|
|
62
61
|
end
|
|
63
62
|
end
|
|
@@ -5,62 +5,61 @@
|
|
|
5
5
|
module RecombeeApiClient
|
|
6
6
|
require_relative 'request'
|
|
7
7
|
require_relative '../errors'
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
##
|
|
10
|
-
#Updates a Property Based Segmentation
|
|
10
|
+
# Updates a Property Based Segmentation
|
|
11
11
|
#
|
|
12
12
|
class UpdatePropertyBasedSegmentation < ApiRequest
|
|
13
13
|
attr_reader :segmentation_id, :property_name, :title, :description
|
|
14
|
-
attr_accessor :timeout
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
#
|
|
14
|
+
attr_accessor :timeout, :ensure_https
|
|
15
|
+
|
|
16
|
+
##
|
|
17
|
+
# * *Required arguments*
|
|
18
|
+
# - +segmentation_id+ -> ID of the updated Segmentation
|
|
19
|
+
#
|
|
20
|
+
# * *Optional arguments (given as hash optional)*
|
|
21
|
+
# - +propertyName+ -> Name of the property on which the Segmentation should be based
|
|
22
|
+
#
|
|
23
|
+
# - +title+ -> Human-readable name that is shown in the Recombee Admin UI.
|
|
24
|
+
#
|
|
25
|
+
# - +description+ -> Description that is shown in the Recombee Admin UI.
|
|
26
|
+
#
|
|
27
|
+
#
|
|
29
28
|
def initialize(segmentation_id, optional = {})
|
|
30
29
|
@segmentation_id = segmentation_id
|
|
31
|
-
optional =
|
|
30
|
+
optional = normalize_hash_to_camel_case(optional)
|
|
32
31
|
@property_name = optional['propertyName']
|
|
33
32
|
@title = optional['title']
|
|
34
33
|
@description = optional['description']
|
|
35
34
|
@optional = optional
|
|
36
|
-
@timeout =
|
|
35
|
+
@timeout = 10_000
|
|
37
36
|
@ensure_https = false
|
|
38
37
|
@optional.each do |par, _|
|
|
39
|
-
|
|
38
|
+
raise UnknownOptionalParameter.new(par) unless %w[propertyName title description].include? par
|
|
40
39
|
end
|
|
41
40
|
end
|
|
42
|
-
|
|
41
|
+
|
|
43
42
|
# HTTP method
|
|
44
43
|
def method
|
|
45
44
|
:post
|
|
46
45
|
end
|
|
47
|
-
|
|
46
|
+
|
|
48
47
|
# Values of body parameters as a Hash
|
|
49
48
|
def body_parameters
|
|
50
|
-
p =
|
|
49
|
+
p = {}
|
|
51
50
|
p['propertyName'] = @optional['propertyName'] if @optional.include? 'propertyName'
|
|
52
51
|
p['title'] = @optional['title'] if @optional.include? 'title'
|
|
53
52
|
p['description'] = @optional['description'] if @optional.include? 'description'
|
|
53
|
+
|
|
54
54
|
p
|
|
55
55
|
end
|
|
56
|
-
|
|
56
|
+
|
|
57
57
|
# Values of query parameters as a Hash.
|
|
58
58
|
# name of parameter => value of the parameter
|
|
59
59
|
def query_parameters
|
|
60
|
-
|
|
61
|
-
params
|
|
60
|
+
{}
|
|
62
61
|
end
|
|
63
|
-
|
|
62
|
+
|
|
64
63
|
# Relative path to the endpoint
|
|
65
64
|
def path
|
|
66
65
|
"/{databaseId}/segmentations/property-based/#{@segmentation_id}"
|
|
@@ -5,11 +5,9 @@ module RecombeeApiClient
|
|
|
5
5
|
|
|
6
6
|
# Response is not 200 or 201
|
|
7
7
|
class ResponseError < APIError
|
|
8
|
-
attr_reader :request
|
|
9
|
-
attr_reader :status_code
|
|
10
|
-
attr_reader :description
|
|
8
|
+
attr_reader :request, :status_code, :description
|
|
11
9
|
|
|
12
|
-
def initialize(
|
|
10
|
+
def initialize(_request, status_code, description)
|
|
13
11
|
@status_code = status_code
|
|
14
12
|
@description = description
|
|
15
13
|
end
|
|
@@ -40,5 +38,4 @@ module RecombeeApiClient
|
|
|
40
38
|
"ApiTimeout: client did not get response within #{@request.timeout} ms"
|
|
41
39
|
end
|
|
42
40
|
end
|
|
43
|
-
|
|
44
41
|
end
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
#
|
|
2
|
+
# This file is auto-generated, do not edit
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
require 'json'
|
|
6
|
+
|
|
7
|
+
module RecombeeApiClient
|
|
8
|
+
require_relative 'input'
|
|
9
|
+
require_relative '../errors'
|
|
10
|
+
|
|
11
|
+
##
|
|
12
|
+
# Initializes CompositeRecommendationStageParameters input#
|
|
13
|
+
class CompositeRecommendationStageParameters < Input
|
|
14
|
+
attr_reader :return_properties, :included_properties, :filter, :booster, :logic, :reql_expressions, :min_relevance,
|
|
15
|
+
:rotation_rate, :rotation_time
|
|
16
|
+
|
|
17
|
+
##
|
|
18
|
+
#
|
|
19
|
+
# * *Optional arguments (given as hash optional)*
|
|
20
|
+
# - +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 to easily display the recommended items to the user.
|
|
21
|
+
#
|
|
22
|
+
# Example response with `returnProperties` set in the `resultSettings`:
|
|
23
|
+
# ```json
|
|
24
|
+
# {
|
|
25
|
+
# "recommId": "ee94fa8b-efe7-4b35-abc6-2bc3456d66ed",
|
|
26
|
+
# "source": {
|
|
27
|
+
# "id": "category-sport"
|
|
28
|
+
# },
|
|
29
|
+
# "recomms": [
|
|
30
|
+
# {
|
|
31
|
+
# "id": "article-1024",
|
|
32
|
+
# "values": {
|
|
33
|
+
# "title": "Champions League: Stunning Comeback Secures Final Spot",
|
|
34
|
+
# "categories": ["Sport", "Football"],
|
|
35
|
+
# "author": "Jane Smith",
|
|
36
|
+
# "url": "newsportal.com/articles/champions-league-comeback"
|
|
37
|
+
# }
|
|
38
|
+
# },
|
|
39
|
+
# {
|
|
40
|
+
# "id": "article-2031",
|
|
41
|
+
# "values": {
|
|
42
|
+
# "title": "Top 10 Moments from the Summer Olympics",
|
|
43
|
+
# "categories": ["Sport", "Olympics"],
|
|
44
|
+
# "author": "Mark Johnson",
|
|
45
|
+
# "url": "newsportal.com/articles/olympic-top-moments"
|
|
46
|
+
# }
|
|
47
|
+
# },
|
|
48
|
+
# {
|
|
49
|
+
# "id": "article-3042",
|
|
50
|
+
# "values": {
|
|
51
|
+
# "title": "Rising Stars in Women's Tennis to Watch This Season",
|
|
52
|
+
# "categories": ["Sport", "Tennis"],
|
|
53
|
+
# "author": "Laura Chen",
|
|
54
|
+
# "url": "newsportal.com/articles/womens-tennis-stars"
|
|
55
|
+
# }
|
|
56
|
+
# }
|
|
57
|
+
# ],
|
|
58
|
+
# "numberNextRecommsCalls": 0
|
|
59
|
+
# }
|
|
60
|
+
#
|
|
61
|
+
# ```
|
|
62
|
+
#
|
|
63
|
+
# - +includedProperties+ -> Allows specifying which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list.
|
|
64
|
+
#
|
|
65
|
+
# Example response for `returnProperties=true` and `includedProperties=title,url` set in `resultSettings`:
|
|
66
|
+
# ```json
|
|
67
|
+
# {
|
|
68
|
+
# "recommId": "ee94fa8b-efe7-4b35-abc6-2bc3456d66ed",
|
|
69
|
+
# "source": {
|
|
70
|
+
# "id": "category-sport"
|
|
71
|
+
# },
|
|
72
|
+
# "recomms": [
|
|
73
|
+
# {
|
|
74
|
+
# "id": "article-1024",
|
|
75
|
+
# "values": {
|
|
76
|
+
# "title": "Champions League: Stunning Comeback Secures Final Spot",
|
|
77
|
+
# "url": "newsportal.com/articles/champions-league-comeback"
|
|
78
|
+
# }
|
|
79
|
+
# },
|
|
80
|
+
# {
|
|
81
|
+
# "id": "article-2031",
|
|
82
|
+
# "values": {
|
|
83
|
+
# "title": "Top 10 Moments from the Summer Olympics",
|
|
84
|
+
# "url": "newsportal.com/articles/olympic-top-moments"
|
|
85
|
+
# }
|
|
86
|
+
# },
|
|
87
|
+
# {
|
|
88
|
+
# "id": "article-3042",
|
|
89
|
+
# "values": {
|
|
90
|
+
# "title": "Rising Stars in Women's Tennis to Watch This Season",
|
|
91
|
+
# "url": "newsportal.com/articles/womens-tennis-stars"
|
|
92
|
+
# }
|
|
93
|
+
# }
|
|
94
|
+
# ],
|
|
95
|
+
# "numberNextRecommsCalls": 0
|
|
96
|
+
# }
|
|
97
|
+
#
|
|
98
|
+
# ```
|
|
99
|
+
#
|
|
100
|
+
# - +filter+ -> Boolean-returning [ReQL](https://docs.recombee.com/reql) expression, which allows you to filter recommended entities based on the values of their attributes.
|
|
101
|
+
#
|
|
102
|
+
# Filters can also be assigned to a [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com).
|
|
103
|
+
#
|
|
104
|
+
# - +booster+ -> Number-returning [ReQL](https://docs.recombee.com/reql) expression, which allows you to boost the recommendation rate of some entities based on the values of their attributes.
|
|
105
|
+
#
|
|
106
|
+
# Boosters can also be assigned to a [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com).
|
|
107
|
+
#
|
|
108
|
+
# - +logic+ -> Logic specifies the particular behavior of the recommendation models. You can pick tailored logic for your domain and use case.
|
|
109
|
+
# See [this section](https://docs.recombee.com/recommendation_logics) for a list of available logics and other details.
|
|
110
|
+
#
|
|
111
|
+
# The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
|
|
112
|
+
#
|
|
113
|
+
# Logic can also be set to a [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com).
|
|
114
|
+
#
|
|
115
|
+
# - +reqlExpressions+ -> Only usable if the stage corresponds to the one of these recommendation endpoints:
|
|
116
|
+
#
|
|
117
|
+
# - [Recommend Items To User](https://docs.recombee.com/api#recommend-items-to-user)
|
|
118
|
+
# - [Recommend Items To Item](https://docs.recombee.com/api#recommend-items-to-item)
|
|
119
|
+
# - [Recommend Items to Item Segment](https://docs.recombee.com/api#recommend-items-to-item-segment)
|
|
120
|
+
# - [Recommend Users to Item](https://docs.recombee.com/api#recommend-users-to-item)
|
|
121
|
+
# - [Recommend Users To User](https://docs.recombee.com/api#recommend-users-to-user)
|
|
122
|
+
#
|
|
123
|
+
# A dictionary of [ReQL](https://docs.recombee.com/reql) expressions that will be executed for each recommended item.
|
|
124
|
+
# This can be used to compute additional properties of the recommended items that are not stored in the database.
|
|
125
|
+
#
|
|
126
|
+
# The keys are the names of the expressions, and the values are the actual ReQL expressions.
|
|
127
|
+
#
|
|
128
|
+
# Example request:
|
|
129
|
+
# ```json
|
|
130
|
+
# {
|
|
131
|
+
# "reqlExpressions": {
|
|
132
|
+
# "isInUsersCity": "context_user[\"city\"] in 'cities'",
|
|
133
|
+
# "distanceToUser": "earth_distance('location', context_user[\"location\"])"
|
|
134
|
+
# }
|
|
135
|
+
# }
|
|
136
|
+
# ```
|
|
137
|
+
#
|
|
138
|
+
# Example response:
|
|
139
|
+
# ```json
|
|
140
|
+
# {
|
|
141
|
+
# "recommId": "ce52ada4-e4d9-4885-943c-407db2dee837",
|
|
142
|
+
# "source": {
|
|
143
|
+
# "id": "restaurant-123",
|
|
144
|
+
# "reqlEvaluations": {
|
|
145
|
+
# "isInUsersCity": true,
|
|
146
|
+
# "distanceToUser": 3450.5
|
|
147
|
+
# }
|
|
148
|
+
# },
|
|
149
|
+
# "recomms":
|
|
150
|
+
# [
|
|
151
|
+
# {
|
|
152
|
+
# "id": "restaurant-178",
|
|
153
|
+
# "reqlEvaluations": {
|
|
154
|
+
# "isInUsersCity": true,
|
|
155
|
+
# "distanceToUser": 5200.2
|
|
156
|
+
# }
|
|
157
|
+
# },
|
|
158
|
+
# {
|
|
159
|
+
# "id": "bar-42",
|
|
160
|
+
# "reqlEvaluations": {
|
|
161
|
+
# "isInUsersCity": false,
|
|
162
|
+
# "distanceToUser": 2516.0
|
|
163
|
+
# }
|
|
164
|
+
# }
|
|
165
|
+
# ],
|
|
166
|
+
# "numberNextRecommsCalls": 0
|
|
167
|
+
# }
|
|
168
|
+
# ```
|
|
169
|
+
#
|
|
170
|
+
# - +minRelevance+ -> **Expert option:** Only usable if the stage corresponds to the one of these recommendation endpoints:
|
|
171
|
+
#
|
|
172
|
+
# - [Recommend Items To User](https://docs.recombee.com/api#recommend-items-to-user)
|
|
173
|
+
# - [Recommend Items To Item](https://docs.recombee.com/api#recommend-items-to-item)
|
|
174
|
+
# - [Recommend Items to Item Segment](https://docs.recombee.com/api#recommend-items-to-item-segment)
|
|
175
|
+
#
|
|
176
|
+
# If the *userId* is provided: Specifies the threshold of how relevant must the recommended items be to the user.
|
|
177
|
+
#
|
|
178
|
+
# Possible values one of: `"low"`, `"medium"`, `"high"`.
|
|
179
|
+
#
|
|
180
|
+
# The default value is `"low"`, meaning that the system attempts to recommend a number of items equal to *count* at any cost. If there is not enough data (such as interactions or item properties), this may even lead to bestseller-based recommendations being appended to reach the full *count*.
|
|
181
|
+
# 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.
|
|
182
|
+
#
|
|
183
|
+
# - +rotationRate+ -> **Expert option:** Only usable if the stage corresponds to the one of these recommendation endpoints:
|
|
184
|
+
# - [Recommend Items To User](https://docs.recombee.com/api#recommend-items-to-user)
|
|
185
|
+
# - [Recommend Items To Item](https://docs.recombee.com/api#recommend-items-to-item)
|
|
186
|
+
# - [Recommend Items to Item Segment](https://docs.recombee.com/api#recommend-items-to-item-segment)
|
|
187
|
+
# - [Recommend Users To User](https://docs.recombee.com/api#recommend-users-to-user)
|
|
188
|
+
#
|
|
189
|
+
# If the *userId* 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 a backward fashion.
|
|
190
|
+
#
|
|
191
|
+
# 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.
|
|
192
|
+
#
|
|
193
|
+
# - +rotationTime+ -> **Expert option:** Only usable if the stage corresponds to the one of these recommendation endpoints:
|
|
194
|
+
# - [Recommend Items To User](https://docs.recombee.com/api#recommend-items-to-user)
|
|
195
|
+
# - [Recommend Items To Item](https://docs.recombee.com/api#recommend-items-to-item)
|
|
196
|
+
# - [Recommend Items to Item Segment](https://docs.recombee.com/api#recommend-items-to-item-segment)
|
|
197
|
+
# - [Recommend Users To User](https://docs.recombee.com/api#recommend-users-to-user)
|
|
198
|
+
#
|
|
199
|
+
# If the *userId* is provided: Taking *rotationRate* into account, specifies how long it takes for an item to recover from the penalization. For example, `rotationTime=7200.0` means that items recommended less than 2 hours ago are penalized.
|
|
200
|
+
#
|
|
201
|
+
#
|
|
202
|
+
def initialize(optional = {})
|
|
203
|
+
optional = normalize_hash_to_camel_case(optional)
|
|
204
|
+
@return_properties = optional['returnProperties']
|
|
205
|
+
@included_properties = optional['includedProperties']
|
|
206
|
+
@filter = optional['filter']
|
|
207
|
+
@booster = optional['booster']
|
|
208
|
+
@logic = optional['logic']
|
|
209
|
+
@reql_expressions = optional['reqlExpressions']
|
|
210
|
+
@min_relevance = optional['minRelevance']
|
|
211
|
+
@rotation_rate = optional['rotationRate']
|
|
212
|
+
@rotation_time = optional['rotationTime']
|
|
213
|
+
@optional = optional
|
|
214
|
+
@optional.each do |par, _|
|
|
215
|
+
raise UnknownOptionalParameter.new(par) unless %w[returnProperties includedProperties filter booster
|
|
216
|
+
logic reqlExpressions minRelevance rotationRate rotationTime].include? par
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
# Return only JSON-serializable primitives.
|
|
221
|
+
def as_json(_options = {})
|
|
222
|
+
res = {}
|
|
223
|
+
res['returnProperties'] = @optional['returnProperties'] if @optional['returnProperties']
|
|
224
|
+
res['includedProperties'] = @optional['includedProperties'] if @optional['includedProperties']
|
|
225
|
+
res['filter'] = @optional['filter'] if @optional['filter']
|
|
226
|
+
res['booster'] = @optional['booster'] if @optional['booster']
|
|
227
|
+
res['logic'] = @optional['logic'] if @optional['logic']
|
|
228
|
+
res['reqlExpressions'] = @optional['reqlExpressions'] if @optional['reqlExpressions']
|
|
229
|
+
res['minRelevance'] = @optional['minRelevance'] if @optional['minRelevance']
|
|
230
|
+
res['rotationRate'] = @optional['rotationRate'] if @optional['rotationRate']
|
|
231
|
+
res['rotationTime'] = @optional['rotationTime'] if @optional['rotationTime']
|
|
232
|
+
|
|
233
|
+
res
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
def to_json(*args)
|
|
237
|
+
as_json.to_json(*args)
|
|
238
|
+
end
|
|
239
|
+
end
|
|
240
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#
|
|
2
|
+
# This file is auto-generated, do not edit
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
require 'json'
|
|
6
|
+
|
|
7
|
+
module RecombeeApiClient
|
|
8
|
+
require_relative 'input'
|
|
9
|
+
require_relative '../errors'
|
|
10
|
+
|
|
11
|
+
##
|
|
12
|
+
# Initializes Logic input#
|
|
13
|
+
class Logic < Input
|
|
14
|
+
attr_reader :name, :settings
|
|
15
|
+
|
|
16
|
+
##
|
|
17
|
+
#
|
|
18
|
+
# * *Optional arguments (given as hash optional)*
|
|
19
|
+
# - +name+ -> Name of the logic that should be used
|
|
20
|
+
# - +settings+ -> Parameters passed to the logic
|
|
21
|
+
#
|
|
22
|
+
def initialize(optional = {})
|
|
23
|
+
optional = normalize_hash_to_camel_case(optional)
|
|
24
|
+
@name = optional['name']
|
|
25
|
+
@settings = optional['settings']
|
|
26
|
+
@optional = optional
|
|
27
|
+
@optional.each do |par, _|
|
|
28
|
+
raise UnknownOptionalParameter.new(par) unless %w[name settings].include? par
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Return only JSON-serializable primitives.
|
|
33
|
+
def as_json(_options = {})
|
|
34
|
+
res = {}
|
|
35
|
+
res['name'] = @optional['name'] if @optional['name']
|
|
36
|
+
res['settings'] = @optional['settings'] if @optional['settings']
|
|
37
|
+
|
|
38
|
+
res
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def to_json(*args)
|
|
42
|
+
as_json.to_json(*args)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module RecombeeApiClient
|
|
2
|
+
##
|
|
3
|
+
# Module to convert Ruby conventions to Recombee's API namings
|
|
4
|
+
#
|
|
5
|
+
module HashNormalizer
|
|
6
|
+
def normalize_hash_to_camel_case(h)
|
|
7
|
+
return h unless h.is_a?(Hash)
|
|
8
|
+
|
|
9
|
+
h_new = {}
|
|
10
|
+
h.each do |k, v|
|
|
11
|
+
key = k.is_a?(String) ? camelize(k) : camelize(k.to_s)
|
|
12
|
+
h_new[key] = v
|
|
13
|
+
end
|
|
14
|
+
h_new
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def camelize(str)
|
|
18
|
+
str.gsub(/_(.)/) { |_e| ::Regexp.last_match(1).upcase }
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|