Skip to content

Commit 727bd11

Browse files
committed
Add recommId parameter to add interaction requests
1 parent 255f5f4 commit 727bd11

File tree

11 files changed

+62
-16
lines changed

11 files changed

+62
-16
lines changed

lib/recombee_api_client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class RecombeeClient
1818
include HTTParty
1919

2020
BATCH_MAX_SIZE = 10000
21-
USER_AGENT = {'User-Agent' => 'recombee-ruby-api-client/2.1.0'}
21+
USER_AGENT = {'User-Agent' => 'recombee-ruby-api-client/2.2.0'}
2222

2323
##
2424
# - +account+ -> Name of your account at Recombee

lib/recombee_api_client/api/add_bookmark.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module RecombeeApiClient
1010
#Adds a bookmark of a given item made by a given user.
1111
#
1212
class AddBookmark < ApiRequest
13-
attr_reader :user_id, :item_id, :timestamp, :cascade_create
13+
attr_reader :user_id, :item_id, :timestamp, :cascade_create, :recomm_id
1414
attr_accessor :timeout
1515
attr_accessor :ensure_https
1616

@@ -22,18 +22,20 @@ class AddBookmark < ApiRequest
2222
# * *Optional arguments (given as hash optional)*
2323
# - +timestamp+ -> UTC timestamp of the bookmark as ISO8601-1 pattern or UTC epoch time. The default value is the current time.
2424
# - +cascadeCreate+ -> Sets whether the given user/item should be created if not present in the database.
25+
# - +recommId+ -> If this bookmark is based on a recommendation request, `recommId` is the id of the clicked recommendation.
2526
#
2627
def initialize(user_id, item_id, optional = {})
2728
@user_id = user_id
2829
@item_id = item_id
2930
optional = normalize_optional(optional)
3031
@timestamp = optional['timestamp']
3132
@cascade_create = optional['cascadeCreate']
33+
@recomm_id = optional['recommId']
3234
@optional = optional
3335
@timeout = 1000
3436
@ensure_https = false
3537
@optional.each do |par, _|
36-
fail UnknownOptionalParameter.new(par) unless ["timestamp","cascadeCreate"].include? par
38+
fail UnknownOptionalParameter.new(par) unless ["timestamp","cascadeCreate","recommId"].include? par
3739
end
3840
end
3941

@@ -49,6 +51,7 @@ def body_parameters
4951
p['itemId'] = @item_id
5052
p['timestamp'] = @optional['timestamp'] if @optional.include? 'timestamp'
5153
p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
54+
p['recommId'] = @optional['recommId'] if @optional.include? 'recommId'
5255
p
5356
end
5457

lib/recombee_api_client/api/add_cart_addition.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module RecombeeApiClient
1010
#Adds a cart addition of a given item made by a given user.
1111
#
1212
class AddCartAddition < ApiRequest
13-
attr_reader :user_id, :item_id, :timestamp, :cascade_create, :amount, :price
13+
attr_reader :user_id, :item_id, :timestamp, :cascade_create, :amount, :price, :recomm_id
1414
attr_accessor :timeout
1515
attr_accessor :ensure_https
1616

@@ -24,6 +24,7 @@ class AddCartAddition < ApiRequest
2424
# - +cascadeCreate+ -> Sets whether the given user/item should be created if not present in the database.
2525
# - +amount+ -> Amount (number) added to cart. The default is 1. For example if `user-x` adds two `item-y` during a single order (session...), the `amount` should equal to 2.
2626
# - +price+ -> Price of the added item. If `amount` is greater than 1, sum of prices of all the items should be given.
27+
# - +recommId+ -> If this cart addition is based on a recommendation request, `recommId` is the id of the clicked recommendation.
2728
#
2829
def initialize(user_id, item_id, optional = {})
2930
@user_id = user_id
@@ -33,11 +34,12 @@ def initialize(user_id, item_id, optional = {})
3334
@cascade_create = optional['cascadeCreate']
3435
@amount = optional['amount']
3536
@price = optional['price']
37+
@recomm_id = optional['recommId']
3638
@optional = optional
3739
@timeout = 1000
3840
@ensure_https = false
3941
@optional.each do |par, _|
40-
fail UnknownOptionalParameter.new(par) unless ["timestamp","cascadeCreate","amount","price"].include? par
42+
fail UnknownOptionalParameter.new(par) unless ["timestamp","cascadeCreate","amount","price","recommId"].include? par
4143
end
4244
end
4345

@@ -55,6 +57,7 @@ def body_parameters
5557
p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
5658
p['amount'] = @optional['amount'] if @optional.include? 'amount'
5759
p['price'] = @optional['price'] if @optional.include? 'price'
60+
p['recommId'] = @optional['recommId'] if @optional.include? 'recommId'
5861
p
5962
end
6063

lib/recombee_api_client/api/add_detail_view.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module RecombeeApiClient
1010
#Adds a detail view of a given item made by a given user.
1111
#
1212
class AddDetailView < ApiRequest
13-
attr_reader :user_id, :item_id, :timestamp, :duration, :cascade_create
13+
attr_reader :user_id, :item_id, :timestamp, :duration, :cascade_create, :recomm_id
1414
attr_accessor :timeout
1515
attr_accessor :ensure_https
1616

@@ -23,6 +23,7 @@ class AddDetailView < ApiRequest
2323
# - +timestamp+ -> UTC timestamp of the view as ISO8601-1 pattern or UTC epoch time. The default value is the current time.
2424
# - +duration+ -> Duration of the view
2525
# - +cascadeCreate+ -> Sets whether the given user/item should be created if not present in the database.
26+
# - +recommId+ -> If this detail view is based on a recommendation request, `recommId` is the id of the clicked recommendation.
2627
#
2728
def initialize(user_id, item_id, optional = {})
2829
@user_id = user_id
@@ -31,11 +32,12 @@ def initialize(user_id, item_id, optional = {})
3132
@timestamp = optional['timestamp']
3233
@duration = optional['duration']
3334
@cascade_create = optional['cascadeCreate']
35+
@recomm_id = optional['recommId']
3436
@optional = optional
3537
@timeout = 1000
3638
@ensure_https = false
3739
@optional.each do |par, _|
38-
fail UnknownOptionalParameter.new(par) unless ["timestamp","duration","cascadeCreate"].include? par
40+
fail UnknownOptionalParameter.new(par) unless ["timestamp","duration","cascadeCreate","recommId"].include? par
3941
end
4042
end
4143

@@ -52,6 +54,7 @@ def body_parameters
5254
p['timestamp'] = @optional['timestamp'] if @optional.include? 'timestamp'
5355
p['duration'] = @optional['duration'] if @optional.include? 'duration'
5456
p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
57+
p['recommId'] = @optional['recommId'] if @optional.include? 'recommId'
5558
p
5659
end
5760

lib/recombee_api_client/api/add_item_property.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,22 @@ class AddItemProperty < ApiRequest
2020
#
2121
# - +type+ -> Value type of the item property to be created. One of: `int`, `double`, `string`, `boolean`, `timestamp`, `set`, `image` or `imageList`.
2222
#
23+
#* `int`- Signed integer number.
24+
#
25+
#* `double` - Floating point number. It uses 64-bit base-2 format (IEEE 754 standard).
26+
#
27+
#* `string` - UTF-8 string.
28+
#
29+
#* `boolean` - *true* / *false*
30+
#
31+
#* `timestamp` - Value representing date and time.
32+
#
33+
#* `set` - Set of strings.
34+
#
35+
#* `image` - URL of an image (`jpeg`, `png` or `gif`).
36+
#
37+
#* `imageList` - List of URLs that refer to images.
38+
#
2339
#
2440
def initialize(property_name, type)
2541
@property_name = property_name

lib/recombee_api_client/api/add_purchase.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module RecombeeApiClient
1010
#Adds a purchase of a given item made by a given user.
1111
#
1212
class AddPurchase < ApiRequest
13-
attr_reader :user_id, :item_id, :timestamp, :cascade_create, :amount, :price, :profit
13+
attr_reader :user_id, :item_id, :timestamp, :cascade_create, :amount, :price, :profit, :recomm_id
1414
attr_accessor :timeout
1515
attr_accessor :ensure_https
1616

@@ -25,6 +25,7 @@ class AddPurchase < ApiRequest
2525
# - +amount+ -> Amount (number) of purchased items. The default is 1. For example if `user-x` purchases two `item-y` during a single order (session...), the `amount` should equal to 2.
2626
# - +price+ -> Price paid by the user for the item. If `amount` is greater than 1, sum of prices of all the items should be given.
2727
# - +profit+ -> Your profit from the purchased item. The profit is natural in e-commerce domain (for example if `user-x` purchases `item-y` for $100 and the gross margin is 30 %, then the profit is $30), but is applicable also in other domains (for example at a news company it may be income from displayed advertisement on article page). If `amount` is greater than 1, sum of profit of all the items should be given.
28+
# - +recommId+ -> If this purchase is based on a recommendation request, `recommId` is the id of the clicked recommendation.
2829
#
2930
def initialize(user_id, item_id, optional = {})
3031
@user_id = user_id
@@ -35,11 +36,12 @@ def initialize(user_id, item_id, optional = {})
3536
@amount = optional['amount']
3637
@price = optional['price']
3738
@profit = optional['profit']
39+
@recomm_id = optional['recommId']
3840
@optional = optional
3941
@timeout = 1000
4042
@ensure_https = false
4143
@optional.each do |par, _|
42-
fail UnknownOptionalParameter.new(par) unless ["timestamp","cascadeCreate","amount","price","profit"].include? par
44+
fail UnknownOptionalParameter.new(par) unless ["timestamp","cascadeCreate","amount","price","profit","recommId"].include? par
4345
end
4446
end
4547

@@ -58,6 +60,7 @@ def body_parameters
5860
p['amount'] = @optional['amount'] if @optional.include? 'amount'
5961
p['price'] = @optional['price'] if @optional.include? 'price'
6062
p['profit'] = @optional['profit'] if @optional.include? 'profit'
63+
p['recommId'] = @optional['recommId'] if @optional.include? 'recommId'
6164
p
6265
end
6366

lib/recombee_api_client/api/add_rating.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module RecombeeApiClient
1010
#Adds a rating of given item made by a given user.
1111
#
1212
class AddRating < ApiRequest
13-
attr_reader :user_id, :item_id, :timestamp, :rating, :cascade_create
13+
attr_reader :user_id, :item_id, :timestamp, :rating, :cascade_create, :recomm_id
1414
attr_accessor :timeout
1515
attr_accessor :ensure_https
1616

@@ -23,6 +23,7 @@ class AddRating < ApiRequest
2323
# * *Optional arguments (given as hash optional)*
2424
# - +timestamp+ -> UTC timestamp of the rating as ISO8601-1 pattern or UTC epoch time. The default value is the current time.
2525
# - +cascadeCreate+ -> Sets whether the given user/item should be created if not present in the database.
26+
# - +recommId+ -> If this rating is based on a recommendation request, `recommId` is the id of the clicked recommendation.
2627
#
2728
def initialize(user_id, item_id, rating, optional = {})
2829
@user_id = user_id
@@ -31,11 +32,12 @@ def initialize(user_id, item_id, rating, optional = {})
3132
optional = normalize_optional(optional)
3233
@timestamp = optional['timestamp']
3334
@cascade_create = optional['cascadeCreate']
35+
@recomm_id = optional['recommId']
3436
@optional = optional
3537
@timeout = 1000
3638
@ensure_https = false
3739
@optional.each do |par, _|
38-
fail UnknownOptionalParameter.new(par) unless ["timestamp","cascadeCreate"].include? par
40+
fail UnknownOptionalParameter.new(par) unless ["timestamp","cascadeCreate","recommId"].include? par
3941
end
4042
end
4143

@@ -52,6 +54,7 @@ def body_parameters
5254
p['rating'] = @rating
5355
p['timestamp'] = @optional['timestamp'] if @optional.include? 'timestamp'
5456
p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
57+
p['recommId'] = @optional['recommId'] if @optional.include? 'recommId'
5558
p
5659
end
5760

lib/recombee_api_client/api/add_user_property.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,19 @@ class AddUserProperty < ApiRequest
1818
# * *Required arguments*
1919
# - +property_name+ -> Name of the user property to be created. Currently, the following names are reserved:`id`, `userid`, case insensitively. Also, the length of the property name must not exceed 63 characters.
2020
#
21-
# - +type+ -> Value type of the user property to be created. One of: `int`, `double`, `string`, `boolean`, `timestamp`, `set`
21+
# - +type+ -> Value type of the user property to be created. One of: `int`, `double`, `string`, `boolean`, `timestamp`, `set`.
22+
#
23+
#* `int` - Signed integer number.
24+
#
25+
#* `double` - Floating point number. It uses 64-bit base-2 format (IEEE 754 standard).
26+
#
27+
#* `string` - UTF-8 string.
28+
#
29+
#* `boolean` - *true* / *false*
30+
#
31+
#* `timestamp` - Value representing date and time.
32+
#
33+
#* `set` - Set of strings.
2234
#
2335
#
2436
def initialize(property_name, type)

lib/recombee_api_client/api/merge_users.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module RecombeeApiClient
1010
#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 together becomes desirable.
1111
#
1212
#
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`.
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**.
1414
#
1515
class MergeUsers < ApiRequest
1616
attr_reader :target_user_id, :source_user_id, :cascade_create

lib/recombee_api_client/api/set_view_portion.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module RecombeeApiClient
1111
#If you send new request with the same (`userId`, `itemId`, `sessionId`), the portion gets updated.
1212
#
1313
class SetViewPortion < ApiRequest
14-
attr_reader :user_id, :item_id, :portion, :session_id, :timestamp, :cascade_create
14+
attr_reader :user_id, :item_id, :portion, :session_id, :timestamp, :cascade_create, :recomm_id
1515
attr_accessor :timeout
1616
attr_accessor :ensure_https
1717

@@ -25,6 +25,7 @@ class SetViewPortion < ApiRequest
2525
# - +sessionId+ -> ID of session in which the user viewed the item. Default is `null` (`None`, `nil`, `NULL` etc. depending on language).
2626
# - +timestamp+ -> UTC timestamp of the rating as ISO8601-1 pattern or UTC epoch time. The default value is the current time.
2727
# - +cascadeCreate+ -> Sets whether the given user/item should be created if not present in the database.
28+
# - +recommId+ -> If this view portion is based on a recommendation request, `recommId` is the id of the clicked recommendation.
2829
#
2930
def initialize(user_id, item_id, portion, optional = {})
3031
@user_id = user_id
@@ -34,11 +35,12 @@ def initialize(user_id, item_id, portion, optional = {})
3435
@session_id = optional['sessionId']
3536
@timestamp = optional['timestamp']
3637
@cascade_create = optional['cascadeCreate']
38+
@recomm_id = optional['recommId']
3739
@optional = optional
3840
@timeout = 1000
3941
@ensure_https = false
4042
@optional.each do |par, _|
41-
fail UnknownOptionalParameter.new(par) unless ["sessionId","timestamp","cascadeCreate"].include? par
43+
fail UnknownOptionalParameter.new(par) unless ["sessionId","timestamp","cascadeCreate","recommId"].include? par
4244
end
4345
end
4446

@@ -56,6 +58,7 @@ def body_parameters
5658
p['sessionId'] = @optional['sessionId'] if @optional.include? 'sessionId'
5759
p['timestamp'] = @optional['timestamp'] if @optional.include? 'timestamp'
5860
p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
61+
p['recommId'] = @optional['recommId'] if @optional.include? 'recommId'
5962
p
6063
end
6164

0 commit comments

Comments
 (0)