Skip to content

Commit df9d307

Browse files
committed
Support returnProperties and includedProperties parameters of recommendation requests
1 parent 56b343e commit df9d307

File tree

120 files changed

+860
-846
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+860
-846
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
A Ruby client for easy use of the [Recombee](https://www.recombee.com/) recommendation API.
44

5+
If you don't have an account at Recombee yet, you can create a free account [here](https://www.recombee.com/).
6+
57
Documentation of the API can be found at [docs.recombee.com](https://docs.recombee.com/).
68

79
## Installation

lib/recombee_api_client.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,25 @@ def check_errors(response, request)
9696
def process_request_uri(request)
9797
uri = request.path
9898
uri.slice! ('/{databaseId}/')
99+
uri += query_parameters_to_url(request)
99100
uri = URI.escape uri
100101
uri
101102
end
102103

104+
def query_parameters_to_url(req)
105+
ps = ''
106+
req.query_parameters.each do |name, val|
107+
ps += (ps.include? '?') ? '&' : '?'
108+
ps += "#{name}=#{format_query_parameter_value(val)}"
109+
end
110+
ps
111+
end
112+
113+
def format_query_parameter_value(value)
114+
return value unless value.kind_of?(Array)
115+
value.join(',')
116+
end
117+
103118
# Sign request with HMAC, request URI must be exacly the same
104119
# We have 30s to complete request with this token
105120
def sign_url(req_part)

lib/recombee_api_client/api/add_bookmark.rb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,16 @@ def body_parameters
5151
p
5252
end
5353

54-
# Values of query path parameters as a Hash.
54+
# Values of query parameters as a Hash.
5555
# name of parameter => value of the parameter
5656
def query_parameters
5757
params = {}
5858
params
5959
end
6060

6161
# Relative path to the endpoint
62-
def basic_path
63-
"/{databaseId}/bookmarks/"
64-
end
65-
66-
# Relative path to the endpoint including query parameters
6762
def path
68-
p = "/{databaseId}/bookmarks/"
69-
p
63+
"/{databaseId}/bookmarks/"
7064
end
7165
end
7266
end

lib/recombee_api_client/api/add_cart_addition.rb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,16 @@ def body_parameters
5151
p
5252
end
5353

54-
# Values of query path parameters as a Hash.
54+
# Values of query parameters as a Hash.
5555
# name of parameter => value of the parameter
5656
def query_parameters
5757
params = {}
5858
params
5959
end
6060

6161
# Relative path to the endpoint
62-
def basic_path
63-
"/{databaseId}/cartadditions/"
64-
end
65-
66-
# Relative path to the endpoint including query parameters
6762
def path
68-
p = "/{databaseId}/cartadditions/"
69-
p
63+
"/{databaseId}/cartadditions/"
7064
end
7165
end
7266
end

lib/recombee_api_client/api/add_detail_view.rb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,16 @@ def body_parameters
5454
p
5555
end
5656

57-
# Values of query path parameters as a Hash.
57+
# Values of query parameters as a Hash.
5858
# name of parameter => value of the parameter
5959
def query_parameters
6060
params = {}
6161
params
6262
end
6363

6464
# Relative path to the endpoint
65-
def basic_path
66-
"/{databaseId}/detailviews/"
67-
end
68-
69-
# Relative path to the endpoint including query parameters
7065
def path
71-
p = "/{databaseId}/detailviews/"
72-
p
66+
"/{databaseId}/detailviews/"
7367
end
7468
end
7569
end

lib/recombee_api_client/api/add_group.rb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,16 @@ def body_parameters
3434
p
3535
end
3636

37-
# Values of query path parameters as a Hash.
37+
# Values of query parameters as a Hash.
3838
# name of parameter => value of the parameter
3939
def query_parameters
4040
params = {}
4141
params
4242
end
4343

4444
# Relative path to the endpoint
45-
def basic_path
46-
"/{databaseId}/groups/#{@group_id}"
47-
end
48-
49-
# Relative path to the endpoint including query parameters
5045
def path
51-
p = "/{databaseId}/groups/#{@group_id}"
52-
p
46+
"/{databaseId}/groups/#{@group_id}"
5347
end
5448
end
5549
end

lib/recombee_api_client/api/add_item.rb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,16 @@ def body_parameters
3737
p
3838
end
3939

40-
# Values of query path parameters as a Hash.
40+
# Values of query parameters as a Hash.
4141
# name of parameter => value of the parameter
4242
def query_parameters
4343
params = {}
4444
params
4545
end
4646

4747
# Relative path to the endpoint
48-
def basic_path
49-
"/{databaseId}/items/#{@item_id}"
50-
end
51-
52-
# Relative path to the endpoint including query parameters
5348
def path
54-
p = "/{databaseId}/items/#{@item_id}"
55-
p
49+
"/{databaseId}/items/#{@item_id}"
5650
end
5751
end
5852
end

lib/recombee_api_client/api/add_item_property.rb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def body_parameters
3939
p
4040
end
4141

42-
# Values of query path parameters as a Hash.
42+
# Values of query parameters as a Hash.
4343
# name of parameter => value of the parameter
4444
def query_parameters
4545
params = {}
@@ -48,14 +48,8 @@ def query_parameters
4848
end
4949

5050
# Relative path to the endpoint
51-
def basic_path
52-
"/{databaseId}/items/properties/#{@property_name}"
53-
end
54-
55-
# Relative path to the endpoint including query parameters
5651
def path
57-
p = "/{databaseId}/items/properties/#{@property_name}?type=#{@type}"
58-
p
52+
"/{databaseId}/items/properties/#{@property_name}"
5953
end
6054
end
6155
end

lib/recombee_api_client/api/add_purchase.rb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,16 @@ def body_parameters
5151
p
5252
end
5353

54-
# Values of query path parameters as a Hash.
54+
# Values of query parameters as a Hash.
5555
# name of parameter => value of the parameter
5656
def query_parameters
5757
params = {}
5858
params
5959
end
6060

6161
# Relative path to the endpoint
62-
def basic_path
63-
"/{databaseId}/purchases/"
64-
end
65-
66-
# Relative path to the endpoint including query parameters
6762
def path
68-
p = "/{databaseId}/purchases/"
69-
p
63+
"/{databaseId}/purchases/"
7064
end
7165
end
7266
end

lib/recombee_api_client/api/add_rating.rb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,16 @@ def body_parameters
5454
p
5555
end
5656

57-
# Values of query path parameters as a Hash.
57+
# Values of query parameters as a Hash.
5858
# name of parameter => value of the parameter
5959
def query_parameters
6060
params = {}
6161
params
6262
end
6363

6464
# Relative path to the endpoint
65-
def basic_path
66-
"/{databaseId}/ratings/"
67-
end
68-
69-
# Relative path to the endpoint including query parameters
7065
def path
71-
p = "/{databaseId}/ratings/"
72-
p
66+
"/{databaseId}/ratings/"
7367
end
7468
end
7569
end

0 commit comments

Comments
 (0)