Skip to content

Commit

Permalink
Add recommId parameter to add interaction requests
Browse files Browse the repository at this point in the history
  • Loading branch information
OndraFiedler committed Sep 10, 2018
1 parent 255f5f4 commit 727bd11
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 16 deletions.
2 changes: 1 addition & 1 deletion lib/recombee_api_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class RecombeeClient
include HTTParty

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

##
# - +account+ -> Name of your account at Recombee
Expand Down
7 changes: 5 additions & 2 deletions lib/recombee_api_client/api/add_bookmark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module RecombeeApiClient
#Adds a bookmark of a given item made by a given user.
#
class AddBookmark < ApiRequest
attr_reader :user_id, :item_id, :timestamp, :cascade_create
attr_reader :user_id, :item_id, :timestamp, :cascade_create, :recomm_id
attr_accessor :timeout
attr_accessor :ensure_https

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

Expand All @@ -49,6 +51,7 @@ def body_parameters
p['itemId'] = @item_id
p['timestamp'] = @optional['timestamp'] if @optional.include? 'timestamp'
p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
p['recommId'] = @optional['recommId'] if @optional.include? 'recommId'
p
end

Expand Down
7 changes: 5 additions & 2 deletions lib/recombee_api_client/api/add_cart_addition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module RecombeeApiClient
#Adds a cart addition of a given item made by a given user.
#
class AddCartAddition < ApiRequest
attr_reader :user_id, :item_id, :timestamp, :cascade_create, :amount, :price
attr_reader :user_id, :item_id, :timestamp, :cascade_create, :amount, :price, :recomm_id
attr_accessor :timeout
attr_accessor :ensure_https

Expand All @@ -24,6 +24,7 @@ class AddCartAddition < ApiRequest
# - +cascadeCreate+ -> Sets whether the given user/item should be created if not present in the database.
# - +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.
# - +price+ -> Price of the added item. If `amount` is greater than 1, sum of prices of all the items should be given.
# - +recommId+ -> If this cart addition is based on a recommendation request, `recommId` is the id of the clicked recommendation.
#
def initialize(user_id, item_id, optional = {})
@user_id = user_id
Expand All @@ -33,11 +34,12 @@ def initialize(user_id, item_id, optional = {})
@cascade_create = optional['cascadeCreate']
@amount = optional['amount']
@price = optional['price']
@recomm_id = optional['recommId']
@optional = optional
@timeout = 1000
@ensure_https = false
@optional.each do |par, _|
fail UnknownOptionalParameter.new(par) unless ["timestamp","cascadeCreate","amount","price"].include? par
fail UnknownOptionalParameter.new(par) unless ["timestamp","cascadeCreate","amount","price","recommId"].include? par
end
end

Expand All @@ -55,6 +57,7 @@ def body_parameters
p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
p['amount'] = @optional['amount'] if @optional.include? 'amount'
p['price'] = @optional['price'] if @optional.include? 'price'
p['recommId'] = @optional['recommId'] if @optional.include? 'recommId'
p
end

Expand Down
7 changes: 5 additions & 2 deletions lib/recombee_api_client/api/add_detail_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module RecombeeApiClient
#Adds a detail view of a given item made by a given user.
#
class AddDetailView < ApiRequest
attr_reader :user_id, :item_id, :timestamp, :duration, :cascade_create
attr_reader :user_id, :item_id, :timestamp, :duration, :cascade_create, :recomm_id
attr_accessor :timeout
attr_accessor :ensure_https

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

Expand All @@ -52,6 +54,7 @@ def body_parameters
p['timestamp'] = @optional['timestamp'] if @optional.include? 'timestamp'
p['duration'] = @optional['duration'] if @optional.include? 'duration'
p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
p['recommId'] = @optional['recommId'] if @optional.include? 'recommId'
p
end

Expand Down
16 changes: 16 additions & 0 deletions lib/recombee_api_client/api/add_item_property.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,22 @@ class AddItemProperty < ApiRequest
#
# - +type+ -> Value type of the item property to be created. One of: `int`, `double`, `string`, `boolean`, `timestamp`, `set`, `image` or `imageList`.
#
#* `int`- Signed integer number.
#
#* `double` - Floating point number. It uses 64-bit base-2 format (IEEE 754 standard).
#
#* `string` - UTF-8 string.
#
#* `boolean` - *true* / *false*
#
#* `timestamp` - Value representing date and time.
#
#* `set` - Set of strings.
#
#* `image` - URL of an image (`jpeg`, `png` or `gif`).
#
#* `imageList` - List of URLs that refer to images.
#
#
def initialize(property_name, type)
@property_name = property_name
Expand Down
7 changes: 5 additions & 2 deletions lib/recombee_api_client/api/add_purchase.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module RecombeeApiClient
#Adds a purchase of a given item made by a given user.
#
class AddPurchase < ApiRequest
attr_reader :user_id, :item_id, :timestamp, :cascade_create, :amount, :price, :profit
attr_reader :user_id, :item_id, :timestamp, :cascade_create, :amount, :price, :profit, :recomm_id
attr_accessor :timeout
attr_accessor :ensure_https

Expand All @@ -25,6 +25,7 @@ class AddPurchase < ApiRequest
# - +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.
# - +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.
# - +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.
# - +recommId+ -> If this purchase is based on a recommendation request, `recommId` is the id of the clicked recommendation.
#
def initialize(user_id, item_id, optional = {})
@user_id = user_id
Expand All @@ -35,11 +36,12 @@ def initialize(user_id, item_id, optional = {})
@amount = optional['amount']
@price = optional['price']
@profit = optional['profit']
@recomm_id = optional['recommId']
@optional = optional
@timeout = 1000
@ensure_https = false
@optional.each do |par, _|
fail UnknownOptionalParameter.new(par) unless ["timestamp","cascadeCreate","amount","price","profit"].include? par
fail UnknownOptionalParameter.new(par) unless ["timestamp","cascadeCreate","amount","price","profit","recommId"].include? par
end
end

Expand All @@ -58,6 +60,7 @@ def body_parameters
p['amount'] = @optional['amount'] if @optional.include? 'amount'
p['price'] = @optional['price'] if @optional.include? 'price'
p['profit'] = @optional['profit'] if @optional.include? 'profit'
p['recommId'] = @optional['recommId'] if @optional.include? 'recommId'
p
end

Expand Down
7 changes: 5 additions & 2 deletions lib/recombee_api_client/api/add_rating.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module RecombeeApiClient
#Adds a rating of given item made by a given user.
#
class AddRating < ApiRequest
attr_reader :user_id, :item_id, :timestamp, :rating, :cascade_create
attr_reader :user_id, :item_id, :timestamp, :rating, :cascade_create, :recomm_id
attr_accessor :timeout
attr_accessor :ensure_https

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

Expand All @@ -52,6 +54,7 @@ def body_parameters
p['rating'] = @rating
p['timestamp'] = @optional['timestamp'] if @optional.include? 'timestamp'
p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
p['recommId'] = @optional['recommId'] if @optional.include? 'recommId'
p
end

Expand Down
14 changes: 13 additions & 1 deletion lib/recombee_api_client/api/add_user_property.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,19 @@ class AddUserProperty < ApiRequest
# * *Required arguments*
# - +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.
#
# - +type+ -> Value type of the user property to be created. One of: `int`, `double`, `string`, `boolean`, `timestamp`, `set`
# - +type+ -> Value type of the user property to be created. One of: `int`, `double`, `string`, `boolean`, `timestamp`, `set`.
#
#* `int` - Signed integer number.
#
#* `double` - Floating point number. It uses 64-bit base-2 format (IEEE 754 standard).
#
#* `string` - UTF-8 string.
#
#* `boolean` - *true* / *false*
#
#* `timestamp` - Value representing date and time.
#
#* `set` - Set of strings.
#
#
def initialize(property_name, type)
Expand Down
2 changes: 1 addition & 1 deletion lib/recombee_api_client/api/merge_users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module RecombeeApiClient
#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.
#
#
#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`.
#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**.
#
class MergeUsers < ApiRequest
attr_reader :target_user_id, :source_user_id, :cascade_create
Expand Down
7 changes: 5 additions & 2 deletions lib/recombee_api_client/api/set_view_portion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module RecombeeApiClient
#If you send new request with the same (`userId`, `itemId`, `sessionId`), the portion gets updated.
#
class SetViewPortion < ApiRequest
attr_reader :user_id, :item_id, :portion, :session_id, :timestamp, :cascade_create
attr_reader :user_id, :item_id, :portion, :session_id, :timestamp, :cascade_create, :recomm_id
attr_accessor :timeout
attr_accessor :ensure_https

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

Expand All @@ -56,6 +58,7 @@ def body_parameters
p['sessionId'] = @optional['sessionId'] if @optional.include? 'sessionId'
p['timestamp'] = @optional['timestamp'] if @optional.include? 'timestamp'
p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
p['recommId'] = @optional['recommId'] if @optional.include? 'recommId'
p
end

Expand Down
2 changes: 1 addition & 1 deletion lib/recombee_api_client/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module RecombeeApiClient
VERSION = '2.1.0'
VERSION = '2.2.0'
end

0 comments on commit 727bd11

Please sign in to comment.