Skip to content

Commit f76f28a

Browse files
committed
Release: v6.0.0
- Added support for the new Composite Recommendation endpoint - Added new parameter `autoPresented` for Detail View and View Portion interactions - Added new parameter `timeSpent` for View Portion interactions - Added support for `reqlExpressions` on recommended items - Breaking change: the `name` parameter of the Logic input is no longer mandatory
1 parent 740d166 commit f76f28a

27 files changed

+1324
-37
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
This file is auto-generated, do not edit
3+
*/
4+
5+
6+
using System;
7+
using System.Collections.Generic;
8+
using System.Linq;
9+
using Xunit;
10+
using Recombee.ApiClient.ApiRequests;
11+
using Recombee.ApiClient.Bindings;
12+
13+
namespace Recombee.ApiClient.Tests
14+
{
15+
public class CompositeRecommendationBatchUnitTest: RecombeeUnitTest
16+
{
17+
18+
[Fact]
19+
public void TestCompositeRecommendation()
20+
{
21+
Object resp2;
22+
Request[] requests = new Request[] {
23+
new CompositeRecommendation("scenario_id", 5, cascadeCreate: true)
24+
};
25+
26+
BatchResponse batchResponse = client.Send(new Batch(requests));
27+
Assert.Equal(400, (int)batchResponse.StatusCodes.ElementAt(0));
28+
}
29+
30+
[Fact]
31+
public async void TestCompositeRecommendationAsync()
32+
{
33+
Object resp2;
34+
Request[] requests = new Request[] {
35+
new CompositeRecommendation("scenario_id", 5, cascadeCreate: true)
36+
};
37+
38+
BatchResponse batchResponse = await client.SendAsync(new Batch(requests));
39+
Assert.Equal(400, (int)batchResponse.StatusCodes.ElementAt(0));
40+
}
41+
}
42+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
This file is auto-generated, do not edit
3+
*/
4+
5+
6+
using System;
7+
using System.Collections.Generic;
8+
using System.Linq;
9+
using Xunit;
10+
using Recombee.ApiClient.ApiRequests;
11+
using Recombee.ApiClient.Bindings;
12+
13+
namespace Recombee.ApiClient.Tests
14+
{
15+
public class CompositeRecommendationUnitTest: RecombeeUnitTest
16+
{
17+
18+
[Fact]
19+
public void TestCompositeRecommendation()
20+
{
21+
CompositeRecommendation req;
22+
CompositeRecommendationResponse resp;
23+
Object resp2;
24+
// it 'rejects request to scenario which is not set up'
25+
try
26+
{
27+
client.Send(new CompositeRecommendation("scenario_id", 5, cascadeCreate: true));
28+
Assert.True(false,"No exception thrown");
29+
}
30+
catch (ResponseException ex)
31+
{
32+
Assert.Equal(400, (int)ex.StatusCode);
33+
}
34+
}
35+
36+
[Fact]
37+
public async void TestCompositeRecommendationAsync()
38+
{
39+
CompositeRecommendation req;
40+
CompositeRecommendationResponse resp;
41+
Object resp2;
42+
// it 'rejects request to scenario which is not set up'
43+
try
44+
{
45+
await client.SendAsync(new CompositeRecommendation("scenario_id", 5, cascadeCreate: true));
46+
Assert.True(false,"No exception thrown");
47+
}
48+
catch (ResponseException ex)
49+
{
50+
Assert.Equal(400, (int)ex.StatusCode);
51+
}
52+
}
53+
}
54+
}

Src/Recombee.ApiClient.Tests/RecommendItemsToUserBatchUnitTest.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ public void TestRecommendItemsToUser()
2222
Request[] requests = new Request[] {
2323
new RecommendItemsToUser("entity_id", 9),
2424
new RecommendItemsToUser("nonexisting", 9, cascadeCreate: true),
25-
new RecommendItemsToUser("nonexisting2", 9, cascadeCreate: true, expertSettings: new Dictionary<string, object>(){})
25+
new RecommendItemsToUser("nonexisting2", 9, cascadeCreate: true, expertSettings: new Dictionary<string, object>(){}),
26+
new RecommendItemsToUser("nonexisting2", 9, cascadeCreate: true, reqlExpressions: new Dictionary<string, string>(){{"boolean","true"}, {"number","if ('answer' > 0) then 1 else 2"}, {"string","\"test\""}})
2627
};
2728

2829
BatchResponse batchResponse = client.Send(new Batch(requests));
2930
Assert.Equal(200, (int)batchResponse.StatusCodes.ElementAt(0));
3031
Assert.Equal(200, (int)batchResponse.StatusCodes.ElementAt(1));
3132
Assert.Equal(200, (int)batchResponse.StatusCodes.ElementAt(2));
33+
Assert.Equal(200, (int)batchResponse.StatusCodes.ElementAt(3));
3234
}
3335

3436
[Fact]
@@ -38,13 +40,15 @@ public async void TestRecommendItemsToUserAsync()
3840
Request[] requests = new Request[] {
3941
new RecommendItemsToUser("entity_id", 9),
4042
new RecommendItemsToUser("nonexisting", 9, cascadeCreate: true),
41-
new RecommendItemsToUser("nonexisting2", 9, cascadeCreate: true, expertSettings: new Dictionary<string, object>(){})
43+
new RecommendItemsToUser("nonexisting2", 9, cascadeCreate: true, expertSettings: new Dictionary<string, object>(){}),
44+
new RecommendItemsToUser("nonexisting2", 9, cascadeCreate: true, reqlExpressions: new Dictionary<string, string>(){{"boolean","true"}, {"number","if ('answer' > 0) then 1 else 2"}, {"string","\"test\""}})
4245
};
4346

4447
BatchResponse batchResponse = await client.SendAsync(new Batch(requests));
4548
Assert.Equal(200, (int)batchResponse.StatusCodes.ElementAt(0));
4649
Assert.Equal(200, (int)batchResponse.StatusCodes.ElementAt(1));
4750
Assert.Equal(200, (int)batchResponse.StatusCodes.ElementAt(2));
51+
Assert.Equal(200, (int)batchResponse.StatusCodes.ElementAt(3));
4852
}
4953
}
5054
}

Src/Recombee.ApiClient.Tests/RecommendItemsToUserUnitTest.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ public void TestRecommendItemsToUser()
2727
resp = client.Send(new RecommendItemsToUser("nonexisting", 9, cascadeCreate: true));
2828
// it 'recommends with expert settings'
2929
resp = client.Send(new RecommendItemsToUser("nonexisting2", 9, cascadeCreate: true, expertSettings: new Dictionary<string, object>(){}));
30+
// it 'recommends with reql expressions'
31+
resp = client.Send(new RecommendItemsToUser("nonexisting2", 9, cascadeCreate: true, reqlExpressions: new Dictionary<string, string>(){{"boolean","true"}, {"number","if ('answer' > 0) then 1 else 2"}, {"string","\"test\""}}));
3032
}
3133

3234
[Fact]
@@ -41,6 +43,8 @@ public async void TestRecommendItemsToUserAsync()
4143
resp = await client.SendAsync(new RecommendItemsToUser("nonexisting", 9, cascadeCreate: true));
4244
// it 'recommends with expert settings'
4345
resp = await client.SendAsync(new RecommendItemsToUser("nonexisting2", 9, cascadeCreate: true, expertSettings: new Dictionary<string, object>(){}));
46+
// it 'recommends with reql expressions'
47+
resp = await client.SendAsync(new RecommendItemsToUser("nonexisting2", 9, cascadeCreate: true, reqlExpressions: new Dictionary<string, string>(){{"boolean","true"}, {"number","if ('answer' > 0) then 1 else 2"}, {"string","\"test\""}}));
4448
}
4549
}
4650
}

Src/Recombee.ApiClient.Tests/RecommendUsersToItemBatchUnitTest.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ public void TestRecommendUsersToItem()
2222
Request[] requests = new Request[] {
2323
new RecommendUsersToItem("entity_id", 9),
2424
new RecommendUsersToItem("nonexisting", 9, cascadeCreate: true),
25-
new RecommendUsersToItem("nonexisting2", 9, cascadeCreate: true, expertSettings: new Dictionary<string, object>(){})
25+
new RecommendUsersToItem("nonexisting2", 9, cascadeCreate: true, expertSettings: new Dictionary<string, object>(){}),
26+
new RecommendUsersToItem("nonexisting2", 9, cascadeCreate: true, reqlExpressions: new Dictionary<string, string>(){{"boolean","true"}, {"number","if ('answer' > 0) then 1 else 2"}, {"string","\"test\""}})
2627
};
2728

2829
BatchResponse batchResponse = client.Send(new Batch(requests));
2930
Assert.Equal(200, (int)batchResponse.StatusCodes.ElementAt(0));
3031
Assert.Equal(200, (int)batchResponse.StatusCodes.ElementAt(1));
3132
Assert.Equal(200, (int)batchResponse.StatusCodes.ElementAt(2));
33+
Assert.Equal(200, (int)batchResponse.StatusCodes.ElementAt(3));
3234
}
3335

3436
[Fact]
@@ -38,13 +40,15 @@ public async void TestRecommendUsersToItemAsync()
3840
Request[] requests = new Request[] {
3941
new RecommendUsersToItem("entity_id", 9),
4042
new RecommendUsersToItem("nonexisting", 9, cascadeCreate: true),
41-
new RecommendUsersToItem("nonexisting2", 9, cascadeCreate: true, expertSettings: new Dictionary<string, object>(){})
43+
new RecommendUsersToItem("nonexisting2", 9, cascadeCreate: true, expertSettings: new Dictionary<string, object>(){}),
44+
new RecommendUsersToItem("nonexisting2", 9, cascadeCreate: true, reqlExpressions: new Dictionary<string, string>(){{"boolean","true"}, {"number","if ('answer' > 0) then 1 else 2"}, {"string","\"test\""}})
4245
};
4346

4447
BatchResponse batchResponse = await client.SendAsync(new Batch(requests));
4548
Assert.Equal(200, (int)batchResponse.StatusCodes.ElementAt(0));
4649
Assert.Equal(200, (int)batchResponse.StatusCodes.ElementAt(1));
4750
Assert.Equal(200, (int)batchResponse.StatusCodes.ElementAt(2));
51+
Assert.Equal(200, (int)batchResponse.StatusCodes.ElementAt(3));
4852
}
4953
}
5054
}

Src/Recombee.ApiClient.Tests/RecommendUsersToItemUnitTest.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ public void TestRecommendUsersToItem()
2727
resp = client.Send(new RecommendUsersToItem("nonexisting", 9, cascadeCreate: true));
2828
// it 'recommends with expert settings'
2929
resp = client.Send(new RecommendUsersToItem("nonexisting2", 9, cascadeCreate: true, expertSettings: new Dictionary<string, object>(){}));
30+
// it 'recommends with reql expressions'
31+
resp = client.Send(new RecommendUsersToItem("nonexisting2", 9, cascadeCreate: true, reqlExpressions: new Dictionary<string, string>(){{"boolean","true"}, {"number","if ('answer' > 0) then 1 else 2"}, {"string","\"test\""}}));
3032
}
3133

3234
[Fact]
@@ -41,6 +43,8 @@ public async void TestRecommendUsersToItemAsync()
4143
resp = await client.SendAsync(new RecommendUsersToItem("nonexisting", 9, cascadeCreate: true));
4244
// it 'recommends with expert settings'
4345
resp = await client.SendAsync(new RecommendUsersToItem("nonexisting2", 9, cascadeCreate: true, expertSettings: new Dictionary<string, object>(){}));
46+
// it 'recommends with reql expressions'
47+
resp = await client.SendAsync(new RecommendUsersToItem("nonexisting2", 9, cascadeCreate: true, reqlExpressions: new Dictionary<string, string>(){{"boolean","true"}, {"number","if ('answer' > 0) then 1 else 2"}, {"string","\"test\""}}));
4448
}
4549
}
4650
}

Src/Recombee.ApiClient.Tests/RecommendUsersToUserBatchUnitTest.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ public void TestRecommendUsersToUser()
2222
Request[] requests = new Request[] {
2323
new RecommendUsersToUser("entity_id", 9),
2424
new RecommendUsersToUser("nonexisting", 9, cascadeCreate: true),
25-
new RecommendUsersToUser("nonexisting2", 9, cascadeCreate: true, expertSettings: new Dictionary<string, object>(){})
25+
new RecommendUsersToUser("nonexisting2", 9, cascadeCreate: true, expertSettings: new Dictionary<string, object>(){}),
26+
new RecommendUsersToUser("nonexisting2", 9, cascadeCreate: true, reqlExpressions: new Dictionary<string, string>(){{"boolean","true"}, {"number","if ('answer' > 0) then 1 else 2"}, {"string","\"test\""}})
2627
};
2728

2829
BatchResponse batchResponse = client.Send(new Batch(requests));
2930
Assert.Equal(200, (int)batchResponse.StatusCodes.ElementAt(0));
3031
Assert.Equal(200, (int)batchResponse.StatusCodes.ElementAt(1));
3132
Assert.Equal(200, (int)batchResponse.StatusCodes.ElementAt(2));
33+
Assert.Equal(200, (int)batchResponse.StatusCodes.ElementAt(3));
3234
}
3335

3436
[Fact]
@@ -38,13 +40,15 @@ public async void TestRecommendUsersToUserAsync()
3840
Request[] requests = new Request[] {
3941
new RecommendUsersToUser("entity_id", 9),
4042
new RecommendUsersToUser("nonexisting", 9, cascadeCreate: true),
41-
new RecommendUsersToUser("nonexisting2", 9, cascadeCreate: true, expertSettings: new Dictionary<string, object>(){})
43+
new RecommendUsersToUser("nonexisting2", 9, cascadeCreate: true, expertSettings: new Dictionary<string, object>(){}),
44+
new RecommendUsersToUser("nonexisting2", 9, cascadeCreate: true, reqlExpressions: new Dictionary<string, string>(){{"boolean","true"}, {"number","if ('answer' > 0) then 1 else 2"}, {"string","\"test\""}})
4245
};
4346

4447
BatchResponse batchResponse = await client.SendAsync(new Batch(requests));
4548
Assert.Equal(200, (int)batchResponse.StatusCodes.ElementAt(0));
4649
Assert.Equal(200, (int)batchResponse.StatusCodes.ElementAt(1));
4750
Assert.Equal(200, (int)batchResponse.StatusCodes.ElementAt(2));
51+
Assert.Equal(200, (int)batchResponse.StatusCodes.ElementAt(3));
4852
}
4953
}
5054
}

Src/Recombee.ApiClient.Tests/RecommendUsersToUserUnitTest.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ public void TestRecommendUsersToUser()
2727
resp = client.Send(new RecommendUsersToUser("nonexisting", 9, cascadeCreate: true));
2828
// it 'recommends with expert settings'
2929
resp = client.Send(new RecommendUsersToUser("nonexisting2", 9, cascadeCreate: true, expertSettings: new Dictionary<string, object>(){}));
30+
// it 'recommends with reql expressions'
31+
resp = client.Send(new RecommendUsersToUser("nonexisting2", 9, cascadeCreate: true, reqlExpressions: new Dictionary<string, string>(){{"boolean","true"}, {"number","if ('answer' > 0) then 1 else 2"}, {"string","\"test\""}}));
3032
}
3133

3234
[Fact]
@@ -41,6 +43,8 @@ public async void TestRecommendUsersToUserAsync()
4143
resp = await client.SendAsync(new RecommendUsersToUser("nonexisting", 9, cascadeCreate: true));
4244
// it 'recommends with expert settings'
4345
resp = await client.SendAsync(new RecommendUsersToUser("nonexisting2", 9, cascadeCreate: true, expertSettings: new Dictionary<string, object>(){}));
46+
// it 'recommends with reql expressions'
47+
resp = await client.SendAsync(new RecommendUsersToUser("nonexisting2", 9, cascadeCreate: true, reqlExpressions: new Dictionary<string, string>(){{"boolean","true"}, {"number","if ('answer' > 0) then 1 else 2"}, {"string","\"test\""}}));
4448
}
4549
}
4650
}

Src/Recombee.ApiClient/ApiRequests/AddDetailView.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ public Dictionary<string, object> AdditionalData
5858
{
5959
get {return additionalData;}
6060
}
61+
private readonly bool? autoPresented;
62+
/// <summary>Indicates whether the item was automatically presented to the user (e.g., in a swiping feed) or explicitly requested by the user (e.g., by clicking on a link). Defaults to `false`.</summary>
63+
public bool? AutoPresented
64+
{
65+
get {return autoPresented;}
66+
}
6167

6268
/// <summary>Construct the request</summary>
6369
/// <param name="userId">User who viewed the item</param>
@@ -67,7 +73,8 @@ public Dictionary<string, object> AdditionalData
6773
/// <param name="cascadeCreate">Sets whether the given user/item should be created if not present in the database.</param>
6874
/// <param name="recommId">If this detail view is based on a recommendation request, `recommId` is the id of the clicked recommendation.</param>
6975
/// <param name="additionalData">A dictionary of additional data for the interaction.</param>
70-
public AddDetailView (string userId, string itemId, DateTime? timestamp = null, long? duration = null, bool? cascadeCreate = null, string recommId = null, Dictionary<string, object> additionalData = null): base(HttpMethod.Post, 3000)
76+
/// <param name="autoPresented">Indicates whether the item was automatically presented to the user (e.g., in a swiping feed) or explicitly requested by the user (e.g., by clicking on a link). Defaults to `false`.</param>
77+
public AddDetailView (string userId, string itemId, DateTime? timestamp = null, long? duration = null, bool? cascadeCreate = null, string recommId = null, Dictionary<string, object> additionalData = null, bool? autoPresented = null): base(HttpMethod.Post, 3000)
7178
{
7279
this.userId = userId;
7380
this.itemId = itemId;
@@ -76,6 +83,7 @@ public AddDetailView (string userId, string itemId, DateTime? timestamp = null,
7683
this.cascadeCreate = cascadeCreate;
7784
this.recommId = recommId;
7885
this.additionalData = additionalData;
86+
this.autoPresented = autoPresented;
7987
}
8088

8189
/// <returns>URI to the endpoint including path parameters</returns>
@@ -114,6 +122,8 @@ public override Dictionary<string, object> BodyParameters()
114122
parameters["recommId"] = this.RecommId;
115123
if (this.AdditionalData != null)
116124
parameters["additionalData"] = this.AdditionalData;
125+
if (this.AutoPresented.HasValue)
126+
parameters["autoPresented"] = this.AutoPresented.Value;
117127
return parameters;
118128
}
119129

0 commit comments

Comments
 (0)