recombee_api_client 5.1.0 → 6.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.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/lib/recombee_api_client/api/add_bookmark.rb +26 -26
  3. data/lib/recombee_api_client/api/add_cart_addition.rb +28 -28
  4. data/lib/recombee_api_client/api/add_detail_view.rb +32 -28
  5. data/lib/recombee_api_client/api/add_item.rb +15 -18
  6. data/lib/recombee_api_client/api/add_item_property.rb +34 -35
  7. data/lib/recombee_api_client/api/add_manual_reql_segment.rb +26 -27
  8. data/lib/recombee_api_client/api/add_purchase.rb +29 -29
  9. data/lib/recombee_api_client/api/add_rating.rb +27 -27
  10. data/lib/recombee_api_client/api/add_search_synonym.rb +29 -30
  11. data/lib/recombee_api_client/api/add_series.rb +20 -21
  12. data/lib/recombee_api_client/api/add_user.rb +14 -17
  13. data/lib/recombee_api_client/api/add_user_property.rb +30 -31
  14. data/lib/recombee_api_client/api/batch.rb +12 -16
  15. data/lib/recombee_api_client/api/composite_recommendation.rb +132 -0
  16. data/lib/recombee_api_client/api/create_auto_reql_segmentation.rb +29 -30
  17. data/lib/recombee_api_client/api/create_manual_reql_segmentation.rb +27 -28
  18. data/lib/recombee_api_client/api/create_property_based_segmentation.rb +30 -31
  19. data/lib/recombee_api_client/api/delete_all_search_synonyms.rb +15 -19
  20. data/lib/recombee_api_client/api/delete_bookmark.rb +21 -22
  21. data/lib/recombee_api_client/api/delete_cart_addition.rb +21 -22
  22. data/lib/recombee_api_client/api/delete_detail_view.rb +21 -22
  23. data/lib/recombee_api_client/api/delete_item.rb +16 -19
  24. data/lib/recombee_api_client/api/delete_item_property.rb +15 -18
  25. data/lib/recombee_api_client/api/delete_manual_reql_segment.rb +16 -19
  26. data/lib/recombee_api_client/api/delete_more_items.rb +18 -19
  27. data/lib/recombee_api_client/api/delete_purchase.rb +21 -22
  28. data/lib/recombee_api_client/api/delete_rating.rb +21 -22
  29. data/lib/recombee_api_client/api/delete_search_synonym.rb +15 -18
  30. data/lib/recombee_api_client/api/delete_segmentation.rb +15 -18
  31. data/lib/recombee_api_client/api/delete_series.rb +21 -22
  32. data/lib/recombee_api_client/api/delete_user.rb +15 -18
  33. data/lib/recombee_api_client/api/delete_user_property.rb +15 -18
  34. data/lib/recombee_api_client/api/delete_view_portion.rb +21 -22
  35. data/lib/recombee_api_client/api/get_item_property_info.rb +14 -17
  36. data/lib/recombee_api_client/api/get_item_values.rb +15 -18
  37. data/lib/recombee_api_client/api/get_segmentation.rb +15 -18
  38. data/lib/recombee_api_client/api/get_user_property_info.rb +15 -18
  39. data/lib/recombee_api_client/api/get_user_values.rb +15 -18
  40. data/lib/recombee_api_client/api/insert_to_series.rb +23 -24
  41. data/lib/recombee_api_client/api/list_item_bookmarks.rb +16 -19
  42. data/lib/recombee_api_client/api/list_item_cart_additions.rb +16 -19
  43. data/lib/recombee_api_client/api/list_item_detail_views.rb +16 -19
  44. data/lib/recombee_api_client/api/list_item_properties.rb +15 -19
  45. data/lib/recombee_api_client/api/list_item_purchases.rb +16 -19
  46. data/lib/recombee_api_client/api/list_item_ratings.rb +16 -19
  47. data/lib/recombee_api_client/api/list_item_view_portions.rb +16 -19
  48. data/lib/recombee_api_client/api/list_items.rb +62 -62
  49. data/lib/recombee_api_client/api/list_scenarios.rb +15 -19
  50. data/lib/recombee_api_client/api/list_search_synonyms.rb +20 -21
  51. data/lib/recombee_api_client/api/list_segmentations.rb +16 -17
  52. data/lib/recombee_api_client/api/list_series.rb +15 -19
  53. data/lib/recombee_api_client/api/list_series_items.rb +15 -18
  54. data/lib/recombee_api_client/api/list_user_bookmarks.rb +15 -18
  55. data/lib/recombee_api_client/api/list_user_cart_additions.rb +15 -18
  56. data/lib/recombee_api_client/api/list_user_detail_views.rb +15 -18
  57. data/lib/recombee_api_client/api/list_user_properties.rb +15 -19
  58. data/lib/recombee_api_client/api/list_user_purchases.rb +15 -18
  59. data/lib/recombee_api_client/api/list_user_ratings.rb +15 -18
  60. data/lib/recombee_api_client/api/list_user_view_portions.rb +15 -18
  61. data/lib/recombee_api_client/api/list_users.rb +56 -56
  62. data/lib/recombee_api_client/api/merge_users.rb +24 -25
  63. data/lib/recombee_api_client/api/recommend_item_segments_to_item.rb +108 -68
  64. data/lib/recombee_api_client/api/recommend_item_segments_to_item_segment.rb +109 -69
  65. data/lib/recombee_api_client/api/recommend_item_segments_to_user.rb +90 -50
  66. data/lib/recombee_api_client/api/recommend_items_to_item.rb +185 -139
  67. data/lib/recombee_api_client/api/recommend_items_to_item_segment.rb +181 -138
  68. data/lib/recombee_api_client/api/recommend_items_to_user.rb +165 -122
  69. data/lib/recombee_api_client/api/recommend_next_items.rb +24 -25
  70. data/lib/recombee_api_client/api/recommend_users_to_item.rb +151 -105
  71. data/lib/recombee_api_client/api/recommend_users_to_user.rb +154 -111
  72. data/lib/recombee_api_client/api/remove_from_series.rb +17 -18
  73. data/lib/recombee_api_client/api/request.rb +1 -1
  74. data/lib/recombee_api_client/api/reset_database.rb +15 -19
  75. data/lib/recombee_api_client/api/search_item_segments.rb +91 -51
  76. data/lib/recombee_api_client/api/search_items.rb +157 -114
  77. data/lib/recombee_api_client/api/set_item_values.rb +28 -29
  78. data/lib/recombee_api_client/api/set_user_values.rb +21 -22
  79. data/lib/recombee_api_client/api/set_values.rb +28 -28
  80. data/lib/recombee_api_client/api/set_view_portion.rb +37 -30
  81. data/lib/recombee_api_client/api/update_auto_reql_segmentation.rb +26 -27
  82. data/lib/recombee_api_client/api/update_manual_reql_segment.rb +25 -26
  83. data/lib/recombee_api_client/api/update_manual_reql_segmentation.rb +24 -25
  84. data/lib/recombee_api_client/api/update_more_items.rb +19 -20
  85. data/lib/recombee_api_client/api/update_property_based_segmentation.rb +26 -27
  86. data/lib/recombee_api_client/errors.rb +2 -5
  87. data/lib/recombee_api_client/inputs/composite_recommendation_stage_parameters.rb +240 -0
  88. data/lib/recombee_api_client/inputs/input.rb +9 -0
  89. data/lib/recombee_api_client/inputs/logic.rb +45 -0
  90. data/lib/recombee_api_client/utils/hash_normalizer.rb +21 -0
  91. data/lib/recombee_api_client/version.rb +1 -1
  92. data/lib/recombee_api_client.rb +40 -35
  93. data/recombee_api_client.gemspec +2 -3
  94. metadata +14 -10
  95. data/lib/recombee_api_client/api/hash_normalizer.rb +0 -21
@@ -5,20 +5,19 @@
5
5
  module RecombeeApiClient
6
6
  require_relative 'request'
7
7
  require_relative '../errors'
8
-
8
+
9
9
  ##
10
- #Removes an existing series item from the series.
10
+ # Removes an existing series item from the series.#
11
11
  class RemoveFromSeries < ApiRequest
12
12
  attr_reader :series_id, :item_type, :item_id
13
- attr_accessor :timeout
14
- attr_accessor :ensure_https
15
-
16
- ##
17
- # * *Required arguments*
18
- # - +series_id+ -> ID of the series from which a series item is to be removed.
19
- # - +item_type+ -> Type of the item to be removed.
20
- # - +item_id+ -> ID of the item iff `itemType` is `item`. ID of the series iff `itemType` is `series`.
21
- #
13
+ attr_accessor :timeout, :ensure_https
14
+
15
+ ##
16
+ # * *Required arguments*
17
+ # - +series_id+ -> ID of the series from which a series item is to be removed.
18
+ # - +item_type+ -> Type of the item to be removed.
19
+ # - +item_id+ -> ID of the item iff `itemType` is `item`. ID of the series iff `itemType` is `series`.
20
+ #
22
21
  def initialize(series_id, item_type, item_id)
23
22
  @series_id = series_id
24
23
  @item_type = item_type
@@ -26,27 +25,27 @@ module RecombeeApiClient
26
25
  @timeout = 3000
27
26
  @ensure_https = false
28
27
  end
29
-
28
+
30
29
  # HTTP method
31
30
  def method
32
31
  :delete
33
32
  end
34
-
33
+
35
34
  # Values of body parameters as a Hash
36
35
  def body_parameters
37
- p = Hash.new
36
+ p = {}
38
37
  p['itemType'] = @item_type
39
38
  p['itemId'] = @item_id
39
+
40
40
  p
41
41
  end
42
-
42
+
43
43
  # Values of query parameters as a Hash.
44
44
  # name of parameter => value of the parameter
45
45
  def query_parameters
46
- params = {}
47
- params
46
+ {}
48
47
  end
49
-
48
+
50
49
  # Relative path to the endpoint
51
50
  def path
52
51
  "/{databaseId}/series/#{@series_id}/items/"
@@ -3,7 +3,7 @@ module RecombeeApiClient
3
3
  # Parent class for API requests
4
4
  #
5
5
  class ApiRequest
6
- require_relative 'hash_normalizer'
6
+ require_relative '../utils/hash_normalizer'
7
7
  include RecombeeApiClient::HashNormalizer
8
8
  end
9
9
  end
@@ -5,43 +5,39 @@
5
5
  module RecombeeApiClient
6
6
  require_relative 'request'
7
7
  require_relative '../errors'
8
-
8
+
9
9
  ##
10
- #Completely erases all your data, including items, item properties, series, user database, purchases, ratings, detail views, and bookmarks. Make sure the request is never executed in the production environment! Resetting your database is irreversible.
10
+ # Completely erases all your data, including items, item properties, series, user database, purchases, ratings, detail views, and bookmarks. Make sure the request is never executed in the production environment! Resetting your database is irreversible.
11
11
  #
12
12
  class ResetDatabase < ApiRequest
13
-
14
- attr_accessor :timeout
15
- attr_accessor :ensure_https
16
-
17
- ##
18
- #
19
- def initialize()
20
- @timeout = 100000
13
+ attr_accessor :timeout, :ensure_https
14
+
15
+ ##
16
+ #
17
+ def initialize
18
+ @timeout = 100_000
21
19
  @ensure_https = false
22
20
  end
23
-
21
+
24
22
  # HTTP method
25
23
  def method
26
24
  :delete
27
25
  end
28
-
26
+
29
27
  # Values of body parameters as a Hash
30
28
  def body_parameters
31
- p = Hash.new
32
- p
29
+ {}
33
30
  end
34
-
31
+
35
32
  # Values of query parameters as a Hash.
36
33
  # name of parameter => value of the parameter
37
34
  def query_parameters
38
- params = {}
39
- params
35
+ {}
40
36
  end
41
-
37
+
42
38
  # Relative path to the endpoint
43
39
  def path
44
- "/{databaseId}/"
40
+ '/{databaseId}/'
45
41
  end
46
42
  end
47
43
  end
@@ -5,64 +5,101 @@
5
5
  module RecombeeApiClient
6
6
  require_relative 'request'
7
7
  require_relative '../errors'
8
-
8
+
9
9
  ##
10
- #Full-text personalized search that returns Segments from a Segmentation. The results are based on the provided `searchQuery` and also on the user's past interactions (purchases, ratings, etc.).
10
+ # Full-text personalized search that returns Segments from a Segmentation. The results are based on the provided `searchQuery` and also on the user's past interactions (purchases, ratings, etc.).
11
11
  #
12
- #Based on the used Segmentation, this endpoint can be used for example for:
12
+ # Based on the used Segmentation, this endpoint can be used for example for:
13
13
  #
14
14
  # - Searching within categories or brands
15
15
  # - Searching within genres or artists
16
16
  #
17
- #For example if the user is searching for "iPhone" this endpoint can return "cell phones" category.
17
+ # For example if the user is searching for "iPhone" this endpoint can return "cell phones" category.
18
18
  #
19
- #You need to set the used Segmentation the Admin UI in the Scenario settings prior to using this endpoint.
19
+ # You need to set the used Segmentation the Admin UI in the Scenario settings prior to using this endpoint.
20
20
  #
21
- #The returned segments are sorted by relevance (first segment being the most relevant).
21
+ # The returned segments are sorted by relevance (first segment being the most relevant).
22
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.
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
24
  #
25
25
  class SearchItemSegments < ApiRequest
26
- attr_reader :user_id, :search_query, :count, :scenario, :cascade_create, :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 segments to be returned (N for the top-N results).
35
- #
36
- # * *Optional arguments (given as hash optional)*
37
- # - +scenario+ -> Scenario defines a particular application of recommendations. It can be, for example, "homepage", "cart", or "emailing".
38
- #
39
- #You can set various settings to the [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com). You can also see the performance of each scenario in the Admin UI separately, so you can check how well each application performs.
40
- #
41
- #The AI that optimizes models 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 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.
44
- #
45
- # - +filter+ -> Boolean-returning [ReQL](https://docs.recombee.com/reql) expression which allows you to filter recommended segments based on the `segmentationId`.
46
- #
47
- # - +booster+ -> Number-returning [ReQL](https://docs.recombee.com/reql) expression which allows you to boost recommendation rate of some segments based on the `segmentationId`.
48
- #
49
- # - +logic+ -> Logic specifies the particular behavior of the recommendation models. You can pick tailored logic for your domain and use case.
50
- #See [this section](https://docs.recombee.com/recommendation_logics) for a list of available logics and other details.
51
- #
52
- #The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
53
- #
54
- #Logic can also be set to a [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com).
55
- #
56
- # - +expertSettings+ -> Dictionary of custom options.
57
- #
58
- # - +returnAbGroup+ -> If there is a custom AB-testing running, return the name of the group to which the request belongs.
59
- #
60
- #
26
+ attr_reader :user_id, :search_query, :count, :scenario, :cascade_create, :filter, :booster, :logic,
27
+ :expert_settings, :return_ab_group, :reql_expressions
28
+ attr_accessor :timeout, :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 segments to be returned (N for the top-N results).
35
+ #
36
+ # * *Optional arguments (given as hash optional)*
37
+ # - +scenario+ -> Scenario defines a particular application of recommendations. It can be, for example, "homepage", "cart", or "emailing".
38
+ #
39
+ # You can set various settings to the [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com). You can also see the performance of each scenario in the Admin UI separately, so you can check how well each application performs.
40
+ #
41
+ # The AI that optimizes models 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 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.
44
+ #
45
+ # - +filter+ -> Boolean-returning [ReQL](https://docs.recombee.com/reql) expression which allows you to filter recommended segments based on the `segmentationId`.
46
+ #
47
+ # - +booster+ -> Number-returning [ReQL](https://docs.recombee.com/reql) expression which allows you to boost recommendation rate of some segments based on the `segmentationId`.
48
+ #
49
+ # - +logic+ -> Logic specifies the particular behavior of the recommendation models. You can pick tailored logic for your domain and use case.
50
+ # See [this section](https://docs.recombee.com/recommendation_logics) for a list of available logics and other details.
51
+ #
52
+ # The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
53
+ #
54
+ # Logic can also be set to a [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com).
55
+ #
56
+ # - +expertSettings+ -> Dictionary of custom options.
57
+ #
58
+ # - +returnAbGroup+ -> If there is a custom AB-testing running, return the name of the group to which the request belongs.
59
+ #
60
+ # - +reqlExpressions+ -> A dictionary of [ReQL](https://docs.recombee.com/reql) expressions that will be executed for each recommended Item Segment.
61
+ # This can be used to compute additional properties of the recommended Item Segments.
62
+ #
63
+ # The keys are the names of the expressions, and the values are the actual ReQL expressions.
64
+ #
65
+ # Example request:
66
+ # ```json
67
+ # {
68
+ # "reqlExpressions": {
69
+ # "countItems": "size(segment_items(\"categories\", 'segmentId'))"
70
+ # }
71
+ # }
72
+ # ```
73
+ #
74
+ # Example response:
75
+ # ```json
76
+ # {
77
+ # "recommId": "a7ac55a4-8d6e-4f19-addc-abac4164d8a8",
78
+ # "recomms":
79
+ # [
80
+ # {
81
+ # "id": "category-fantasy-books",
82
+ # "reqlEvaluations": {
83
+ # "countItems": 486
84
+ # }
85
+ # },
86
+ # {
87
+ # "id": "category-sci-fi-costumes",
88
+ # "reqlEvaluations": {
89
+ # "countItems": 19
90
+ # }
91
+ # }
92
+ # ],
93
+ # "numberNextRecommsCalls": 0
94
+ # }
95
+ # ```
96
+ #
97
+ #
61
98
  def initialize(user_id, search_query, count, optional = {})
62
99
  @user_id = user_id
63
100
  @search_query = search_query
64
101
  @count = count
65
- optional = normalize_optional(optional)
102
+ optional = normalize_hash_to_camel_case(optional)
66
103
  @scenario = optional['scenario']
67
104
  @cascade_create = optional['cascadeCreate']
68
105
  @filter = optional['filter']
@@ -70,22 +107,24 @@ module RecombeeApiClient
70
107
  @logic = optional['logic']
71
108
  @expert_settings = optional['expertSettings']
72
109
  @return_ab_group = optional['returnAbGroup']
110
+ @reql_expressions = optional['reqlExpressions']
73
111
  @optional = optional
74
112
  @timeout = 3000
75
113
  @ensure_https = false
76
114
  @optional.each do |par, _|
77
- fail UnknownOptionalParameter.new(par) unless ["scenario","cascadeCreate","filter","booster","logic","expertSettings","returnAbGroup"].include? par
115
+ raise UnknownOptionalParameter.new(par) unless %w[scenario cascadeCreate filter booster logic
116
+ expertSettings returnAbGroup reqlExpressions].include? par
78
117
  end
79
118
  end
80
-
119
+
81
120
  # HTTP method
82
121
  def method
83
122
  :post
84
123
  end
85
-
124
+
86
125
  # Values of body parameters as a Hash
87
126
  def body_parameters
88
- p = Hash.new
127
+ p = {}
89
128
  p['searchQuery'] = @search_query
90
129
  p['count'] = @count
91
130
  p['scenario'] = @optional['scenario'] if @optional.include? 'scenario'
@@ -95,16 +134,17 @@ module RecombeeApiClient
95
134
  p['logic'] = @optional['logic'] if @optional.include? 'logic'
96
135
  p['expertSettings'] = @optional['expertSettings'] if @optional.include? 'expertSettings'
97
136
  p['returnAbGroup'] = @optional['returnAbGroup'] if @optional.include? 'returnAbGroup'
137
+ p['reqlExpressions'] = @optional['reqlExpressions'] if @optional.include? 'reqlExpressions'
138
+
98
139
  p
99
140
  end
100
-
141
+
101
142
  # Values of query parameters as a Hash.
102
143
  # name of parameter => value of the parameter
103
144
  def query_parameters
104
- params = {}
105
- params
145
+ {}
106
146
  end
107
-
147
+
108
148
  # Relative path to the endpoint
109
149
  def path
110
150
  "/{databaseId}/search/users/#{@user_id}/item-segments/"