recombee_api_client 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +3 -0
  3. data/LICENSE.txt +21 -0
  4. data/README.md +157 -0
  5. data/Rakefile +6 -0
  6. data/lib/recombee_api_client/api/add_bookmark.rb +70 -0
  7. data/lib/recombee_api_client/api/add_cart_addition.rb +70 -0
  8. data/lib/recombee_api_client/api/add_detail_view.rb +73 -0
  9. data/lib/recombee_api_client/api/add_group.rb +53 -0
  10. data/lib/recombee_api_client/api/add_item.rb +56 -0
  11. data/lib/recombee_api_client/api/add_item_property.rb +59 -0
  12. data/lib/recombee_api_client/api/add_purchase.rb +70 -0
  13. data/lib/recombee_api_client/api/add_rating.rb +73 -0
  14. data/lib/recombee_api_client/api/add_series.rb +53 -0
  15. data/lib/recombee_api_client/api/add_user.rb +54 -0
  16. data/lib/recombee_api_client/api/batch.rb +64 -0
  17. data/lib/recombee_api_client/api/delete_bookmark.rb +61 -0
  18. data/lib/recombee_api_client/api/delete_cart_addition.rb +61 -0
  19. data/lib/recombee_api_client/api/delete_detail_view.rb +61 -0
  20. data/lib/recombee_api_client/api/delete_group.rb +56 -0
  21. data/lib/recombee_api_client/api/delete_item.rb +58 -0
  22. data/lib/recombee_api_client/api/delete_item_property.rb +54 -0
  23. data/lib/recombee_api_client/api/delete_purchase.rb +61 -0
  24. data/lib/recombee_api_client/api/delete_rating.rb +61 -0
  25. data/lib/recombee_api_client/api/delete_series.rb +56 -0
  26. data/lib/recombee_api_client/api/delete_user.rb +56 -0
  27. data/lib/recombee_api_client/api/get_item_property_info.rb +54 -0
  28. data/lib/recombee_api_client/api/get_item_values.rb +55 -0
  29. data/lib/recombee_api_client/api/insert_to_group.rb +69 -0
  30. data/lib/recombee_api_client/api/insert_to_series.rb +72 -0
  31. data/lib/recombee_api_client/api/item_based_recommendation.rb +131 -0
  32. data/lib/recombee_api_client/api/list_group_items.rb +53 -0
  33. data/lib/recombee_api_client/api/list_groups.rb +50 -0
  34. data/lib/recombee_api_client/api/list_item_bookmarks.rb +54 -0
  35. data/lib/recombee_api_client/api/list_item_cart_additions.rb +54 -0
  36. data/lib/recombee_api_client/api/list_item_detail_views.rb +54 -0
  37. data/lib/recombee_api_client/api/list_item_properties.rb +51 -0
  38. data/lib/recombee_api_client/api/list_item_purchases.rb +54 -0
  39. data/lib/recombee_api_client/api/list_item_ratings.rb +54 -0
  40. data/lib/recombee_api_client/api/list_items.rb +63 -0
  41. data/lib/recombee_api_client/api/list_series.rb +50 -0
  42. data/lib/recombee_api_client/api/list_series_items.rb +53 -0
  43. data/lib/recombee_api_client/api/list_user_bookmarks.rb +53 -0
  44. data/lib/recombee_api_client/api/list_user_cart_additions.rb +53 -0
  45. data/lib/recombee_api_client/api/list_user_detail_views.rb +53 -0
  46. data/lib/recombee_api_client/api/list_user_purchases.rb +53 -0
  47. data/lib/recombee_api_client/api/list_user_ratings.rb +53 -0
  48. data/lib/recombee_api_client/api/list_users.rb +50 -0
  49. data/lib/recombee_api_client/api/merge_users.rb +72 -0
  50. data/lib/recombee_api_client/api/remove_from_group.rb +59 -0
  51. data/lib/recombee_api_client/api/remove_from_series.rb +62 -0
  52. data/lib/recombee_api_client/api/request.rb +7 -0
  53. data/lib/recombee_api_client/api/reset_database.rb +51 -0
  54. data/lib/recombee_api_client/api/set_item_values.rb +70 -0
  55. data/lib/recombee_api_client/api/user_based_recommendation.rb +116 -0
  56. data/lib/recombee_api_client/errors.rb +44 -0
  57. data/lib/recombee_api_client/version.rb +3 -0
  58. data/lib/recombee_api_client.rb +105 -0
  59. data/recombee_api_client.gemspec +26 -0
  60. metadata +173 -0
@@ -0,0 +1,56 @@
1
+ #
2
+ # This file is auto-generated, do not edit
3
+ #
4
+
5
+ module RecombeeApiClient
6
+ require_relative 'request'
7
+ require_relative '../errors'
8
+
9
+ ##
10
+ #Adds new item of given `itemId` to the items catalog.
11
+ #
12
+ #All the item properties for the newly created items are set null.
13
+ #
14
+ class AddItem < ApiRequest
15
+ attr_reader :item_id
16
+ attr_accessor :timeout
17
+
18
+ ##
19
+ # * *Required arguments*
20
+ # - +item_id+ -> ID of the item to be created.
21
+ #
22
+ def initialize(item_id)
23
+ @item_id = item_id
24
+ @timeout = 1000
25
+ end
26
+
27
+ # HTTP method
28
+ def method
29
+ :put
30
+ end
31
+
32
+ # Values of body parameters as a Hash
33
+ def body_parameters
34
+ p = Hash.new
35
+ p
36
+ end
37
+
38
+ # Values of query path parameters as a Hash.
39
+ # name of parameter => value of the parameter
40
+ def query_parameters
41
+ params = {}
42
+ params
43
+ end
44
+
45
+ # Relative path to the endpoint
46
+ def basic_path
47
+ "/{databaseId}/items/#{@item_id}"
48
+ end
49
+
50
+ # Relative path to the endpoint including query parameters
51
+ def path
52
+ p = "/{databaseId}/items/#{@item_id}"
53
+ p
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,59 @@
1
+ #
2
+ # This file is auto-generated, do not edit
3
+ #
4
+
5
+ module RecombeeApiClient
6
+ require_relative 'request'
7
+ require_relative '../errors'
8
+
9
+ ##
10
+ #Adding an item property is somehow equivalent to adding a column to the table of items. The items may be characterized by various properties of different types.
11
+ #
12
+ class AddItemProperty < ApiRequest
13
+ attr_reader :property_name, :type
14
+ attr_accessor :timeout
15
+
16
+ ##
17
+ # * *Required arguments*
18
+ # - +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.
19
+ #
20
+ # - +type+ -> Value type of the item property to be created. One of: `int`, `double`, `string`, `boolean`, `timestamp`, `set`
21
+ #
22
+ #
23
+ def initialize(property_name, type)
24
+ @property_name = property_name
25
+ @type = type
26
+ @timeout = 1000
27
+ end
28
+
29
+ # HTTP method
30
+ def method
31
+ :put
32
+ end
33
+
34
+ # Values of body parameters as a Hash
35
+ def body_parameters
36
+ p = Hash.new
37
+ p
38
+ end
39
+
40
+ # Values of query path parameters as a Hash.
41
+ # name of parameter => value of the parameter
42
+ def query_parameters
43
+ params = {}
44
+ params['type'] = @type
45
+ params
46
+ end
47
+
48
+ # Relative path to the endpoint
49
+ def basic_path
50
+ "/{databaseId}/items/properties/#{@property_name}"
51
+ end
52
+
53
+ # Relative path to the endpoint including query parameters
54
+ def path
55
+ p = "/{databaseId}/items/properties/#{@property_name}?type=#{@type}"
56
+ p
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,70 @@
1
+ #
2
+ # This file is auto-generated, do not edit
3
+ #
4
+
5
+ module RecombeeApiClient
6
+ require_relative 'request'
7
+ require_relative '../errors'
8
+
9
+ ##
10
+ #Adds a purchase of a given item made by a given user.
11
+ #
12
+ class AddPurchase < ApiRequest
13
+ attr_reader :user_id, :item_id, :timestamp, :cascade_create
14
+ attr_accessor :timeout
15
+
16
+ ##
17
+ # * *Required arguments*
18
+ # - +user_id+ -> User who purchased the item
19
+ # - +item_id+ -> Purchased item
20
+ # - +timestamp+ -> Unix timestamp of the purchase. If you don't have the timestamp value available, you may use some artificial value, such as 0. It is preferable, however, to provide the timestamp whenever possible as the user's preferences may evolve over time.
21
+ #
22
+ # * *Optional arguments (given as hash optional)*
23
+ # - +cascadeCreate+ -> Sets whether the given user/item should be created if not present in the database.
24
+ #
25
+ def initialize(user_id, item_id, timestamp, optional = {})
26
+ @user_id = user_id
27
+ @item_id = item_id
28
+ @timestamp = timestamp
29
+ @cascade_create = optional['cascadeCreate']
30
+ @optional = optional
31
+ @timeout = 1000
32
+ @optional.each do |par, _|
33
+ fail UnknownOptionalParameter.new(par) unless ["cascadeCreate"].include? par
34
+ end
35
+ end
36
+
37
+ # HTTP method
38
+ def method
39
+ :post
40
+ end
41
+
42
+ # Values of body parameters as a Hash
43
+ def body_parameters
44
+ p = Hash.new
45
+ p['userId'] = @user_id
46
+ p['itemId'] = @item_id
47
+ p['timestamp'] = @timestamp
48
+ p['cascadeCreate'] = @optional['cascadeCreate'] if @optional['cascadeCreate']
49
+ p
50
+ end
51
+
52
+ # Values of query path parameters as a Hash.
53
+ # name of parameter => value of the parameter
54
+ def query_parameters
55
+ params = {}
56
+ params
57
+ end
58
+
59
+ # Relative path to the endpoint
60
+ def basic_path
61
+ "/{databaseId}/purchases/"
62
+ end
63
+
64
+ # Relative path to the endpoint including query parameters
65
+ def path
66
+ p = "/{databaseId}/purchases/"
67
+ p
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,73 @@
1
+ #
2
+ # This file is auto-generated, do not edit
3
+ #
4
+
5
+ module RecombeeApiClient
6
+ require_relative 'request'
7
+ require_relative '../errors'
8
+
9
+ ##
10
+ #Adds a rating of given item made by a given user.
11
+ #
12
+ class AddRating < ApiRequest
13
+ attr_reader :user_id, :item_id, :timestamp, :rating, :cascade_create
14
+ attr_accessor :timeout
15
+
16
+ ##
17
+ # * *Required arguments*
18
+ # - +user_id+ -> User who submitted the rating
19
+ # - +item_id+ -> Rated item
20
+ # - +timestamp+ -> Unix timestamp of the rating. If you don't have the timestamp value available, you may use some artificial value, such as 0. It is preferable, however, to provide the timestamp whenever possible as the user's preferences may evolve over time.
21
+ # - +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.
22
+ #
23
+ # * *Optional arguments (given as hash optional)*
24
+ # - +cascadeCreate+ -> Sets whether the given user/item should be created if not present in the database.
25
+ #
26
+ def initialize(user_id, item_id, timestamp, rating, optional = {})
27
+ @user_id = user_id
28
+ @item_id = item_id
29
+ @timestamp = timestamp
30
+ @rating = rating
31
+ @cascade_create = optional['cascadeCreate']
32
+ @optional = optional
33
+ @timeout = 1000
34
+ @optional.each do |par, _|
35
+ fail UnknownOptionalParameter.new(par) unless ["cascadeCreate"].include? par
36
+ end
37
+ end
38
+
39
+ # HTTP method
40
+ def method
41
+ :post
42
+ end
43
+
44
+ # Values of body parameters as a Hash
45
+ def body_parameters
46
+ p = Hash.new
47
+ p['userId'] = @user_id
48
+ p['itemId'] = @item_id
49
+ p['timestamp'] = @timestamp
50
+ p['rating'] = @rating
51
+ p['cascadeCreate'] = @optional['cascadeCreate'] if @optional['cascadeCreate']
52
+ p
53
+ end
54
+
55
+ # Values of query path parameters as a Hash.
56
+ # name of parameter => value of the parameter
57
+ def query_parameters
58
+ params = {}
59
+ params
60
+ end
61
+
62
+ # Relative path to the endpoint
63
+ def basic_path
64
+ "/{databaseId}/ratings/"
65
+ end
66
+
67
+ # Relative path to the endpoint including query parameters
68
+ def path
69
+ p = "/{databaseId}/ratings/"
70
+ p
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,53 @@
1
+ #
2
+ # This file is auto-generated, do not edit
3
+ #
4
+
5
+ module RecombeeApiClient
6
+ require_relative 'request'
7
+ require_relative '../errors'
8
+
9
+ ##
10
+ #Creates new series in the database.
11
+ class AddSeries < ApiRequest
12
+ attr_reader :series_id
13
+ attr_accessor :timeout
14
+
15
+ ##
16
+ # * *Required arguments*
17
+ # - +series_id+ -> ID of the series to be created.
18
+ #
19
+ def initialize(series_id)
20
+ @series_id = series_id
21
+ @timeout = 1000
22
+ end
23
+
24
+ # HTTP method
25
+ def method
26
+ :put
27
+ end
28
+
29
+ # Values of body parameters as a Hash
30
+ def body_parameters
31
+ p = Hash.new
32
+ p
33
+ end
34
+
35
+ # Values of query path parameters as a Hash.
36
+ # name of parameter => value of the parameter
37
+ def query_parameters
38
+ params = {}
39
+ params
40
+ end
41
+
42
+ # Relative path to the endpoint
43
+ def basic_path
44
+ "/{databaseId}/series/#{@series_id}"
45
+ end
46
+
47
+ # Relative path to the endpoint including query parameters
48
+ def path
49
+ p = "/{databaseId}/series/#{@series_id}"
50
+ p
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,54 @@
1
+ #
2
+ # This file is auto-generated, do not edit
3
+ #
4
+
5
+ module RecombeeApiClient
6
+ require_relative 'request'
7
+ require_relative '../errors'
8
+
9
+ ##
10
+ #Adds a new user to the database.
11
+ #
12
+ class AddUser < ApiRequest
13
+ attr_reader :user_id
14
+ attr_accessor :timeout
15
+
16
+ ##
17
+ # * *Required arguments*
18
+ # - +user_id+ -> ID of the user to be added.
19
+ #
20
+ def initialize(user_id)
21
+ @user_id = user_id
22
+ @timeout = 1000
23
+ end
24
+
25
+ # HTTP method
26
+ def method
27
+ :put
28
+ end
29
+
30
+ # Values of body parameters as a Hash
31
+ def body_parameters
32
+ p = Hash.new
33
+ p
34
+ end
35
+
36
+ # Values of query path parameters as a Hash.
37
+ # name of parameter => value of the parameter
38
+ def query_parameters
39
+ params = {}
40
+ params
41
+ end
42
+
43
+ # Relative path to the endpoint
44
+ def basic_path
45
+ "/{databaseId}/users/#{@user_id}"
46
+ end
47
+
48
+ # Relative path to the endpoint including query parameters
49
+ def path
50
+ p = "/{databaseId}/users/#{@user_id}"
51
+ p
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,64 @@
1
+ require 'json'
2
+ require 'cgi'
3
+ require_relative 'request'
4
+
5
+ module RecombeeApiClient
6
+ ##
7
+ # Batch processing allows you to submit arbitrary sequence of requests
8
+ #
9
+ class Batch < ApiRequest
10
+ attr_reader :requests
11
+ attr_accessor :timeout
12
+ ##
13
+ # * *Required arguments*
14
+ # - +requests+ -> Array of API requests.
15
+ #
16
+ def initialize(requests)
17
+ @requests = requests
18
+ @body_parameters = requests_to_batch_hash
19
+ @timeout = requests.map{|r| r.timeout}.reduce(:+)
20
+ end
21
+
22
+ # HTTP method
23
+ def method
24
+ :post
25
+ end
26
+
27
+ # Values of body parameters as a Hash
28
+ attr_reader :body_parameters
29
+
30
+ # Get values of parameters in form a Hash.
31
+ # name of parameter => value of the parameter
32
+ def params_hash
33
+ end
34
+
35
+ # Relative path to the endpoint
36
+ def path
37
+ p = '/{databaseId}/batch/'
38
+ p
39
+ end
40
+
41
+ private
42
+
43
+ def requests_to_batch_hash
44
+ reqs = []
45
+ @requests.each { |r| reqs.push(request_to_batch_hash r) }
46
+ {'requests' => reqs}
47
+ end
48
+
49
+ def request_to_batch_hash(req)
50
+ path = req.basic_path
51
+ path.slice! ('/{databaseId}')
52
+ bh = {
53
+ 'method' => req.method.to_s.upcase,
54
+ 'path' => path
55
+ }
56
+ params = req.query_parameters
57
+ if req.body_parameters
58
+ params = params.merge(req.body_parameters)
59
+ end
60
+ bh['params'] = params if params.size > 0
61
+ bh
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,61 @@
1
+ #
2
+ # This file is auto-generated, do not edit
3
+ #
4
+
5
+ module RecombeeApiClient
6
+ require_relative 'request'
7
+ require_relative '../errors'
8
+
9
+ ##
10
+ #Deletes a bookmark uniquely specified by `userId`, `itemId`, and `timestamp`.
11
+ #
12
+ class DeleteBookmark < ApiRequest
13
+ attr_reader :user_id, :item_id, :timestamp
14
+ attr_accessor :timeout
15
+
16
+ ##
17
+ # * *Required arguments*
18
+ # - +user_id+ -> ID of the user who made the bookmark.
19
+ # - +item_id+ -> ID of the item of which was bookmarked.
20
+ # - +timestamp+ -> Unix timestamp of the bookmark.
21
+ #
22
+ def initialize(user_id, item_id, timestamp)
23
+ @user_id = user_id
24
+ @item_id = item_id
25
+ @timestamp = timestamp
26
+ @timeout = 1000
27
+ end
28
+
29
+ # HTTP method
30
+ def method
31
+ :delete
32
+ end
33
+
34
+ # Values of body parameters as a Hash
35
+ def body_parameters
36
+ p = Hash.new
37
+ p
38
+ end
39
+
40
+ # Values of query path parameters as a Hash.
41
+ # name of parameter => value of the parameter
42
+ def query_parameters
43
+ params = {}
44
+ params['userId'] = @user_id
45
+ params['itemId'] = @item_id
46
+ params['timestamp'] = @timestamp
47
+ params
48
+ end
49
+
50
+ # Relative path to the endpoint
51
+ def basic_path
52
+ "/{databaseId}/bookmarks/"
53
+ end
54
+
55
+ # Relative path to the endpoint including query parameters
56
+ def path
57
+ p = "/{databaseId}/bookmarks/?userId=#{@user_id}&itemId=#{@item_id}&timestamp=#{@timestamp}"
58
+ p
59
+ end
60
+ end
61
+ end