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.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/lib/recombee_api_client/api/add_bookmark.rb +26 -26
  3. data/lib/recombee_api_client/api/add_cart_addition.rb +28 -28
  4. data/lib/recombee_api_client/api/add_detail_view.rb +32 -28
  5. data/lib/recombee_api_client/api/add_item.rb +15 -18
  6. data/lib/recombee_api_client/api/add_item_property.rb +34 -35
  7. data/lib/recombee_api_client/api/add_manual_reql_segment.rb +26 -27
  8. data/lib/recombee_api_client/api/add_purchase.rb +29 -29
  9. data/lib/recombee_api_client/api/add_rating.rb +27 -27
  10. data/lib/recombee_api_client/api/add_search_synonym.rb +29 -30
  11. data/lib/recombee_api_client/api/add_series.rb +20 -21
  12. data/lib/recombee_api_client/api/add_user.rb +14 -17
  13. data/lib/recombee_api_client/api/add_user_property.rb +30 -31
  14. data/lib/recombee_api_client/api/batch.rb +12 -16
  15. data/lib/recombee_api_client/api/composite_recommendation.rb +132 -0
  16. data/lib/recombee_api_client/api/create_auto_reql_segmentation.rb +29 -30
  17. data/lib/recombee_api_client/api/create_manual_reql_segmentation.rb +27 -28
  18. data/lib/recombee_api_client/api/create_property_based_segmentation.rb +30 -31
  19. data/lib/recombee_api_client/api/delete_all_search_synonyms.rb +15 -19
  20. data/lib/recombee_api_client/api/delete_bookmark.rb +21 -22
  21. data/lib/recombee_api_client/api/delete_cart_addition.rb +21 -22
  22. data/lib/recombee_api_client/api/delete_detail_view.rb +21 -22
  23. data/lib/recombee_api_client/api/delete_item.rb +16 -19
  24. data/lib/recombee_api_client/api/delete_item_property.rb +15 -18
  25. data/lib/recombee_api_client/api/delete_manual_reql_segment.rb +16 -19
  26. data/lib/recombee_api_client/api/delete_more_items.rb +18 -19
  27. data/lib/recombee_api_client/api/delete_purchase.rb +21 -22
  28. data/lib/recombee_api_client/api/delete_rating.rb +21 -22
  29. data/lib/recombee_api_client/api/delete_search_synonym.rb +15 -18
  30. data/lib/recombee_api_client/api/delete_segmentation.rb +15 -18
  31. data/lib/recombee_api_client/api/delete_series.rb +21 -22
  32. data/lib/recombee_api_client/api/delete_user.rb +15 -18
  33. data/lib/recombee_api_client/api/delete_user_property.rb +15 -18
  34. data/lib/recombee_api_client/api/delete_view_portion.rb +21 -22
  35. data/lib/recombee_api_client/api/get_item_property_info.rb +14 -17
  36. data/lib/recombee_api_client/api/get_item_values.rb +15 -18
  37. data/lib/recombee_api_client/api/get_segmentation.rb +15 -18
  38. data/lib/recombee_api_client/api/get_user_property_info.rb +15 -18
  39. data/lib/recombee_api_client/api/get_user_values.rb +15 -18
  40. data/lib/recombee_api_client/api/insert_to_series.rb +23 -24
  41. data/lib/recombee_api_client/api/list_item_bookmarks.rb +16 -19
  42. data/lib/recombee_api_client/api/list_item_cart_additions.rb +16 -19
  43. data/lib/recombee_api_client/api/list_item_detail_views.rb +16 -19
  44. data/lib/recombee_api_client/api/list_item_properties.rb +15 -19
  45. data/lib/recombee_api_client/api/list_item_purchases.rb +16 -19
  46. data/lib/recombee_api_client/api/list_item_ratings.rb +16 -19
  47. data/lib/recombee_api_client/api/list_item_view_portions.rb +16 -19
  48. data/lib/recombee_api_client/api/list_items.rb +62 -62
  49. data/lib/recombee_api_client/api/list_scenarios.rb +15 -19
  50. data/lib/recombee_api_client/api/list_search_synonyms.rb +20 -21
  51. data/lib/recombee_api_client/api/list_segmentations.rb +16 -17
  52. data/lib/recombee_api_client/api/list_series.rb +15 -19
  53. data/lib/recombee_api_client/api/list_series_items.rb +15 -18
  54. data/lib/recombee_api_client/api/list_user_bookmarks.rb +15 -18
  55. data/lib/recombee_api_client/api/list_user_cart_additions.rb +15 -18
  56. data/lib/recombee_api_client/api/list_user_detail_views.rb +15 -18
  57. data/lib/recombee_api_client/api/list_user_properties.rb +15 -19
  58. data/lib/recombee_api_client/api/list_user_purchases.rb +15 -18
  59. data/lib/recombee_api_client/api/list_user_ratings.rb +15 -18
  60. data/lib/recombee_api_client/api/list_user_view_portions.rb +15 -18
  61. data/lib/recombee_api_client/api/list_users.rb +56 -56
  62. data/lib/recombee_api_client/api/merge_users.rb +24 -25
  63. data/lib/recombee_api_client/api/recommend_item_segments_to_item.rb +69 -68
  64. data/lib/recombee_api_client/api/recommend_item_segments_to_item_segment.rb +70 -69
  65. data/lib/recombee_api_client/api/recommend_item_segments_to_user.rb +51 -50
  66. data/lib/recombee_api_client/api/recommend_items_to_item.rb +185 -139
  67. data/lib/recombee_api_client/api/recommend_items_to_item_segment.rb +181 -138
  68. data/lib/recombee_api_client/api/recommend_items_to_user.rb +165 -122
  69. data/lib/recombee_api_client/api/recommend_next_items.rb +24 -25
  70. data/lib/recombee_api_client/api/recommend_users_to_item.rb +151 -105
  71. data/lib/recombee_api_client/api/recommend_users_to_user.rb +154 -111
  72. data/lib/recombee_api_client/api/remove_from_series.rb +17 -18
  73. data/lib/recombee_api_client/api/request.rb +1 -1
  74. data/lib/recombee_api_client/api/reset_database.rb +15 -19
  75. data/lib/recombee_api_client/api/search_item_segments.rb +52 -51
  76. data/lib/recombee_api_client/api/search_items.rb +157 -114
  77. data/lib/recombee_api_client/api/set_item_values.rb +28 -29
  78. data/lib/recombee_api_client/api/set_user_values.rb +21 -22
  79. data/lib/recombee_api_client/api/set_values.rb +28 -28
  80. data/lib/recombee_api_client/api/set_view_portion.rb +37 -30
  81. data/lib/recombee_api_client/api/update_auto_reql_segmentation.rb +26 -27
  82. data/lib/recombee_api_client/api/update_manual_reql_segment.rb +25 -26
  83. data/lib/recombee_api_client/api/update_manual_reql_segmentation.rb +24 -25
  84. data/lib/recombee_api_client/api/update_more_items.rb +19 -20
  85. data/lib/recombee_api_client/api/update_property_based_segmentation.rb +26 -27
  86. data/lib/recombee_api_client/errors.rb +2 -5
  87. data/lib/recombee_api_client/inputs/composite_recommendation_stage_parameters.rb +240 -0
  88. data/lib/recombee_api_client/inputs/input.rb +9 -0
  89. data/lib/recombee_api_client/inputs/logic.rb +45 -0
  90. data/lib/recombee_api_client/utils/hash_normalizer.rb +21 -0
  91. data/lib/recombee_api_client/version.rb +1 -1
  92. data/lib/recombee_api_client.rb +40 -35
  93. data/recombee_api_client.gemspec +2 -3
  94. metadata +14 -10
  95. data/lib/recombee_api_client/api/hash_normalizer.rb +0 -21
@@ -5,55 +5,54 @@
5
5
  module RecombeeApiClient
6
6
  require_relative 'request'
7
7
  require_relative '../errors'
8
-
8
+
9
9
  ##
10
- #Deletes the series of the given `seriesId` from the database.
10
+ # Deletes the series of the given `seriesId` from the database.
11
11
  #
12
- #Deleting a series will only delete assignment of items to it, not the items themselves!
12
+ # Deleting a series will only delete assignment of items to it, not the items themselves!
13
13
  #
14
14
  class DeleteSeries < ApiRequest
15
15
  attr_reader :series_id, :cascade_delete
16
- attr_accessor :timeout
17
- attr_accessor :ensure_https
18
-
19
- ##
20
- # * *Required arguments*
21
- # - +series_id+ -> ID of the series to be deleted.
22
- #
23
- # * *Optional arguments (given as hash optional)*
24
- # - +cascadeDelete+ -> If set to `true`, item with the same ID as seriesId will be also deleted. Default is `false`.
25
- #
16
+ attr_accessor :timeout, :ensure_https
17
+
18
+ ##
19
+ # * *Required arguments*
20
+ # - +series_id+ -> ID of the series to be deleted.
21
+ #
22
+ # * *Optional arguments (given as hash optional)*
23
+ # - +cascadeDelete+ -> If set to `true`, item with the same ID as seriesId will be also deleted. Default is `false`.
24
+ #
26
25
  def initialize(series_id, optional = {})
27
26
  @series_id = series_id
28
- optional = normalize_optional(optional)
27
+ optional = normalize_hash_to_camel_case(optional)
29
28
  @cascade_delete = optional['cascadeDelete']
30
29
  @optional = optional
31
30
  @timeout = 3000
32
31
  @ensure_https = false
33
32
  @optional.each do |par, _|
34
- fail UnknownOptionalParameter.new(par) unless ["cascadeDelete"].include? par
33
+ raise UnknownOptionalParameter.new(par) unless ['cascadeDelete'].include? par
35
34
  end
36
35
  end
37
-
36
+
38
37
  # HTTP method
39
38
  def method
40
39
  :delete
41
40
  end
42
-
41
+
43
42
  # Values of body parameters as a Hash
44
43
  def body_parameters
45
- p = Hash.new
44
+ p = {}
46
45
  p['cascadeDelete'] = @optional['cascadeDelete'] if @optional.include? 'cascadeDelete'
46
+
47
47
  p
48
48
  end
49
-
49
+
50
50
  # Values of query parameters as a Hash.
51
51
  # name of parameter => value of the parameter
52
52
  def query_parameters
53
- params = {}
54
- params
53
+ {}
55
54
  end
56
-
55
+
57
56
  # Relative path to the endpoint
58
57
  def path
59
58
  "/{databaseId}/series/#{@series_id}"
@@ -5,45 +5,42 @@
5
5
  module RecombeeApiClient
6
6
  require_relative 'request'
7
7
  require_relative '../errors'
8
-
8
+
9
9
  ##
10
- #Deletes a user of the given *userId* from the database.
10
+ # Deletes a user of the given *userId* from the database.
11
11
  #
12
- #If there are any purchases, ratings, bookmarks, cart additions or detail views made by the user present in the database, they will be deleted in cascade as well.
12
+ # If there are any purchases, ratings, bookmarks, cart additions or detail views made by the user present in the database, they will be deleted in cascade as well.
13
13
  #
14
14
  class DeleteUser < ApiRequest
15
15
  attr_reader :user_id
16
- attr_accessor :timeout
17
- attr_accessor :ensure_https
18
-
19
- ##
20
- # * *Required arguments*
21
- # - +user_id+ -> ID of the user to be deleted.
22
- #
16
+ attr_accessor :timeout, :ensure_https
17
+
18
+ ##
19
+ # * *Required arguments*
20
+ # - +user_id+ -> ID of the user to be deleted.
21
+ #
23
22
  def initialize(user_id)
24
23
  @user_id = user_id
25
24
  @timeout = 3000
26
25
  @ensure_https = false
27
26
  end
28
-
27
+
29
28
  # HTTP method
30
29
  def method
31
30
  :delete
32
31
  end
33
-
32
+
34
33
  # Values of body parameters as a Hash
35
34
  def body_parameters
36
- p = Hash.new
37
- p
35
+ {}
38
36
  end
39
-
37
+
40
38
  # Values of query parameters as a Hash.
41
39
  # name of parameter => value of the parameter
42
40
  def query_parameters
43
- params = {}
44
- params
41
+ {}
45
42
  end
46
-
43
+
47
44
  # Relative path to the endpoint
48
45
  def path
49
46
  "/{databaseId}/users/#{@user_id}"
@@ -5,43 +5,40 @@
5
5
  module RecombeeApiClient
6
6
  require_relative 'request'
7
7
  require_relative '../errors'
8
-
8
+
9
9
  ##
10
- #Deleting a user property is roughly equivalent to removing a column from the table of users.
10
+ # Deleting a user property is roughly equivalent to removing a column from the table of users.
11
11
  #
12
12
  class DeleteUserProperty < ApiRequest
13
13
  attr_reader :property_name
14
- attr_accessor :timeout
15
- attr_accessor :ensure_https
16
-
17
- ##
18
- # * *Required arguments*
19
- # - +property_name+ -> Name of the property to be deleted.
20
- #
14
+ attr_accessor :timeout, :ensure_https
15
+
16
+ ##
17
+ # * *Required arguments*
18
+ # - +property_name+ -> Name of the property to be deleted.
19
+ #
21
20
  def initialize(property_name)
22
21
  @property_name = property_name
23
- @timeout = 100000
22
+ @timeout = 100_000
24
23
  @ensure_https = false
25
24
  end
26
-
25
+
27
26
  # HTTP method
28
27
  def method
29
28
  :delete
30
29
  end
31
-
30
+
32
31
  # Values of body parameters as a Hash
33
32
  def body_parameters
34
- p = Hash.new
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
- params = {}
42
- params
39
+ {}
43
40
  end
44
-
41
+
45
42
  # Relative path to the endpoint
46
43
  def path
47
44
  "/{databaseId}/users/properties/#{@property_name}"
@@ -5,47 +5,45 @@
5
5
  module RecombeeApiClient
6
6
  require_relative 'request'
7
7
  require_relative '../errors'
8
-
8
+
9
9
  ##
10
- #Deletes an existing view portion specified by (`userId`, `itemId`, `sessionId`) from the database.
10
+ # Deletes an existing view portion specified by (`userId`, `itemId`, `sessionId`) from the database.
11
11
  #
12
12
  class DeleteViewPortion < ApiRequest
13
13
  attr_reader :user_id, :item_id, :session_id
14
- attr_accessor :timeout
15
- attr_accessor :ensure_https
16
-
17
- ##
18
- # * *Required arguments*
19
- # - +user_id+ -> ID of the user who rated the item.
20
- # - +item_id+ -> ID of the item which was rated.
21
- #
22
- # * *Optional arguments (given as hash optional)*
23
- # - +sessionId+ -> Identifier of a session.
24
- #
14
+ attr_accessor :timeout, :ensure_https
15
+
16
+ ##
17
+ # * *Required arguments*
18
+ # - +user_id+ -> ID of the user who rated the item.
19
+ # - +item_id+ -> ID of the item which was rated.
20
+ #
21
+ # * *Optional arguments (given as hash optional)*
22
+ # - +sessionId+ -> Identifier of a session.
23
+ #
25
24
  def initialize(user_id, item_id, optional = {})
26
25
  @user_id = user_id
27
26
  @item_id = item_id
28
- optional = normalize_optional(optional)
27
+ optional = normalize_hash_to_camel_case(optional)
29
28
  @session_id = optional['sessionId']
30
29
  @optional = optional
31
30
  @timeout = 3000
32
31
  @ensure_https = false
33
32
  @optional.each do |par, _|
34
- fail UnknownOptionalParameter.new(par) unless ["sessionId"].include? par
33
+ raise UnknownOptionalParameter.new(par) unless ['sessionId'].include? par
35
34
  end
36
35
  end
37
-
36
+
38
37
  # HTTP method
39
38
  def method
40
39
  :delete
41
40
  end
42
-
41
+
43
42
  # Values of body parameters as a Hash
44
43
  def body_parameters
45
- p = Hash.new
46
- p
44
+ {}
47
45
  end
48
-
46
+
49
47
  # Values of query parameters as a Hash.
50
48
  # name of parameter => value of the parameter
51
49
  def query_parameters
@@ -53,12 +51,13 @@ module RecombeeApiClient
53
51
  params['userId'] = @user_id
54
52
  params['itemId'] = @item_id
55
53
  params['sessionId'] = @optional['sessionId'] if @optional['sessionId']
54
+
56
55
  params
57
56
  end
58
-
57
+
59
58
  # Relative path to the endpoint
60
59
  def path
61
- "/{databaseId}/viewportions/"
60
+ '/{databaseId}/viewportions/'
62
61
  end
63
62
  end
64
63
  end
@@ -5,43 +5,40 @@
5
5
  module RecombeeApiClient
6
6
  require_relative 'request'
7
7
  require_relative '../errors'
8
-
8
+
9
9
  ##
10
- #Gets information about specified item property.
10
+ # Gets information about specified item property.
11
11
  #
12
12
  class GetItemPropertyInfo < ApiRequest
13
13
  attr_reader :property_name
14
- attr_accessor :timeout
15
- attr_accessor :ensure_https
16
-
17
- ##
18
- # * *Required arguments*
19
- # - +property_name+ -> Name of the property about which the information is to be retrieved.
20
- #
14
+ attr_accessor :timeout, :ensure_https
15
+
16
+ ##
17
+ # * *Required arguments*
18
+ # - +property_name+ -> Name of the property about which the information is to be retrieved.
19
+ #
21
20
  def initialize(property_name)
22
21
  @property_name = property_name
23
22
  @timeout = 3000
24
23
  @ensure_https = false
25
24
  end
26
-
25
+
27
26
  # HTTP method
28
27
  def method
29
28
  :get
30
29
  end
31
-
30
+
32
31
  # Values of body parameters as a Hash
33
32
  def body_parameters
34
- p = Hash.new
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
- params = {}
42
- params
39
+ {}
43
40
  end
44
-
41
+
45
42
  # Relative path to the endpoint
46
43
  def path
47
44
  "/{databaseId}/items/properties/#{@property_name}"
@@ -5,44 +5,41 @@
5
5
  module RecombeeApiClient
6
6
  require_relative 'request'
7
7
  require_relative '../errors'
8
-
8
+
9
9
  ##
10
- #Gets all the current property values of the given item.
10
+ # Gets all the current property values of the given item.
11
11
  #
12
12
  class GetItemValues < ApiRequest
13
13
  attr_reader :item_id
14
- attr_accessor :timeout
15
- attr_accessor :ensure_https
16
-
17
- ##
18
- # * *Required arguments*
19
- # - +item_id+ -> ID of the item whose properties are to be obtained.
20
- #
21
- #
14
+ attr_accessor :timeout, :ensure_https
15
+
16
+ ##
17
+ # * *Required arguments*
18
+ # - +item_id+ -> ID of the item whose properties are to be obtained.
19
+ #
20
+ #
22
21
  def initialize(item_id)
23
22
  @item_id = item_id
24
23
  @timeout = 3000
25
24
  @ensure_https = false
26
25
  end
27
-
26
+
28
27
  # HTTP method
29
28
  def method
30
29
  :get
31
30
  end
32
-
31
+
33
32
  # Values of body parameters as a Hash
34
33
  def body_parameters
35
- p = Hash.new
36
- p
34
+ {}
37
35
  end
38
-
36
+
39
37
  # Values of query parameters as a Hash.
40
38
  # name of parameter => value of the parameter
41
39
  def query_parameters
42
- params = {}
43
- params
40
+ {}
44
41
  end
45
-
42
+
46
43
  # Relative path to the endpoint
47
44
  def path
48
45
  "/{databaseId}/items/#{@item_id}"
@@ -5,43 +5,40 @@
5
5
  module RecombeeApiClient
6
6
  require_relative 'request'
7
7
  require_relative '../errors'
8
-
8
+
9
9
  ##
10
- #Get existing Segmentation.
10
+ # Get existing Segmentation.
11
11
  #
12
12
  class GetSegmentation < ApiRequest
13
13
  attr_reader :segmentation_id
14
- attr_accessor :timeout
15
- attr_accessor :ensure_https
16
-
17
- ##
18
- # * *Required arguments*
19
- # - +segmentation_id+ -> ID of the Segmentation that should be returned
20
- #
14
+ attr_accessor :timeout, :ensure_https
15
+
16
+ ##
17
+ # * *Required arguments*
18
+ # - +segmentation_id+ -> ID of the Segmentation that should be returned
19
+ #
21
20
  def initialize(segmentation_id)
22
21
  @segmentation_id = segmentation_id
23
- @timeout = 10000
22
+ @timeout = 10_000
24
23
  @ensure_https = false
25
24
  end
26
-
25
+
27
26
  # HTTP method
28
27
  def method
29
28
  :get
30
29
  end
31
-
30
+
32
31
  # Values of body parameters as a Hash
33
32
  def body_parameters
34
- p = Hash.new
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
- params = {}
42
- params
39
+ {}
43
40
  end
44
-
41
+
45
42
  # Relative path to the endpoint
46
43
  def path
47
44
  "/{databaseId}/segmentations/list/#{@segmentation_id}"
@@ -5,43 +5,40 @@
5
5
  module RecombeeApiClient
6
6
  require_relative 'request'
7
7
  require_relative '../errors'
8
-
8
+
9
9
  ##
10
- #Gets information about specified user property.
10
+ # Gets information about specified user property.
11
11
  #
12
12
  class GetUserPropertyInfo < ApiRequest
13
13
  attr_reader :property_name
14
- attr_accessor :timeout
15
- attr_accessor :ensure_https
16
-
17
- ##
18
- # * *Required arguments*
19
- # - +property_name+ -> Name of the property about which the information is to be retrieved.
20
- #
14
+ attr_accessor :timeout, :ensure_https
15
+
16
+ ##
17
+ # * *Required arguments*
18
+ # - +property_name+ -> Name of the property about which the information is to be retrieved.
19
+ #
21
20
  def initialize(property_name)
22
21
  @property_name = property_name
23
- @timeout = 100000
22
+ @timeout = 100_000
24
23
  @ensure_https = false
25
24
  end
26
-
25
+
27
26
  # HTTP method
28
27
  def method
29
28
  :get
30
29
  end
31
-
30
+
32
31
  # Values of body parameters as a Hash
33
32
  def body_parameters
34
- p = Hash.new
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
- params = {}
42
- params
39
+ {}
43
40
  end
44
-
41
+
45
42
  # Relative path to the endpoint
46
43
  def path
47
44
  "/{databaseId}/users/properties/#{@property_name}"
@@ -5,44 +5,41 @@
5
5
  module RecombeeApiClient
6
6
  require_relative 'request'
7
7
  require_relative '../errors'
8
-
8
+
9
9
  ##
10
- #Gets all the current property values of the given user.
10
+ # Gets all the current property values of the given user.
11
11
  #
12
12
  class GetUserValues < ApiRequest
13
13
  attr_reader :user_id
14
- attr_accessor :timeout
15
- attr_accessor :ensure_https
16
-
17
- ##
18
- # * *Required arguments*
19
- # - +user_id+ -> ID of the user whose properties are to be obtained.
20
- #
21
- #
14
+ attr_accessor :timeout, :ensure_https
15
+
16
+ ##
17
+ # * *Required arguments*
18
+ # - +user_id+ -> ID of the user whose properties are to be obtained.
19
+ #
20
+ #
22
21
  def initialize(user_id)
23
22
  @user_id = user_id
24
23
  @timeout = 3000
25
24
  @ensure_https = false
26
25
  end
27
-
26
+
28
27
  # HTTP method
29
28
  def method
30
29
  :get
31
30
  end
32
-
31
+
33
32
  # Values of body parameters as a Hash
34
33
  def body_parameters
35
- p = Hash.new
36
- p
34
+ {}
37
35
  end
38
-
36
+
39
37
  # Values of query parameters as a Hash.
40
38
  # name of parameter => value of the parameter
41
39
  def query_parameters
42
- params = {}
43
- params
40
+ {}
44
41
  end
45
-
42
+
46
43
  # Relative path to the endpoint
47
44
  def path
48
45
  "/{databaseId}/users/#{@user_id}"
@@ -5,62 +5,61 @@
5
5
  module RecombeeApiClient
6
6
  require_relative 'request'
7
7
  require_relative '../errors'
8
-
8
+
9
9
  ##
10
- #Inserts an existing item/series into a series of the given seriesId at a position determined by time.
10
+ # Inserts an existing item/series into a series of the given seriesId at a position determined by time.
11
11
  #
12
12
  class InsertToSeries < ApiRequest
13
13
  attr_reader :series_id, :item_type, :item_id, :time, :cascade_create
14
- attr_accessor :timeout
15
- attr_accessor :ensure_https
16
-
17
- ##
18
- # * *Required arguments*
19
- # - +series_id+ -> ID of the series to be inserted into.
20
- # - +item_type+ -> `item` iff the regular item from the catalog is to be inserted, `series` iff series is inserted as the item.
21
- # - +item_id+ -> ID of the item iff `itemType` is `item`. ID of the series iff `itemType` is `series`.
22
- # - +time+ -> Time index used for sorting items in the series. According to time, items are sorted within series in ascending order. In the example of TV show episodes, the episode number is a natural choice to be passed as time.
23
- #
24
- # * *Optional arguments (given as hash optional)*
25
- # - +cascadeCreate+ -> Indicates that any non-existing entity specified within the request should be created (as if corresponding PUT requests were invoked). This concerns both the `seriesId` and the `itemId`. If `cascadeCreate` is set to true, the behavior also depends on the `itemType`. In case of `item`, an item is created, in case of `series` a series + corresponding item with the same ID is created.
26
- #
14
+ attr_accessor :timeout, :ensure_https
15
+
16
+ ##
17
+ # * *Required arguments*
18
+ # - +series_id+ -> ID of the series to be inserted into.
19
+ # - +item_type+ -> `item` iff the regular item from the catalog is to be inserted, `series` iff series is inserted as the item.
20
+ # - +item_id+ -> ID of the item iff `itemType` is `item`. ID of the series iff `itemType` is `series`.
21
+ # - +time+ -> Time index used for sorting items in the series. According to time, items are sorted within series in ascending order. In the example of TV show episodes, the episode number is a natural choice to be passed as time.
22
+ #
23
+ # * *Optional arguments (given as hash optional)*
24
+ # - +cascadeCreate+ -> Indicates that any non-existing entity specified within the request should be created (as if corresponding PUT requests were invoked). This concerns both the `seriesId` and the `itemId`. If `cascadeCreate` is set to true, the behavior also depends on the `itemType`. In case of `item`, an item is created, in case of `series` a series + corresponding item with the same ID is created.
25
+ #
27
26
  def initialize(series_id, item_type, item_id, time, optional = {})
28
27
  @series_id = series_id
29
28
  @item_type = item_type
30
29
  @item_id = item_id
31
30
  @time = time
32
- optional = normalize_optional(optional)
31
+ optional = normalize_hash_to_camel_case(optional)
33
32
  @cascade_create = optional['cascadeCreate']
34
33
  @optional = optional
35
34
  @timeout = 3000
36
35
  @ensure_https = false
37
36
  @optional.each do |par, _|
38
- fail UnknownOptionalParameter.new(par) unless ["cascadeCreate"].include? par
37
+ raise UnknownOptionalParameter.new(par) unless ['cascadeCreate'].include? par
39
38
  end
40
39
  end
41
-
40
+
42
41
  # HTTP method
43
42
  def method
44
43
  :post
45
44
  end
46
-
45
+
47
46
  # Values of body parameters as a Hash
48
47
  def body_parameters
49
- p = Hash.new
48
+ p = {}
50
49
  p['itemType'] = @item_type
51
50
  p['itemId'] = @item_id
52
51
  p['time'] = @time
53
52
  p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
53
+
54
54
  p
55
55
  end
56
-
56
+
57
57
  # Values of query parameters as a Hash.
58
58
  # name of parameter => value of the parameter
59
59
  def query_parameters
60
- params = {}
61
- params
60
+ {}
62
61
  end
63
-
62
+
64
63
  # Relative path to the endpoint
65
64
  def path
66
65
  "/{databaseId}/series/#{@series_id}/items/"