Class: RecombeeApiClient::MergeUsers

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

Overview

Merges interactions (purchases, ratings, bookmarks, detail views …) of two different users under a single user ID. This is especially useful for online e-commerce applications working with anonymous users identified by unique tokens such as the session ID. In such applications, it may often happen that a user owns a persistent account, yet accesses the system anonymously while, e.g., putting items into a shopping cart. At some point in time, such as when the user wishes to confirm the purchase, (s)he logs into the system using his/her username and password. The interactions made under anonymous session ID then become connected with the persistent account, and merging these two together becomes desirable.

Merging happens between two users referred to as the target and the source. After the merge, all the interactions of the source user are attributed to the target user, and the source user is deleted.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HashNormalizer

#camelize, #normalize_optional

Constructor Details

#initialize(target_user_id, source_user_id, optional = {}) ⇒ MergeUsers

  • *Required arguments*

    • target_user_id -> ID of the targer user.

    • source_user_id -> ID of the source user.

  • *Optional arguments (given as hash optional)*

    • cascadeCreate -> Sets whether the user targetUserId should be created if not present in the database.



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

def initialize(target_user_id, source_user_id, optional = {})
  @target_user_id = target_user_id
  @source_user_id = source_user_id
  optional = normalize_optional(optional)
  @cascade_create = optional['cascadeCreate']
  @optional = optional
  @timeout = 10000
  @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.



16
17
18
# File 'lib/recombee_api_client/api/merge_users.rb', line 16

def cascade_create
  @cascade_create
end

#ensure_httpsObject

Returns the value of attribute ensure_https.



18
19
20
# File 'lib/recombee_api_client/api/merge_users.rb', line 18

def ensure_https
  @ensure_https
end

#source_user_idObject (readonly)

Returns the value of attribute source_user_id.



16
17
18
# File 'lib/recombee_api_client/api/merge_users.rb', line 16

def source_user_id
  @source_user_id
end

#target_user_idObject (readonly)

Returns the value of attribute target_user_id.



16
17
18
# File 'lib/recombee_api_client/api/merge_users.rb', line 16

def target_user_id
  @target_user_id
end

#timeoutObject

Returns the value of attribute timeout.



17
18
19
# File 'lib/recombee_api_client/api/merge_users.rb', line 17

def timeout
  @timeout
end

Instance Method Details

#body_parametersObject

Values of body parameters as a Hash



47
48
49
50
# File 'lib/recombee_api_client/api/merge_users.rb', line 47

def body_parameters
  p = Hash.new
  p
end

#methodObject

HTTP method



42
43
44
# File 'lib/recombee_api_client/api/merge_users.rb', line 42

def method
  :put
end

#pathObject

Relative path to the endpoint



61
62
63
# File 'lib/recombee_api_client/api/merge_users.rb', line 61

def path
  "/{databaseId}/users/#{@target_user_id}/merge/#{@source_user_id}"
end

#query_parametersObject

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



54
55
56
57
58
# File 'lib/recombee_api_client/api/merge_users.rb', line 54

def query_parameters
  params = {}
  params['cascadeCreate'] = @optional['cascadeCreate'] if @optional['cascadeCreate']
  params
end