Class: RecombeeApiClient::InsertToGroup

Inherits:
ApiRequest
  • Object
show all
Defined in:
lib/recombee_api_client/api/insert_to_group.rb

Overview

Inserts an existing item/group into group of given ‘groupId`.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HashNormalizer

#camelize, #normalize_optional

Constructor Details

#initialize(group_id, item_type, item_id, optional = {}) ⇒ InsertToGroup

  • *Required arguments*

    • group_id -> ID of the group to be inserted into.

    • item_type -> ‘item` iff the regular item from the catalog is to be inserted, `group` iff group is inserted as the item.

    • item_id -> ID of the item iff ‘itemType` is `item`. ID of the group iff `itemType` is `group`.

  • *Optional arguments (given as hash optional)*

    • cascadeCreate -> Indicates that any non-existing entity specified within the request should be created (as is corresponding PUT requests were invoked). This concerns both the ‘groupId` and the `groupId`. If `cascadeCreate` is set true, the behavior also depends on the `itemType`. Either items or group may be created if not present in the database.



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/recombee_api_client/api/insert_to_group.rb', line 26

def initialize(group_id, item_type, item_id, optional = {})
  @group_id = group_id
  @item_type = item_type
  @item_id = item_id
  optional = normalize_optional(optional)
  @cascade_create = optional['cascadeCreate']
  @optional = optional
  @timeout = 1000
  @ensure_https = false
  @optional.each do |par, _|
    fail UnknownOptionalParameter.new(par) unless ["cascadeCreate"].include? par
  end
end

Instance Attribute Details

#cascade_createObject (readonly)

Returns the value of attribute cascade_create.



13
14
15
# File 'lib/recombee_api_client/api/insert_to_group.rb', line 13

def cascade_create
  @cascade_create
end

#ensure_httpsObject

Returns the value of attribute ensure_https.



15
16
17
# File 'lib/recombee_api_client/api/insert_to_group.rb', line 15

def ensure_https
  @ensure_https
end

#group_idObject (readonly)

Returns the value of attribute group_id.



13
14
15
# File 'lib/recombee_api_client/api/insert_to_group.rb', line 13

def group_id
  @group_id
end

#item_idObject (readonly)

Returns the value of attribute item_id.



13
14
15
# File 'lib/recombee_api_client/api/insert_to_group.rb', line 13

def item_id
  @item_id
end

#item_typeObject (readonly)

Returns the value of attribute item_type.



13
14
15
# File 'lib/recombee_api_client/api/insert_to_group.rb', line 13

def item_type
  @item_type
end

#timeoutObject

Returns the value of attribute timeout.



14
15
16
# File 'lib/recombee_api_client/api/insert_to_group.rb', line 14

def timeout
  @timeout
end

Instance Method Details

#body_parametersObject

Values of body parameters as a Hash



46
47
48
49
50
51
52
# File 'lib/recombee_api_client/api/insert_to_group.rb', line 46

def body_parameters
  p = Hash.new
  p['itemType'] = @item_type
  p['itemId'] = @item_id
  p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
  p
end

#methodObject

HTTP method



41
42
43
# File 'lib/recombee_api_client/api/insert_to_group.rb', line 41

def method
  :post
end

#pathObject

Relative path to the endpoint



62
63
64
# File 'lib/recombee_api_client/api/insert_to_group.rb', line 62

def path
  "/{databaseId}/groups/#{@group_id}/items/"
end

#query_parametersObject

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



56
57
58
59
# File 'lib/recombee_api_client/api/insert_to_group.rb', line 56

def query_parameters
  params = {}
  params
end