Class: RecombeeApiClient::SetViewPortion
- Inherits:
-
ApiRequest
- Object
- ApiRequest
- RecombeeApiClient::SetViewPortion
- Defined in:
- lib/recombee_api_client/api/set_view_portion.rb
Overview
Sets viewed portion of an item (for example a video or article) by a user (at a session). If you send a new request with the same (‘userId`, `itemId`, `sessionId`), the portion gets updated.
Instance Attribute Summary collapse
-
#additional_data ⇒ Object
readonly
Returns the value of attribute additional_data.
-
#cascade_create ⇒ Object
readonly
Returns the value of attribute cascade_create.
-
#ensure_https ⇒ Object
Returns the value of attribute ensure_https.
-
#item_id ⇒ Object
readonly
Returns the value of attribute item_id.
-
#portion ⇒ Object
readonly
Returns the value of attribute portion.
-
#recomm_id ⇒ Object
readonly
Returns the value of attribute recomm_id.
-
#session_id ⇒ Object
readonly
Returns the value of attribute session_id.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
-
#user_id ⇒ Object
readonly
Returns the value of attribute user_id.
Instance Method Summary collapse
-
#body_parameters ⇒ Object
Values of body parameters as a Hash.
-
#initialize(user_id, item_id, portion, optional = {}) ⇒ SetViewPortion
constructor
-
*Required arguments* -
user_id
-> User who viewed a portion of the item -item_id
-> Viewed item -portion
-> Viewed portion of the item (number between 0.0 (viewed nothing) and 1.0 (viewed full item) ).
-
-
#method ⇒ Object
HTTP method.
-
#path ⇒ Object
Relative path to the endpoint.
-
#query_parameters ⇒ Object
Values of query parameters as a Hash.
Methods included from HashNormalizer
#camelize, #normalize_optional
Constructor Details
#initialize(user_id, item_id, portion, optional = {}) ⇒ SetViewPortion
-
*Required arguments*
-
user_id
-> User who viewed a portion of the item -
item_id
-> Viewed item -
portion
-> Viewed portion of the item (number between 0.0 (viewed nothing) and 1.0 (viewed full item) ). It should be the actual viewed part of the item, no matter the seeking. For example, if the user seeked immediately to half of the item and then viewed 10% of the item, the ‘portion` should still be `0.1`.
-
-
*Optional arguments (given as hash optional)*
-
sessionId
-> ID of the session in which the user viewed the item. Default is ‘null` (`None`, `nil`, `NULL` etc., depending on the language). -
timestamp
-> UTC timestamp of the view portion as ISO8601-1 pattern or UTC epoch time. The default value is the current time. -
cascadeCreate
-> Sets whether the given user/item should be created if not present in the database. -
recommId
-> If this view portion is based on a recommendation request, ‘recommId` is the id of the clicked recommendation. -
additionalData
-> A dictionary of additional data for the interaction.
-
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/recombee_api_client/api/set_view_portion.rb', line 31 def initialize(user_id, item_id, portion, optional = {}) @user_id = user_id @item_id = item_id @portion = portion optional = normalize_optional(optional) @session_id = optional['sessionId'] @timestamp = optional['timestamp'] @cascade_create = optional['cascadeCreate'] @recomm_id = optional['recommId'] @additional_data = optional['additionalData'] @optional = optional @timeout = 3000 @ensure_https = false @optional.each do |par, _| fail UnknownOptionalParameter.new(par) unless ["sessionId","timestamp","cascadeCreate","recommId","additionalData"].include? par end end |
Instance Attribute Details
#additional_data ⇒ Object (readonly)
Returns the value of attribute additional_data.
14 15 16 |
# File 'lib/recombee_api_client/api/set_view_portion.rb', line 14 def additional_data @additional_data end |
#cascade_create ⇒ Object (readonly)
Returns the value of attribute cascade_create.
14 15 16 |
# File 'lib/recombee_api_client/api/set_view_portion.rb', line 14 def cascade_create @cascade_create end |
#ensure_https ⇒ Object
Returns the value of attribute ensure_https.
16 17 18 |
# File 'lib/recombee_api_client/api/set_view_portion.rb', line 16 def ensure_https @ensure_https end |
#item_id ⇒ Object (readonly)
Returns the value of attribute item_id.
14 15 16 |
# File 'lib/recombee_api_client/api/set_view_portion.rb', line 14 def item_id @item_id end |
#portion ⇒ Object (readonly)
Returns the value of attribute portion.
14 15 16 |
# File 'lib/recombee_api_client/api/set_view_portion.rb', line 14 def portion @portion end |
#recomm_id ⇒ Object (readonly)
Returns the value of attribute recomm_id.
14 15 16 |
# File 'lib/recombee_api_client/api/set_view_portion.rb', line 14 def recomm_id @recomm_id end |
#session_id ⇒ Object (readonly)
Returns the value of attribute session_id.
14 15 16 |
# File 'lib/recombee_api_client/api/set_view_portion.rb', line 14 def session_id @session_id end |
#timeout ⇒ Object
Returns the value of attribute timeout.
15 16 17 |
# File 'lib/recombee_api_client/api/set_view_portion.rb', line 15 def timeout @timeout end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
14 15 16 |
# File 'lib/recombee_api_client/api/set_view_portion.rb', line 14 def @timestamp end |
#user_id ⇒ Object (readonly)
Returns the value of attribute user_id.
14 15 16 |
# File 'lib/recombee_api_client/api/set_view_portion.rb', line 14 def user_id @user_id end |
Instance Method Details
#body_parameters ⇒ Object
Values of body parameters as a Hash
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/recombee_api_client/api/set_view_portion.rb', line 55 def body_parameters p = Hash.new p['userId'] = @user_id p['itemId'] = @item_id p['portion'] = @portion p['sessionId'] = @optional['sessionId'] if @optional.include? 'sessionId' p['timestamp'] = @optional['timestamp'] if @optional.include? 'timestamp' p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate' p['recommId'] = @optional['recommId'] if @optional.include? 'recommId' p['additionalData'] = @optional['additionalData'] if @optional.include? 'additionalData' p end |
#method ⇒ Object
HTTP method
50 51 52 |
# File 'lib/recombee_api_client/api/set_view_portion.rb', line 50 def method :post end |
#path ⇒ Object
Relative path to the endpoint
76 77 78 |
# File 'lib/recombee_api_client/api/set_view_portion.rb', line 76 def path "/{databaseId}/viewportions/" end |
#query_parameters ⇒ Object
Values of query parameters as a Hash. name of parameter => value of the parameter
70 71 72 73 |
# File 'lib/recombee_api_client/api/set_view_portion.rb', line 70 def query_parameters params = {} params end |