Skip to content

Commit 4f1da58

Browse files
committed
Added support for view portions
1 parent 3ad7396 commit 4f1da58

13 files changed

+370
-3
lines changed

lib/recombee_api_client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class RecombeeClient
1818
include HTTParty
1919

2020
BATCH_MAX_SIZE = 10000
21-
USER_AGENT = {'User-Agent' => 'recombee-ruby-api-client/1.4.0'}
21+
USER_AGENT = {'User-Agent' => 'recombee-ruby-api-client/1.5.0'}
2222

2323
##
2424
# - +account+ -> Name of your account at Recombee
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#
2+
# This file is auto-generated, do not edit
3+
#
4+
5+
module RecombeeApiClient
6+
require_relative 'request'
7+
require_relative '../errors'
8+
9+
##
10+
#The view portions feature is currently experimental.
11+
#
12+
#Deletes an existing view portion specified by (`userId`, `itemId`, `sessionId`) from the database.
13+
#
14+
class DeleteViewPortion < ApiRequest
15+
attr_reader :user_id, :item_id, :session_id
16+
attr_accessor :timeout
17+
attr_accessor :ensure_https
18+
19+
##
20+
# * *Required arguments*
21+
# - +user_id+ -> ID of the user who rated the item.
22+
# - +item_id+ -> ID of the item which was rated.
23+
#
24+
# * *Optional arguments (given as hash optional)*
25+
# - +sessionId+ -> Identifier of a session.
26+
#
27+
def initialize(user_id, item_id, optional = {})
28+
@user_id = user_id
29+
@item_id = item_id
30+
@session_id = optional['sessionId']
31+
@optional = optional
32+
@timeout = 1000
33+
@ensure_https = false
34+
@optional.each do |par, _|
35+
fail UnknownOptionalParameter.new(par) unless ["sessionId"].include? par
36+
end
37+
end
38+
39+
# HTTP method
40+
def method
41+
:delete
42+
end
43+
44+
# Values of body parameters as a Hash
45+
def body_parameters
46+
p = Hash.new
47+
p
48+
end
49+
50+
# Values of query parameters as a Hash.
51+
# name of parameter => value of the parameter
52+
def query_parameters
53+
params = {}
54+
params['userId'] = @user_id
55+
params['itemId'] = @item_id
56+
params['sessionId'] = @optional['sessionId'] if @optional['sessionId']
57+
params
58+
end
59+
60+
# Relative path to the endpoint
61+
def path
62+
"/{databaseId}/viewportions/"
63+
end
64+
end
65+
end
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#
2+
# This file is auto-generated, do not edit
3+
#
4+
5+
module RecombeeApiClient
6+
require_relative 'request'
7+
require_relative '../errors'
8+
9+
##
10+
#The view portions feature is currently experimental.
11+
#
12+
#List all the view portions of an item ever submitted by different users.
13+
#
14+
class ListItemViewPortions < ApiRequest
15+
attr_reader :item_id
16+
attr_accessor :timeout
17+
attr_accessor :ensure_https
18+
19+
##
20+
# * *Required arguments*
21+
# - +item_id+ -> ID of the item of which the view portions are to be listed.
22+
#
23+
#
24+
def initialize(item_id)
25+
@item_id = item_id
26+
@timeout = 100000
27+
@ensure_https = false
28+
end
29+
30+
# HTTP method
31+
def method
32+
:get
33+
end
34+
35+
# Values of body parameters as a Hash
36+
def body_parameters
37+
p = Hash.new
38+
p
39+
end
40+
41+
# Values of query parameters as a Hash.
42+
# name of parameter => value of the parameter
43+
def query_parameters
44+
params = {}
45+
params
46+
end
47+
48+
# Relative path to the endpoint
49+
def path
50+
"/{databaseId}/items/#{@item_id}/viewportions/"
51+
end
52+
end
53+
end
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#
2+
# This file is auto-generated, do not edit
3+
#
4+
5+
module RecombeeApiClient
6+
require_relative 'request'
7+
require_relative '../errors'
8+
9+
##
10+
#The view portions feature is currently experimental.
11+
#
12+
#List all the view portions ever submitted by a given user.
13+
#
14+
class ListUserViewPortions < ApiRequest
15+
attr_reader :user_id
16+
attr_accessor :timeout
17+
attr_accessor :ensure_https
18+
19+
##
20+
# * *Required arguments*
21+
# - +user_id+ -> ID of the user whose view portions are to be listed.
22+
#
23+
def initialize(user_id)
24+
@user_id = user_id
25+
@timeout = 100000
26+
@ensure_https = false
27+
end
28+
29+
# HTTP method
30+
def method
31+
:get
32+
end
33+
34+
# Values of body parameters as a Hash
35+
def body_parameters
36+
p = Hash.new
37+
p
38+
end
39+
40+
# Values of query parameters as a Hash.
41+
# name of parameter => value of the parameter
42+
def query_parameters
43+
params = {}
44+
params
45+
end
46+
47+
# Relative path to the endpoint
48+
def path
49+
"/{databaseId}/users/#{@user_id}/viewportions/"
50+
end
51+
end
52+
end
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#
2+
# This file is auto-generated, do not edit
3+
#
4+
5+
module RecombeeApiClient
6+
require_relative 'request'
7+
require_relative '../errors'
8+
9+
##
10+
#The view portions feature is currently experimental.
11+
#
12+
#Sets viewed portion of an item (for example a video or article) by a user (at a session).
13+
#If you send new request with the same (`userId`, `itemId`, `sessionId`), the portion gets updated.
14+
#
15+
class SetViewPortion < ApiRequest
16+
attr_reader :user_id, :item_id, :session_id, :timestamp, :portion, :cascade_create
17+
attr_accessor :timeout
18+
attr_accessor :ensure_https
19+
20+
##
21+
# * *Required arguments*
22+
# - +user_id+ -> User who viewed a portion of the item
23+
# - +item_id+ -> Viewed item
24+
# - +portion+ -> Viewed portion of the item (number between 0.0 (viewed nothing) and 1.0 (viewed full item) ).
25+
#
26+
# * *Optional arguments (given as hash optional)*
27+
# - +sessionId+ -> Id of session in which the user viewed the item
28+
# - +timestamp+ -> UTC timestamp of the rating as ISO8601-1 pattern or UTC epoch time. The default value is the current time.
29+
# - +cascadeCreate+ -> Sets whether the given user/item should be created if not present in the database.
30+
#
31+
def initialize(user_id, item_id, portion, optional = {})
32+
@user_id = user_id
33+
@item_id = item_id
34+
@portion = portion
35+
@session_id = optional['sessionId']
36+
@timestamp = optional['timestamp']
37+
@cascade_create = optional['cascadeCreate']
38+
@optional = optional
39+
@timeout = 1000
40+
@ensure_https = false
41+
@optional.each do |par, _|
42+
fail UnknownOptionalParameter.new(par) unless ["sessionId","timestamp","cascadeCreate"].include? par
43+
end
44+
end
45+
46+
# HTTP method
47+
def method
48+
:post
49+
end
50+
51+
# Values of body parameters as a Hash
52+
def body_parameters
53+
p = Hash.new
54+
p['userId'] = @user_id
55+
p['itemId'] = @item_id
56+
p['portion'] = @portion
57+
p['sessionId'] = @optional['sessionId'] if @optional.include? 'sessionId'
58+
p['timestamp'] = @optional['timestamp'] if @optional.include? 'timestamp'
59+
p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
60+
p
61+
end
62+
63+
# Values of query parameters as a Hash.
64+
# name of parameter => value of the parameter
65+
def query_parameters
66+
params = {}
67+
params
68+
end
69+
70+
# Relative path to the endpoint
71+
def path
72+
"/{databaseId}/viewportions/"
73+
end
74+
end
75+
end

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

spec/api/delete_view_portion.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#
2+
# This file is auto-generated, do not edit
3+
#
4+
5+
require 'spec_helper'
6+
require_relative 'set_environment'
7+
shared_examples 'delete view portion' do
8+
include_context 'set environment'
9+
include_context 'set interactions'
10+
11+
it 'does not fail with existing entity id' do
12+
req = described_class.new('user','item')
13+
resp = @client.send(req)
14+
req = described_class.new('user','item')
15+
expect { @client.send(req) }.to raise_exception { |exception|
16+
expect(exception).to be_a(RecombeeApiClient::ResponseError)
17+
expect(exception.status_code).to eq 404
18+
}
19+
end
20+
21+
end
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#
2+
# This file is auto-generated, do not edit
3+
#
4+
5+
require 'spec_helper'
6+
require_relative "delete_view_portion"
7+
8+
describe RecombeeApiClient::DeleteViewPortion do
9+
it_behaves_like "delete view portion"
10+
end
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#
2+
# This file is auto-generated, do not edit
3+
#
4+
5+
require 'spec_helper'
6+
require_relative "list_item_interactions"
7+
8+
describe RecombeeApiClient::ListItemViewPortions do
9+
it_behaves_like "list item interactions"
10+
end
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#
2+
# This file is auto-generated, do not edit
3+
#
4+
5+
require 'spec_helper'
6+
require_relative "list_user_interactions"
7+
8+
describe RecombeeApiClient::ListUserViewPortions do
9+
it_behaves_like "list user interactions"
10+
end

0 commit comments

Comments
 (0)