recombee_api_client 5.1.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/recombee_api_client/api/add_bookmark.rb +26 -26
- data/lib/recombee_api_client/api/add_cart_addition.rb +28 -28
- data/lib/recombee_api_client/api/add_detail_view.rb +32 -28
- data/lib/recombee_api_client/api/add_item.rb +15 -18
- data/lib/recombee_api_client/api/add_item_property.rb +34 -35
- data/lib/recombee_api_client/api/add_manual_reql_segment.rb +26 -27
- data/lib/recombee_api_client/api/add_purchase.rb +29 -29
- data/lib/recombee_api_client/api/add_rating.rb +27 -27
- data/lib/recombee_api_client/api/add_search_synonym.rb +29 -30
- data/lib/recombee_api_client/api/add_series.rb +20 -21
- data/lib/recombee_api_client/api/add_user.rb +14 -17
- data/lib/recombee_api_client/api/add_user_property.rb +30 -31
- data/lib/recombee_api_client/api/batch.rb +12 -16
- data/lib/recombee_api_client/api/composite_recommendation.rb +132 -0
- data/lib/recombee_api_client/api/create_auto_reql_segmentation.rb +29 -30
- data/lib/recombee_api_client/api/create_manual_reql_segmentation.rb +27 -28
- data/lib/recombee_api_client/api/create_property_based_segmentation.rb +30 -31
- data/lib/recombee_api_client/api/delete_all_search_synonyms.rb +15 -19
- data/lib/recombee_api_client/api/delete_bookmark.rb +21 -22
- data/lib/recombee_api_client/api/delete_cart_addition.rb +21 -22
- data/lib/recombee_api_client/api/delete_detail_view.rb +21 -22
- data/lib/recombee_api_client/api/delete_item.rb +16 -19
- data/lib/recombee_api_client/api/delete_item_property.rb +15 -18
- data/lib/recombee_api_client/api/delete_manual_reql_segment.rb +16 -19
- data/lib/recombee_api_client/api/delete_more_items.rb +18 -19
- data/lib/recombee_api_client/api/delete_purchase.rb +21 -22
- data/lib/recombee_api_client/api/delete_rating.rb +21 -22
- data/lib/recombee_api_client/api/delete_search_synonym.rb +15 -18
- data/lib/recombee_api_client/api/delete_segmentation.rb +15 -18
- data/lib/recombee_api_client/api/delete_series.rb +21 -22
- data/lib/recombee_api_client/api/delete_user.rb +15 -18
- data/lib/recombee_api_client/api/delete_user_property.rb +15 -18
- data/lib/recombee_api_client/api/delete_view_portion.rb +21 -22
- data/lib/recombee_api_client/api/get_item_property_info.rb +14 -17
- data/lib/recombee_api_client/api/get_item_values.rb +15 -18
- data/lib/recombee_api_client/api/get_segmentation.rb +15 -18
- data/lib/recombee_api_client/api/get_user_property_info.rb +15 -18
- data/lib/recombee_api_client/api/get_user_values.rb +15 -18
- data/lib/recombee_api_client/api/insert_to_series.rb +23 -24
- data/lib/recombee_api_client/api/list_item_bookmarks.rb +16 -19
- data/lib/recombee_api_client/api/list_item_cart_additions.rb +16 -19
- data/lib/recombee_api_client/api/list_item_detail_views.rb +16 -19
- data/lib/recombee_api_client/api/list_item_properties.rb +15 -19
- data/lib/recombee_api_client/api/list_item_purchases.rb +16 -19
- data/lib/recombee_api_client/api/list_item_ratings.rb +16 -19
- data/lib/recombee_api_client/api/list_item_view_portions.rb +16 -19
- data/lib/recombee_api_client/api/list_items.rb +62 -62
- data/lib/recombee_api_client/api/list_scenarios.rb +15 -19
- data/lib/recombee_api_client/api/list_search_synonyms.rb +20 -21
- data/lib/recombee_api_client/api/list_segmentations.rb +16 -17
- data/lib/recombee_api_client/api/list_series.rb +15 -19
- data/lib/recombee_api_client/api/list_series_items.rb +15 -18
- data/lib/recombee_api_client/api/list_user_bookmarks.rb +15 -18
- data/lib/recombee_api_client/api/list_user_cart_additions.rb +15 -18
- data/lib/recombee_api_client/api/list_user_detail_views.rb +15 -18
- data/lib/recombee_api_client/api/list_user_properties.rb +15 -19
- data/lib/recombee_api_client/api/list_user_purchases.rb +15 -18
- data/lib/recombee_api_client/api/list_user_ratings.rb +15 -18
- data/lib/recombee_api_client/api/list_user_view_portions.rb +15 -18
- data/lib/recombee_api_client/api/list_users.rb +56 -56
- data/lib/recombee_api_client/api/merge_users.rb +24 -25
- data/lib/recombee_api_client/api/recommend_item_segments_to_item.rb +69 -68
- data/lib/recombee_api_client/api/recommend_item_segments_to_item_segment.rb +70 -69
- data/lib/recombee_api_client/api/recommend_item_segments_to_user.rb +51 -50
- data/lib/recombee_api_client/api/recommend_items_to_item.rb +185 -139
- data/lib/recombee_api_client/api/recommend_items_to_item_segment.rb +181 -138
- data/lib/recombee_api_client/api/recommend_items_to_user.rb +165 -122
- data/lib/recombee_api_client/api/recommend_next_items.rb +24 -25
- data/lib/recombee_api_client/api/recommend_users_to_item.rb +151 -105
- data/lib/recombee_api_client/api/recommend_users_to_user.rb +154 -111
- data/lib/recombee_api_client/api/remove_from_series.rb +17 -18
- data/lib/recombee_api_client/api/request.rb +1 -1
- data/lib/recombee_api_client/api/reset_database.rb +15 -19
- data/lib/recombee_api_client/api/search_item_segments.rb +52 -51
- data/lib/recombee_api_client/api/search_items.rb +157 -114
- data/lib/recombee_api_client/api/set_item_values.rb +28 -29
- data/lib/recombee_api_client/api/set_user_values.rb +21 -22
- data/lib/recombee_api_client/api/set_values.rb +28 -28
- data/lib/recombee_api_client/api/set_view_portion.rb +37 -30
- data/lib/recombee_api_client/api/update_auto_reql_segmentation.rb +26 -27
- data/lib/recombee_api_client/api/update_manual_reql_segment.rb +25 -26
- data/lib/recombee_api_client/api/update_manual_reql_segmentation.rb +24 -25
- data/lib/recombee_api_client/api/update_more_items.rb +19 -20
- data/lib/recombee_api_client/api/update_property_based_segmentation.rb +26 -27
- data/lib/recombee_api_client/errors.rb +2 -5
- data/lib/recombee_api_client/inputs/composite_recommendation_stage_parameters.rb +240 -0
- data/lib/recombee_api_client/inputs/input.rb +9 -0
- data/lib/recombee_api_client/inputs/logic.rb +45 -0
- data/lib/recombee_api_client/utils/hash_normalizer.rb +21 -0
- data/lib/recombee_api_client/version.rb +1 -1
- data/lib/recombee_api_client.rb +40 -35
- data/recombee_api_client.gemspec +2 -3
- metadata +14 -10
- data/lib/recombee_api_client/api/hash_normalizer.rb +0 -21
|
@@ -5,33 +5,32 @@
|
|
|
5
5
|
module RecombeeApiClient
|
|
6
6
|
require_relative 'request'
|
|
7
7
|
require_relative '../errors'
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
##
|
|
10
|
-
#Adds a purchase of the given item made by the given user.
|
|
10
|
+
# Adds a purchase of the given item made by the given user.
|
|
11
11
|
#
|
|
12
12
|
class AddPurchase < ApiRequest
|
|
13
13
|
attr_reader :user_id, :item_id, :timestamp, :cascade_create, :amount, :price, :profit, :recomm_id, :additional_data
|
|
14
|
-
attr_accessor :timeout
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
#
|
|
14
|
+
attr_accessor :timeout, :ensure_https
|
|
15
|
+
|
|
16
|
+
##
|
|
17
|
+
# * *Required arguments*
|
|
18
|
+
# - +user_id+ -> User who purchased the item
|
|
19
|
+
# - +item_id+ -> Purchased item
|
|
20
|
+
#
|
|
21
|
+
# * *Optional arguments (given as hash optional)*
|
|
22
|
+
# - +timestamp+ -> UTC timestamp of the purchase as ISO8601-1 pattern or UTC epoch time. The default value is the current time.
|
|
23
|
+
# - +cascadeCreate+ -> Sets whether the given user/item should be created if not present in the database.
|
|
24
|
+
# - +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.
|
|
25
|
+
# - +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.
|
|
26
|
+
# - +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.
|
|
27
|
+
# - +recommId+ -> If this purchase is based on a recommendation request, `recommId` is the id of the clicked recommendation.
|
|
28
|
+
# - +additionalData+ -> A dictionary of additional data for the interaction.
|
|
29
|
+
#
|
|
31
30
|
def initialize(user_id, item_id, optional = {})
|
|
32
31
|
@user_id = user_id
|
|
33
32
|
@item_id = item_id
|
|
34
|
-
optional =
|
|
33
|
+
optional = normalize_hash_to_camel_case(optional)
|
|
35
34
|
@timestamp = optional['timestamp']
|
|
36
35
|
@cascade_create = optional['cascadeCreate']
|
|
37
36
|
@amount = optional['amount']
|
|
@@ -43,18 +42,19 @@ module RecombeeApiClient
|
|
|
43
42
|
@timeout = 3000
|
|
44
43
|
@ensure_https = false
|
|
45
44
|
@optional.each do |par, _|
|
|
46
|
-
|
|
45
|
+
raise UnknownOptionalParameter.new(par) unless %w[timestamp cascadeCreate amount price profit recommId
|
|
46
|
+
additionalData].include? par
|
|
47
47
|
end
|
|
48
48
|
end
|
|
49
|
-
|
|
49
|
+
|
|
50
50
|
# HTTP method
|
|
51
51
|
def method
|
|
52
52
|
:post
|
|
53
53
|
end
|
|
54
|
-
|
|
54
|
+
|
|
55
55
|
# Values of body parameters as a Hash
|
|
56
56
|
def body_parameters
|
|
57
|
-
p =
|
|
57
|
+
p = {}
|
|
58
58
|
p['userId'] = @user_id
|
|
59
59
|
p['itemId'] = @item_id
|
|
60
60
|
p['timestamp'] = @optional['timestamp'] if @optional.include? 'timestamp'
|
|
@@ -64,19 +64,19 @@ module RecombeeApiClient
|
|
|
64
64
|
p['profit'] = @optional['profit'] if @optional.include? 'profit'
|
|
65
65
|
p['recommId'] = @optional['recommId'] if @optional.include? 'recommId'
|
|
66
66
|
p['additionalData'] = @optional['additionalData'] if @optional.include? 'additionalData'
|
|
67
|
+
|
|
67
68
|
p
|
|
68
69
|
end
|
|
69
|
-
|
|
70
|
+
|
|
70
71
|
# Values of query parameters as a Hash.
|
|
71
72
|
# name of parameter => value of the parameter
|
|
72
73
|
def query_parameters
|
|
73
|
-
|
|
74
|
-
params
|
|
74
|
+
{}
|
|
75
75
|
end
|
|
76
|
-
|
|
76
|
+
|
|
77
77
|
# Relative path to the endpoint
|
|
78
78
|
def path
|
|
79
|
-
|
|
79
|
+
'/{databaseId}/purchases/'
|
|
80
80
|
end
|
|
81
81
|
end
|
|
82
82
|
end
|
|
@@ -5,32 +5,31 @@
|
|
|
5
5
|
module RecombeeApiClient
|
|
6
6
|
require_relative 'request'
|
|
7
7
|
require_relative '../errors'
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
##
|
|
10
|
-
#Adds a rating of the given item made by the given user.
|
|
10
|
+
# Adds a rating of the given item made by the given user.
|
|
11
11
|
#
|
|
12
12
|
class AddRating < ApiRequest
|
|
13
13
|
attr_reader :user_id, :item_id, :timestamp, :rating, :cascade_create, :recomm_id, :additional_data
|
|
14
|
-
attr_accessor :timeout
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
#
|
|
14
|
+
attr_accessor :timeout, :ensure_https
|
|
15
|
+
|
|
16
|
+
##
|
|
17
|
+
# * *Required arguments*
|
|
18
|
+
# - +user_id+ -> User who submitted the rating
|
|
19
|
+
# - +item_id+ -> Rated item
|
|
20
|
+
# - +rating+ -> Rating rescaled to interval [-1.0,1.0], where -1.0 means the worst rating possible, 0.0 means neutral, and 1.0 means absolutely positive rating. For example, in the case of 5-star evaluations, rating = (numStars-3)/2 formula may be used for the conversion.
|
|
21
|
+
#
|
|
22
|
+
# * *Optional arguments (given as hash optional)*
|
|
23
|
+
# - +timestamp+ -> UTC timestamp of the rating as ISO8601-1 pattern or UTC epoch time. The default value is the current time.
|
|
24
|
+
# - +cascadeCreate+ -> Sets whether the given user/item should be created if not present in the database.
|
|
25
|
+
# - +recommId+ -> If this rating is based on a recommendation request, `recommId` is the id of the clicked recommendation.
|
|
26
|
+
# - +additionalData+ -> A dictionary of additional data for the interaction.
|
|
27
|
+
#
|
|
29
28
|
def initialize(user_id, item_id, rating, optional = {})
|
|
30
29
|
@user_id = user_id
|
|
31
30
|
@item_id = item_id
|
|
32
31
|
@rating = rating
|
|
33
|
-
optional =
|
|
32
|
+
optional = normalize_hash_to_camel_case(optional)
|
|
34
33
|
@timestamp = optional['timestamp']
|
|
35
34
|
@cascade_create = optional['cascadeCreate']
|
|
36
35
|
@recomm_id = optional['recommId']
|
|
@@ -39,18 +38,19 @@ module RecombeeApiClient
|
|
|
39
38
|
@timeout = 3000
|
|
40
39
|
@ensure_https = false
|
|
41
40
|
@optional.each do |par, _|
|
|
42
|
-
|
|
41
|
+
raise UnknownOptionalParameter.new(par) unless %w[timestamp cascadeCreate recommId
|
|
42
|
+
additionalData].include? par
|
|
43
43
|
end
|
|
44
44
|
end
|
|
45
|
-
|
|
45
|
+
|
|
46
46
|
# HTTP method
|
|
47
47
|
def method
|
|
48
48
|
:post
|
|
49
49
|
end
|
|
50
|
-
|
|
50
|
+
|
|
51
51
|
# Values of body parameters as a Hash
|
|
52
52
|
def body_parameters
|
|
53
|
-
p =
|
|
53
|
+
p = {}
|
|
54
54
|
p['userId'] = @user_id
|
|
55
55
|
p['itemId'] = @item_id
|
|
56
56
|
p['rating'] = @rating
|
|
@@ -58,19 +58,19 @@ module RecombeeApiClient
|
|
|
58
58
|
p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
|
|
59
59
|
p['recommId'] = @optional['recommId'] if @optional.include? 'recommId'
|
|
60
60
|
p['additionalData'] = @optional['additionalData'] if @optional.include? 'additionalData'
|
|
61
|
+
|
|
61
62
|
p
|
|
62
63
|
end
|
|
63
|
-
|
|
64
|
+
|
|
64
65
|
# Values of query parameters as a Hash.
|
|
65
66
|
# name of parameter => value of the parameter
|
|
66
67
|
def query_parameters
|
|
67
|
-
|
|
68
|
-
params
|
|
68
|
+
{}
|
|
69
69
|
end
|
|
70
|
-
|
|
70
|
+
|
|
71
71
|
# Relative path to the endpoint
|
|
72
72
|
def path
|
|
73
|
-
|
|
73
|
+
'/{databaseId}/ratings/'
|
|
74
74
|
end
|
|
75
75
|
end
|
|
76
76
|
end
|
|
@@ -5,68 +5,67 @@
|
|
|
5
5
|
module RecombeeApiClient
|
|
6
6
|
require_relative 'request'
|
|
7
7
|
require_relative '../errors'
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
##
|
|
10
|
-
#Adds a new synonym for the [Search items](https://docs.recombee.com/api#search-items).
|
|
10
|
+
# Adds a new synonym for the [Search items](https://docs.recombee.com/api#search-items).
|
|
11
11
|
#
|
|
12
|
-
#When the `term` is used in the search query, the `synonym` is also used for the full-text search.
|
|
13
|
-
#Unless `oneWay=true`, it works also in the opposite way (`synonym` -> `term`).
|
|
12
|
+
# When the `term` is used in the search query, the `synonym` is also used for the full-text search.
|
|
13
|
+
# Unless `oneWay=true`, it works also in the opposite way (`synonym` -> `term`).
|
|
14
14
|
#
|
|
15
|
-
#An example of a synonym can be `science fiction` for the term `sci-fi`.
|
|
15
|
+
# An example of a synonym can be `science fiction` for the term `sci-fi`.
|
|
16
16
|
#
|
|
17
17
|
class AddSearchSynonym < ApiRequest
|
|
18
18
|
attr_reader :term, :synonym, :one_way
|
|
19
|
-
attr_accessor :timeout
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
#
|
|
19
|
+
attr_accessor :timeout, :ensure_https
|
|
20
|
+
|
|
21
|
+
##
|
|
22
|
+
# * *Required arguments*
|
|
23
|
+
# - +term+ -> A word to which the `synonym` is specified.
|
|
24
|
+
# - +synonym+ -> A word that should be considered equal to the `term` by the full-text search engine.
|
|
25
|
+
#
|
|
26
|
+
# * *Optional arguments (given as hash optional)*
|
|
27
|
+
# - +oneWay+ -> If set to `true`, only `term` -> `synonym` is considered. If set to `false`, also `synonym` -> `term` works.
|
|
28
|
+
#
|
|
29
|
+
# Default: `false`.
|
|
30
|
+
#
|
|
31
|
+
#
|
|
33
32
|
def initialize(term, synonym, optional = {})
|
|
34
33
|
@term = term
|
|
35
34
|
@synonym = synonym
|
|
36
|
-
optional =
|
|
35
|
+
optional = normalize_hash_to_camel_case(optional)
|
|
37
36
|
@one_way = optional['oneWay']
|
|
38
37
|
@optional = optional
|
|
39
|
-
@timeout =
|
|
38
|
+
@timeout = 10_000
|
|
40
39
|
@ensure_https = false
|
|
41
40
|
@optional.each do |par, _|
|
|
42
|
-
|
|
41
|
+
raise UnknownOptionalParameter.new(par) unless ['oneWay'].include? par
|
|
43
42
|
end
|
|
44
43
|
end
|
|
45
|
-
|
|
44
|
+
|
|
46
45
|
# HTTP method
|
|
47
46
|
def method
|
|
48
47
|
:post
|
|
49
48
|
end
|
|
50
|
-
|
|
49
|
+
|
|
51
50
|
# Values of body parameters as a Hash
|
|
52
51
|
def body_parameters
|
|
53
|
-
p =
|
|
52
|
+
p = {}
|
|
54
53
|
p['term'] = @term
|
|
55
54
|
p['synonym'] = @synonym
|
|
56
55
|
p['oneWay'] = @optional['oneWay'] if @optional.include? 'oneWay'
|
|
56
|
+
|
|
57
57
|
p
|
|
58
58
|
end
|
|
59
|
-
|
|
59
|
+
|
|
60
60
|
# Values of query parameters as a Hash.
|
|
61
61
|
# name of parameter => value of the parameter
|
|
62
62
|
def query_parameters
|
|
63
|
-
|
|
64
|
-
params
|
|
63
|
+
{}
|
|
65
64
|
end
|
|
66
|
-
|
|
65
|
+
|
|
67
66
|
# Relative path to the endpoint
|
|
68
67
|
def path
|
|
69
|
-
|
|
68
|
+
'/{databaseId}/synonyms/items/'
|
|
70
69
|
end
|
|
71
70
|
end
|
|
72
71
|
end
|
|
@@ -5,52 +5,51 @@
|
|
|
5
5
|
module RecombeeApiClient
|
|
6
6
|
require_relative 'request'
|
|
7
7
|
require_relative '../errors'
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
##
|
|
10
|
-
#Creates a new series in the database
|
|
10
|
+
# Creates a new series in the database.#
|
|
11
11
|
class AddSeries < ApiRequest
|
|
12
12
|
attr_reader :series_id, :cascade_create
|
|
13
|
-
attr_accessor :timeout
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
#
|
|
13
|
+
attr_accessor :timeout, :ensure_https
|
|
14
|
+
|
|
15
|
+
##
|
|
16
|
+
# * *Required arguments*
|
|
17
|
+
# - +series_id+ -> ID of the series to be created.
|
|
18
|
+
#
|
|
19
|
+
# * *Optional arguments (given as hash optional)*
|
|
20
|
+
# - +cascadeCreate+ -> If set to `true`, the item will be created with the same ID as the series. Default is `true`.
|
|
21
|
+
#
|
|
23
22
|
def initialize(series_id, optional = {})
|
|
24
23
|
@series_id = series_id
|
|
25
|
-
optional =
|
|
24
|
+
optional = normalize_hash_to_camel_case(optional)
|
|
26
25
|
@cascade_create = optional['cascadeCreate']
|
|
27
26
|
@optional = optional
|
|
28
27
|
@timeout = 3000
|
|
29
28
|
@ensure_https = false
|
|
30
29
|
@optional.each do |par, _|
|
|
31
|
-
|
|
30
|
+
raise UnknownOptionalParameter.new(par) unless ['cascadeCreate'].include? par
|
|
32
31
|
end
|
|
33
32
|
end
|
|
34
|
-
|
|
33
|
+
|
|
35
34
|
# HTTP method
|
|
36
35
|
def method
|
|
37
36
|
:put
|
|
38
37
|
end
|
|
39
|
-
|
|
38
|
+
|
|
40
39
|
# Values of body parameters as a Hash
|
|
41
40
|
def body_parameters
|
|
42
|
-
p =
|
|
41
|
+
p = {}
|
|
43
42
|
p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
|
|
43
|
+
|
|
44
44
|
p
|
|
45
45
|
end
|
|
46
|
-
|
|
46
|
+
|
|
47
47
|
# Values of query parameters as a Hash.
|
|
48
48
|
# name of parameter => value of the parameter
|
|
49
49
|
def query_parameters
|
|
50
|
-
|
|
51
|
-
params
|
|
50
|
+
{}
|
|
52
51
|
end
|
|
53
|
-
|
|
52
|
+
|
|
54
53
|
# Relative path to the endpoint
|
|
55
54
|
def path
|
|
56
55
|
"/{databaseId}/series/#{@series_id}"
|
|
@@ -5,43 +5,40 @@
|
|
|
5
5
|
module RecombeeApiClient
|
|
6
6
|
require_relative 'request'
|
|
7
7
|
require_relative '../errors'
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
##
|
|
10
|
-
#Adds a new user to the database.
|
|
10
|
+
# Adds a new user to the database.
|
|
11
11
|
#
|
|
12
12
|
class AddUser < ApiRequest
|
|
13
13
|
attr_reader :user_id
|
|
14
|
-
attr_accessor :timeout
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
#
|
|
14
|
+
attr_accessor :timeout, :ensure_https
|
|
15
|
+
|
|
16
|
+
##
|
|
17
|
+
# * *Required arguments*
|
|
18
|
+
# - +user_id+ -> ID of the user to be added.
|
|
19
|
+
#
|
|
21
20
|
def initialize(user_id)
|
|
22
21
|
@user_id = user_id
|
|
23
22
|
@timeout = 3000
|
|
24
23
|
@ensure_https = false
|
|
25
24
|
end
|
|
26
|
-
|
|
25
|
+
|
|
27
26
|
# HTTP method
|
|
28
27
|
def method
|
|
29
28
|
:put
|
|
30
29
|
end
|
|
31
|
-
|
|
30
|
+
|
|
32
31
|
# Values of body parameters as a Hash
|
|
33
32
|
def body_parameters
|
|
34
|
-
|
|
35
|
-
p
|
|
33
|
+
{}
|
|
36
34
|
end
|
|
37
|
-
|
|
35
|
+
|
|
38
36
|
# Values of query parameters as a Hash.
|
|
39
37
|
# name of parameter => value of the parameter
|
|
40
38
|
def query_parameters
|
|
41
|
-
|
|
42
|
-
params
|
|
39
|
+
{}
|
|
43
40
|
end
|
|
44
|
-
|
|
41
|
+
|
|
45
42
|
# Relative path to the endpoint
|
|
46
43
|
def path
|
|
47
44
|
"/{databaseId}/users/#{@user_id}"
|
|
@@ -5,60 +5,59 @@
|
|
|
5
5
|
module RecombeeApiClient
|
|
6
6
|
require_relative 'request'
|
|
7
7
|
require_relative '../errors'
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
##
|
|
10
|
-
#Adding a user property is somewhat equivalent to adding a column to the table of users. The users may be characterized by various properties of different types.
|
|
10
|
+
# Adding a user property is somewhat equivalent to adding a column to the table of users. The users may be characterized by various properties of different types.
|
|
11
11
|
#
|
|
12
12
|
class AddUserProperty < ApiRequest
|
|
13
13
|
attr_reader :property_name, :type
|
|
14
|
-
attr_accessor :timeout
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
#
|
|
14
|
+
attr_accessor :timeout, :ensure_https
|
|
15
|
+
|
|
16
|
+
##
|
|
17
|
+
# * *Required arguments*
|
|
18
|
+
# - +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.
|
|
19
|
+
#
|
|
20
|
+
# - +type+ -> Value type of the user property to be created. One of: `int`, `double`, `string`, `boolean`, `timestamp`, `set`.
|
|
21
|
+
#
|
|
22
|
+
# * `int` - Signed integer number.
|
|
23
|
+
#
|
|
24
|
+
# * `double` - Floating point number. It uses 64-bit base-2 format (IEEE 754 standard).
|
|
25
|
+
#
|
|
26
|
+
# * `string` - UTF-8 string.
|
|
27
|
+
#
|
|
28
|
+
# * `boolean` - *true* / *false*
|
|
29
|
+
#
|
|
30
|
+
# * `timestamp` - Value representing date and time.
|
|
31
|
+
#
|
|
32
|
+
# * `set` - Set of strings.
|
|
33
|
+
#
|
|
34
|
+
#
|
|
36
35
|
def initialize(property_name, type)
|
|
37
36
|
@property_name = property_name
|
|
38
37
|
@type = type
|
|
39
|
-
@timeout =
|
|
38
|
+
@timeout = 100_000
|
|
40
39
|
@ensure_https = false
|
|
41
40
|
end
|
|
42
|
-
|
|
41
|
+
|
|
43
42
|
# HTTP method
|
|
44
43
|
def method
|
|
45
44
|
:put
|
|
46
45
|
end
|
|
47
|
-
|
|
46
|
+
|
|
48
47
|
# Values of body parameters as a Hash
|
|
49
48
|
def body_parameters
|
|
50
|
-
|
|
51
|
-
p
|
|
49
|
+
{}
|
|
52
50
|
end
|
|
53
|
-
|
|
51
|
+
|
|
54
52
|
# Values of query parameters as a Hash.
|
|
55
53
|
# name of parameter => value of the parameter
|
|
56
54
|
def query_parameters
|
|
57
55
|
params = {}
|
|
58
56
|
params['type'] = @type
|
|
57
|
+
|
|
59
58
|
params
|
|
60
59
|
end
|
|
61
|
-
|
|
60
|
+
|
|
62
61
|
# Relative path to the endpoint
|
|
63
62
|
def path
|
|
64
63
|
"/{databaseId}/users/properties/#{@property_name}"
|
|
@@ -8,22 +8,22 @@ module RecombeeApiClient
|
|
|
8
8
|
#
|
|
9
9
|
class Batch < ApiRequest
|
|
10
10
|
attr_reader :requests
|
|
11
|
-
attr_accessor :timeout
|
|
12
|
-
|
|
11
|
+
attr_accessor :timeout, :ensure_https
|
|
12
|
+
|
|
13
13
|
##
|
|
14
14
|
# * *Required arguments*
|
|
15
15
|
# - +requests+ -> Array of API requests.
|
|
16
16
|
#
|
|
17
17
|
def initialize(requests, optional = {})
|
|
18
18
|
@requests = requests
|
|
19
|
-
optional =
|
|
19
|
+
optional = normalize_hash_to_camel_case(optional)
|
|
20
20
|
@optional = optional
|
|
21
21
|
@body_parameters = requests_to_batch_hash
|
|
22
|
-
@timeout = requests.map{|r| r.timeout}.reduce(:+)
|
|
22
|
+
@timeout = requests.map { |r| r.timeout }.reduce(:+)
|
|
23
23
|
@ensure_https = true
|
|
24
24
|
|
|
25
25
|
@optional.each do |par, _|
|
|
26
|
-
|
|
26
|
+
raise UnknownOptionalParameter.new(par) unless ['distinctRecomms'].include? par
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
|
|
@@ -38,39 +38,35 @@ module RecombeeApiClient
|
|
|
38
38
|
# Values of query path parameters as a Hash.
|
|
39
39
|
# name of parameter => value of the parameter
|
|
40
40
|
def query_parameters
|
|
41
|
-
|
|
42
|
-
params
|
|
41
|
+
{}
|
|
43
42
|
end
|
|
44
43
|
|
|
45
44
|
# Relative path to the endpoint
|
|
46
45
|
def path
|
|
47
|
-
|
|
48
|
-
p
|
|
46
|
+
'/{databaseId}/batch/'
|
|
49
47
|
end
|
|
50
48
|
|
|
51
49
|
private
|
|
52
50
|
|
|
53
51
|
def requests_to_batch_hash
|
|
54
52
|
reqs = []
|
|
55
|
-
@requests.each { |r| reqs.push(request_to_batch_hash
|
|
56
|
-
result = {'requests' => reqs}
|
|
53
|
+
@requests.each { |r| reqs.push(request_to_batch_hash(r)) }
|
|
54
|
+
result = { 'requests' => reqs }
|
|
57
55
|
result['distinctRecomms'] = @optional['distinctRecomms'] if @optional.key? 'distinctRecomms'
|
|
58
56
|
result
|
|
59
57
|
end
|
|
60
58
|
|
|
61
59
|
def request_to_batch_hash(req)
|
|
62
60
|
path = req.path
|
|
63
|
-
path.slice!
|
|
61
|
+
path.slice!('/{databaseId}')
|
|
64
62
|
bh = {
|
|
65
63
|
'method' => req.method.to_s.upcase,
|
|
66
64
|
'path' => path
|
|
67
65
|
}
|
|
68
66
|
params = req.query_parameters
|
|
69
67
|
|
|
70
|
-
if req.body_parameters
|
|
71
|
-
|
|
72
|
-
end
|
|
73
|
-
|
|
68
|
+
params = params.merge(req.body_parameters) if req.body_parameters
|
|
69
|
+
|
|
74
70
|
bh['params'] = params if params.size > 0
|
|
75
71
|
bh
|
|
76
72
|
end
|