Skip to content

Commit 08d41c0

Browse files
committed
Added parameters amount,price,profit to AddPurchase and amount,price to AddCartAddition
1 parent 4f1da58 commit 08d41c0

35 files changed

+794
-60
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/1.5.0'}
21+
USER_AGENT = {'User-Agent' => 'recombee-ruby-api-client/1.6.0'}
2222

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

lib/recombee_api_client/api/add_cart_addition.rb

Lines changed: 8 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
13+
attr_reader :user_id, :item_id, :timestamp, :cascade_create, :amount, :price
1414
attr_accessor :timeout
1515
attr_accessor :ensure_https
1616

@@ -22,17 +22,21 @@ class AddCartAddition < ApiRequest
2222
# * *Optional arguments (given as hash optional)*
2323
# - +timestamp+ -> UTC timestamp of the cart addition 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+
# - +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.
26+
# - +price+ -> Price of the added item. If `amount` is greater than 1, sum of prices of all the items should be given.
2527
#
2628
def initialize(user_id, item_id, optional = {})
2729
@user_id = user_id
2830
@item_id = item_id
2931
@timestamp = optional['timestamp']
3032
@cascade_create = optional['cascadeCreate']
33+
@amount = optional['amount']
34+
@price = optional['price']
3135
@optional = optional
3236
@timeout = 1000
3337
@ensure_https = false
3438
@optional.each do |par, _|
35-
fail UnknownOptionalParameter.new(par) unless ["timestamp","cascadeCreate"].include? par
39+
fail UnknownOptionalParameter.new(par) unless ["timestamp","cascadeCreate","amount","price"].include? par
3640
end
3741
end
3842

@@ -48,6 +52,8 @@ def body_parameters
4852
p['itemId'] = @item_id
4953
p['timestamp'] = @optional['timestamp'] if @optional.include? 'timestamp'
5054
p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
55+
p['amount'] = @optional['amount'] if @optional.include? 'amount'
56+
p['price'] = @optional['price'] if @optional.include? 'price'
5157
p
5258
end
5359

lib/recombee_api_client/api/add_item_property.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class AddItemProperty < ApiRequest
2424
def initialize(property_name, type)
2525
@property_name = property_name
2626
@type = type
27-
@timeout = 1000
27+
@timeout = 100000
2828
@ensure_https = false
2929
end
3030

lib/recombee_api_client/api/add_purchase.rb

Lines changed: 11 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
13+
attr_reader :user_id, :item_id, :timestamp, :cascade_create, :amount, :price, :profit
1414
attr_accessor :timeout
1515
attr_accessor :ensure_https
1616

@@ -22,17 +22,23 @@ class AddPurchase < ApiRequest
2222
# * *Optional arguments (given as hash optional)*
2323
# - +timestamp+ -> UTC timestamp of the purchase 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+
# - +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.
26+
# - +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.
27+
# - +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.
2528
#
2629
def initialize(user_id, item_id, optional = {})
2730
@user_id = user_id
2831
@item_id = item_id
2932
@timestamp = optional['timestamp']
3033
@cascade_create = optional['cascadeCreate']
34+
@amount = optional['amount']
35+
@price = optional['price']
36+
@profit = optional['profit']
3137
@optional = optional
3238
@timeout = 1000
3339
@ensure_https = false
3440
@optional.each do |par, _|
35-
fail UnknownOptionalParameter.new(par) unless ["timestamp","cascadeCreate"].include? par
41+
fail UnknownOptionalParameter.new(par) unless ["timestamp","cascadeCreate","amount","price","profit"].include? par
3642
end
3743
end
3844

@@ -48,6 +54,9 @@ def body_parameters
4854
p['itemId'] = @item_id
4955
p['timestamp'] = @optional['timestamp'] if @optional.include? 'timestamp'
5056
p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
57+
p['amount'] = @optional['amount'] if @optional.include? 'amount'
58+
p['price'] = @optional['price'] if @optional.include? 'price'
59+
p['profit'] = @optional['profit'] if @optional.include? 'profit'
5160
p
5261
end
5362

lib/recombee_api_client/api/add_user_property.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class AddUserProperty < ApiRequest
2424
def initialize(property_name, type)
2525
@property_name = property_name
2626
@type = type
27-
@timeout = 1000
27+
@timeout = 100000
2828
@ensure_https = false
2929
end
3030

lib/recombee_api_client/api/delete_item_property.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class DeleteItemProperty < ApiRequest
2020
#
2121
def initialize(property_name)
2222
@property_name = property_name
23-
@timeout = 1000
23+
@timeout = 100000
2424
@ensure_https = false
2525
end
2626

lib/recombee_api_client/api/delete_user_property.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class DeleteUserProperty < ApiRequest
2020
#
2121
def initialize(property_name)
2222
@property_name = property_name
23-
@timeout = 1000
23+
@timeout = 100000
2424
@ensure_https = false
2525
end
2626

lib/recombee_api_client/api/get_user_property_info.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class GetUserPropertyInfo < ApiRequest
2020
#
2121
def initialize(property_name)
2222
@property_name = property_name
23-
@timeout = 1000
23+
@timeout = 100000
2424
@ensure_https = false
2525
end
2626

lib/recombee_api_client/api/list_group_items.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class ListGroupItems < ApiRequest
1919
#
2020
def initialize(group_id)
2121
@group_id = group_id
22-
@timeout = 1000
22+
@timeout = 100000
2323
@ensure_https = false
2424
end
2525

lib/recombee_api_client/api/list_groups.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ListGroups < ApiRequest
1616
##
1717
#
1818
def initialize()
19-
@timeout = 239000
19+
@timeout = 100000
2020
@ensure_https = false
2121
end
2222

0 commit comments

Comments
 (0)