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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '01199f5f35eecc707fae959cf983926aeb1a27a0abbeba5c04d3aedacf1a750b'
4
- data.tar.gz: 96df288201b167f39e340732398f1e084d9cf503b778b220e5fadc0638df4b76
3
+ metadata.gz: 88fa1bd148ace9bb4ddfa4c75037c4242bf693a96e7395de3b0c23dafb325d03
4
+ data.tar.gz: c4bbc5474baf87cfaabc58f07b0c4e5161190473e1816e2b6f6ab61b90d32347
5
5
  SHA512:
6
- metadata.gz: d248ef770c97da18c94379e924ab57943dfea87b7a4f2483fc28f328623763281853362352321c8d5c25cb8b5556bbf82cf688574ded90da8e530bf611b9407c
7
- data.tar.gz: 8c7748c00edff1a6e5459aa853d18cb743a96ec6e4b0d796ade5b6ec69cd0567fc8e3dfbda3b061141a069439e6011447e26540d41e527d1f67e6ef2104c2d02
6
+ metadata.gz: ba77e029c00f29e3e4ec1d8b7790620d205e13bb4cbcc16b06061f0ce3045b74b39b815706bf0cde69d88964460a6149d8012f976e2563c9f2188464833ebc2b
7
+ data.tar.gz: 3a6abbe8a347b15d2fec1ec457a23870c4321839c18f75e344adaf607dcb95b2e379b20057af1d90a3edb023eb97643d2788a35088c853588cfe368e7a9a7abe
@@ -5,30 +5,29 @@
5
5
  module RecombeeApiClient
6
6
  require_relative 'request'
7
7
  require_relative '../errors'
8
-
8
+
9
9
  ##
10
- #Adds a bookmark of the given item made by the given user.
10
+ # Adds a bookmark of the given item made by the given user.
11
11
  #
12
12
  class AddBookmark < ApiRequest
13
13
  attr_reader :user_id, :item_id, :timestamp, :cascade_create, :recomm_id, :additional_data
14
- attr_accessor :timeout
15
- attr_accessor :ensure_https
16
-
17
- ##
18
- # * *Required arguments*
19
- # - +user_id+ -> User who bookmarked the item
20
- # - +item_id+ -> Bookmarked item
21
- #
22
- # * *Optional arguments (given as hash optional)*
23
- # - +timestamp+ -> UTC timestamp of the bookmark 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 bookmark 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
- #
14
+ attr_accessor :timeout, :ensure_https
15
+
16
+ ##
17
+ # * *Required arguments*
18
+ # - +user_id+ -> User who bookmarked the item
19
+ # - +item_id+ -> Bookmarked item
20
+ #
21
+ # * *Optional arguments (given as hash optional)*
22
+ # - +timestamp+ -> UTC timestamp of the bookmark 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
+ # - +recommId+ -> If this bookmark is based on a recommendation request, `recommId` is the id of the clicked recommendation.
25
+ # - +additionalData+ -> A dictionary of additional data for the interaction.
26
+ #
28
27
  def initialize(user_id, item_id, optional = {})
29
28
  @user_id = user_id
30
29
  @item_id = item_id
31
- optional = normalize_optional(optional)
30
+ optional = normalize_hash_to_camel_case(optional)
32
31
  @timestamp = optional['timestamp']
33
32
  @cascade_create = optional['cascadeCreate']
34
33
  @recomm_id = optional['recommId']
@@ -37,37 +36,38 @@ module RecombeeApiClient
37
36
  @timeout = 3000
38
37
  @ensure_https = false
39
38
  @optional.each do |par, _|
40
- fail UnknownOptionalParameter.new(par) unless ["timestamp","cascadeCreate","recommId","additionalData"].include? par
39
+ raise UnknownOptionalParameter.new(par) unless %w[timestamp cascadeCreate recommId
40
+ additionalData].include? par
41
41
  end
42
42
  end
43
-
43
+
44
44
  # HTTP method
45
45
  def method
46
46
  :post
47
47
  end
48
-
48
+
49
49
  # Values of body parameters as a Hash
50
50
  def body_parameters
51
- p = Hash.new
51
+ p = {}
52
52
  p['userId'] = @user_id
53
53
  p['itemId'] = @item_id
54
54
  p['timestamp'] = @optional['timestamp'] if @optional.include? 'timestamp'
55
55
  p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
56
56
  p['recommId'] = @optional['recommId'] if @optional.include? 'recommId'
57
57
  p['additionalData'] = @optional['additionalData'] if @optional.include? 'additionalData'
58
+
58
59
  p
59
60
  end
60
-
61
+
61
62
  # Values of query parameters as a Hash.
62
63
  # name of parameter => value of the parameter
63
64
  def query_parameters
64
- params = {}
65
- params
65
+ {}
66
66
  end
67
-
67
+
68
68
  # Relative path to the endpoint
69
69
  def path
70
- "/{databaseId}/bookmarks/"
70
+ '/{databaseId}/bookmarks/'
71
71
  end
72
72
  end
73
73
  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 cart addition of the given item made by the given user.
10
+ # Adds a cart addition of the given item made by the given user.
11
11
  #
12
12
  class AddCartAddition < ApiRequest
13
13
  attr_reader :user_id, :item_id, :timestamp, :cascade_create, :amount, :price, :recomm_id, :additional_data
14
- attr_accessor :timeout
15
- attr_accessor :ensure_https
16
-
17
- ##
18
- # * *Required arguments*
19
- # - +user_id+ -> User who added the item to the cart
20
- # - +item_id+ -> Item added to the cart
21
- #
22
- # * *Optional arguments (given as hash optional)*
23
- # - +timestamp+ -> UTC timestamp of the cart addition 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
- # - +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.
26
- # - +price+ -> Price of the added item. If `amount` is greater than 1, the sum of prices of all the items should be given.
27
- # - +recommId+ -> If this cart addition 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
- #
14
+ attr_accessor :timeout, :ensure_https
15
+
16
+ ##
17
+ # * *Required arguments*
18
+ # - +user_id+ -> User who added the item to the cart
19
+ # - +item_id+ -> Item added to the cart
20
+ #
21
+ # * *Optional arguments (given as hash optional)*
22
+ # - +timestamp+ -> UTC timestamp of the cart addition 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) 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.
25
+ # - +price+ -> Price of the added item. If `amount` is greater than 1, the sum of prices of all the items should be given.
26
+ # - +recommId+ -> If this cart addition is based on a recommendation request, `recommId` is the id of the clicked recommendation.
27
+ # - +additionalData+ -> A dictionary of additional data for the interaction.
28
+ #
30
29
  def initialize(user_id, item_id, optional = {})
31
30
  @user_id = user_id
32
31
  @item_id = item_id
33
- optional = normalize_optional(optional)
32
+ optional = normalize_hash_to_camel_case(optional)
34
33
  @timestamp = optional['timestamp']
35
34
  @cascade_create = optional['cascadeCreate']
36
35
  @amount = optional['amount']
@@ -41,18 +40,19 @@ module RecombeeApiClient
41
40
  @timeout = 3000
42
41
  @ensure_https = false
43
42
  @optional.each do |par, _|
44
- fail UnknownOptionalParameter.new(par) unless ["timestamp","cascadeCreate","amount","price","recommId","additionalData"].include? par
43
+ raise UnknownOptionalParameter.new(par) unless %w[timestamp cascadeCreate amount price recommId
44
+ additionalData].include? par
45
45
  end
46
46
  end
47
-
47
+
48
48
  # HTTP method
49
49
  def method
50
50
  :post
51
51
  end
52
-
52
+
53
53
  # Values of body parameters as a Hash
54
54
  def body_parameters
55
- p = Hash.new
55
+ p = {}
56
56
  p['userId'] = @user_id
57
57
  p['itemId'] = @item_id
58
58
  p['timestamp'] = @optional['timestamp'] if @optional.include? 'timestamp'
@@ -61,19 +61,19 @@ module RecombeeApiClient
61
61
  p['price'] = @optional['price'] if @optional.include? 'price'
62
62
  p['recommId'] = @optional['recommId'] if @optional.include? 'recommId'
63
63
  p['additionalData'] = @optional['additionalData'] if @optional.include? 'additionalData'
64
+
64
65
  p
65
66
  end
66
-
67
+
67
68
  # Values of query parameters as a Hash.
68
69
  # name of parameter => value of the parameter
69
70
  def query_parameters
70
- params = {}
71
- params
71
+ {}
72
72
  end
73
-
73
+
74
74
  # Relative path to the endpoint
75
75
  def path
76
- "/{databaseId}/cartadditions/"
76
+ '/{databaseId}/cartadditions/'
77
77
  end
78
78
  end
79
79
  end
@@ -5,52 +5,55 @@
5
5
  module RecombeeApiClient
6
6
  require_relative 'request'
7
7
  require_relative '../errors'
8
-
8
+
9
9
  ##
10
- #Adds a detail view of the given item made by the given user.
10
+ # Adds a detail view of the given item made by the given user.
11
11
  #
12
12
  class AddDetailView < ApiRequest
13
- attr_reader :user_id, :item_id, :timestamp, :duration, :cascade_create, :recomm_id, :additional_data
14
- attr_accessor :timeout
15
- attr_accessor :ensure_https
16
-
17
- ##
18
- # * *Required arguments*
19
- # - +user_id+ -> User who viewed the item
20
- # - +item_id+ -> Viewed item
21
- #
22
- # * *Optional arguments (given as hash optional)*
23
- # - +timestamp+ -> UTC timestamp of the view as ISO8601-1 pattern or UTC epoch time. The default value is the current time.
24
- # - +duration+ -> Duration of the view
25
- # - +cascadeCreate+ -> Sets whether the given user/item should be created if not present in the database.
26
- # - +recommId+ -> If this detail view is based on a recommendation request, `recommId` is the id of the clicked recommendation.
27
- # - +additionalData+ -> A dictionary of additional data for the interaction.
28
- #
13
+ attr_reader :user_id, :item_id, :timestamp, :duration, :cascade_create, :recomm_id, :additional_data,
14
+ :auto_presented
15
+ attr_accessor :timeout, :ensure_https
16
+
17
+ ##
18
+ # * *Required arguments*
19
+ # - +user_id+ -> User who viewed the item
20
+ # - +item_id+ -> Viewed item
21
+ #
22
+ # * *Optional arguments (given as hash optional)*
23
+ # - +timestamp+ -> UTC timestamp of the view as ISO8601-1 pattern or UTC epoch time. The default value is the current time.
24
+ # - +duration+ -> Duration of the view
25
+ # - +cascadeCreate+ -> Sets whether the given user/item should be created if not present in the database.
26
+ # - +recommId+ -> If this detail view is based on a recommendation request, `recommId` is the id of the clicked recommendation.
27
+ # - +additionalData+ -> A dictionary of additional data for the interaction.
28
+ # - +autoPresented+ -> Indicates whether the item was automatically presented to the user (e.g., in a swiping feed) or explicitly requested by the user (e.g., by clicking on a link). Defaults to `false`.
29
+ #
29
30
  def initialize(user_id, item_id, optional = {})
30
31
  @user_id = user_id
31
32
  @item_id = item_id
32
- optional = normalize_optional(optional)
33
+ optional = normalize_hash_to_camel_case(optional)
33
34
  @timestamp = optional['timestamp']
34
35
  @duration = optional['duration']
35
36
  @cascade_create = optional['cascadeCreate']
36
37
  @recomm_id = optional['recommId']
37
38
  @additional_data = optional['additionalData']
39
+ @auto_presented = optional['autoPresented']
38
40
  @optional = optional
39
41
  @timeout = 3000
40
42
  @ensure_https = false
41
43
  @optional.each do |par, _|
42
- fail UnknownOptionalParameter.new(par) unless ["timestamp","duration","cascadeCreate","recommId","additionalData"].include? par
44
+ raise UnknownOptionalParameter.new(par) unless %w[timestamp duration cascadeCreate recommId
45
+ additionalData autoPresented].include? par
43
46
  end
44
47
  end
45
-
48
+
46
49
  # HTTP method
47
50
  def method
48
51
  :post
49
52
  end
50
-
53
+
51
54
  # Values of body parameters as a Hash
52
55
  def body_parameters
53
- p = Hash.new
56
+ p = {}
54
57
  p['userId'] = @user_id
55
58
  p['itemId'] = @item_id
56
59
  p['timestamp'] = @optional['timestamp'] if @optional.include? 'timestamp'
@@ -58,19 +61,20 @@ module RecombeeApiClient
58
61
  p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
59
62
  p['recommId'] = @optional['recommId'] if @optional.include? 'recommId'
60
63
  p['additionalData'] = @optional['additionalData'] if @optional.include? 'additionalData'
64
+ p['autoPresented'] = @optional['autoPresented'] if @optional.include? 'autoPresented'
65
+
61
66
  p
62
67
  end
63
-
68
+
64
69
  # Values of query parameters as a Hash.
65
70
  # name of parameter => value of the parameter
66
71
  def query_parameters
67
- params = {}
68
- params
72
+ {}
69
73
  end
70
-
74
+
71
75
  # Relative path to the endpoint
72
76
  def path
73
- "/{databaseId}/detailviews/"
77
+ '/{databaseId}/detailviews/'
74
78
  end
75
79
  end
76
80
  end
@@ -5,45 +5,42 @@
5
5
  module RecombeeApiClient
6
6
  require_relative 'request'
7
7
  require_relative '../errors'
8
-
8
+
9
9
  ##
10
- #Adds new item of the given `itemId` to the items catalog.
10
+ # Adds new item of the given `itemId` to the items catalog.
11
11
  #
12
- #All the item properties for the newly created items are set to null.
12
+ # All the item properties for the newly created items are set to null.
13
13
  #
14
14
  class AddItem < ApiRequest
15
15
  attr_reader :item_id
16
- attr_accessor :timeout
17
- attr_accessor :ensure_https
18
-
19
- ##
20
- # * *Required arguments*
21
- # - +item_id+ -> ID of the item to be created.
22
- #
16
+ attr_accessor :timeout, :ensure_https
17
+
18
+ ##
19
+ # * *Required arguments*
20
+ # - +item_id+ -> ID of the item to be created.
21
+ #
23
22
  def initialize(item_id)
24
23
  @item_id = item_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
  :put
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}/items/#{@item_id}"
@@ -5,64 +5,63 @@
5
5
  module RecombeeApiClient
6
6
  require_relative 'request'
7
7
  require_relative '../errors'
8
-
8
+
9
9
  ##
10
- #Adding an item property is somewhat equivalent to adding a column to the table of items. The items may be characterized by various properties of different types.
10
+ # Adding an item property is somewhat equivalent to adding a column to the table of items. The items may be characterized by various properties of different types.
11
11
  #
12
12
  class AddItemProperty < ApiRequest
13
13
  attr_reader :property_name, :type
14
- attr_accessor :timeout
15
- attr_accessor :ensure_https
16
-
17
- ##
18
- # * *Required arguments*
19
- # - +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.
20
- #
21
- # - +type+ -> Value type of the item property to be created. One of: `int`, `double`, `string`, `boolean`, `timestamp`, `set`, `image` or `imageList`.
22
- #
23
- #* `int`- Signed integer number.
24
- #
25
- #* `double` - Floating point number. It uses 64-bit base-2 format (IEEE 754 standard).
26
- #
27
- #* `string` - UTF-8 string.
28
- #
29
- #* `boolean` - *true* / *false*
30
- #
31
- #* `timestamp` - Value representing date and time.
32
- #
33
- #* `set` - Set of strings.
34
- #
35
- #* `image` - URL of an image (`jpeg`, `png` or `gif`).
36
- #
37
- #* `imageList` - List of URLs that refer to images.
38
- #
39
- #
14
+ attr_accessor :timeout, :ensure_https
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`, `image` or `imageList`.
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
+ # * `image` - URL of an image (`jpeg`, `png` or `gif`).
35
+ #
36
+ # * `imageList` - List of URLs that refer to images.
37
+ #
38
+ #
40
39
  def initialize(property_name, type)
41
40
  @property_name = property_name
42
41
  @type = type
43
- @timeout = 100000
42
+ @timeout = 100_000
44
43
  @ensure_https = false
45
44
  end
46
-
45
+
47
46
  # HTTP method
48
47
  def method
49
48
  :put
50
49
  end
51
-
50
+
52
51
  # Values of body parameters as a Hash
53
52
  def body_parameters
54
- p = Hash.new
55
- p
53
+ {}
56
54
  end
57
-
55
+
58
56
  # Values of query parameters as a Hash.
59
57
  # name of parameter => value of the parameter
60
58
  def query_parameters
61
59
  params = {}
62
60
  params['type'] = @type
61
+
63
62
  params
64
63
  end
65
-
64
+
66
65
  # Relative path to the endpoint
67
66
  def path
68
67
  "/{databaseId}/items/properties/#{@property_name}"
@@ -5,62 +5,61 @@
5
5
  module RecombeeApiClient
6
6
  require_relative 'request'
7
7
  require_relative '../errors'
8
-
8
+
9
9
  ##
10
- #Adds a new Segment into a Manual ReQL Segmentation.
10
+ # Adds a new Segment into a Manual ReQL Segmentation.
11
11
  #
12
- #The new Segment is defined by a [ReQL](https://docs.recombee.com/reql) filter that returns `true` for an item in case that this item belongs to the segment.
12
+ # The new Segment is defined by a [ReQL](https://docs.recombee.com/reql) filter that returns `true` for an item in case that this item belongs to the segment.
13
13
  #
14
14
  class AddManualReqlSegment < ApiRequest
15
15
  attr_reader :segmentation_id, :segment_id, :filter, :title
16
- attr_accessor :timeout
17
- attr_accessor :ensure_https
18
-
19
- ##
20
- # * *Required arguments*
21
- # - +segmentation_id+ -> ID of the Segmentation to which the new Segment should be added
22
- # - +segment_id+ -> ID of the newly created Segment
23
- # - +filter+ -> ReQL filter that returns `true` for items that belong to this Segment. Otherwise returns `false`.
24
- #
25
- #
26
- # * *Optional arguments (given as hash optional)*
27
- # - +title+ -> Human-readable name of the Segment that is shown in the Recombee Admin UI.
28
- #
29
- #
16
+ attr_accessor :timeout, :ensure_https
17
+
18
+ ##
19
+ # * *Required arguments*
20
+ # - +segmentation_id+ -> ID of the Segmentation to which the new Segment should be added
21
+ # - +segment_id+ -> ID of the newly created Segment
22
+ # - +filter+ -> ReQL filter that returns `true` for items that belong to this Segment. Otherwise returns `false`.
23
+ #
24
+ #
25
+ # * *Optional arguments (given as hash optional)*
26
+ # - +title+ -> Human-readable name of the Segment that is shown in the Recombee Admin UI.
27
+ #
28
+ #
30
29
  def initialize(segmentation_id, segment_id, filter, optional = {})
31
30
  @segmentation_id = segmentation_id
32
31
  @segment_id = segment_id
33
32
  @filter = filter
34
- optional = normalize_optional(optional)
33
+ optional = normalize_hash_to_camel_case(optional)
35
34
  @title = optional['title']
36
35
  @optional = optional
37
- @timeout = 10000
36
+ @timeout = 10_000
38
37
  @ensure_https = false
39
38
  @optional.each do |par, _|
40
- fail UnknownOptionalParameter.new(par) unless ["title"].include? par
39
+ raise UnknownOptionalParameter.new(par) unless ['title'].include? par
41
40
  end
42
41
  end
43
-
42
+
44
43
  # HTTP method
45
44
  def method
46
45
  :put
47
46
  end
48
-
47
+
49
48
  # Values of body parameters as a Hash
50
49
  def body_parameters
51
- p = Hash.new
50
+ p = {}
52
51
  p['filter'] = @filter
53
52
  p['title'] = @optional['title'] if @optional.include? 'title'
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}/segmentations/manual-reql/#{@segmentation_id}/segments/#{@segment_id}"