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
@@ -40,7 +40,7 @@ module RecombeeApiClient
40
40
  p
41
41
  end
42
42
 
43
- # Values of query path parameters as a Hash.
43
+ # Values of query parameters as a Hash.
44
44
  # name of parameter => value of the parameter
45
45
  def query_parameters
46
46
  params = {}
@@ -51,14 +51,8 @@ module RecombeeApiClient
51
51
  end
52
52
 
53
53
  # Relative path to the endpoint
54
- def basic_path
55
- "/{databaseId}/series/#{@series_id}/items/"
56
- end
57
-
58
- # Relative path to the endpoint including query parameters
59
54
  def path
60
- p = "/{databaseId}/series/#{@series_id}/items/?itemType=#{@item_type}&itemId=#{@item_id}&time=#{@time}"
61
- p
55
+ "/{databaseId}/series/#{@series_id}/items/"
62
56
  end
63
57
  end
64
58
  end
@@ -17,7 +17,7 @@ module RecombeeApiClient
17
17
  ##
18
18
  #
19
19
  def initialize()
20
- @timeout = 5000
20
+ @timeout = 20000
21
21
  @ensure_https = false
22
22
  end
23
23
 
@@ -32,7 +32,7 @@ module RecombeeApiClient
32
32
  p
33
33
  end
34
34
 
35
- # Values of query path parameters as a Hash.
35
+ # Values of query parameters as a Hash.
36
36
  # name of parameter => value of the parameter
37
37
  def query_parameters
38
38
  params = {}
@@ -40,14 +40,8 @@ module RecombeeApiClient
40
40
  end
41
41
 
42
42
  # Relative path to the endpoint
43
- def basic_path
44
- "/{databaseId}/"
45
- end
46
-
47
- # Relative path to the endpoint including query parameters
48
43
  def path
49
- p = "/{databaseId}/"
50
- p
44
+ "/{databaseId}/"
51
45
  end
52
46
  end
53
47
  end
@@ -7,7 +7,7 @@ module RecombeeApiClient
7
7
  require_relative '../errors'
8
8
 
9
9
  ##
10
- #Set/update (some) property values of a given item.
10
+ #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.html#add-item-property).
11
11
  #
12
12
  class SetItemValues < ApiRequest
13
13
  attr_reader :item_id, :values
@@ -23,8 +23,9 @@ module RecombeeApiClient
23
23
  #Example of body:
24
24
  #```
25
25
  # {
26
- # "string_property": "strvalue",
27
- # "integer_property": 42,
26
+ # "product_description": "4K TV with 3D feature",
27
+ # "categories": ["Electronics", "Televisions"],
28
+ # "price_usd": 342,
28
29
  # "!cascadeCreate": true
29
30
  # }
30
31
  #```
@@ -51,7 +52,7 @@ module RecombeeApiClient
51
52
  p
52
53
  end
53
54
 
54
- # Values of query path parameters as a Hash.
55
+ # Values of query parameters as a Hash.
55
56
  # name of parameter => value of the parameter
56
57
  def query_parameters
57
58
  params = {}
@@ -59,14 +60,8 @@ module RecombeeApiClient
59
60
  end
60
61
 
61
62
  # Relative path to the endpoint
62
- def basic_path
63
- "/{databaseId}/items/#{@item_id}"
64
- end
65
-
66
- # Relative path to the endpoint including query parameters
67
63
  def path
68
- p = "/{databaseId}/items/#{@item_id}"
69
- p
64
+ "/{databaseId}/items/#{@item_id}"
70
65
  end
71
66
  end
72
67
  end
@@ -10,7 +10,7 @@ module RecombeeApiClient
10
10
  #Based on user's past interactions (purchases, ratings, etc.) with the items, recommends top-N items that are most likely to be of high value for a given user.
11
11
  #
12
12
  class UserBasedRecommendation < ApiRequest
13
- attr_reader :user_id, :count, :filter, :booster, :allow_nonexistent, :cascade_create, :scenario, :diversity, :min_relevance, :rotation_rate, :rotation_time
13
+ attr_reader :user_id, :count, :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
 
@@ -25,13 +25,53 @@ module RecombeeApiClient
25
25
  # - +allowNonexistent+ -> If the user does not exist in the database, returns a list of non-personalized recommendations instead of causing HTTP 404 error. It doesn't create the user in the database.
26
26
  # - +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.
27
27
  # - +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.
28
+ # - +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.
29
+ #
30
+ #Example response:
31
+ #```
32
+ # [
33
+ # {
34
+ # "itemId": "tv-178",
35
+ # "description": "4K TV with 3D feature",
36
+ # "categories": ["Electronics", "Televisions"],
37
+ # "price": 342,
38
+ # "url": "myshop.com/tv-178"
39
+ # },
40
+ # {
41
+ # "itemId": "mixer-42",
42
+ # "description": "Stainless Steel Mixer",
43
+ # "categories": ["Home & Kitchen"],
44
+ # "price": 39,
45
+ # "url": "myshop.com/mixer-42"
46
+ # }
47
+ # ]
48
+ #```
49
+ #
50
+ # - +includedProperties+ -> Allows to specify, which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list.
51
+ #
52
+ #Example response for `includedProperties=description,price`:
53
+ #```
54
+ # [
55
+ # {
56
+ # "itemId": "tv-178",
57
+ # "description": "4K TV with 3D feature",
58
+ # "price": 342
59
+ # },
60
+ # {
61
+ # "itemId": "mixer-42",
62
+ # "description": "Stainless Steel Mixer",
63
+ # "price": 39
64
+ # }
65
+ # ]
66
+ #```
67
+ #
28
68
  # - +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.
29
69
  #
30
70
  # - +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.
31
71
  #
32
72
  # - +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.
33
73
  #
34
- # - +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. |
74
+ # - +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.
35
75
  #
36
76
  #
37
77
  def initialize(user_id, count, optional = {})
@@ -42,6 +82,8 @@ module RecombeeApiClient
42
82
  @allow_nonexistent = optional['allowNonexistent']
43
83
  @cascade_create = optional['cascadeCreate']
44
84
  @scenario = optional['scenario']
85
+ @return_properties = optional['returnProperties']
86
+ @included_properties = optional['includedProperties']
45
87
  @diversity = optional['diversity']
46
88
  @min_relevance = optional['minRelevance']
47
89
  @rotation_rate = optional['rotationRate']
@@ -50,7 +92,7 @@ module RecombeeApiClient
50
92
  @timeout = 3000
51
93
  @ensure_https = false
52
94
  @optional.each do |par, _|
53
- fail UnknownOptionalParameter.new(par) unless ["filter","booster","allowNonexistent","cascadeCreate","scenario","diversity","minRelevance","rotationRate","rotationTime"].include? par
95
+ fail UnknownOptionalParameter.new(par) unless ["filter","booster","allowNonexistent","cascadeCreate","scenario","returnProperties","includedProperties","diversity","minRelevance","rotationRate","rotationTime"].include? par
54
96
  end
55
97
  end
56
98
 
@@ -65,7 +107,7 @@ module RecombeeApiClient
65
107
  p
66
108
  end
67
109
 
68
- # Values of query path parameters as a Hash.
110
+ # Values of query parameters as a Hash.
69
111
  # name of parameter => value of the parameter
70
112
  def query_parameters
71
113
  params = {}
@@ -75,6 +117,8 @@ module RecombeeApiClient
75
117
  params['allowNonexistent'] = @optional['allowNonexistent'] if @optional['allowNonexistent']
76
118
  params['cascadeCreate'] = @optional['cascadeCreate'] if @optional['cascadeCreate']
77
119
  params['scenario'] = @optional['scenario'] if @optional['scenario']
120
+ params['returnProperties'] = @optional['returnProperties'] if @optional['returnProperties']
121
+ params['includedProperties'] = @optional['includedProperties'] if @optional['includedProperties']
78
122
  params['diversity'] = @optional['diversity'] if @optional['diversity']
79
123
  params['minRelevance'] = @optional['minRelevance'] if @optional['minRelevance']
80
124
  params['rotationRate'] = @optional['rotationRate'] if @optional['rotationRate']
@@ -83,50 +127,8 @@ module RecombeeApiClient
83
127
  end
84
128
 
85
129
  # Relative path to the endpoint
86
- def basic_path
87
- "/{databaseId}/users/#{@user_id}/recomms/"
88
- end
89
-
90
- # Relative path to the endpoint including query parameters
91
130
  def path
92
- p = "/{databaseId}/users/#{@user_id}/recomms/?count=#{@count}"
93
- if @optional.include? 'filter'
94
- p += (p.include? '?') ? '&' : '?'
95
- p += "filter=#{@optional['filter']}"
96
- end
97
- if @optional.include? 'booster'
98
- p += (p.include? '?') ? '&' : '?'
99
- p += "booster=#{@optional['booster']}"
100
- end
101
- if @optional.include? 'allowNonexistent'
102
- p += (p.include? '?') ? '&' : '?'
103
- p += "allowNonexistent=#{@optional['allowNonexistent']}"
104
- end
105
- if @optional.include? 'cascadeCreate'
106
- p += (p.include? '?') ? '&' : '?'
107
- p += "cascadeCreate=#{@optional['cascadeCreate']}"
108
- end
109
- if @optional.include? 'scenario'
110
- p += (p.include? '?') ? '&' : '?'
111
- p += "scenario=#{@optional['scenario']}"
112
- end
113
- if @optional.include? 'diversity'
114
- p += (p.include? '?') ? '&' : '?'
115
- p += "diversity=#{@optional['diversity']}"
116
- end
117
- if @optional.include? 'minRelevance'
118
- p += (p.include? '?') ? '&' : '?'
119
- p += "minRelevance=#{@optional['minRelevance']}"
120
- end
121
- if @optional.include? 'rotationRate'
122
- p += (p.include? '?') ? '&' : '?'
123
- p += "rotationRate=#{@optional['rotationRate']}"
124
- end
125
- if @optional.include? 'rotationTime'
126
- p += (p.include? '?') ? '&' : '?'
127
- p += "rotationTime=#{@optional['rotationTime']}"
128
- end
129
- p
131
+ "/{databaseId}/users/#{@user_id}/recomms/"
130
132
  end
131
133
  end
132
134
  end
@@ -1,3 +1,3 @@
1
1
  module RecombeeApiClient
2
- VERSION = '1.2.0'
2
+ VERSION = '1.2.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recombee_api_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ondřej Fiedler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-27 00:00:00.000000000 Z
11
+ date: 2016-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json