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,125 +5,165 @@
5
5
  module RecombeeApiClient
6
6
  require_relative 'request'
7
7
  require_relative '../errors'
8
-
8
+
9
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).
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
11
  #
12
- #All the string and set item properties are indexed by the search engine.
12
+ # All the string and set item properties are indexed by the search engine.
13
13
  #
14
- #This endpoint should be used in a search box on 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 the current state of the query, or once after submitting the whole query.
14
+ # This endpoint should be used in a search box on 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 the current state of the query, or once after submitting the whole query.
15
15
  #
16
- #The returned items are sorted by relevance (the first item being the most relevant).
16
+ # The returned items are sorted by relevance (the first item being the most relevant).
17
17
  #
18
- #Besides the recommended items, also a unique `recommId` is returned in the response. It can be used to:
18
+ # Besides the recommended items, also a unique `recommId` is returned in the response. It can be used to:
19
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#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#recommend-next-items).
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#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#recommend-next-items).
22
22
  #
23
- #It is also possible to use POST HTTP method (for example in the case of a very long ReQL filter) - query parameters then become body parameters.
23
+ # It is also possible to use POST HTTP method (for example in the case of a very long ReQL filter) - query parameters then become body parameters.
24
24
  #
25
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) 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 field 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 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 to easily display the recommended items to the user.
45
- #
46
- #Example response:
47
- #```json
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 specifying 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
- #```json
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) expression, which allows you to filter recommended items based on the values of their attributes.
103
- #
104
- #Filters can also be assigned to a [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com).
105
- #
106
- # - +booster+ -> Number-returning [ReQL](https://docs.recombee.com/reql) expression, which allows you to boost the recommendation rate of some items based on the values of their attributes.
107
- #
108
- #Boosters can also be assigned to a [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com).
109
- #
110
- # - +logic+ -> Logic specifies the 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) for a 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 also be set to a [scenario](https://docs.recombee.com/scenarios) 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 the name of the group to which the request belongs.
120
- #
121
- #
26
+ attr_reader :user_id, :search_query, :count, :scenario, :cascade_create, :return_properties, :included_properties,
27
+ :filter, :booster, :logic, :reql_expressions, :expert_settings, :return_ab_group
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 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) 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 field 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 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 to easily display the recommended items to the user.
45
+ #
46
+ # Example response:
47
+ # ```json
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 specifying 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
+ # ```json
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) expression, which allows you to filter recommended items based on the values of their attributes.
103
+ #
104
+ # Filters can also be assigned to a [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com).
105
+ #
106
+ # - +booster+ -> Number-returning [ReQL](https://docs.recombee.com/reql) expression, which allows you to boost the recommendation rate of some items based on the values of their attributes.
107
+ #
108
+ # Boosters can also be assigned to a [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com).
109
+ #
110
+ # - +logic+ -> Logic specifies the 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) for a 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 also be set to a [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com).
116
+ #
117
+ # - +reqlExpressions+ -> A dictionary of [ReQL](https://docs.recombee.com/reql) expressions that will be executed for each recommended item.
118
+ # This can be used to compute additional properties of the recommended items that are not stored in the database.
119
+ #
120
+ # The keys are the names of the expressions, and the values are the actual ReQL expressions.
121
+ #
122
+ # Example request:
123
+ # ```json
124
+ # {
125
+ # "reqlExpressions": {
126
+ # "isInUsersCity": "context_user[\"city\"] in 'cities'",
127
+ # "distanceToUser": "earth_distance('location', context_user[\"location\"])"
128
+ # }
129
+ # }
130
+ # ```
131
+ #
132
+ # Example response:
133
+ # ```json
134
+ # {
135
+ # "recommId": "ce52ada4-e4d9-4885-943c-407db2dee837",
136
+ # "recomms":
137
+ # [
138
+ # {
139
+ # "id": "restaurant-178",
140
+ # "reqlEvaluations": {
141
+ # "isInUsersCity": true,
142
+ # "distanceToUser": 5200.2
143
+ # }
144
+ # },
145
+ # {
146
+ # "id": "bar-42",
147
+ # "reqlEvaluations": {
148
+ # "isInUsersCity": false,
149
+ # "distanceToUser": 2516.0
150
+ # }
151
+ # }
152
+ # ],
153
+ # "numberNextRecommsCalls": 0
154
+ # }
155
+ # ```
156
+ #
157
+ # - +expertSettings+ -> Dictionary of custom options.
158
+ #
159
+ # - +returnAbGroup+ -> If there is a custom AB-testing running, return the name of the group to which the request belongs.
160
+ #
161
+ #
122
162
  def initialize(user_id, search_query, count, optional = {})
123
163
  @user_id = user_id
124
164
  @search_query = search_query
125
165
  @count = count
126
- optional = normalize_optional(optional)
166
+ optional = normalize_hash_to_camel_case(optional)
127
167
  @scenario = optional['scenario']
128
168
  @cascade_create = optional['cascadeCreate']
129
169
  @return_properties = optional['returnProperties']
@@ -131,24 +171,26 @@ module RecombeeApiClient
131
171
  @filter = optional['filter']
132
172
  @booster = optional['booster']
133
173
  @logic = optional['logic']
174
+ @reql_expressions = optional['reqlExpressions']
134
175
  @expert_settings = optional['expertSettings']
135
176
  @return_ab_group = optional['returnAbGroup']
136
177
  @optional = optional
137
178
  @timeout = 3000
138
179
  @ensure_https = false
139
180
  @optional.each do |par, _|
140
- fail UnknownOptionalParameter.new(par) unless ["scenario","cascadeCreate","returnProperties","includedProperties","filter","booster","logic","expertSettings","returnAbGroup"].include? par
181
+ raise UnknownOptionalParameter.new(par) unless %w[scenario cascadeCreate returnProperties
182
+ includedProperties filter booster logic reqlExpressions expertSettings returnAbGroup].include? par
141
183
  end
142
184
  end
143
-
185
+
144
186
  # HTTP method
145
187
  def method
146
188
  :post
147
189
  end
148
-
190
+
149
191
  # Values of body parameters as a Hash
150
192
  def body_parameters
151
- p = Hash.new
193
+ p = {}
152
194
  p['searchQuery'] = @search_query
153
195
  p['count'] = @count
154
196
  p['scenario'] = @optional['scenario'] if @optional.include? 'scenario'
@@ -158,18 +200,19 @@ module RecombeeApiClient
158
200
  p['filter'] = @optional['filter'] if @optional.include? 'filter'
159
201
  p['booster'] = @optional['booster'] if @optional.include? 'booster'
160
202
  p['logic'] = @optional['logic'] if @optional.include? 'logic'
203
+ p['reqlExpressions'] = @optional['reqlExpressions'] if @optional.include? 'reqlExpressions'
161
204
  p['expertSettings'] = @optional['expertSettings'] if @optional.include? 'expertSettings'
162
205
  p['returnAbGroup'] = @optional['returnAbGroup'] if @optional.include? 'returnAbGroup'
206
+
163
207
  p
164
208
  end
165
-
209
+
166
210
  # Values of query parameters as a Hash.
167
211
  # name of parameter => value of the parameter
168
212
  def query_parameters
169
- params = {}
170
- params
213
+ {}
171
214
  end
172
-
215
+
173
216
  # Relative path to the endpoint
174
217
  def path
175
218
  "/{databaseId}/search/users/#{@user_id}/items/"
@@ -1,45 +1,44 @@
1
1
  module RecombeeApiClient
2
2
  require_relative 'set_values'
3
3
  require_relative '../errors'
4
-
4
+
5
5
  ##
6
- #Set/update (some) property values of a given item. The properties (columns) must be previously created by [Add item property](https://docs.recombee.com/api#add-item-property).
6
+ # Set/update (some) property values of a given item. The properties (columns) must be previously created by [Add item property](https://docs.recombee.com/api#add-item-property).
7
7
  #
8
8
  class SetItemValues < SetValues
9
9
  attr_reader :item_id
10
- attr_accessor :timeout
11
- attr_accessor :ensure_https
12
-
13
- ##
14
- # * *Required arguments*
15
- # - +item_id+ -> ID of the item which will be modified.
16
- #
17
- # - +values+ -> The values for the individual properties.
18
- #
19
- #Example of body:
20
- #```
21
- # {
22
- # "product_description": "4K TV with 3D feature",
23
- # "categories": ["Electronics", "Televisions"],
24
- # "price_usd": 342,
25
- # "in_stock_from": "2016-11-16T08:00Z",
26
- # "!cascadeCreate": true
27
- # }
28
- #```
29
- #
30
- #Special parameter `!cascadeCreate` may be used. It indicates that the item of the given itemId should be created if it does not exist in the database, as if the corresponding PUT method was used. Note the exclamation mark (!) at the beginning of the parameter's name to distinguish it from item property names.
31
- #
32
- #
33
- # * *Optional arguments (given as hash optional)*
34
- # - +cascadeCreate+ -> Sets whether the item should be created if not present in the database.
35
- #
10
+ attr_accessor :timeout, :ensure_https
11
+
12
+ ##
13
+ # * *Required arguments*
14
+ # - +item_id+ -> ID of the item which will be modified.
15
+ #
16
+ # - +values+ -> The values for the individual properties.
17
+ #
18
+ # Example of body:
19
+ # ```
20
+ # {
21
+ # "product_description": "4K TV with 3D feature",
22
+ # "categories": ["Electronics", "Televisions"],
23
+ # "price_usd": 342,
24
+ # "in_stock_from": "2016-11-16T08:00Z",
25
+ # "!cascadeCreate": true
26
+ # }
27
+ # ```
28
+ #
29
+ # Special parameter `!cascadeCreate` may be used. It indicates that the item of the given itemId should be created if it does not exist in the database, as if the corresponding PUT method was used. Note the exclamation mark (!) at the beginning of the parameter's name to distinguish it from item property names.
30
+ #
31
+ #
32
+ # * *Optional arguments (given as hash optional)*
33
+ # - +cascadeCreate+ -> Sets whether the item should be created if not present in the database.
34
+ #
36
35
  def initialize(item_id, values, optional = {})
37
36
  super(values, optional)
38
37
  @item_id = item_id
39
38
  @timeout = 1000
40
39
  @ensure_https = false
41
40
  end
42
-
41
+
43
42
  # Relative path to the endpoint
44
43
  def path
45
44
  "/{databaseId}/items/#{@item_id}"
@@ -1,32 +1,31 @@
1
1
  module RecombeeApiClient
2
2
  require_relative 'set_values'
3
3
  require_relative '../errors'
4
-
4
+
5
5
  ##
6
- #Set/update (some) property values of a given user. The properties (columns) must be previously created by [Add user property](https://docs.recombee.com/api#add-user-property).
6
+ # Set/update (some) property values of a given user. The properties (columns) must be previously created by [Add user property](https://docs.recombee.com/api#add-user-property).
7
7
  #
8
8
  class SetUserValues < SetValues
9
9
  attr_reader :user_id
10
- attr_accessor :timeout
11
- attr_accessor :ensure_https
12
-
13
- ##
14
- # * *Required arguments*
15
- # - +user_id+ -> ID of the user which will be modified.
16
- #
17
- # - +values+ -> The values for the individual properties.
18
- #
19
- #Example of body:
20
- #```
21
- # {
22
- # "country": "US",
23
- # "sex": "F",
24
- # }
25
- #```
26
- #
27
- # * *Optional arguments (given as hash optional)*
28
- # - +cascadeCreate+ -> Sets whether the item should be created if not present in the database.
29
- #
10
+ attr_accessor :timeout, :ensure_https
11
+
12
+ ##
13
+ # * *Required arguments*
14
+ # - +user_id+ -> ID of the user which will be modified.
15
+ #
16
+ # - +values+ -> The values for the individual properties.
17
+ #
18
+ # Example of body:
19
+ # ```
20
+ # {
21
+ # "country": "US",
22
+ # "sex": "F",
23
+ # }
24
+ # ```
25
+ #
26
+ # * *Optional arguments (given as hash optional)*
27
+ # - +cascadeCreate+ -> Sets whether the item should be created if not present in the database.
28
+ #
30
29
  def initialize(user_id, values, optional = {})
31
30
  super(values, optional)
32
31
  @user_id = user_id
@@ -1,57 +1,57 @@
1
1
  module RecombeeApiClient
2
2
  require_relative 'request'
3
3
  require_relative '../errors'
4
-
4
+
5
5
  ##
6
- #Set/update (some) property values of a given entity.
6
+ # Set/update (some) property values of a given entity.
7
7
  #
8
8
  class SetValues < ApiRequest
9
9
  attr_reader :cascade_create, :values
10
-
11
- ##
12
- # * *Required arguments*
13
- # - +values+ -> The values for the individual properties.
14
- #
15
- #Example of body:
16
- #```
17
- # {
18
- # "product_description": "4K TV with 3D feature",
19
- # "categories": ["Electronics", "Televisions"],
20
- # "price_usd": 342,
21
- # "in_stock_from": "2016-11-16T08:00Z",
22
- # }
23
- #```
24
- #
25
- # * *Optional arguments (given as hash optional)*
26
- # - +cascadeCreate+ -> Sets whether the item should be created if not present in the database.
27
- #
28
- def initialize( values, optional = {})
10
+
11
+ ##
12
+ # * *Required arguments*
13
+ # - +values+ -> The values for the individual properties.
14
+ #
15
+ # Example of body:
16
+ # ```
17
+ # {
18
+ # "product_description": "4K TV with 3D feature",
19
+ # "categories": ["Electronics", "Televisions"],
20
+ # "price_usd": 342,
21
+ # "in_stock_from": "2016-11-16T08:00Z",
22
+ # }
23
+ # ```
24
+ #
25
+ # * *Optional arguments (given as hash optional)*
26
+ # - +cascadeCreate+ -> Sets whether the item should be created if not present in the database.
27
+ #
28
+ def initialize(values, optional = {})
29
29
  @values = values
30
- optional = normalize_optional(optional)
30
+ optional = normalize_hash_to_camel_case(optional)
31
31
  @cascade_create = optional['cascadeCreate']
32
32
  @optional = optional
33
33
  @optional.each do |par, _|
34
- fail UnknownOptionalParameter.new(par) unless ["cascadeCreate"].include? par
34
+ raise UnknownOptionalParameter.new(par) unless ['cascadeCreate'].include? par
35
35
  end
36
36
  end
37
-
37
+
38
38
  # HTTP method
39
39
  def method
40
40
  :post
41
41
  end
42
-
42
+
43
43
  # Values of body parameters as a Hash
44
44
  def body_parameters
45
- result = Hash.new
45
+ result = {}
46
46
  result = result.merge(@values)
47
47
  result['!cascadeCreate'] = true if @cascade_create
48
48
  result
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
- Hash.new
54
+ {}
55
55
  end
56
56
  end
57
57
  end