recombee_api_client 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -0
  3. data/lib/recombee_api_client.rb +15 -0
  4. data/lib/recombee_api_client/api/add_bookmark.rb +2 -8
  5. data/lib/recombee_api_client/api/add_cart_addition.rb +2 -8
  6. data/lib/recombee_api_client/api/add_detail_view.rb +2 -8
  7. data/lib/recombee_api_client/api/add_group.rb +2 -8
  8. data/lib/recombee_api_client/api/add_item.rb +2 -8
  9. data/lib/recombee_api_client/api/add_item_property.rb +2 -8
  10. data/lib/recombee_api_client/api/add_purchase.rb +2 -8
  11. data/lib/recombee_api_client/api/add_rating.rb +2 -8
  12. data/lib/recombee_api_client/api/add_series.rb +2 -8
  13. data/lib/recombee_api_client/api/add_user.rb +2 -8
  14. data/lib/recombee_api_client/api/batch.rb +5 -3
  15. data/lib/recombee_api_client/api/delete_bookmark.rb +3 -13
  16. data/lib/recombee_api_client/api/delete_cart_addition.rb +3 -13
  17. data/lib/recombee_api_client/api/delete_detail_view.rb +3 -13
  18. data/lib/recombee_api_client/api/delete_group.rb +2 -8
  19. data/lib/recombee_api_client/api/delete_item.rb +2 -8
  20. data/lib/recombee_api_client/api/delete_item_property.rb +2 -8
  21. data/lib/recombee_api_client/api/delete_purchase.rb +3 -13
  22. data/lib/recombee_api_client/api/delete_rating.rb +3 -13
  23. data/lib/recombee_api_client/api/delete_series.rb +2 -8
  24. data/lib/recombee_api_client/api/delete_user.rb +2 -8
  25. data/lib/recombee_api_client/api/get_item_property_info.rb +2 -8
  26. data/lib/recombee_api_client/api/get_item_values.rb +2 -8
  27. data/lib/recombee_api_client/api/insert_to_group.rb +2 -8
  28. data/lib/recombee_api_client/api/insert_to_series.rb +2 -8
  29. data/lib/recombee_api_client/api/item_based_recommendation.rb +49 -55
  30. data/lib/recombee_api_client/api/list_group_items.rb +2 -8
  31. data/lib/recombee_api_client/api/list_groups.rb +2 -8
  32. data/lib/recombee_api_client/api/list_item_bookmarks.rb +2 -8
  33. data/lib/recombee_api_client/api/list_item_cart_additions.rb +2 -8
  34. data/lib/recombee_api_client/api/list_item_detail_views.rb +2 -8
  35. data/lib/recombee_api_client/api/list_item_properties.rb +2 -8
  36. data/lib/recombee_api_client/api/list_item_purchases.rb +2 -8
  37. data/lib/recombee_api_client/api/list_item_ratings.rb +2 -8
  38. data/lib/recombee_api_client/api/list_items.rb +2 -12
  39. data/lib/recombee_api_client/api/list_series.rb +2 -8
  40. data/lib/recombee_api_client/api/list_series_items.rb +2 -8
  41. data/lib/recombee_api_client/api/list_user_bookmarks.rb +2 -8
  42. data/lib/recombee_api_client/api/list_user_cart_additions.rb +2 -8
  43. data/lib/recombee_api_client/api/list_user_detail_views.rb +2 -8
  44. data/lib/recombee_api_client/api/list_user_purchases.rb +2 -8
  45. data/lib/recombee_api_client/api/list_user_ratings.rb +2 -8
  46. data/lib/recombee_api_client/api/list_users.rb +2 -8
  47. data/lib/recombee_api_client/api/merge_users.rb +2 -12
  48. data/lib/recombee_api_client/api/remove_from_group.rb +2 -8
  49. data/lib/recombee_api_client/api/remove_from_series.rb +2 -8
  50. data/lib/recombee_api_client/api/reset_database.rb +3 -9
  51. data/lib/recombee_api_client/api/set_item_values.rb +6 -11
  52. data/lib/recombee_api_client/api/user_based_recommendation.rb +49 -47
  53. data/lib/recombee_api_client/version.rb +1 -1
  54. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 11704e7192a3cf0b6f8122a3049608247b5c274f
4
- data.tar.gz: 1841fd3587cde54649877aaf150f798649264072
3
+ metadata.gz: 83b584f1d11c806d77846c5619ca291e2bbaa498
4
+ data.tar.gz: 317bde2ed001ea6a00b10d045123098e27b268c4
5
5
  SHA512:
6
- metadata.gz: 5f61d16bcb1bd799376ba4e4c984ab806960bb14ccd3f7c2c22754bdcdcc4228107873a72a88c15a1f186be7f19e256a38041fe72392778be5a452e26589e97d
7
- data.tar.gz: 21109e33ba9b98f43a62b512c825420c4f1e1544f067b109a1195386785d488365229f94bcf618d271a0b3992dafe15e188c885e5389cd42c7f6653e9cf2ba81
6
+ metadata.gz: eb191d7f12f872936719dc11a7c6e37e8e4c925c424f53aef19975dd7931ee5a43d3a2265f3e2c62d78e523363d91ce1c44e7c5a8cbecea878e122c67cbb27e1
7
+ data.tar.gz: c1d90063fe718a27a0cf665c0bcaebaa9d1fa1066ef3b917fb1492329a2c63fb386d5f01b1e7c957f9ba6754a94b3fc0abea9c804278a20c144af2fd7ed8c6bd
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  A Ruby client for easy use of the [Recombee](https://www.recombee.com/) recommendation API.
4
4
 
5
+ If you don't have an account at Recombee yet, you can create a free account [here](https://www.recombee.com/).
6
+
5
7
  Documentation of the API can be found at [docs.recombee.com](https://docs.recombee.com/).
6
8
 
7
9
  ## Installation
@@ -96,10 +96,25 @@ module RecombeeApiClient
96
96
  def process_request_uri(request)
97
97
  uri = request.path
98
98
  uri.slice! ('/{databaseId}/')
99
+ uri += query_parameters_to_url(request)
99
100
  uri = URI.escape uri
100
101
  uri
101
102
  end
102
103
 
104
+ def query_parameters_to_url(req)
105
+ ps = ''
106
+ req.query_parameters.each do |name, val|
107
+ ps += (ps.include? '?') ? '&' : '?'
108
+ ps += "#{name}=#{format_query_parameter_value(val)}"
109
+ end
110
+ ps
111
+ end
112
+
113
+ def format_query_parameter_value(value)
114
+ return value unless value.kind_of?(Array)
115
+ value.join(',')
116
+ end
117
+
103
118
  # Sign request with HMAC, request URI must be exacly the same
104
119
  # We have 30s to complete request with this token
105
120
  def sign_url(req_part)
@@ -51,7 +51,7 @@ module RecombeeApiClient
51
51
  p
52
52
  end
53
53
 
54
- # Values of query path parameters as a Hash.
54
+ # Values of query parameters as a Hash.
55
55
  # name of parameter => value of the parameter
56
56
  def query_parameters
57
57
  params = {}
@@ -59,14 +59,8 @@ module RecombeeApiClient
59
59
  end
60
60
 
61
61
  # Relative path to the endpoint
62
- def basic_path
63
- "/{databaseId}/bookmarks/"
64
- end
65
-
66
- # Relative path to the endpoint including query parameters
67
62
  def path
68
- p = "/{databaseId}/bookmarks/"
69
- p
63
+ "/{databaseId}/bookmarks/"
70
64
  end
71
65
  end
72
66
  end
@@ -51,7 +51,7 @@ module RecombeeApiClient
51
51
  p
52
52
  end
53
53
 
54
- # Values of query path parameters as a Hash.
54
+ # Values of query parameters as a Hash.
55
55
  # name of parameter => value of the parameter
56
56
  def query_parameters
57
57
  params = {}
@@ -59,14 +59,8 @@ module RecombeeApiClient
59
59
  end
60
60
 
61
61
  # Relative path to the endpoint
62
- def basic_path
63
- "/{databaseId}/cartadditions/"
64
- end
65
-
66
- # Relative path to the endpoint including query parameters
67
62
  def path
68
- p = "/{databaseId}/cartadditions/"
69
- p
63
+ "/{databaseId}/cartadditions/"
70
64
  end
71
65
  end
72
66
  end
@@ -54,7 +54,7 @@ module RecombeeApiClient
54
54
  p
55
55
  end
56
56
 
57
- # Values of query path parameters as a Hash.
57
+ # Values of query parameters as a Hash.
58
58
  # name of parameter => value of the parameter
59
59
  def query_parameters
60
60
  params = {}
@@ -62,14 +62,8 @@ module RecombeeApiClient
62
62
  end
63
63
 
64
64
  # Relative path to the endpoint
65
- def basic_path
66
- "/{databaseId}/detailviews/"
67
- end
68
-
69
- # Relative path to the endpoint including query parameters
70
65
  def path
71
- p = "/{databaseId}/detailviews/"
72
- p
66
+ "/{databaseId}/detailviews/"
73
67
  end
74
68
  end
75
69
  end
@@ -34,7 +34,7 @@ module RecombeeApiClient
34
34
  p
35
35
  end
36
36
 
37
- # Values of query path parameters as a Hash.
37
+ # Values of query parameters as a Hash.
38
38
  # name of parameter => value of the parameter
39
39
  def query_parameters
40
40
  params = {}
@@ -42,14 +42,8 @@ module RecombeeApiClient
42
42
  end
43
43
 
44
44
  # Relative path to the endpoint
45
- def basic_path
46
- "/{databaseId}/groups/#{@group_id}"
47
- end
48
-
49
- # Relative path to the endpoint including query parameters
50
45
  def path
51
- p = "/{databaseId}/groups/#{@group_id}"
52
- p
46
+ "/{databaseId}/groups/#{@group_id}"
53
47
  end
54
48
  end
55
49
  end
@@ -37,7 +37,7 @@ module RecombeeApiClient
37
37
  p
38
38
  end
39
39
 
40
- # Values of query path parameters as a Hash.
40
+ # Values of query parameters as a Hash.
41
41
  # name of parameter => value of the parameter
42
42
  def query_parameters
43
43
  params = {}
@@ -45,14 +45,8 @@ module RecombeeApiClient
45
45
  end
46
46
 
47
47
  # Relative path to the endpoint
48
- def basic_path
49
- "/{databaseId}/items/#{@item_id}"
50
- end
51
-
52
- # Relative path to the endpoint including query parameters
53
48
  def path
54
- p = "/{databaseId}/items/#{@item_id}"
55
- p
49
+ "/{databaseId}/items/#{@item_id}"
56
50
  end
57
51
  end
58
52
  end
@@ -39,7 +39,7 @@ module RecombeeApiClient
39
39
  p
40
40
  end
41
41
 
42
- # Values of query path parameters as a Hash.
42
+ # Values of query parameters as a Hash.
43
43
  # name of parameter => value of the parameter
44
44
  def query_parameters
45
45
  params = {}
@@ -48,14 +48,8 @@ module RecombeeApiClient
48
48
  end
49
49
 
50
50
  # Relative path to the endpoint
51
- def basic_path
52
- "/{databaseId}/items/properties/#{@property_name}"
53
- end
54
-
55
- # Relative path to the endpoint including query parameters
56
51
  def path
57
- p = "/{databaseId}/items/properties/#{@property_name}?type=#{@type}"
58
- p
52
+ "/{databaseId}/items/properties/#{@property_name}"
59
53
  end
60
54
  end
61
55
  end
@@ -51,7 +51,7 @@ module RecombeeApiClient
51
51
  p
52
52
  end
53
53
 
54
- # Values of query path parameters as a Hash.
54
+ # Values of query parameters as a Hash.
55
55
  # name of parameter => value of the parameter
56
56
  def query_parameters
57
57
  params = {}
@@ -59,14 +59,8 @@ module RecombeeApiClient
59
59
  end
60
60
 
61
61
  # Relative path to the endpoint
62
- def basic_path
63
- "/{databaseId}/purchases/"
64
- end
65
-
66
- # Relative path to the endpoint including query parameters
67
62
  def path
68
- p = "/{databaseId}/purchases/"
69
- p
63
+ "/{databaseId}/purchases/"
70
64
  end
71
65
  end
72
66
  end
@@ -54,7 +54,7 @@ module RecombeeApiClient
54
54
  p
55
55
  end
56
56
 
57
- # Values of query path parameters as a Hash.
57
+ # Values of query parameters as a Hash.
58
58
  # name of parameter => value of the parameter
59
59
  def query_parameters
60
60
  params = {}
@@ -62,14 +62,8 @@ module RecombeeApiClient
62
62
  end
63
63
 
64
64
  # Relative path to the endpoint
65
- def basic_path
66
- "/{databaseId}/ratings/"
67
- end
68
-
69
- # Relative path to the endpoint including query parameters
70
65
  def path
71
- p = "/{databaseId}/ratings/"
72
- p
66
+ "/{databaseId}/ratings/"
73
67
  end
74
68
  end
75
69
  end
@@ -34,7 +34,7 @@ module RecombeeApiClient
34
34
  p
35
35
  end
36
36
 
37
- # Values of query path parameters as a Hash.
37
+ # Values of query parameters as a Hash.
38
38
  # name of parameter => value of the parameter
39
39
  def query_parameters
40
40
  params = {}
@@ -42,14 +42,8 @@ module RecombeeApiClient
42
42
  end
43
43
 
44
44
  # Relative path to the endpoint
45
- def basic_path
46
- "/{databaseId}/series/#{@series_id}"
47
- end
48
-
49
- # Relative path to the endpoint including query parameters
50
45
  def path
51
- p = "/{databaseId}/series/#{@series_id}"
52
- p
46
+ "/{databaseId}/series/#{@series_id}"
53
47
  end
54
48
  end
55
49
  end
@@ -35,7 +35,7 @@ module RecombeeApiClient
35
35
  p
36
36
  end
37
37
 
38
- # Values of query path parameters as a Hash.
38
+ # Values of query parameters as a Hash.
39
39
  # name of parameter => value of the parameter
40
40
  def query_parameters
41
41
  params = {}
@@ -43,14 +43,8 @@ module RecombeeApiClient
43
43
  end
44
44
 
45
45
  # Relative path to the endpoint
46
- def basic_path
47
- "/{databaseId}/users/#{@user_id}"
48
- end
49
-
50
- # Relative path to the endpoint including query parameters
51
46
  def path
52
- p = "/{databaseId}/users/#{@user_id}"
53
- p
47
+ "/{databaseId}/users/#{@user_id}"
54
48
  end
55
49
  end
56
50
  end
@@ -29,9 +29,11 @@ module RecombeeApiClient
29
29
  # Values of body parameters as a Hash
30
30
  attr_reader :body_parameters
31
31
 
32
- # Get values of parameters in form a Hash.
32
+ # Values of query path parameters as a Hash.
33
33
  # name of parameter => value of the parameter
34
- def params_hash
34
+ def query_parameters
35
+ params = {}
36
+ params
35
37
  end
36
38
 
37
39
  # Relative path to the endpoint
@@ -49,7 +51,7 @@ module RecombeeApiClient
49
51
  end
50
52
 
51
53
  def request_to_batch_hash(req)
52
- path = req.basic_path
54
+ path = req.path
53
55
  path.slice! ('/{databaseId}')
54
56
  bh = {
55
57
  'method' => req.method.to_s.upcase,
@@ -7,7 +7,7 @@ module RecombeeApiClient
7
7
  require_relative '../errors'
8
8
 
9
9
  ##
10
- #Deletes a bookmark uniquely specified by `userId`, `itemId`, and `timestamp`.
10
+ #Deletes a bookmark uniquely specified by `userId`, `itemId`, and `timestamp` or all the bookmarks with given `userId` and `itemId` if `timestamp` is omitted.
11
11
  #
12
12
  class DeleteBookmark < ApiRequest
13
13
  attr_reader :user_id, :item_id, :timestamp
@@ -45,7 +45,7 @@ module RecombeeApiClient
45
45
  p
46
46
  end
47
47
 
48
- # Values of query path parameters as a Hash.
48
+ # Values of query parameters as a Hash.
49
49
  # name of parameter => value of the parameter
50
50
  def query_parameters
51
51
  params = {}
@@ -56,18 +56,8 @@ module RecombeeApiClient
56
56
  end
57
57
 
58
58
  # Relative path to the endpoint
59
- def basic_path
60
- "/{databaseId}/bookmarks/"
61
- end
62
-
63
- # Relative path to the endpoint including query parameters
64
59
  def path
65
- p = "/{databaseId}/bookmarks/?userId=#{@user_id}&itemId=#{@item_id}"
66
- if @optional.include? 'timestamp'
67
- p += (p.include? '?') ? '&' : '?'
68
- p += "timestamp=#{@optional['timestamp']}"
69
- end
70
- p
60
+ "/{databaseId}/bookmarks/"
71
61
  end
72
62
  end
73
63
  end
@@ -7,7 +7,7 @@ module RecombeeApiClient
7
7
  require_relative '../errors'
8
8
 
9
9
  ##
10
- #Deletes an existing cart addition uniquely specified by `userId`, `itemId`, and `timestamp`.
10
+ #Deletes an existing cart addition uniquely specified by `userId`, `itemId`, and `timestamp` or all the cart additions with given `userId` and `itemId` if `timestamp` is omitted.
11
11
  #
12
12
  class DeleteCartAddition < ApiRequest
13
13
  attr_reader :user_id, :item_id, :timestamp
@@ -45,7 +45,7 @@ module RecombeeApiClient
45
45
  p
46
46
  end
47
47
 
48
- # Values of query path parameters as a Hash.
48
+ # Values of query parameters as a Hash.
49
49
  # name of parameter => value of the parameter
50
50
  def query_parameters
51
51
  params = {}
@@ -56,18 +56,8 @@ module RecombeeApiClient
56
56
  end
57
57
 
58
58
  # Relative path to the endpoint
59
- def basic_path
60
- "/{databaseId}/cartadditions/"
61
- end
62
-
63
- # Relative path to the endpoint including query parameters
64
59
  def path
65
- p = "/{databaseId}/cartadditions/?userId=#{@user_id}&itemId=#{@item_id}"
66
- if @optional.include? 'timestamp'
67
- p += (p.include? '?') ? '&' : '?'
68
- p += "timestamp=#{@optional['timestamp']}"
69
- end
70
- p
60
+ "/{databaseId}/cartadditions/"
71
61
  end
72
62
  end
73
63
  end
@@ -7,7 +7,7 @@ module RecombeeApiClient
7
7
  require_relative '../errors'
8
8
 
9
9
  ##
10
- #Deletes an existing detail view uniquely specified by (`userId`, `itemId`, and `timestamp`).
10
+ #Deletes an existing detail view uniquely specified by (`userId`, `itemId`, and `timestamp`) or all the detail views with given `userId` and `itemId` if `timestamp` is omitted.
11
11
  #
12
12
  class DeleteDetailView < ApiRequest
13
13
  attr_reader :user_id, :item_id, :timestamp
@@ -45,7 +45,7 @@ module RecombeeApiClient
45
45
  p
46
46
  end
47
47
 
48
- # Values of query path parameters as a Hash.
48
+ # Values of query parameters as a Hash.
49
49
  # name of parameter => value of the parameter
50
50
  def query_parameters
51
51
  params = {}
@@ -56,18 +56,8 @@ module RecombeeApiClient
56
56
  end
57
57
 
58
58
  # Relative path to the endpoint
59
- def basic_path
60
- "/{databaseId}/detailviews/"
61
- end
62
-
63
- # Relative path to the endpoint including query parameters
64
59
  def path
65
- p = "/{databaseId}/detailviews/?userId=#{@user_id}&itemId=#{@item_id}"
66
- if @optional.include? 'timestamp'
67
- p += (p.include? '?') ? '&' : '?'
68
- p += "timestamp=#{@optional['timestamp']}"
69
- end
70
- p
60
+ "/{databaseId}/detailviews/"
71
61
  end
72
62
  end
73
63
  end
@@ -37,7 +37,7 @@ module RecombeeApiClient
37
37
  p
38
38
  end
39
39
 
40
- # Values of query path parameters as a Hash.
40
+ # Values of query parameters as a Hash.
41
41
  # name of parameter => value of the parameter
42
42
  def query_parameters
43
43
  params = {}
@@ -45,14 +45,8 @@ module RecombeeApiClient
45
45
  end
46
46
 
47
47
  # Relative path to the endpoint
48
- def basic_path
49
- "/{databaseId}/groups/#{@group_id}"
50
- end
51
-
52
- # Relative path to the endpoint including query parameters
53
48
  def path
54
- p = "/{databaseId}/groups/#{@group_id}"
55
- p
49
+ "/{databaseId}/groups/#{@group_id}"
56
50
  end
57
51
  end
58
52
  end