recombee_api_client 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -0
  3. data/lib/recombee_api_client.rb +15 -0
  4. data/lib/recombee_api_client/api/add_bookmark.rb +2 -8
  5. data/lib/recombee_api_client/api/add_cart_addition.rb +2 -8
  6. data/lib/recombee_api_client/api/add_detail_view.rb +2 -8
  7. data/lib/recombee_api_client/api/add_group.rb +2 -8
  8. data/lib/recombee_api_client/api/add_item.rb +2 -8
  9. data/lib/recombee_api_client/api/add_item_property.rb +2 -8
  10. data/lib/recombee_api_client/api/add_purchase.rb +2 -8
  11. data/lib/recombee_api_client/api/add_rating.rb +2 -8
  12. data/lib/recombee_api_client/api/add_series.rb +2 -8
  13. data/lib/recombee_api_client/api/add_user.rb +2 -8
  14. data/lib/recombee_api_client/api/batch.rb +5 -3
  15. data/lib/recombee_api_client/api/delete_bookmark.rb +3 -13
  16. data/lib/recombee_api_client/api/delete_cart_addition.rb +3 -13
  17. data/lib/recombee_api_client/api/delete_detail_view.rb +3 -13
  18. data/lib/recombee_api_client/api/delete_group.rb +2 -8
  19. data/lib/recombee_api_client/api/delete_item.rb +2 -8
  20. data/lib/recombee_api_client/api/delete_item_property.rb +2 -8
  21. data/lib/recombee_api_client/api/delete_purchase.rb +3 -13
  22. data/lib/recombee_api_client/api/delete_rating.rb +3 -13
  23. data/lib/recombee_api_client/api/delete_series.rb +2 -8
  24. data/lib/recombee_api_client/api/delete_user.rb +2 -8
  25. data/lib/recombee_api_client/api/get_item_property_info.rb +2 -8
  26. data/lib/recombee_api_client/api/get_item_values.rb +2 -8
  27. data/lib/recombee_api_client/api/insert_to_group.rb +2 -8
  28. data/lib/recombee_api_client/api/insert_to_series.rb +2 -8
  29. data/lib/recombee_api_client/api/item_based_recommendation.rb +49 -55
  30. data/lib/recombee_api_client/api/list_group_items.rb +2 -8
  31. data/lib/recombee_api_client/api/list_groups.rb +2 -8
  32. data/lib/recombee_api_client/api/list_item_bookmarks.rb +2 -8
  33. data/lib/recombee_api_client/api/list_item_cart_additions.rb +2 -8
  34. data/lib/recombee_api_client/api/list_item_detail_views.rb +2 -8
  35. data/lib/recombee_api_client/api/list_item_properties.rb +2 -8
  36. data/lib/recombee_api_client/api/list_item_purchases.rb +2 -8
  37. data/lib/recombee_api_client/api/list_item_ratings.rb +2 -8
  38. data/lib/recombee_api_client/api/list_items.rb +2 -12
  39. data/lib/recombee_api_client/api/list_series.rb +2 -8
  40. data/lib/recombee_api_client/api/list_series_items.rb +2 -8
  41. data/lib/recombee_api_client/api/list_user_bookmarks.rb +2 -8
  42. data/lib/recombee_api_client/api/list_user_cart_additions.rb +2 -8
  43. data/lib/recombee_api_client/api/list_user_detail_views.rb +2 -8
  44. data/lib/recombee_api_client/api/list_user_purchases.rb +2 -8
  45. data/lib/recombee_api_client/api/list_user_ratings.rb +2 -8
  46. data/lib/recombee_api_client/api/list_users.rb +2 -8
  47. data/lib/recombee_api_client/api/merge_users.rb +2 -12
  48. data/lib/recombee_api_client/api/remove_from_group.rb +2 -8
  49. data/lib/recombee_api_client/api/remove_from_series.rb +2 -8
  50. data/lib/recombee_api_client/api/reset_database.rb +3 -9
  51. data/lib/recombee_api_client/api/set_item_values.rb +6 -11
  52. data/lib/recombee_api_client/api/user_based_recommendation.rb +49 -47
  53. data/lib/recombee_api_client/version.rb +1 -1
  54. metadata +2 -2
@@ -39,7 +39,7 @@ module RecombeeApiClient
39
39
  p
40
40
  end
41
41
 
42
- # Values of query path parameters as a Hash.
42
+ # Values of query parameters as a Hash.
43
43
  # name of parameter => value of the parameter
44
44
  def query_parameters
45
45
  params = {}
@@ -47,14 +47,8 @@ module RecombeeApiClient
47
47
  end
48
48
 
49
49
  # Relative path to the endpoint
50
- def basic_path
51
- "/{databaseId}/items/#{@item_id}"
52
- end
53
-
54
- # Relative path to the endpoint including query parameters
55
50
  def path
56
- p = "/{databaseId}/items/#{@item_id}"
57
- p
51
+ "/{databaseId}/items/#{@item_id}"
58
52
  end
59
53
  end
60
54
  end
@@ -35,7 +35,7 @@ module RecombeeApiClient
35
35
  p
36
36
  end
37
37
 
38
- # Values of query path parameters as a Hash.
38
+ # Values of query parameters as a Hash.
39
39
  # name of parameter => value of the parameter
40
40
  def query_parameters
41
41
  params = {}
@@ -43,14 +43,8 @@ module RecombeeApiClient
43
43
  end
44
44
 
45
45
  # Relative path to the endpoint
46
- def basic_path
47
- "/{databaseId}/items/properties/#{@property_name}"
48
- end
49
-
50
- # Relative path to the endpoint including query parameters
51
46
  def path
52
- p = "/{databaseId}/items/properties/#{@property_name}"
53
- p
47
+ "/{databaseId}/items/properties/#{@property_name}"
54
48
  end
55
49
  end
56
50
  end
@@ -7,7 +7,7 @@ module RecombeeApiClient
7
7
  require_relative '../errors'
8
8
 
9
9
  ##
10
- #Deletes an existing purchase uniquely specified by `userId`, `itemId`, and `timestamp`.
10
+ #Deletes an existing purchase uniquely specified by `userId`, `itemId`, and `timestamp` or all the purchases with given `userId` and `itemId` if `timestamp` is omitted.
11
11
  #
12
12
  class DeletePurchase < ApiRequest
13
13
  attr_reader :user_id, :item_id, :timestamp
@@ -45,7 +45,7 @@ module RecombeeApiClient
45
45
  p
46
46
  end
47
47
 
48
- # Values of query path parameters as a Hash.
48
+ # Values of query parameters as a Hash.
49
49
  # name of parameter => value of the parameter
50
50
  def query_parameters
51
51
  params = {}
@@ -56,18 +56,8 @@ module RecombeeApiClient
56
56
  end
57
57
 
58
58
  # Relative path to the endpoint
59
- def basic_path
60
- "/{databaseId}/purchases/"
61
- end
62
-
63
- # Relative path to the endpoint including query parameters
64
59
  def path
65
- p = "/{databaseId}/purchases/?userId=#{@user_id}&itemId=#{@item_id}"
66
- if @optional.include? 'timestamp'
67
- p += (p.include? '?') ? '&' : '?'
68
- p += "timestamp=#{@optional['timestamp']}"
69
- end
70
- p
60
+ "/{databaseId}/purchases/"
71
61
  end
72
62
  end
73
63
  end
@@ -7,7 +7,7 @@ module RecombeeApiClient
7
7
  require_relative '../errors'
8
8
 
9
9
  ##
10
- #Deletes an existing rating specified by (`userId`, `itemId`, `timestamp`) from the database.
10
+ #Deletes an existing rating specified by (`userId`, `itemId`, `timestamp`) from the database or all the ratings with given `userId` and `itemId` if `timestamp` is omitted.
11
11
  #
12
12
  class DeleteRating < ApiRequest
13
13
  attr_reader :user_id, :item_id, :timestamp
@@ -45,7 +45,7 @@ module RecombeeApiClient
45
45
  p
46
46
  end
47
47
 
48
- # Values of query path parameters as a Hash.
48
+ # Values of query parameters as a Hash.
49
49
  # name of parameter => value of the parameter
50
50
  def query_parameters
51
51
  params = {}
@@ -56,18 +56,8 @@ module RecombeeApiClient
56
56
  end
57
57
 
58
58
  # Relative path to the endpoint
59
- def basic_path
60
- "/{databaseId}/ratings/"
61
- end
62
-
63
- # Relative path to the endpoint including query parameters
64
59
  def path
65
- p = "/{databaseId}/ratings/?userId=#{@user_id}&itemId=#{@item_id}"
66
- if @optional.include? 'timestamp'
67
- p += (p.include? '?') ? '&' : '?'
68
- p += "timestamp=#{@optional['timestamp']}"
69
- end
70
- p
60
+ "/{databaseId}/ratings/"
71
61
  end
72
62
  end
73
63
  end
@@ -37,7 +37,7 @@ module RecombeeApiClient
37
37
  p
38
38
  end
39
39
 
40
- # Values of query path parameters as a Hash.
40
+ # Values of query parameters as a Hash.
41
41
  # name of parameter => value of the parameter
42
42
  def query_parameters
43
43
  params = {}
@@ -45,14 +45,8 @@ module RecombeeApiClient
45
45
  end
46
46
 
47
47
  # Relative path to the endpoint
48
- def basic_path
49
- "/{databaseId}/series/#{@series_id}"
50
- end
51
-
52
- # Relative path to the endpoint including query parameters
53
48
  def path
54
- p = "/{databaseId}/series/#{@series_id}"
55
- p
49
+ "/{databaseId}/series/#{@series_id}"
56
50
  end
57
51
  end
58
52
  end
@@ -37,7 +37,7 @@ module RecombeeApiClient
37
37
  p
38
38
  end
39
39
 
40
- # Values of query path parameters as a Hash.
40
+ # Values of query parameters as a Hash.
41
41
  # name of parameter => value of the parameter
42
42
  def query_parameters
43
43
  params = {}
@@ -45,14 +45,8 @@ module RecombeeApiClient
45
45
  end
46
46
 
47
47
  # Relative path to the endpoint
48
- def basic_path
49
- "/{databaseId}/users/#{@user_id}"
50
- end
51
-
52
- # Relative path to the endpoint including query parameters
53
48
  def path
54
- p = "/{databaseId}/users/#{@user_id}"
55
- p
49
+ "/{databaseId}/users/#{@user_id}"
56
50
  end
57
51
  end
58
52
  end
@@ -35,7 +35,7 @@ module RecombeeApiClient
35
35
  p
36
36
  end
37
37
 
38
- # Values of query path parameters as a Hash.
38
+ # Values of query parameters as a Hash.
39
39
  # name of parameter => value of the parameter
40
40
  def query_parameters
41
41
  params = {}
@@ -43,14 +43,8 @@ module RecombeeApiClient
43
43
  end
44
44
 
45
45
  # Relative path to the endpoint
46
- def basic_path
47
- "/{databaseId}/items/properties/#{@property_name}"
48
- end
49
-
50
- # Relative path to the endpoint including query parameters
51
46
  def path
52
- p = "/{databaseId}/items/properties/#{@property_name}"
53
- p
47
+ "/{databaseId}/items/properties/#{@property_name}"
54
48
  end
55
49
  end
56
50
  end
@@ -36,7 +36,7 @@ module RecombeeApiClient
36
36
  p
37
37
  end
38
38
 
39
- # Values of query path parameters as a Hash.
39
+ # Values of query parameters as a Hash.
40
40
  # name of parameter => value of the parameter
41
41
  def query_parameters
42
42
  params = {}
@@ -44,14 +44,8 @@ module RecombeeApiClient
44
44
  end
45
45
 
46
46
  # Relative path to the endpoint
47
- def basic_path
48
- "/{databaseId}/items/#{@item_id}"
49
- end
50
-
51
- # Relative path to the endpoint including query parameters
52
47
  def path
53
- p = "/{databaseId}/items/#{@item_id}"
54
- p
48
+ "/{databaseId}/items/#{@item_id}"
55
49
  end
56
50
  end
57
51
  end
@@ -50,7 +50,7 @@ module RecombeeApiClient
50
50
  p
51
51
  end
52
52
 
53
- # Values of query path parameters as a Hash.
53
+ # Values of query parameters as a Hash.
54
54
  # name of parameter => value of the parameter
55
55
  def query_parameters
56
56
  params = {}
@@ -58,14 +58,8 @@ module RecombeeApiClient
58
58
  end
59
59
 
60
60
  # Relative path to the endpoint
61
- def basic_path
62
- "/{databaseId}/groups/#{@group_id}/items/"
63
- end
64
-
65
- # Relative path to the endpoint including query parameters
66
61
  def path
67
- p = "/{databaseId}/groups/#{@group_id}/items/"
68
- p
62
+ "/{databaseId}/groups/#{@group_id}/items/"
69
63
  end
70
64
  end
71
65
  end
@@ -53,7 +53,7 @@ module RecombeeApiClient
53
53
  p
54
54
  end
55
55
 
56
- # Values of query path parameters as a Hash.
56
+ # Values of query parameters as a Hash.
57
57
  # name of parameter => value of the parameter
58
58
  def query_parameters
59
59
  params = {}
@@ -61,14 +61,8 @@ module RecombeeApiClient
61
61
  end
62
62
 
63
63
  # Relative path to the endpoint
64
- def basic_path
65
- "/{databaseId}/series/#{@series_id}/items/"
66
- end
67
-
68
- # Relative path to the endpoint including query parameters
69
64
  def path
70
- p = "/{databaseId}/series/#{@series_id}/items/"
71
- p
65
+ "/{databaseId}/series/#{@series_id}/items/"
72
66
  end
73
67
  end
74
68
  end
@@ -10,7 +10,7 @@ module RecombeeApiClient
10
10
  #Recommends set of items that are somehow related to one given item, *X*. Typical scenario for using item-based recommendation is when user *A* is viewing *X*. Then you may display items to the user that he might be also interested in. Item-recommendation request gives you Top-N such items, optionally taking the target user *A* into account.
11
11
  #
12
12
  class ItemBasedRecommendation < ApiRequest
13
- attr_reader :item_id, :count, :target_user_id, :user_impact, :filter, :booster, :allow_nonexistent, :cascade_create, :scenario, :diversity, :min_relevance, :rotation_rate, :rotation_time
13
+ attr_reader :item_id, :count, :target_user_id, :user_impact, :filter, :booster, :allow_nonexistent, :cascade_create, :scenario, :return_properties, :included_properties, :diversity, :min_relevance, :rotation_rate, :rotation_time
14
14
  attr_accessor :timeout
15
15
  attr_accessor :ensure_https
16
16
 
@@ -28,13 +28,53 @@ module RecombeeApiClient
28
28
  # - +allowNonexistent+ -> Instead of causing HTTP 404 error, returns some (non-personalized) recommendations if either item of given *itemId* or user of given *targetUserId* does not exist in the database. It creates neither of the missing entities in the database.
29
29
  # - +cascadeCreate+ -> If item of given *itemId* or user of given *targetUserId* doesn't exist in the database, it creates the missing enity/entities and returns some (non-personalized) recommendations. This allows for example rotations in the following recommendations for the user of given *targetUserId*, as the user will be already known to the system.
30
30
  # - +scenario+ -> Scenario defines a particular application of recommendations. It can be for example "homepage" or "cart". The AI which optimizes models in order to get the best results may optimize different scenarios separately, or even use different models in each of the scenarios.
31
+ # - +returnProperties+ -> With `returnProperties=true`, property values of the recommended items are returned along with their IDs in a JSON dictionary. The acquired property values can be used for easy displaying of the recommended items to the user.
32
+ #
33
+ #Example response:
34
+ #```
35
+ # [
36
+ # {
37
+ # "itemId": "tv-178",
38
+ # "description": "4K TV with 3D feature",
39
+ # "categories": ["Electronics", "Televisions"],
40
+ # "price": 342,
41
+ # "url": "myshop.com/tv-178"
42
+ # },
43
+ # {
44
+ # "itemId": "mixer-42",
45
+ # "description": "Stainless Steel Mixer",
46
+ # "categories": ["Home & Kitchen"],
47
+ # "price": 39,
48
+ # "url": "myshop.com/mixer-42"
49
+ # }
50
+ # ]
51
+ #```
52
+ #
53
+ # - +includedProperties+ -> Allows to specify, which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list.
54
+ #
55
+ #Example response for `includedProperties=description,price`:
56
+ #```
57
+ # [
58
+ # {
59
+ # "itemId": "tv-178",
60
+ # "description": "4K TV with 3D feature",
61
+ # "price": 342
62
+ # },
63
+ # {
64
+ # "itemId": "mixer-42",
65
+ # "description": "Stainless Steel Mixer",
66
+ # "price": 39
67
+ # }
68
+ # ]
69
+ #```
70
+ #
31
71
  # - +diversity+ -> **Expert option** Real number from [0.0, 1.0] which determines how much mutually dissimilar should the recommended items be. The default value is 0.0, i.e., no diversification. Value 1.0 means maximal diversification.
32
72
  #
33
73
  # - +minRelevance+ -> **Expert option** Specifies the threshold of how much relevant must the recommended items be to the user. Possible values one of: "low", "medium", "high". The default value is "low", meaning that the system attempts to recommend number of items equal to *count* at any cost. If there are not enough data (such as interactions or item properties), this may even lead to bestseller-based recommendations to be appended to reach the full *count*. This behavior may be suppressed by using "medium" or "high" values. In such case, the system only recommends items of at least the requested qualit, and may return less than *count* items when there is not enough data to fulfill it.
34
74
  #
35
75
  # - +rotationRate+ -> **Expert option** 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 backward fashion. 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.
36
76
  #
37
- # - +rotationTime+ -> **Expert option** Taking *rotationRate* into account, specifies how long time it takes to an item to fully recover from the penalization. By example, `rotationTime=7200.0` means that items recommended more than 2 hours ago are definitely not penalized anymore. Currently, the penalization is linear, so for `rotationTime=7200.0`, an item is still penalized by `0.5` to the user after 1 hour. |
77
+ # - +rotationTime+ -> **Expert option** Taking *rotationRate* into account, specifies how long time it takes to an item to fully recover from the penalization. By example, `rotationTime=7200.0` means that items recommended more than 2 hours ago are definitely not penalized anymore. Currently, the penalization is linear, so for `rotationTime=7200.0`, an item is still penalized by `0.5` to the user after 1 hour.
38
78
  #
39
79
  #
40
80
  def initialize(item_id, count, optional = {})
@@ -47,6 +87,8 @@ module RecombeeApiClient
47
87
  @allow_nonexistent = optional['allowNonexistent']
48
88
  @cascade_create = optional['cascadeCreate']
49
89
  @scenario = optional['scenario']
90
+ @return_properties = optional['returnProperties']
91
+ @included_properties = optional['includedProperties']
50
92
  @diversity = optional['diversity']
51
93
  @min_relevance = optional['minRelevance']
52
94
  @rotation_rate = optional['rotationRate']
@@ -55,7 +97,7 @@ module RecombeeApiClient
55
97
  @timeout = 3000
56
98
  @ensure_https = false
57
99
  @optional.each do |par, _|
58
- fail UnknownOptionalParameter.new(par) unless ["targetUserId","userImpact","filter","booster","allowNonexistent","cascadeCreate","scenario","diversity","minRelevance","rotationRate","rotationTime"].include? par
100
+ fail UnknownOptionalParameter.new(par) unless ["targetUserId","userImpact","filter","booster","allowNonexistent","cascadeCreate","scenario","returnProperties","includedProperties","diversity","minRelevance","rotationRate","rotationTime"].include? par
59
101
  end
60
102
  end
61
103
 
@@ -70,7 +112,7 @@ module RecombeeApiClient
70
112
  p
71
113
  end
72
114
 
73
- # Values of query path parameters as a Hash.
115
+ # Values of query parameters as a Hash.
74
116
  # name of parameter => value of the parameter
75
117
  def query_parameters
76
118
  params = {}
@@ -82,6 +124,8 @@ module RecombeeApiClient
82
124
  params['allowNonexistent'] = @optional['allowNonexistent'] if @optional['allowNonexistent']
83
125
  params['cascadeCreate'] = @optional['cascadeCreate'] if @optional['cascadeCreate']
84
126
  params['scenario'] = @optional['scenario'] if @optional['scenario']
127
+ params['returnProperties'] = @optional['returnProperties'] if @optional['returnProperties']
128
+ params['includedProperties'] = @optional['includedProperties'] if @optional['includedProperties']
85
129
  params['diversity'] = @optional['diversity'] if @optional['diversity']
86
130
  params['minRelevance'] = @optional['minRelevance'] if @optional['minRelevance']
87
131
  params['rotationRate'] = @optional['rotationRate'] if @optional['rotationRate']
@@ -90,58 +134,8 @@ module RecombeeApiClient
90
134
  end
91
135
 
92
136
  # Relative path to the endpoint
93
- def basic_path
94
- "/{databaseId}/items/#{@item_id}/recomms/"
95
- end
96
-
97
- # Relative path to the endpoint including query parameters
98
137
  def path
99
- p = "/{databaseId}/items/#{@item_id}/recomms/?count=#{@count}"
100
- if @optional.include? 'targetUserId'
101
- p += (p.include? '?') ? '&' : '?'
102
- p += "targetUserId=#{@optional['targetUserId']}"
103
- end
104
- if @optional.include? 'userImpact'
105
- p += (p.include? '?') ? '&' : '?'
106
- p += "userImpact=#{@optional['userImpact']}"
107
- end
108
- if @optional.include? 'filter'
109
- p += (p.include? '?') ? '&' : '?'
110
- p += "filter=#{@optional['filter']}"
111
- end
112
- if @optional.include? 'booster'
113
- p += (p.include? '?') ? '&' : '?'
114
- p += "booster=#{@optional['booster']}"
115
- end
116
- if @optional.include? 'allowNonexistent'
117
- p += (p.include? '?') ? '&' : '?'
118
- p += "allowNonexistent=#{@optional['allowNonexistent']}"
119
- end
120
- if @optional.include? 'cascadeCreate'
121
- p += (p.include? '?') ? '&' : '?'
122
- p += "cascadeCreate=#{@optional['cascadeCreate']}"
123
- end
124
- if @optional.include? 'scenario'
125
- p += (p.include? '?') ? '&' : '?'
126
- p += "scenario=#{@optional['scenario']}"
127
- end
128
- if @optional.include? 'diversity'
129
- p += (p.include? '?') ? '&' : '?'
130
- p += "diversity=#{@optional['diversity']}"
131
- end
132
- if @optional.include? 'minRelevance'
133
- p += (p.include? '?') ? '&' : '?'
134
- p += "minRelevance=#{@optional['minRelevance']}"
135
- end
136
- if @optional.include? 'rotationRate'
137
- p += (p.include? '?') ? '&' : '?'
138
- p += "rotationRate=#{@optional['rotationRate']}"
139
- end
140
- if @optional.include? 'rotationTime'
141
- p += (p.include? '?') ? '&' : '?'
142
- p += "rotationTime=#{@optional['rotationTime']}"
143
- end
144
- p
138
+ "/{databaseId}/items/#{@item_id}/recomms/"
145
139
  end
146
140
  end
147
141
  end
@@ -34,7 +34,7 @@ module RecombeeApiClient
34
34
  p
35
35
  end
36
36
 
37
- # Values of query path parameters as a Hash.
37
+ # Values of query parameters as a Hash.
38
38
  # name of parameter => value of the parameter
39
39
  def query_parameters
40
40
  params = {}
@@ -42,14 +42,8 @@ module RecombeeApiClient
42
42
  end
43
43
 
44
44
  # Relative path to the endpoint
45
- def basic_path
46
- "/{databaseId}/groups/#{@group_id}/items/"
47
- end
48
-
49
- # Relative path to the endpoint including query parameters
50
45
  def path
51
- p = "/{databaseId}/groups/#{@group_id}/items/"
52
- p
46
+ "/{databaseId}/groups/#{@group_id}/items/"
53
47
  end
54
48
  end
55
49
  end