Skip to content

Commit 648a6a9

Browse files
committed
Added distinctRecomms parameter to batch request
1 parent 809c4a0 commit 648a6a9

File tree

8 files changed

+23
-8
lines changed

8 files changed

+23
-8
lines changed

lib/recombee_api_client/api/batch.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,16 @@ class Batch < ApiRequest
1414
# * *Required arguments*
1515
# - +requests+ -> Array of API requests.
1616
#
17-
def initialize(requests)
17+
def initialize(requests, optional = {})
1818
@requests = requests
19+
@optional = optional
1920
@body_parameters = requests_to_batch_hash
2021
@timeout = requests.map{|r| r.timeout}.reduce(:+)
2122
@ensure_https = true
23+
24+
@optional.each do |par, _|
25+
fail UnknownOptionalParameter.new(par) unless ["distinctRecomms"].include? par
26+
end
2227
end
2328

2429
# HTTP method
@@ -47,7 +52,9 @@ def path
4752
def requests_to_batch_hash
4853
reqs = []
4954
@requests.each { |r| reqs.push(request_to_batch_hash r) }
50-
{'requests' => reqs}
55+
result = {'requests' => reqs}
56+
result['distinctRecomms'] = @optional['distinctRecomms'] if @optional.key? 'distinctRecomms'
57+
result
5158
end
5259

5360
def request_to_batch_hash(req)

lib/recombee_api_client/api/list_groups.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ListGroups < ApiRequest
1616
##
1717
#
1818
def initialize()
19-
@timeout = 1000
19+
@timeout = 30000
2020
@ensure_https = false
2121
end
2222

lib/recombee_api_client/api/list_items.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ListItems < ApiRequest
2121
def initialize(optional = {})
2222
@filter = optional['filter']
2323
@optional = optional
24-
@timeout = 1000
24+
@timeout = 30000
2525
@ensure_https = false
2626
@optional.each do |par, _|
2727
fail UnknownOptionalParameter.new(par) unless ["filter"].include? par

lib/recombee_api_client/api/list_series.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ListSeries < ApiRequest
1616
##
1717
#
1818
def initialize()
19-
@timeout = 1000
19+
@timeout = 30000
2020
@ensure_https = false
2121
end
2222

lib/recombee_api_client/api/list_users.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ListUsers < ApiRequest
1616
##
1717
#
1818
def initialize()
19-
@timeout = 1000
19+
@timeout = 30000
2020
@ensure_https = false
2121
end
2222

lib/recombee_api_client/api/merge_users.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module RecombeeApiClient
1010
#Merges purchases, ratings, bookmarks, and 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.
1111
#
1212
#
13-
#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`.
13+
#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** unless special parameter `keepSourceUser` is set `true`.
1414
#
1515
class MergeUsers < ApiRequest
1616
attr_reader :target_user_id, :source_user_id, :keep_source_user, :cascade_create

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.3'
2+
VERSION = '1.2.4'
33
end

spec/api/add_interaction.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@
2323
end
2424

2525
it 'fails with nonexisting item id' do
26+
req = described_class.new('entity_id','nonex_id')
27+
expect { @client.send(req) }.to raise_exception { |exception|
28+
expect(exception).to be_a(RecombeeApiClient::ResponseError)
29+
expect(exception.status_code).to eq 404
30+
}
31+
end
32+
33+
it 'fails with nonexisting user id' do
2634
req = described_class.new('nonex_id','entity_id')
2735
expect { @client.send(req) }.to raise_exception { |exception|
2836
expect(exception).to be_a(RecombeeApiClient::ResponseError)

0 commit comments

Comments
 (0)