recombee_api_client 1.3.1 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/lib/recombee_api_client/api/add_bookmark.rb +2 -2
  3. data/lib/recombee_api_client/api/add_cart_addition.rb +2 -2
  4. data/lib/recombee_api_client/api/add_detail_view.rb +3 -3
  5. data/lib/recombee_api_client/api/add_purchase.rb +2 -2
  6. data/lib/recombee_api_client/api/add_rating.rb +2 -2
  7. data/lib/recombee_api_client/api/insert_to_group.rb +1 -1
  8. data/lib/recombee_api_client/api/insert_to_series.rb +1 -1
  9. data/lib/recombee_api_client/api/item_based_recommendation.rb +31 -22
  10. data/lib/recombee_api_client/api/list_groups.rb +1 -1
  11. data/lib/recombee_api_client/api/list_item_bookmarks.rb +1 -1
  12. data/lib/recombee_api_client/api/list_item_cart_additions.rb +1 -1
  13. data/lib/recombee_api_client/api/list_item_detail_views.rb +1 -1
  14. data/lib/recombee_api_client/api/list_item_purchases.rb +1 -1
  15. data/lib/recombee_api_client/api/list_item_ratings.rb +1 -1
  16. data/lib/recombee_api_client/api/list_items.rb +53 -3
  17. data/lib/recombee_api_client/api/list_series.rb +1 -1
  18. data/lib/recombee_api_client/api/list_user_bookmarks.rb +1 -1
  19. data/lib/recombee_api_client/api/list_user_cart_additions.rb +1 -1
  20. data/lib/recombee_api_client/api/list_user_detail_views.rb +1 -1
  21. data/lib/recombee_api_client/api/list_user_purchases.rb +1 -1
  22. data/lib/recombee_api_client/api/list_user_ratings.rb +1 -1
  23. data/lib/recombee_api_client/api/list_users.rb +56 -3
  24. data/lib/recombee_api_client/api/merge_users.rb +3 -6
  25. data/lib/recombee_api_client/api/reset_database.rb +1 -1
  26. data/lib/recombee_api_client/api/user_based_recommendation.rb +23 -17
  27. data/lib/recombee_api_client/version.rb +1 -1
  28. data/lib/recombee_api_client.rb +7 -4
  29. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f4bc519621572e646541d23ca0d6ccf8748344d2
4
- data.tar.gz: f57786e0c50990eab3d21ff781448dd012b30bac
3
+ metadata.gz: 2f21bfcff0358bddbb67867f07587e6debb8ae94
4
+ data.tar.gz: 4117139086e3e3f515a692f39d42df273e9cb1be
5
5
  SHA512:
6
- metadata.gz: 9e2fda2576c5cdcf35fe48ee23bb3bd5a6360930f8078e3511b394ef6a2bfa5dc9bd98d48c34c337e236ba1f015e0c18eac8903784943e894427d89a4c85e47b
7
- data.tar.gz: 053a016e1e4fd90708de1998e1625559e09604a09da9c631f7ce0ac0b5ec997bcf57ea8a2a55e6bdf25a35942bcdb3ec130e3e186454a471853b81c019e49e4e
6
+ metadata.gz: c124f71c954aaada1ce7832713dcab6538dde62d35a8802e448cef1d3f9ac0c1cfe7276c5932b1341c8f26a0a5153c68e669d0c2c84f66161fdc2b2571de410f
7
+ data.tar.gz: e0aafaeb3454dfe99f2d3084baff1878d581c4c06192638ebaee5b758b1cf62ffd264f614efc342b29524b668ff7f933c193b133f30344a0fce5f51129107905
@@ -46,8 +46,8 @@ module RecombeeApiClient
46
46
  p = Hash.new
47
47
  p['userId'] = @user_id
48
48
  p['itemId'] = @item_id
49
- p['timestamp'] = @optional['timestamp'] if @optional['timestamp']
50
- p['cascadeCreate'] = @optional['cascadeCreate'] if @optional['cascadeCreate']
49
+ p['timestamp'] = @optional['timestamp'] if @optional.include? 'timestamp'
50
+ p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
51
51
  p
52
52
  end
53
53
 
@@ -46,8 +46,8 @@ module RecombeeApiClient
46
46
  p = Hash.new
47
47
  p['userId'] = @user_id
48
48
  p['itemId'] = @item_id
49
- p['timestamp'] = @optional['timestamp'] if @optional['timestamp']
50
- p['cascadeCreate'] = @optional['cascadeCreate'] if @optional['cascadeCreate']
49
+ p['timestamp'] = @optional['timestamp'] if @optional.include? 'timestamp'
50
+ p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
51
51
  p
52
52
  end
53
53
 
@@ -48,9 +48,9 @@ module RecombeeApiClient
48
48
  p = Hash.new
49
49
  p['userId'] = @user_id
50
50
  p['itemId'] = @item_id
51
- p['timestamp'] = @optional['timestamp'] if @optional['timestamp']
52
- p['duration'] = @optional['duration'] if @optional['duration']
53
- p['cascadeCreate'] = @optional['cascadeCreate'] if @optional['cascadeCreate']
51
+ p['timestamp'] = @optional['timestamp'] if @optional.include? 'timestamp'
52
+ p['duration'] = @optional['duration'] if @optional.include? 'duration'
53
+ p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
54
54
  p
55
55
  end
56
56
 
@@ -46,8 +46,8 @@ module RecombeeApiClient
46
46
  p = Hash.new
47
47
  p['userId'] = @user_id
48
48
  p['itemId'] = @item_id
49
- p['timestamp'] = @optional['timestamp'] if @optional['timestamp']
50
- p['cascadeCreate'] = @optional['cascadeCreate'] if @optional['cascadeCreate']
49
+ p['timestamp'] = @optional['timestamp'] if @optional.include? 'timestamp'
50
+ p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
51
51
  p
52
52
  end
53
53
 
@@ -49,8 +49,8 @@ module RecombeeApiClient
49
49
  p['userId'] = @user_id
50
50
  p['itemId'] = @item_id
51
51
  p['rating'] = @rating
52
- p['timestamp'] = @optional['timestamp'] if @optional['timestamp']
53
- p['cascadeCreate'] = @optional['cascadeCreate'] if @optional['cascadeCreate']
52
+ p['timestamp'] = @optional['timestamp'] if @optional.include? 'timestamp'
53
+ p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
54
54
  p
55
55
  end
56
56
 
@@ -46,7 +46,7 @@ module RecombeeApiClient
46
46
  p = Hash.new
47
47
  p['itemType'] = @item_type
48
48
  p['itemId'] = @item_id
49
- p['cascadeCreate'] = @optional['cascadeCreate'] if @optional['cascadeCreate']
49
+ p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
50
50
  p
51
51
  end
52
52
 
@@ -49,7 +49,7 @@ module RecombeeApiClient
49
49
  p['itemType'] = @item_type
50
50
  p['itemId'] = @item_id
51
51
  p['time'] = @time
52
- p['cascadeCreate'] = @optional['cascadeCreate'] if @optional['cascadeCreate']
52
+ p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
53
53
  p
54
54
  end
55
55
 
@@ -9,14 +9,16 @@ module RecombeeApiClient
9
9
  ##
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
+ # It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters.
13
+ #
12
14
  class ItemBasedRecommendation < ApiRequest
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
15
+ 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, :expert_settings
14
16
  attr_accessor :timeout
15
17
  attr_accessor :ensure_https
16
18
 
17
19
  ##
18
20
  # * *Required arguments*
19
- # - +item_id+ -> ID of the item recommendations for which are to be generated.
21
+ # - +item_id+ -> ID of the item for which the recommendations are to be generated.
20
22
  # - +count+ -> Number of items to be recommended (N for the top-N recommendation).
21
23
  #
22
24
  # * *Optional arguments (given as hash optional)*
@@ -25,15 +27,18 @@ module RecombeeApiClient
25
27
  #Specifying the *targetUserId* is beneficial because:
26
28
  #
27
29
  #* It makes the recommendations personalized
28
- #* Allows calculations of Actions and Conversions in the graphical user interface, as Recombee can pair the user who got recommendations and who afterwards viewed/purchased an item.
30
+ #* Allows the calculation of Actions and Conversions in the graphical user interface,
31
+ # as Recombee can pair the user who got recommendations and who afterwards viewed/purchased an item.
32
+ #
33
+ #For the above reasons, we encourage you to set the *targetUserId* even for anonymous/unregistered users (i.e. use their session ID).
29
34
  #
30
- # - +userImpact+ -> If *targetUserId* parameter is present, the recommendations are biased towards the user given. Using *userImpact*, you may control this bias. For an extreme case of `userImpact=0.0`, the interactions made by the user are not taken into account at all (with the exception of history-based blacklisting), for `userImpact=1.0`, you'll get user-based recommendation. The default value is `0.1`
35
+ # - +userImpact+ -> If *targetUserId* parameter is present, the recommendations are biased towards the user given. Using *userImpact*, you may control this bias. For an extreme case of `userImpact=0.0`, the interactions made by the user are not taken into account at all (with the exception of history-based blacklisting), for `userImpact=1.0`, you'll get user-based recommendation. The default value is `0`.
31
36
  #
32
37
  # - +filter+ -> Boolean-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to filter recommended items based on the values of their attributes.
33
38
  # - +booster+ -> Number-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to boost recommendation rate of some items based on the values of their attributes.
34
39
  # - +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.
35
40
  # - +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.
36
- # - +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.
41
+ # - +scenario+ -> Scenario defines a particular application of recommendations. It can be for example "homepage", "cart" or "emailing". You can see each scenario in the UI separately, so you can check how well each application performs. 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.
37
42
  # - +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.
38
43
  #
39
44
  #Example response:
@@ -80,7 +85,9 @@ module RecombeeApiClient
80
85
  #
81
86
  # - +rotationRate+ -> **Expert option** If the *targetUserId* is provided: 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.
82
87
  #
83
- # - +rotationTime+ -> **Expert option** If the *targetUserId* is provided: Taking *rotationRate* into account, specifies how long time it takes to an item to fully recover from the penalization. For 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.
88
+ # - +rotationTime+ -> **Expert option** If the *targetUserId* is provided: Taking *rotationRate* into account, specifies how long time it takes to an item to recover from the penalization. For example, `rotationTime=7200.0` means that items recommended less than 2 hours ago are penalized.
89
+ #
90
+ # - +expertSettings+ -> Dictionary of custom options.
84
91
  #
85
92
  #
86
93
  def initialize(item_id, count, optional = {})
@@ -99,22 +106,38 @@ module RecombeeApiClient
99
106
  @min_relevance = optional['minRelevance']
100
107
  @rotation_rate = optional['rotationRate']
101
108
  @rotation_time = optional['rotationTime']
109
+ @expert_settings = optional['expertSettings']
102
110
  @optional = optional
103
111
  @timeout = 3000
104
112
  @ensure_https = false
105
113
  @optional.each do |par, _|
106
- fail UnknownOptionalParameter.new(par) unless ["targetUserId","userImpact","filter","booster","allowNonexistent","cascadeCreate","scenario","returnProperties","includedProperties","diversity","minRelevance","rotationRate","rotationTime"].include? par
114
+ fail UnknownOptionalParameter.new(par) unless ["targetUserId","userImpact","filter","booster","allowNonexistent","cascadeCreate","scenario","returnProperties","includedProperties","diversity","minRelevance","rotationRate","rotationTime","expertSettings"].include? par
107
115
  end
108
116
  end
109
117
 
110
118
  # HTTP method
111
119
  def method
112
- :get
120
+ :post
113
121
  end
114
122
 
115
123
  # Values of body parameters as a Hash
116
124
  def body_parameters
117
125
  p = Hash.new
126
+ p['count'] = @count
127
+ p['targetUserId'] = @optional['targetUserId'] if @optional.include? 'targetUserId'
128
+ p['userImpact'] = @optional['userImpact'] if @optional.include? 'userImpact'
129
+ p['filter'] = @optional['filter'] if @optional.include? 'filter'
130
+ p['booster'] = @optional['booster'] if @optional.include? 'booster'
131
+ p['allowNonexistent'] = @optional['allowNonexistent'] if @optional.include? 'allowNonexistent'
132
+ p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
133
+ p['scenario'] = @optional['scenario'] if @optional.include? 'scenario'
134
+ p['returnProperties'] = @optional['returnProperties'] if @optional.include? 'returnProperties'
135
+ p['includedProperties'] = @optional['includedProperties'] if @optional.include? 'includedProperties'
136
+ p['diversity'] = @optional['diversity'] if @optional.include? 'diversity'
137
+ p['minRelevance'] = @optional['minRelevance'] if @optional.include? 'minRelevance'
138
+ p['rotationRate'] = @optional['rotationRate'] if @optional.include? 'rotationRate'
139
+ p['rotationTime'] = @optional['rotationTime'] if @optional.include? 'rotationTime'
140
+ p['expertSettings'] = @optional['expertSettings'] if @optional.include? 'expertSettings'
118
141
  p
119
142
  end
120
143
 
@@ -122,20 +145,6 @@ module RecombeeApiClient
122
145
  # name of parameter => value of the parameter
123
146
  def query_parameters
124
147
  params = {}
125
- params['count'] = @count
126
- params['targetUserId'] = @optional['targetUserId'] if @optional['targetUserId']
127
- params['userImpact'] = @optional['userImpact'] if @optional['userImpact']
128
- params['filter'] = @optional['filter'] if @optional['filter']
129
- params['booster'] = @optional['booster'] if @optional['booster']
130
- params['allowNonexistent'] = @optional['allowNonexistent'] if @optional['allowNonexistent']
131
- params['cascadeCreate'] = @optional['cascadeCreate'] if @optional['cascadeCreate']
132
- params['scenario'] = @optional['scenario'] if @optional['scenario']
133
- params['returnProperties'] = @optional['returnProperties'] if @optional['returnProperties']
134
- params['includedProperties'] = @optional['includedProperties'] if @optional['includedProperties']
135
- params['diversity'] = @optional['diversity'] if @optional['diversity']
136
- params['minRelevance'] = @optional['minRelevance'] if @optional['minRelevance']
137
- params['rotationRate'] = @optional['rotationRate'] if @optional['rotationRate']
138
- params['rotationTime'] = @optional['rotationTime'] if @optional['rotationTime']
139
148
  params
140
149
  end
141
150
 
@@ -16,7 +16,7 @@ module RecombeeApiClient
16
16
  ##
17
17
  #
18
18
  def initialize()
19
- @timeout = 30000
19
+ @timeout = 239000
20
20
  @ensure_https = false
21
21
  end
22
22
 
@@ -20,7 +20,7 @@ module RecombeeApiClient
20
20
  #
21
21
  def initialize(item_id)
22
22
  @item_id = item_id
23
- @timeout = 1000
23
+ @timeout = 100000
24
24
  @ensure_https = false
25
25
  end
26
26
 
@@ -20,7 +20,7 @@ module RecombeeApiClient
20
20
  #
21
21
  def initialize(item_id)
22
22
  @item_id = item_id
23
- @timeout = 1000
23
+ @timeout = 100000
24
24
  @ensure_https = false
25
25
  end
26
26
 
@@ -20,7 +20,7 @@ module RecombeeApiClient
20
20
  #
21
21
  def initialize(item_id)
22
22
  @item_id = item_id
23
- @timeout = 1000
23
+ @timeout = 100000
24
24
  @ensure_https = false
25
25
  end
26
26
 
@@ -20,7 +20,7 @@ module RecombeeApiClient
20
20
  #
21
21
  def initialize(item_id)
22
22
  @item_id = item_id
23
- @timeout = 1000
23
+ @timeout = 100000
24
24
  @ensure_https = false
25
25
  end
26
26
 
@@ -20,7 +20,7 @@ module RecombeeApiClient
20
20
  #
21
21
  def initialize(item_id)
22
22
  @item_id = item_id
23
- @timeout = 1000
23
+ @timeout = 100000
24
24
  @ensure_https = false
25
25
  end
26
26
 
@@ -9,7 +9,7 @@ module RecombeeApiClient
9
9
  ##
10
10
  #Gets a list of IDs of items currently present in the catalog.
11
11
  class ListItems < ApiRequest
12
- attr_reader :filter
12
+ attr_reader :filter, :count, :offset, :return_properties, :included_properties
13
13
  attr_accessor :timeout
14
14
  attr_accessor :ensure_https
15
15
 
@@ -17,14 +17,60 @@ module RecombeeApiClient
17
17
  #
18
18
  # * *Optional arguments (given as hash optional)*
19
19
  # - +filter+ -> Boolean-returning [ReQL](https://docs.recombee.com/reql.html) expression, which allows you to filter items to be listed. Only the items for which the expression is *true* will be returned.
20
+ # - +count+ -> The number of items to be listed.
21
+ # - +offset+ -> Specifies the number of items to skip (ordered by `itemId`).
22
+ # - +returnProperties+ -> With `returnProperties=true`, property values of the listed items are returned along with their IDs in a JSON dictionary.
23
+ #
24
+ #Example response:
25
+ #```
26
+ # [
27
+ # {
28
+ # "itemId": "tv-178",
29
+ # "description": "4K TV with 3D feature",
30
+ # "categories": ["Electronics", "Televisions"],
31
+ # "price": 342,
32
+ # "url": "myshop.com/tv-178"
33
+ # },
34
+ # {
35
+ # "itemId": "mixer-42",
36
+ # "description": "Stainless Steel Mixer",
37
+ # "categories": ["Home & Kitchen"],
38
+ # "price": 39,
39
+ # "url": "myshop.com/mixer-42"
40
+ # }
41
+ # ]
42
+ #```
43
+ #
44
+ # - +includedProperties+ -> Allows to specify, which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list.
45
+ #
46
+ #Example response for `includedProperties=description,price`:
47
+ #```
48
+ # [
49
+ # {
50
+ # "itemId": "tv-178",
51
+ # "description": "4K TV with 3D feature",
52
+ # "price": 342
53
+ # },
54
+ # {
55
+ # "itemId": "mixer-42",
56
+ # "description": "Stainless Steel Mixer",
57
+ # "price": 39
58
+ # }
59
+ # ]
60
+ #```
61
+ #
20
62
  #
21
63
  def initialize(optional = {})
22
64
  @filter = optional['filter']
65
+ @count = optional['count']
66
+ @offset = optional['offset']
67
+ @return_properties = optional['returnProperties']
68
+ @included_properties = optional['includedProperties']
23
69
  @optional = optional
24
- @timeout = 30000
70
+ @timeout = 600000
25
71
  @ensure_https = false
26
72
  @optional.each do |par, _|
27
- fail UnknownOptionalParameter.new(par) unless ["filter"].include? par
73
+ fail UnknownOptionalParameter.new(par) unless ["filter","count","offset","returnProperties","includedProperties"].include? par
28
74
  end
29
75
  end
30
76
 
@@ -44,6 +90,10 @@ module RecombeeApiClient
44
90
  def query_parameters
45
91
  params = {}
46
92
  params['filter'] = @optional['filter'] if @optional['filter']
93
+ params['count'] = @optional['count'] if @optional['count']
94
+ params['offset'] = @optional['offset'] if @optional['offset']
95
+ params['returnProperties'] = @optional['returnProperties'] if @optional['returnProperties']
96
+ params['includedProperties'] = @optional['includedProperties'] if @optional['includedProperties']
47
97
  params
48
98
  end
49
99
 
@@ -16,7 +16,7 @@ module RecombeeApiClient
16
16
  ##
17
17
  #
18
18
  def initialize()
19
- @timeout = 30000
19
+ @timeout = 239000
20
20
  @ensure_https = false
21
21
  end
22
22
 
@@ -19,7 +19,7 @@ module RecombeeApiClient
19
19
  #
20
20
  def initialize(user_id)
21
21
  @user_id = user_id
22
- @timeout = 1000
22
+ @timeout = 100000
23
23
  @ensure_https = false
24
24
  end
25
25
 
@@ -19,7 +19,7 @@ module RecombeeApiClient
19
19
  #
20
20
  def initialize(user_id)
21
21
  @user_id = user_id
22
- @timeout = 1000
22
+ @timeout = 100000
23
23
  @ensure_https = false
24
24
  end
25
25
 
@@ -19,7 +19,7 @@ module RecombeeApiClient
19
19
  #
20
20
  def initialize(user_id)
21
21
  @user_id = user_id
22
- @timeout = 1000
22
+ @timeout = 100000
23
23
  @ensure_https = false
24
24
  end
25
25
 
@@ -19,7 +19,7 @@ module RecombeeApiClient
19
19
  #
20
20
  def initialize(user_id)
21
21
  @user_id = user_id
22
- @timeout = 1000
22
+ @timeout = 100000
23
23
  @ensure_https = false
24
24
  end
25
25
 
@@ -19,7 +19,7 @@ module RecombeeApiClient
19
19
  #
20
20
  def initialize(user_id)
21
21
  @user_id = user_id
22
- @timeout = 1000
22
+ @timeout = 100000
23
23
  @ensure_https = false
24
24
  end
25
25
 
@@ -9,15 +9,63 @@ module RecombeeApiClient
9
9
  ##
10
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
13
  attr_accessor :timeout
14
14
  attr_accessor :ensure_https
15
15
 
16
16
  ##
17
17
  #
18
- def initialize()
19
- @timeout = 30000
18
+ # * *Optional arguments (given as hash optional)*
19
+ # - +filter+ -> Boolean-returning [ReQL](https://docs.recombee.com/reql.html) 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
+ #```
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 to specify, 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
+ #```
44
+ # [
45
+ # {
46
+ # "userId": "user-81",
47
+ # "country": "US"
48
+ # },
49
+ # {
50
+ # "userId": "user-314",
51
+ # "country": "CAN"
52
+ # }
53
+ # ]
54
+ #```
55
+ #
56
+ #
57
+ def initialize(optional = {})
58
+ @filter = optional['filter']
59
+ @count = optional['count']
60
+ @offset = optional['offset']
61
+ @return_properties = optional['returnProperties']
62
+ @included_properties = optional['includedProperties']
63
+ @optional = optional
64
+ @timeout = 239000
20
65
  @ensure_https = false
66
+ @optional.each do |par, _|
67
+ fail UnknownOptionalParameter.new(par) unless ["filter","count","offset","returnProperties","includedProperties"].include? par
68
+ end
21
69
  end
22
70
 
23
71
  # HTTP method
@@ -35,6 +83,11 @@ module RecombeeApiClient
35
83
  # name of parameter => value of the parameter
36
84
  def query_parameters
37
85
  params = {}
86
+ params['filter'] = @optional['filter'] if @optional['filter']
87
+ params['count'] = @optional['count'] if @optional['count']
88
+ params['offset'] = @optional['offset'] if @optional['offset']
89
+ params['returnProperties'] = @optional['returnProperties'] if @optional['returnProperties']
90
+ params['includedProperties'] = @optional['includedProperties'] if @optional['includedProperties']
38
91
  params
39
92
  end
40
93
 
@@ -13,7 +13,7 @@ module RecombeeApiClient
13
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** unless special parameter `keepSourceUser` is set `true`.
14
14
  #
15
15
  class MergeUsers < ApiRequest
16
- attr_reader :target_user_id, :source_user_id, :keep_source_user, :cascade_create
16
+ attr_reader :target_user_id, :source_user_id, :cascade_create
17
17
  attr_accessor :timeout
18
18
  attr_accessor :ensure_https
19
19
 
@@ -23,19 +23,17 @@ module RecombeeApiClient
23
23
  # - +source_user_id+ -> ID of the target user.
24
24
  #
25
25
  # * *Optional arguments (given as hash optional)*
26
- # - +keepSourceUser+ -> If true, the source user will not be deleted, but also kept in the database.
27
26
  # - +cascadeCreate+ -> Sets whether the user *targetUserId* should be created if not present in the database.
28
27
  #
29
28
  def initialize(target_user_id, source_user_id, optional = {})
30
29
  @target_user_id = target_user_id
31
30
  @source_user_id = source_user_id
32
- @keep_source_user = optional['keepSourceUser']
33
31
  @cascade_create = optional['cascadeCreate']
34
32
  @optional = optional
35
- @timeout = 1000
33
+ @timeout = 10000
36
34
  @ensure_https = false
37
35
  @optional.each do |par, _|
38
- fail UnknownOptionalParameter.new(par) unless ["keepSourceUser","cascadeCreate"].include? par
36
+ fail UnknownOptionalParameter.new(par) unless ["cascadeCreate"].include? par
39
37
  end
40
38
  end
41
39
 
@@ -54,7 +52,6 @@ module RecombeeApiClient
54
52
  # name of parameter => value of the parameter
55
53
  def query_parameters
56
54
  params = {}
57
- params['keepSourceUser'] = @optional['keepSourceUser'] if @optional['keepSourceUser']
58
55
  params['cascadeCreate'] = @optional['cascadeCreate'] if @optional['cascadeCreate']
59
56
  params
60
57
  end
@@ -17,7 +17,7 @@ module RecombeeApiClient
17
17
  ##
18
18
  #
19
19
  def initialize()
20
- @timeout = 20000
20
+ @timeout = 239000
21
21
  @ensure_https = false
22
22
  end
23
23
 
@@ -9,8 +9,10 @@ module RecombeeApiClient
9
9
  ##
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
+ #It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters.
13
+ #
12
14
  class UserBasedRecommendation < ApiRequest
13
- attr_reader :user_id, :count, :filter, :booster, :allow_nonexistent, :cascade_create, :scenario, :return_properties, :included_properties, :diversity, :min_relevance, :rotation_rate, :rotation_time
15
+ attr_reader :user_id, :count, :filter, :booster, :allow_nonexistent, :cascade_create, :scenario, :return_properties, :included_properties, :diversity, :min_relevance, :rotation_rate, :rotation_time, :expert_settings
14
16
  attr_accessor :timeout
15
17
  attr_accessor :ensure_https
16
18
 
@@ -24,7 +26,7 @@ module RecombeeApiClient
24
26
  # - +booster+ -> Number-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to boost recommendation rate of some items based on the values of their attributes.
25
27
  # - +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
28
  # - +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
- # - +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.
29
+ # - +scenario+ -> Scenario defines a particular application of recommendations. It can be for example "homepage", "cart" or "emailing". You can see each scenario in the UI separately, so you can check how well each application performs. 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
30
  # - +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
31
  #
30
32
  #Example response:
@@ -71,7 +73,9 @@ module RecombeeApiClient
71
73
  #
72
74
  # - +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.
73
75
  #
74
- # - +rotationTime+ -> **Expert option** Taking *rotationRate* into account, specifies how long time it takes to an item to fully recover from the penalization. For 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.
76
+ # - +rotationTime+ -> **Expert option** Taking *rotationRate* into account, specifies how long time it takes to an item to recover from the penalization. For example, `rotationTime=7200.0` means that items recommended less than 2 hours ago are penalized.
77
+ #
78
+ # - +expertSettings+ -> Dictionary of custom options.
75
79
  #
76
80
  #
77
81
  def initialize(user_id, count, optional = {})
@@ -88,22 +92,36 @@ module RecombeeApiClient
88
92
  @min_relevance = optional['minRelevance']
89
93
  @rotation_rate = optional['rotationRate']
90
94
  @rotation_time = optional['rotationTime']
95
+ @expert_settings = optional['expertSettings']
91
96
  @optional = optional
92
97
  @timeout = 3000
93
98
  @ensure_https = false
94
99
  @optional.each do |par, _|
95
- fail UnknownOptionalParameter.new(par) unless ["filter","booster","allowNonexistent","cascadeCreate","scenario","returnProperties","includedProperties","diversity","minRelevance","rotationRate","rotationTime"].include? par
100
+ fail UnknownOptionalParameter.new(par) unless ["filter","booster","allowNonexistent","cascadeCreate","scenario","returnProperties","includedProperties","diversity","minRelevance","rotationRate","rotationTime","expertSettings"].include? par
96
101
  end
97
102
  end
98
103
 
99
104
  # HTTP method
100
105
  def method
101
- :get
106
+ :post
102
107
  end
103
108
 
104
109
  # Values of body parameters as a Hash
105
110
  def body_parameters
106
111
  p = Hash.new
112
+ p['count'] = @count
113
+ p['filter'] = @optional['filter'] if @optional.include? 'filter'
114
+ p['booster'] = @optional['booster'] if @optional.include? 'booster'
115
+ p['allowNonexistent'] = @optional['allowNonexistent'] if @optional.include? 'allowNonexistent'
116
+ p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
117
+ p['scenario'] = @optional['scenario'] if @optional.include? 'scenario'
118
+ p['returnProperties'] = @optional['returnProperties'] if @optional.include? 'returnProperties'
119
+ p['includedProperties'] = @optional['includedProperties'] if @optional.include? 'includedProperties'
120
+ p['diversity'] = @optional['diversity'] if @optional.include? 'diversity'
121
+ p['minRelevance'] = @optional['minRelevance'] if @optional.include? 'minRelevance'
122
+ p['rotationRate'] = @optional['rotationRate'] if @optional.include? 'rotationRate'
123
+ p['rotationTime'] = @optional['rotationTime'] if @optional.include? 'rotationTime'
124
+ p['expertSettings'] = @optional['expertSettings'] if @optional.include? 'expertSettings'
107
125
  p
108
126
  end
109
127
 
@@ -111,18 +129,6 @@ module RecombeeApiClient
111
129
  # name of parameter => value of the parameter
112
130
  def query_parameters
113
131
  params = {}
114
- params['count'] = @count
115
- params['filter'] = @optional['filter'] if @optional['filter']
116
- params['booster'] = @optional['booster'] if @optional['booster']
117
- params['allowNonexistent'] = @optional['allowNonexistent'] if @optional['allowNonexistent']
118
- params['cascadeCreate'] = @optional['cascadeCreate'] if @optional['cascadeCreate']
119
- params['scenario'] = @optional['scenario'] if @optional['scenario']
120
- params['returnProperties'] = @optional['returnProperties'] if @optional['returnProperties']
121
- params['includedProperties'] = @optional['includedProperties'] if @optional['includedProperties']
122
- params['diversity'] = @optional['diversity'] if @optional['diversity']
123
- params['minRelevance'] = @optional['minRelevance'] if @optional['minRelevance']
124
- params['rotationRate'] = @optional['rotationRate'] if @optional['rotationRate']
125
- params['rotationTime'] = @optional['rotationTime'] if @optional['rotationTime']
126
132
  params
127
133
  end
128
134
 
@@ -1,3 +1,3 @@
1
1
  module RecombeeApiClient
2
- VERSION = '1.3.1'
2
+ VERSION = '1.4.0'
3
3
  end
@@ -18,6 +18,7 @@ module RecombeeApiClient
18
18
  include HTTParty
19
19
 
20
20
  BATCH_MAX_SIZE = 10000
21
+ USER_AGENT = {'User-Agent' => 'recombee-ruby-api-client/1.4.0'}
21
22
 
22
23
  ##
23
24
  # - +account+ -> Name of your account at Recombee
@@ -63,13 +64,15 @@ module RecombeeApiClient
63
64
  private
64
65
 
65
66
  def put(request, uri, timeout)
66
- response = self.class.put(uri, timeout: timeout)
67
+ response = self.class.put(uri, body: request.body_parameters.to_json,
68
+ headers: { 'Content-Type' => 'application/json' }.merge(USER_AGENT),
69
+ timeout: timeout)
67
70
  check_errors(response, request)
68
71
  response.body
69
72
  end
70
73
 
71
74
  def get(request, uri, timeout)
72
- response = self.class.get(uri, timeout: timeout)
75
+ response = self.class.get(uri, timeout: timeout, headers: USER_AGENT)
73
76
  check_errors(response, request)
74
77
  JSON.parse(response.body)
75
78
  end
@@ -77,7 +80,7 @@ module RecombeeApiClient
77
80
  def post(request, uri, timeout)
78
81
  # pass arguments in body
79
82
  response = self.class.post(uri, body: request.body_parameters.to_json,
80
- headers: { 'Content-Type' => 'application/json' },
83
+ headers: { 'Content-Type' => 'application/json' }.merge(USER_AGENT),
81
84
  timeout: timeout)
82
85
  check_errors(response, request)
83
86
  begin
@@ -88,7 +91,7 @@ module RecombeeApiClient
88
91
  end
89
92
 
90
93
  def delete(request, uri, timeout)
91
- response = self.class.delete(uri, timeout: timeout)
94
+ response = self.class.delete(uri, timeout: timeout, headers: USER_AGENT)
92
95
  check_errors(response, request)
93
96
  response.body
94
97
  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.3.1
4
+ version: 1.4.0
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-12-29 00:00:00.000000000 Z
11
+ date: 2017-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -172,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
172
  version: '0'
173
173
  requirements: []
174
174
  rubyforge_project:
175
- rubygems_version: 2.6.8
175
+ rubygems_version: 2.6.11
176
176
  signing_key:
177
177
  specification_version: 4
178
178
  summary: Client for Recombee recommendation API