Class: RecombeeApiClient::AddCartAddition
- Inherits:
-
ApiRequest
- Object
- ApiRequest
- RecombeeApiClient::AddCartAddition
- Defined in:
- lib/recombee_api_client/api/add_cart_addition.rb
Overview
Adds a cart addition of the given item made by the given user.
Instance Attribute Summary collapse
-
#additional_data ⇒ Object
readonly
Returns the value of attribute additional_data.
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#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.
-
#price ⇒ Object
readonly
Returns the value of attribute price.
-
#recomm_id ⇒ Object
readonly
Returns the value of attribute recomm_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, optional = {}) ⇒ AddCartAddition
constructor
-
*Required arguments* -
user_id
-> User who added the item to the cart -item_id
-> Item added to the cart.
-
-
#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, optional = {}) ⇒ AddCartAddition
-
*Required arguments*
-
user_id
-> User who added the item to the cart -
item_id
-> Item added to the cart
-
-
*Optional arguments (given as hash optional)*
-
timestamp
-> UTC timestamp of the cart addition 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. -
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. -
price
-> Price of the added item. If ‘amount` is greater than 1, the sum of prices of all the items should be given. -
recommId
-> If this cart addition is based on a recommendation request, ‘recommId` is the id of the clicked recommendation. -
additionalData
-> A dictionary of additional data for the interaction.
-
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/recombee_api_client/api/add_cart_addition.rb', line 30 def initialize(user_id, item_id, optional = {}) @user_id = user_id @item_id = item_id optional = normalize_optional(optional) @timestamp = optional['timestamp'] @cascade_create = optional['cascadeCreate'] @amount = optional['amount'] @price = optional['price'] @recomm_id = optional['recommId'] @additional_data = optional['additionalData'] @optional = optional @timeout = 3000 @ensure_https = false @optional.each do |par, _| fail UnknownOptionalParameter.new(par) unless ["timestamp","cascadeCreate","amount","price","recommId","additionalData"].include? par end end |
Instance Attribute Details
#additional_data ⇒ Object (readonly)
Returns the value of attribute additional_data.
13 14 15 |
# File 'lib/recombee_api_client/api/add_cart_addition.rb', line 13 def additional_data @additional_data end |
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
13 14 15 |
# File 'lib/recombee_api_client/api/add_cart_addition.rb', line 13 def amount @amount end |
#cascade_create ⇒ Object (readonly)
Returns the value of attribute cascade_create.
13 14 15 |
# File 'lib/recombee_api_client/api/add_cart_addition.rb', line 13 def cascade_create @cascade_create end |
#ensure_https ⇒ Object
Returns the value of attribute ensure_https.
15 16 17 |
# File 'lib/recombee_api_client/api/add_cart_addition.rb', line 15 def ensure_https @ensure_https end |
#item_id ⇒ Object (readonly)
Returns the value of attribute item_id.
13 14 15 |
# File 'lib/recombee_api_client/api/add_cart_addition.rb', line 13 def item_id @item_id end |
#price ⇒ Object (readonly)
Returns the value of attribute price.
13 14 15 |
# File 'lib/recombee_api_client/api/add_cart_addition.rb', line 13 def price @price end |
#recomm_id ⇒ Object (readonly)
Returns the value of attribute recomm_id.
13 14 15 |
# File 'lib/recombee_api_client/api/add_cart_addition.rb', line 13 def recomm_id @recomm_id end |
#timeout ⇒ Object
Returns the value of attribute timeout.
14 15 16 |
# File 'lib/recombee_api_client/api/add_cart_addition.rb', line 14 def timeout @timeout end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
13 14 15 |
# File 'lib/recombee_api_client/api/add_cart_addition.rb', line 13 def @timestamp end |
#user_id ⇒ Object (readonly)
Returns the value of attribute user_id.
13 14 15 |
# File 'lib/recombee_api_client/api/add_cart_addition.rb', line 13 def user_id @user_id end |
Instance Method Details
#body_parameters ⇒ Object
Values of body parameters as a Hash
54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/recombee_api_client/api/add_cart_addition.rb', line 54 def body_parameters p = Hash.new p['userId'] = @user_id p['itemId'] = @item_id p['timestamp'] = @optional['timestamp'] if @optional.include? 'timestamp' p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate' p['amount'] = @optional['amount'] if @optional.include? 'amount' p['price'] = @optional['price'] if @optional.include? 'price' p['recommId'] = @optional['recommId'] if @optional.include? 'recommId' p['additionalData'] = @optional['additionalData'] if @optional.include? 'additionalData' p end |
#method ⇒ Object
HTTP method
49 50 51 |
# File 'lib/recombee_api_client/api/add_cart_addition.rb', line 49 def method :post end |
#path ⇒ Object
Relative path to the endpoint
75 76 77 |
# File 'lib/recombee_api_client/api/add_cart_addition.rb', line 75 def path "/{databaseId}/cartadditions/" end |
#query_parameters ⇒ Object
Values of query parameters as a Hash. name of parameter => value of the parameter
69 70 71 72 |
# File 'lib/recombee_api_client/api/add_cart_addition.rb', line 69 def query_parameters params = {} params end |