Class: RecombeeApiClient::SetValues

Inherits:
ApiRequest show all
Defined in:
lib/recombee_api_client/api/set_values.rb

Overview

Set/update (some) property values of a given entity.

Direct Known Subclasses

SetItemValues, SetUserValues

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HashNormalizer

#camelize, #normalize_hash_to_camel_case

Constructor Details

#initialize(values, optional = {}) ⇒ SetValues

  • Required arguments
    • values -> The values for the individual properties.

Example of body:

 {
   "product_description": "4K TV with 3D feature",
   "categories":   ["Electronics", "Televisions"],
   "price_usd": 342,
   "in_stock_from": "2016-11-16T08:00Z",
 }
  • Optional arguments (given as hash optional)
    • cascadeCreate -> Sets whether the item should be created if not present in the database.


28
29
30
31
32
33
34
35
36
# File 'lib/recombee_api_client/api/set_values.rb', line 28

def initialize(values, optional = {})
  @values = values
  optional = normalize_hash_to_camel_case(optional)
  @cascade_create = optional['cascadeCreate']
  @optional = optional
  @optional.each do |par, _|
    raise UnknownOptionalParameter.new(par) unless ['cascadeCreate'].include? par
  end
end

Instance Attribute Details

#cascade_create ⇒ Object (readonly)

Returns the value of attribute cascade_create.



9
10
11
# File 'lib/recombee_api_client/api/set_values.rb', line 9

def cascade_create
  @cascade_create
end

#values ⇒ Object (readonly)

Returns the value of attribute values.



9
10
11
# File 'lib/recombee_api_client/api/set_values.rb', line 9

def values
  @values
end

Instance Method Details

#body_parameters ⇒ Object

Values of body parameters as a Hash



44
45
46
47
48
49
# File 'lib/recombee_api_client/api/set_values.rb', line 44

def body_parameters
  result = {}
  result = result.merge(@values)
  result['!cascadeCreate'] = true if @cascade_create
  result
end

#method ⇒ Object

HTTP method



39
40
41
# File 'lib/recombee_api_client/api/set_values.rb', line 39

def method
  :post
end

#query_parameters ⇒ Object

Values of query parameters as a Hash. name of parameter => value of the parameter



53
54
55
# File 'lib/recombee_api_client/api/set_values.rb', line 53

def query_parameters
  {}
end