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.
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 +69 -68
  64. data/lib/recombee_api_client/api/recommend_item_segments_to_item_segment.rb +70 -69
  65. data/lib/recombee_api_client/api/recommend_item_segments_to_user.rb +51 -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 +52 -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,81 +5,80 @@
5
5
  module RecombeeApiClient
6
6
  require_relative 'request'
7
7
  require_relative '../errors'
8
-
8
+
9
9
  ##
10
- #Gets a list of IDs of users currently present in the catalog.
10
+ # Gets a list of IDs of users currently present in the catalog.#
11
11
  class ListUsers < ApiRequest
12
12
  attr_reader :filter, :count, :offset, :return_properties, :included_properties
13
- attr_accessor :timeout
14
- attr_accessor :ensure_https
15
-
16
- ##
17
- #
18
- # * *Optional arguments (given as hash optional)*
19
- # - +filter+ -> Boolean-returning [ReQL](https://docs.recombee.com/reql) expression, which allows you to filter users to be listed. Only the users for which the expression is *true* will be returned.
20
- # - +count+ -> The number of users to be listed.
21
- # - +offset+ -> Specifies the number of users to skip (ordered by `userId`).
22
- # - +returnProperties+ -> With `returnProperties=true`, property values of the listed users are returned along with their IDs in a JSON dictionary.
23
- #
24
- #Example response:
25
- #```json
26
- # [
27
- # {
28
- # "userId": "user-81",
29
- # "country": "US",
30
- # "sex": "M"
31
- # },
32
- # {
33
- # "userId": "user-314",
34
- # "country": "CAN",
35
- # "sex": "F"
36
- # }
37
- # ]
38
- #```
39
- #
40
- # - +includedProperties+ -> Allows specifying which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list.
41
- #
42
- #Example response for `includedProperties=country`:
43
- #```json
44
- # [
45
- # {
46
- # "userId": "user-81",
47
- # "country": "US"
48
- # },
49
- # {
50
- # "userId": "user-314",
51
- # "country": "CAN"
52
- # }
53
- # ]
54
- #```
55
- #
56
- #
13
+ attr_accessor :timeout, :ensure_https
14
+
15
+ ##
16
+ #
17
+ # * *Optional arguments (given as hash optional)*
18
+ # - +filter+ -> Boolean-returning [ReQL](https://docs.recombee.com/reql) expression, which allows you to filter users to be listed. Only the users for which the expression is *true* will be returned.
19
+ # - +count+ -> The number of users to be listed.
20
+ # - +offset+ -> Specifies the number of users to skip (ordered by `userId`).
21
+ # - +returnProperties+ -> With `returnProperties=true`, property values of the listed users are returned along with their IDs in a JSON dictionary.
22
+ #
23
+ # Example response:
24
+ # ```json
25
+ # [
26
+ # {
27
+ # "userId": "user-81",
28
+ # "country": "US",
29
+ # "sex": "M"
30
+ # },
31
+ # {
32
+ # "userId": "user-314",
33
+ # "country": "CAN",
34
+ # "sex": "F"
35
+ # }
36
+ # ]
37
+ # ```
38
+ #
39
+ # - +includedProperties+ -> Allows specifying which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list.
40
+ #
41
+ # Example response for `includedProperties=country`:
42
+ # ```json
43
+ # [
44
+ # {
45
+ # "userId": "user-81",
46
+ # "country": "US"
47
+ # },
48
+ # {
49
+ # "userId": "user-314",
50
+ # "country": "CAN"
51
+ # }
52
+ # ]
53
+ # ```
54
+ #
55
+ #
57
56
  def initialize(optional = {})
58
- optional = normalize_optional(optional)
57
+ optional = normalize_hash_to_camel_case(optional)
59
58
  @filter = optional['filter']
60
59
  @count = optional['count']
61
60
  @offset = optional['offset']
62
61
  @return_properties = optional['returnProperties']
63
62
  @included_properties = optional['includedProperties']
64
63
  @optional = optional
65
- @timeout = 100000
64
+ @timeout = 100_000
66
65
  @ensure_https = false
67
66
  @optional.each do |par, _|
68
- fail UnknownOptionalParameter.new(par) unless ["filter","count","offset","returnProperties","includedProperties"].include? par
67
+ raise UnknownOptionalParameter.new(par) unless %w[filter count offset returnProperties
68
+ includedProperties].include? par
69
69
  end
70
70
  end
71
-
71
+
72
72
  # HTTP method
73
73
  def method
74
74
  :get
75
75
  end
76
-
76
+
77
77
  # Values of body parameters as a Hash
78
78
  def body_parameters
79
- p = Hash.new
80
- p
79
+ {}
81
80
  end
82
-
81
+
83
82
  # Values of query parameters as a Hash.
84
83
  # name of parameter => value of the parameter
85
84
  def query_parameters
@@ -89,12 +88,13 @@ module RecombeeApiClient
89
88
  params['offset'] = @optional['offset'] if @optional['offset']
90
89
  params['returnProperties'] = @optional['returnProperties'] if @optional['returnProperties']
91
90
  params['includedProperties'] = @optional['includedProperties'] if @optional['includedProperties']
91
+
92
92
  params
93
93
  end
94
-
94
+
95
95
  # Relative path to the endpoint
96
96
  def path
97
- "/{databaseId}/users/list/"
97
+ '/{databaseId}/users/list/'
98
98
  end
99
99
  end
100
100
  end
@@ -5,61 +5,60 @@
5
5
  module RecombeeApiClient
6
6
  require_relative 'request'
7
7
  require_relative '../errors'
8
-
8
+
9
9
  ##
10
- #Merges interactions (purchases, ratings, bookmarks, detail views ...) of two different users under a single user ID. This is especially useful for online e-commerce applications working with anonymous users identified by unique tokens such as the session ID. In such applications, it may often happen that a user owns a persistent account, yet accesses the system anonymously while, e.g., putting items into a shopping cart. At some point in time, such as when the user wishes to confirm the purchase, (s)he logs into the system using his/her username and password. The interactions made under anonymous session ID then become connected with the persistent account, and merging these two becomes desirable.
10
+ # Merges interactions (purchases, ratings, bookmarks, detail views ...) of two different users under a single user ID. This is especially useful for online e-commerce applications working with anonymous users identified by unique tokens such as the session ID. In such applications, it may often happen that a user owns a persistent account, yet accesses the system anonymously while, e.g., putting items into a shopping cart. At some point in time, such as when the user wishes to confirm the purchase, (s)he logs into the system using his/her username and password. The interactions made under anonymous session ID then become connected with the persistent account, and merging these two becomes desirable.
11
11
  #
12
12
  #
13
- #Merging happens between two users referred to as the *target* and the *source*. After the merge, all the interactions of the source user are attributed to the target user, and the source user is **deleted**.
13
+ # Merging happens between two users referred to as the *target* and the *source*. After the merge, all the interactions of the source user are attributed to the target user, and the source user is **deleted**.
14
14
  #
15
- #By default, the *Merge Users* request is only available from server-side integrations for security reasons, to prevent potential abuse.
16
- #If you need to call this request from a client-side environment (such as a web or mobile app), please contact our support and request access to enable this feature for your database.
15
+ # By default, the *Merge Users* request is only available from server-side integrations for security reasons, to prevent potential abuse.
16
+ # If you need to call this request from a client-side environment (such as a web or mobile app), please contact our support and request access to enable this feature for your database.
17
17
  #
18
18
  class MergeUsers < ApiRequest
19
19
  attr_reader :target_user_id, :source_user_id, :cascade_create
20
- attr_accessor :timeout
21
- attr_accessor :ensure_https
22
-
23
- ##
24
- # * *Required arguments*
25
- # - +target_user_id+ -> ID of the target user.
26
- # - +source_user_id+ -> ID of the source user.
27
- #
28
- # * *Optional arguments (given as hash optional)*
29
- # - +cascadeCreate+ -> Sets whether the user *targetUserId* should be created if not present in the database.
30
- #
20
+ attr_accessor :timeout, :ensure_https
21
+
22
+ ##
23
+ # * *Required arguments*
24
+ # - +target_user_id+ -> ID of the target user.
25
+ # - +source_user_id+ -> ID of the source user.
26
+ #
27
+ # * *Optional arguments (given as hash optional)*
28
+ # - +cascadeCreate+ -> Sets whether the user *targetUserId* should be created if not present in the database.
29
+ #
31
30
  def initialize(target_user_id, source_user_id, optional = {})
32
31
  @target_user_id = target_user_id
33
32
  @source_user_id = source_user_id
34
- optional = normalize_optional(optional)
33
+ optional = normalize_hash_to_camel_case(optional)
35
34
  @cascade_create = optional['cascadeCreate']
36
35
  @optional = optional
37
- @timeout = 10000
36
+ @timeout = 10_000
38
37
  @ensure_https = false
39
38
  @optional.each do |par, _|
40
- fail UnknownOptionalParameter.new(par) unless ["cascadeCreate"].include? par
39
+ raise UnknownOptionalParameter.new(par) unless ['cascadeCreate'].include? par
41
40
  end
42
41
  end
43
-
42
+
44
43
  # HTTP method
45
44
  def method
46
45
  :put
47
46
  end
48
-
47
+
49
48
  # Values of body parameters as a Hash
50
49
  def body_parameters
51
- p = Hash.new
52
- p
50
+ {}
53
51
  end
54
-
52
+
55
53
  # Values of query parameters as a Hash.
56
54
  # name of parameter => value of the parameter
57
55
  def query_parameters
58
56
  params = {}
59
57
  params['cascadeCreate'] = @optional['cascadeCreate'] if @optional['cascadeCreate']
58
+
60
59
  params
61
60
  end
62
-
61
+
63
62
  # Relative path to the endpoint
64
63
  def path
65
64
  "/{databaseId}/users/#{@target_user_id}/merge/#{@source_user_id}"
@@ -5,82 +5,82 @@
5
5
  module RecombeeApiClient
6
6
  require_relative 'request'
7
7
  require_relative '../errors'
8
-
8
+
9
9
  ##
10
- #Recommends Segments from a [Segmentation](https://docs.recombee.com/segmentations) that are the most relevant to a particular item.
10
+ # Recommends Segments from a [Segmentation](https://docs.recombee.com/segmentations) that are the most relevant to a particular item.
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
  # - Recommending the related categories
15
15
  # - Recommending the related genres
16
16
  # - Recommending the related brands
17
17
  # - Recommending the related artists
18
18
  #
19
- #You need to set the used Segmentation the Admin UI in the [Scenario settings](https://docs.recombee.com/scenarios) prior to using this endpoint.
19
+ # You need to set the used Segmentation the Admin UI in the [Scenario settings](https://docs.recombee.com/scenarios) 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 RecommendItemSegmentsToItem < ApiRequest
26
- attr_reader :item_id, :target_user_id, :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
- # - +item_id+ -> ID of the item for which the recommendations are to be generated.
33
- # - +target_user_id+ -> ID of the user who will see the recommendations.
34
- #
35
- #Specifying the *targetUserId* is beneficial because:
36
- #
37
- #* It makes the recommendations personalized
38
- #* Allows the calculation of Actions and Conversions
39
- # in the graphical user interface,
40
- # as Recombee can pair the user who got recommendations
41
- # and who afterward viewed/purchased an item.
42
- #
43
- #If you insist on not specifying the user, pass `null`
44
- #(`None`, `nil`, `NULL` etc., depending on the language) to *targetUserId*.
45
- #Do not create some special dummy user for getting recommendations,
46
- #as it could mislead the recommendation models,
47
- #and result in wrong recommendations.
48
- #
49
- #For anonymous/unregistered users, it is possible to use, for example, their session ID.
50
- #
51
- # - +count+ -> Number of item segments to be recommended (N for the top-N recommendation).
52
- #
53
- #
54
- # * *Optional arguments (given as hash optional)*
55
- # - +scenario+ -> Scenario defines a particular application of recommendations. It can be, for example, "homepage", "cart", or "emailing".
56
- #
57
- #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.
58
- #
59
- #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.
60
- #
61
- # - +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.
62
- #
63
- # - +filter+ -> Boolean-returning [ReQL](https://docs.recombee.com/reql) expression which allows you to filter recommended segments based on the `segmentationId`.
64
- #
65
- # - +booster+ -> Number-returning [ReQL](https://docs.recombee.com/reql) expression which allows you to boost recommendation rate of some segments based on the `segmentationId`.
66
- #
67
- # - +logic+ -> Logic specifies the particular behavior of the recommendation models. You can pick tailored logic for your domain and use case.
68
- #See [this section](https://docs.recombee.com/recommendation_logics) for a list of available logics and other details.
69
- #
70
- #The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
71
- #
72
- #Logic can also be set to a [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com).
73
- #
74
- # - +expertSettings+ -> Dictionary of custom options.
75
- #
76
- # - +returnAbGroup+ -> If there is a custom AB-testing running, return the name of the group to which the request belongs.
77
- #
78
- #
26
+ attr_reader :item_id, :target_user_id, :count, :scenario, :cascade_create, :filter, :booster, :logic,
27
+ :expert_settings, :return_ab_group
28
+ attr_accessor :timeout, :ensure_https
29
+
30
+ ##
31
+ # * *Required arguments*
32
+ # - +item_id+ -> ID of the item for which the recommendations are to be generated.
33
+ # - +target_user_id+ -> ID of the user who will see the recommendations.
34
+ #
35
+ # Specifying the *targetUserId* is beneficial because:
36
+ #
37
+ # * It makes the recommendations personalized
38
+ # * Allows the calculation of Actions and Conversions
39
+ # in the graphical user interface,
40
+ # as Recombee can pair the user who got recommendations
41
+ # and who afterward viewed/purchased an item.
42
+ #
43
+ # If you insist on not specifying the user, pass `null`
44
+ # (`None`, `nil`, `NULL` etc., depending on the language) to *targetUserId*.
45
+ # Do not create some special dummy user for getting recommendations,
46
+ # as it could mislead the recommendation models,
47
+ # and result in wrong recommendations.
48
+ #
49
+ # For anonymous/unregistered users, it is possible to use, for example, their session ID.
50
+ #
51
+ # - +count+ -> Number of item segments to be recommended (N for the top-N recommendation).
52
+ #
53
+ #
54
+ # * *Optional arguments (given as hash optional)*
55
+ # - +scenario+ -> Scenario defines a particular application of recommendations. It can be, for example, "homepage", "cart", or "emailing".
56
+ #
57
+ # 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.
58
+ #
59
+ # 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.
60
+ #
61
+ # - +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.
62
+ #
63
+ # - +filter+ -> Boolean-returning [ReQL](https://docs.recombee.com/reql) expression which allows you to filter recommended segments based on the `segmentationId`.
64
+ #
65
+ # - +booster+ -> Number-returning [ReQL](https://docs.recombee.com/reql) expression which allows you to boost recommendation rate of some segments based on the `segmentationId`.
66
+ #
67
+ # - +logic+ -> Logic specifies the particular behavior of the recommendation models. You can pick tailored logic for your domain and use case.
68
+ # See [this section](https://docs.recombee.com/recommendation_logics) for a list of available logics and other details.
69
+ #
70
+ # The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
71
+ #
72
+ # Logic can also be set to a [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com).
73
+ #
74
+ # - +expertSettings+ -> Dictionary of custom options.
75
+ #
76
+ # - +returnAbGroup+ -> If there is a custom AB-testing running, return the name of the group to which the request belongs.
77
+ #
78
+ #
79
79
  def initialize(item_id, target_user_id, count, optional = {})
80
80
  @item_id = item_id
81
81
  @target_user_id = target_user_id
82
82
  @count = count
83
- optional = normalize_optional(optional)
83
+ optional = normalize_hash_to_camel_case(optional)
84
84
  @scenario = optional['scenario']
85
85
  @cascade_create = optional['cascadeCreate']
86
86
  @filter = optional['filter']
@@ -92,18 +92,19 @@ module RecombeeApiClient
92
92
  @timeout = 3000
93
93
  @ensure_https = false
94
94
  @optional.each do |par, _|
95
- fail UnknownOptionalParameter.new(par) unless ["scenario","cascadeCreate","filter","booster","logic","expertSettings","returnAbGroup"].include? par
95
+ raise UnknownOptionalParameter.new(par) unless %w[scenario cascadeCreate filter booster logic
96
+ expertSettings returnAbGroup].include? par
96
97
  end
97
98
  end
98
-
99
+
99
100
  # HTTP method
100
101
  def method
101
102
  :post
102
103
  end
103
-
104
+
104
105
  # Values of body parameters as a Hash
105
106
  def body_parameters
106
- p = Hash.new
107
+ p = {}
107
108
  p['targetUserId'] = @target_user_id
108
109
  p['count'] = @count
109
110
  p['scenario'] = @optional['scenario'] if @optional.include? 'scenario'
@@ -113,16 +114,16 @@ module RecombeeApiClient
113
114
  p['logic'] = @optional['logic'] if @optional.include? 'logic'
114
115
  p['expertSettings'] = @optional['expertSettings'] if @optional.include? 'expertSettings'
115
116
  p['returnAbGroup'] = @optional['returnAbGroup'] if @optional.include? 'returnAbGroup'
117
+
116
118
  p
117
119
  end
118
-
120
+
119
121
  # Values of query parameters as a Hash.
120
122
  # name of parameter => value of the parameter
121
123
  def query_parameters
122
- params = {}
123
- params
124
+ {}
124
125
  end
125
-
126
+
126
127
  # Relative path to the endpoint
127
128
  def path
128
129
  "/{databaseId}/recomms/items/#{@item_id}/item-segments/"
@@ -5,81 +5,81 @@
5
5
  module RecombeeApiClient
6
6
  require_relative 'request'
7
7
  require_relative '../errors'
8
-
8
+
9
9
  ##
10
- #Recommends Segments from a result [Segmentation](https://docs.recombee.com/segmentations) that are the most relevant to a particular Segment from a context Segmentation.
10
+ # Recommends Segments from a result [Segmentation](https://docs.recombee.com/segmentations) that are the most relevant to a particular Segment from a context Segmentation.
11
11
  #
12
- #Based on the used Segmentations, this endpoint can be used for example for:
12
+ # Based on the used Segmentations, this endpoint can be used for example for:
13
13
  #
14
14
  # - Recommending the related brands to particular brand
15
15
  # - Recommending the related brands to particular category
16
16
  # - Recommending the related artists to a particular genre (assuming songs are the Items)
17
17
  #
18
- #You need to set the used context and result Segmentation the Admin UI in the [Scenario settings](https://docs.recombee.com/scenarios) prior to using this endpoint.
18
+ # You need to set the used context and result Segmentation the Admin UI in the [Scenario settings](https://docs.recombee.com/scenarios) prior to using this endpoint.
19
19
  #
20
- #The returned segments are sorted by relevance (first segment being the most relevant).
20
+ # The returned segments are sorted by relevance (first segment being the most relevant).
21
21
  #
22
- #It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters.
22
+ # 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
23
  #
24
24
  class RecommendItemSegmentsToItemSegment < ApiRequest
25
- attr_reader :context_segment_id, :target_user_id, :count, :scenario, :cascade_create, :filter, :booster, :logic, :expert_settings, :return_ab_group
26
- attr_accessor :timeout
27
- attr_accessor :ensure_https
28
-
29
- ##
30
- # * *Required arguments*
31
- # - +context_segment_id+ -> ID of the segment from `contextSegmentationId` for which the recommendations are to be generated.
32
- # - +target_user_id+ -> ID of the user who will see the recommendations.
33
- #
34
- #Specifying the *targetUserId* is beneficial because:
35
- #
36
- #* It makes the recommendations personalized
37
- #* Allows the calculation of Actions and Conversions
38
- # in the graphical user interface,
39
- # as Recombee can pair the user who got recommendations
40
- # and who afterward viewed/purchased an item.
41
- #
42
- #If you insist on not specifying the user, pass `null`
43
- #(`None`, `nil`, `NULL` etc., depending on the language) to *targetUserId*.
44
- #Do not create some special dummy user for getting recommendations,
45
- #as it could mislead the recommendation models,
46
- #and result in wrong recommendations.
47
- #
48
- #For anonymous/unregistered users, it is possible to use, for example, their session ID.
49
- #
50
- # - +count+ -> Number of item segments to be recommended (N for the top-N recommendation).
51
- #
52
- #
53
- # * *Optional arguments (given as hash optional)*
54
- # - +scenario+ -> Scenario defines a particular application of recommendations. It can be, for example, "homepage", "cart", or "emailing".
55
- #
56
- #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.
57
- #
58
- #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.
59
- #
60
- # - +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.
61
- #
62
- # - +filter+ -> Boolean-returning [ReQL](https://docs.recombee.com/reql) expression which allows you to filter recommended segments based on the `segmentationId`.
63
- #
64
- # - +booster+ -> Number-returning [ReQL](https://docs.recombee.com/reql) expression which allows you to boost recommendation rate of some segments based on the `segmentationId`.
65
- #
66
- # - +logic+ -> Logic specifies the particular behavior of the recommendation models. You can pick tailored logic for your domain and use case.
67
- #See [this section](https://docs.recombee.com/recommendation_logics) for a list of available logics and other details.
68
- #
69
- #The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
70
- #
71
- #Logic can also be set to a [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com).
72
- #
73
- # - +expertSettings+ -> Dictionary of custom options.
74
- #
75
- # - +returnAbGroup+ -> If there is a custom AB-testing running, return the name of the group to which the request belongs.
76
- #
77
- #
25
+ attr_reader :context_segment_id, :target_user_id, :count, :scenario, :cascade_create, :filter, :booster, :logic,
26
+ :expert_settings, :return_ab_group
27
+ attr_accessor :timeout, :ensure_https
28
+
29
+ ##
30
+ # * *Required arguments*
31
+ # - +context_segment_id+ -> ID of the segment from `contextSegmentationId` for which the recommendations are to be generated.
32
+ # - +target_user_id+ -> ID of the user who will see the recommendations.
33
+ #
34
+ # Specifying the *targetUserId* is beneficial because:
35
+ #
36
+ # * It makes the recommendations personalized
37
+ # * Allows the calculation of Actions and Conversions
38
+ # in the graphical user interface,
39
+ # as Recombee can pair the user who got recommendations
40
+ # and who afterward viewed/purchased an item.
41
+ #
42
+ # If you insist on not specifying the user, pass `null`
43
+ # (`None`, `nil`, `NULL` etc., depending on the language) to *targetUserId*.
44
+ # Do not create some special dummy user for getting recommendations,
45
+ # as it could mislead the recommendation models,
46
+ # and result in wrong recommendations.
47
+ #
48
+ # For anonymous/unregistered users, it is possible to use, for example, their session ID.
49
+ #
50
+ # - +count+ -> Number of item segments to be recommended (N for the top-N recommendation).
51
+ #
52
+ #
53
+ # * *Optional arguments (given as hash optional)*
54
+ # - +scenario+ -> Scenario defines a particular application of recommendations. It can be, for example, "homepage", "cart", or "emailing".
55
+ #
56
+ # 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.
57
+ #
58
+ # 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.
59
+ #
60
+ # - +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.
61
+ #
62
+ # - +filter+ -> Boolean-returning [ReQL](https://docs.recombee.com/reql) expression which allows you to filter recommended segments based on the `segmentationId`.
63
+ #
64
+ # - +booster+ -> Number-returning [ReQL](https://docs.recombee.com/reql) expression which allows you to boost recommendation rate of some segments based on the `segmentationId`.
65
+ #
66
+ # - +logic+ -> Logic specifies the particular behavior of the recommendation models. You can pick tailored logic for your domain and use case.
67
+ # See [this section](https://docs.recombee.com/recommendation_logics) for a list of available logics and other details.
68
+ #
69
+ # The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
70
+ #
71
+ # Logic can also be set to a [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com).
72
+ #
73
+ # - +expertSettings+ -> Dictionary of custom options.
74
+ #
75
+ # - +returnAbGroup+ -> If there is a custom AB-testing running, return the name of the group to which the request belongs.
76
+ #
77
+ #
78
78
  def initialize(context_segment_id, target_user_id, count, optional = {})
79
79
  @context_segment_id = context_segment_id
80
80
  @target_user_id = target_user_id
81
81
  @count = count
82
- optional = normalize_optional(optional)
82
+ optional = normalize_hash_to_camel_case(optional)
83
83
  @scenario = optional['scenario']
84
84
  @cascade_create = optional['cascadeCreate']
85
85
  @filter = optional['filter']
@@ -91,18 +91,19 @@ module RecombeeApiClient
91
91
  @timeout = 3000
92
92
  @ensure_https = false
93
93
  @optional.each do |par, _|
94
- fail UnknownOptionalParameter.new(par) unless ["scenario","cascadeCreate","filter","booster","logic","expertSettings","returnAbGroup"].include? par
94
+ raise UnknownOptionalParameter.new(par) unless %w[scenario cascadeCreate filter booster logic
95
+ expertSettings returnAbGroup].include? par
95
96
  end
96
97
  end
97
-
98
+
98
99
  # HTTP method
99
100
  def method
100
101
  :post
101
102
  end
102
-
103
+
103
104
  # Values of body parameters as a Hash
104
105
  def body_parameters
105
- p = Hash.new
106
+ p = {}
106
107
  p['contextSegmentId'] = @context_segment_id
107
108
  p['targetUserId'] = @target_user_id
108
109
  p['count'] = @count
@@ -113,19 +114,19 @@ module RecombeeApiClient
113
114
  p['logic'] = @optional['logic'] if @optional.include? 'logic'
114
115
  p['expertSettings'] = @optional['expertSettings'] if @optional.include? 'expertSettings'
115
116
  p['returnAbGroup'] = @optional['returnAbGroup'] if @optional.include? 'returnAbGroup'
117
+
116
118
  p
117
119
  end
118
-
120
+
119
121
  # Values of query parameters as a Hash.
120
122
  # name of parameter => value of the parameter
121
123
  def query_parameters
122
- params = {}
123
- params
124
+ {}
124
125
  end
125
-
126
+
126
127
  # Relative path to the endpoint
127
128
  def path
128
- "/{databaseId}/recomms/item-segments/item-segments/"
129
+ '/{databaseId}/recomms/item-segments/item-segments/'
129
130
  end
130
131
  end
131
132
  end