Skip to content

Commit

Permalink
Support Item Segmentations
Browse files Browse the repository at this point in the history
  • Loading branch information
OndraFiedler committed Jan 6, 2023
1 parent 12b77c9 commit a5fe6d9
Show file tree
Hide file tree
Showing 102 changed files with 1,898 additions and 191 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/4.0.0'}
USER_AGENT = {'User-Agent' => 'recombee-ruby-api-client/4.1.0'}

##
# - +account+ -> Name of your account at Recombee
Expand Down
2 changes: 1 addition & 1 deletion lib/recombee_api_client/api/add_bookmark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module RecombeeApiClient
require_relative '../errors'

##
#Adds a bookmark of a given item made by a given user.
#Adds a bookmark of the given item made by the given user.
#
class AddBookmark < ApiRequest
attr_reader :user_id, :item_id, :timestamp, :cascade_create, :recomm_id, :additional_data
Expand Down
6 changes: 3 additions & 3 deletions lib/recombee_api_client/api/add_cart_addition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module RecombeeApiClient
require_relative '../errors'

##
#Adds a cart addition of a given item made by a given user.
#Adds a cart addition of the given item made by the given user.
#
class AddCartAddition < ApiRequest
attr_reader :user_id, :item_id, :timestamp, :cascade_create, :amount, :price, :recomm_id, :additional_data
Expand All @@ -22,8 +22,8 @@ class AddCartAddition < ApiRequest
# * *Optional arguments (given as hash optional)*
# - +timestamp+ -> UTC timestamp of the cart addition 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.
# - +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.
# - +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 2.
# - +price+ -> Price of the added item. If `amount` is greater than 1, the 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.
# - +additionalData+ -> A dictionary of additional data for the interaction.
#
Expand Down
2 changes: 1 addition & 1 deletion lib/recombee_api_client/api/add_detail_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module RecombeeApiClient
require_relative '../errors'

##
#Adds a detail view of a given item made by a given user.
#Adds a detail view of the given item made by the given user.
#
class AddDetailView < ApiRequest
attr_reader :user_id, :item_id, :timestamp, :duration, :cascade_create, :recomm_id, :additional_data
Expand Down
2 changes: 1 addition & 1 deletion lib/recombee_api_client/api/add_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module RecombeeApiClient
require_relative '../errors'

##
#Creates new group in the database.
#Creates a new group in the database.
class AddGroup < ApiRequest
attr_reader :group_id
attr_accessor :timeout
Expand Down
4 changes: 2 additions & 2 deletions lib/recombee_api_client/api/add_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ module RecombeeApiClient
require_relative '../errors'

##
#Adds new item of given `itemId` to the items catalog.
#Adds new item of the given `itemId` to the items catalog.
#
#All the item properties for the newly created items are set null.
#All the item properties for the newly created items are set to null.
#
class AddItem < ApiRequest
attr_reader :item_id
Expand Down
2 changes: 1 addition & 1 deletion lib/recombee_api_client/api/add_item_property.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class AddItemProperty < ApiRequest

##
# * *Required arguments*
# - +property_name+ -> Name of the item property to be created. Currently, the following names are reserved:`id`, `itemid`, case insensitively. Also, the length of the property name must not exceed 63 characters.
# - +property_name+ -> Name of the item property to be created. Currently, the following names are reserved: `id`, `itemid`, case-insensitively. Also, the length of the property name must not exceed 63 characters.
#
# - +type+ -> Value type of the item property to be created. One of: `int`, `double`, `string`, `boolean`, `timestamp`, `set`, `image` or `imageList`.
#
Expand Down
69 changes: 69 additions & 0 deletions lib/recombee_api_client/api/add_manual_reql_segment.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#
# This file is auto-generated, do not edit
#

module RecombeeApiClient
require_relative 'request'
require_relative '../errors'

##
#Adds a new Segment into a Manual ReQL Segmentation.
#
#The new Segment is defined by a [ReQL](https://docs.recombee.com/reql.html) filter that returns `true` for an item in case that this item belongs to the segment.
#
class AddManualReqlSegment < ApiRequest
attr_reader :segmentation_id, :segment_id, :filter, :title
attr_accessor :timeout
attr_accessor :ensure_https

##
# * *Required arguments*
# - +segmentation_id+ -> ID of the Segmentation to which the new Segment should be added
# - +segment_id+ -> ID of the newly created Segment
# - +filter+ -> ReQL filter that returns `true` for items that belong to this Segment. Otherwise returns `false`.
#
#
# * *Optional arguments (given as hash optional)*
# - +title+ -> Human-readable name of the Segment that is shown in the Recombee Admin UI.
#
#
def initialize(segmentation_id, segment_id, filter, optional = {})
@segmentation_id = segmentation_id
@segment_id = segment_id
@filter = filter
optional = normalize_optional(optional)
@title = optional['title']
@optional = optional
@timeout = 10000
@ensure_https = false
@optional.each do |par, _|
fail UnknownOptionalParameter.new(par) unless ["title"].include? par
end
end

# HTTP method
def method
:put
end

# Values of body parameters as a Hash
def body_parameters
p = Hash.new
p['filter'] = @filter
p['title'] = @optional['title'] if @optional.include? 'title'
p
end

# Values of query parameters as a Hash.
# name of parameter => value of the parameter
def query_parameters
params = {}
params
end

# Relative path to the endpoint
def path
"/{databaseId}/segmentations/manual-reql/#{@segmentation_id}/segments/#{@segment_id}"
end
end
end
8 changes: 4 additions & 4 deletions lib/recombee_api_client/api/add_purchase.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module RecombeeApiClient
require_relative '../errors'

##
#Adds a purchase of a given item made by a given user.
#Adds a purchase of the given item made by the given user.
#
class AddPurchase < ApiRequest
attr_reader :user_id, :item_id, :timestamp, :cascade_create, :amount, :price, :profit, :recomm_id, :additional_data
Expand All @@ -22,9 +22,9 @@ class AddPurchase < ApiRequest
# * *Optional arguments (given as hash optional)*
# - +timestamp+ -> UTC timestamp of the purchase 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.
# - +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.
# - +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 2.
# - +price+ -> Price paid by the user for the item. If `amount` is greater than 1, the sum of prices of all the items should be given.
# - +profit+ -> Your profit from the purchased item. The profit is natural in the 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 also applicable in other domains (for example, at a news company it may be income from a displayed advertisement on article page). If `amount` is greater than 1, the 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.
# - +additionalData+ -> A dictionary of additional data for the interaction.
#
Expand Down
2 changes: 1 addition & 1 deletion lib/recombee_api_client/api/add_rating.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module RecombeeApiClient
require_relative '../errors'

##
#Adds a rating of given item made by a given user.
#Adds a rating of the given item made by the given user.
#
class AddRating < ApiRequest
attr_reader :user_id, :item_id, :timestamp, :rating, :cascade_create, :recomm_id, :additional_data
Expand Down
2 changes: 1 addition & 1 deletion lib/recombee_api_client/api/add_series.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module RecombeeApiClient
require_relative '../errors'

##
#Creates new series in the database.
#Creates a new series in the database.
class AddSeries < ApiRequest
attr_reader :series_id
attr_accessor :timeout
Expand Down
4 changes: 2 additions & 2 deletions lib/recombee_api_client/api/add_user_property.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module RecombeeApiClient
require_relative '../errors'

##
#Adding an user property is somehow equivalent to adding a column to the table of users. The users may be characterized by various properties of different types.
#Adding a user property is somehow equivalent to adding a column to the table of users. The users may be characterized by various properties of different types.
#
class AddUserProperty < ApiRequest
attr_reader :property_name, :type
Expand All @@ -16,7 +16,7 @@ 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.
# - +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`.
#
Expand Down
75 changes: 75 additions & 0 deletions lib/recombee_api_client/api/create_auto_reql_segmentation.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#
# This file is auto-generated, do not edit
#

module RecombeeApiClient
require_relative 'request'
require_relative '../errors'

##
#Segment the items using a [ReQL](https://docs.recombee.com/reql.html) expression.
#
#For each item, the expression should return a set that contains IDs of segments to which the item belongs to.
#
class CreateAutoReqlSegmentation < ApiRequest
attr_reader :segmentation_id, :source_type, :expression, :title, :description
attr_accessor :timeout
attr_accessor :ensure_https

##
# * *Required arguments*
# - +segmentation_id+ -> ID of the newly created Segmentation
# - +source_type+ -> What type of data should be segmented. Currently only `items` are supported.
#
# - +expression+ -> ReQL expression that returns for each item a set with IDs of segments to which the item belongs
#
#
# * *Optional arguments (given as hash optional)*
# - +title+ -> Human-readable name that is shown in the Recombee Admin UI.
#
# - +description+ -> Description that is shown in the Recombee Admin UI.
#
#
def initialize(segmentation_id, source_type, expression, optional = {})
@segmentation_id = segmentation_id
@source_type = source_type
@expression = expression
optional = normalize_optional(optional)
@title = optional['title']
@description = optional['description']
@optional = optional
@timeout = 10000
@ensure_https = false
@optional.each do |par, _|
fail UnknownOptionalParameter.new(par) unless ["title","description"].include? par
end
end

# HTTP method
def method
:put
end

# Values of body parameters as a Hash
def body_parameters
p = Hash.new
p['sourceType'] = @source_type
p['expression'] = @expression
p['title'] = @optional['title'] if @optional.include? 'title'
p['description'] = @optional['description'] if @optional.include? 'description'
p
end

# Values of query parameters as a Hash.
# name of parameter => value of the parameter
def query_parameters
params = {}
params
end

# Relative path to the endpoint
def path
"/{databaseId}/segmentations/auto-reql/#{@segmentation_id}"
end
end
end
71 changes: 71 additions & 0 deletions lib/recombee_api_client/api/create_manual_reql_segmentation.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#
# This file is auto-generated, do not edit
#

module RecombeeApiClient
require_relative 'request'
require_relative '../errors'

##
#Segment the items using multiple [ReQL](https://docs.recombee.com/reql.html) filters.
#
#Use the Add Manual ReQL Items Segment endpoint to create the individual segments.
#
class CreateManualReqlSegmentation < ApiRequest
attr_reader :segmentation_id, :source_type, :title, :description
attr_accessor :timeout
attr_accessor :ensure_https

##
# * *Required arguments*
# - +segmentation_id+ -> ID of the newly created Segmentation
# - +source_type+ -> What type of data should be segmented. Currently only `items` are supported.
#
#
# * *Optional arguments (given as hash optional)*
# - +title+ -> Human-readable name that is shown in the Recombee Admin UI.
#
# - +description+ -> Description that is shown in the Recombee Admin UI.
#
#
def initialize(segmentation_id, source_type, optional = {})
@segmentation_id = segmentation_id
@source_type = source_type
optional = normalize_optional(optional)
@title = optional['title']
@description = optional['description']
@optional = optional
@timeout = 10000
@ensure_https = false
@optional.each do |par, _|
fail UnknownOptionalParameter.new(par) unless ["title","description"].include? par
end
end

# HTTP method
def method
:put
end

# Values of body parameters as a Hash
def body_parameters
p = Hash.new
p['sourceType'] = @source_type
p['title'] = @optional['title'] if @optional.include? 'title'
p['description'] = @optional['description'] if @optional.include? 'description'
p
end

# Values of query parameters as a Hash.
# name of parameter => value of the parameter
def query_parameters
params = {}
params
end

# Relative path to the endpoint
def path
"/{databaseId}/segmentations/manual-reql/#{@segmentation_id}"
end
end
end
Loading

0 comments on commit a5fe6d9

Please sign in to comment.