Skip to content

Commit 809c4a0

Browse files
committed
Added cascadeCreate parameter to merge users request
1 parent df9d307 commit 809c4a0

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ begin
5757
puts 'Recommend for a user'
5858
recommended = client.send(UserBasedRecommendation.new('user-25', 5, 'rotationRate' => 0))
5959
puts "Recommended items: #{recommended}"
60-
rescue ResponseError => e
60+
rescue APIError => e
6161
puts e
6262
end
6363
```

lib/recombee_api_client/api/merge_users.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module RecombeeApiClient
1313
#Merging happens between two users referred to as the *source* and the *target*. After the merge, all the interactions of the source user are attributed to the target user, and the source user is **deleted** unless special parameter `keepSourceUser` is set `true`.
1414
#
1515
class MergeUsers < ApiRequest
16-
attr_reader :target_user_id, :source_user_id, :keep_source_user
16+
attr_reader :target_user_id, :source_user_id, :keep_source_user, :cascade_create
1717
attr_accessor :timeout
1818
attr_accessor :ensure_https
1919

@@ -23,17 +23,19 @@ class MergeUsers < ApiRequest
2323
# - +source_user_id+ -> ID of the target user.
2424
#
2525
# * *Optional arguments (given as hash optional)*
26-
# - +keepSourceUser+ -> If true, the source user will not be deleted, but also kept in the database..
26+
# - +keepSourceUser+ -> If true, the source user will not be deleted, but also kept in the database.
27+
# - +cascadeCreate+ -> Sets whether the user *targetUserId* should be created if not present in the database.
2728
#
2829
def initialize(target_user_id, source_user_id, optional = {})
2930
@target_user_id = target_user_id
3031
@source_user_id = source_user_id
3132
@keep_source_user = optional['keepSourceUser']
33+
@cascade_create = optional['cascadeCreate']
3234
@optional = optional
3335
@timeout = 1000
3436
@ensure_https = false
3537
@optional.each do |par, _|
36-
fail UnknownOptionalParameter.new(par) unless ["keepSourceUser"].include? par
38+
fail UnknownOptionalParameter.new(par) unless ["keepSourceUser","cascadeCreate"].include? par
3739
end
3840
end
3941

@@ -53,6 +55,7 @@ def body_parameters
5355
def query_parameters
5456
params = {}
5557
params['keepSourceUser'] = @optional['keepSourceUser'] if @optional['keepSourceUser']
58+
params['cascadeCreate'] = @optional['cascadeCreate'] if @optional['cascadeCreate']
5659
params
5760
end
5861

lib/recombee_api_client/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module RecombeeApiClient
2-
VERSION = '1.2.1'
2+
VERSION = '1.2.3'
33
end

spec/api/set_values.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
resp = @client.send(req)
1313
end
1414

15+
it 'does not fail with non-ASCII string' do
16+
req = described_class.new('entity_id',{'str_property' => 'šřžذ的‎'})
17+
resp = @client.send(req)
18+
end
19+
1520
it 'sets multiple properties' do
1621
req = described_class.new('entity_id',{'int_property' => 5,'str_property' => 'test'})
1722
resp = @client.send(req)

0 commit comments

Comments
 (0)