Skip to content

Commit

Permalink
Support setting the region of your DB. Added Update / Delete More Ite…
Browse files Browse the repository at this point in the history
…ms endpoints.

Removed deprecated endpoints Item Based Recommendation and User Based Recommendation.
  • Loading branch information
OndraFiedler committed Apr 20, 2022
1 parent a794ac0 commit 4ee8200
Show file tree
Hide file tree
Showing 23 changed files with 582 additions and 901 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ using System.Linq;
using Recombee.ApiClient;
using Recombee.ApiClient.ApiRequests;
using Recombee.ApiClient.Bindings;
using Recombee.ApiClient.Util;

public class BasicExample
{
static int Main(string[] args)
{
RecombeeClient client = new RecombeeClient("--my-database-id--", "--db-private-token--");
RecombeeClient client = new RecombeeClient("--my-database-id--", "--db-private-token--", region: Region.UsWest);

try
{
Expand Down Expand Up @@ -86,12 +87,13 @@ using System.Linq;
using Recombee.ApiClient;
using Recombee.ApiClient.ApiRequests;
using Recombee.ApiClient.Bindings;
using Recombee.ApiClient.Util;

public class PropertiesExample
{
static async Task<int> Main(string[] args)
{
RecombeeClient client = new RecombeeClient("--my-database-id--", "--db-private-token--");
RecombeeClient client = new RecombeeClient("--my-database-id--", "--db-private-token--", region: Region.ApSe);

/*
We will use computers as items in this example
Expand Down
46 changes: 46 additions & 0 deletions Src/Recombee.ApiClient.Tests/DeleteMoreItemsBatchUnitTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
This file is auto-generated, do not edit
*/


using System;
using System.Collections.Generic;
using System.Linq;
using Xunit;
using Recombee.ApiClient.ApiRequests;
using Recombee.ApiClient.Bindings;

namespace Recombee.ApiClient.Tests
{
public class DeleteMoreItemsBatchUnitTest: RecombeeUnitTest
{

[Fact]
public void TestDeleteMoreItems()
{
Object resp2;
Request[] requests = new Request[] {
new DeleteMoreItems("'int_property' == 42")
};

BatchResponse batchResponse = client.Send(new Batch(requests));
Assert.Equal(200, (int)batchResponse.StatusCodes.ElementAt(0));
Assert.Equal(1, ((DeleteMoreItemsResponse) batchResponse[0]).ItemIds.Count());
Assert.Equal (1,((DeleteMoreItemsResponse) batchResponse[0]).Count);
}

[Fact]
public async void TestDeleteMoreItemsAsync()
{
Object resp2;
Request[] requests = new Request[] {
new DeleteMoreItems("'int_property' == 42")
};

BatchResponse batchResponse = await client.SendAsync(new Batch(requests));
Assert.Equal(200, (int)batchResponse.StatusCodes.ElementAt(0));
Assert.Equal(1, ((DeleteMoreItemsResponse) batchResponse[0]).ItemIds.Count());
Assert.Equal (1,((DeleteMoreItemsResponse) batchResponse[0]).Count);
}
}
}
42 changes: 42 additions & 0 deletions Src/Recombee.ApiClient.Tests/DeleteMoreItemsUnitTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
This file is auto-generated, do not edit
*/


using System;
using System.Collections.Generic;
using System.Linq;
using Xunit;
using Recombee.ApiClient.ApiRequests;
using Recombee.ApiClient.Bindings;

namespace Recombee.ApiClient.Tests
{
public class DeleteMoreItemsUnitTest: RecombeeUnitTest
{

[Fact]
public void TestDeleteMoreItems()
{
DeleteMoreItems req;
DeleteMoreItemsResponse resp;
Object resp2;
// it 'deletes more items'
resp = client.Send(new DeleteMoreItems("'int_property' == 42"));
Assert.Equal(1, resp.ItemIds.Count());
Assert.Equal (1,resp.Count);
}

[Fact]
public async void TestDeleteMoreItemsAsync()
{
DeleteMoreItems req;
DeleteMoreItemsResponse resp;
Object resp2;
// it 'deletes more items'
resp = await client.SendAsync(new DeleteMoreItems("'int_property' == 42"));
Assert.Equal(1, resp.ItemIds.Count());
Assert.Equal (1,resp.Count);
}
}
}

This file was deleted.

72 changes: 0 additions & 72 deletions Src/Recombee.ApiClient.Tests/ItemBasedRecommendationUnitTest.cs

This file was deleted.

3 changes: 2 additions & 1 deletion Src/Recombee.ApiClient.Tests/RecombeeUnitTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using Recombee.ApiClient.ApiRequests;
using Recombee.ApiClient.Util;
using Xunit;

[assembly: CollectionBehavior(DisableTestParallelization = true)]
Expand All @@ -13,7 +14,7 @@ public class RecombeeUnitTest

public RecombeeUnitTest()
{
client = new RecombeeClient("client-test", "jGGQ6ZKa8rQ1zTAyxTc0EMn55YPF7FJLUtaMLhbsGxmvwxgTwXYqmUk5xVZFw98L");
client = new RecombeeClient("client-test", "jGGQ6ZKa8rQ1zTAyxTc0EMn55YPF7FJLUtaMLhbsGxmvwxgTwXYqmUk5xVZFw98L", region: Region.EuWest);
client.Send(new ResetDatabase());
while (true)
{
Expand Down
46 changes: 46 additions & 0 deletions Src/Recombee.ApiClient.Tests/UpdateMoreItemsBatchUnitTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
This file is auto-generated, do not edit
*/


using System;
using System.Collections.Generic;
using System.Linq;
using Xunit;
using Recombee.ApiClient.ApiRequests;
using Recombee.ApiClient.Bindings;

namespace Recombee.ApiClient.Tests
{
public class UpdateMoreItemsBatchUnitTest: RecombeeUnitTest
{

[Fact]
public void TestUpdateMoreItems()
{
Object resp2;
Request[] requests = new Request[] {
new UpdateMoreItems("'int_property' == 42", new Dictionary<string, object>(){{"int_property",77}})
};

BatchResponse batchResponse = client.Send(new Batch(requests));
Assert.Equal(200, (int)batchResponse.StatusCodes.ElementAt(0));
Assert.Equal(1, ((UpdateMoreItemsResponse) batchResponse[0]).ItemIds.Count());
Assert.Equal (1,((UpdateMoreItemsResponse) batchResponse[0]).Count);
}

[Fact]
public async void TestUpdateMoreItemsAsync()
{
Object resp2;
Request[] requests = new Request[] {
new UpdateMoreItems("'int_property' == 42", new Dictionary<string, object>(){{"int_property",77}})
};

BatchResponse batchResponse = await client.SendAsync(new Batch(requests));
Assert.Equal(200, (int)batchResponse.StatusCodes.ElementAt(0));
Assert.Equal(1, ((UpdateMoreItemsResponse) batchResponse[0]).ItemIds.Count());
Assert.Equal (1,((UpdateMoreItemsResponse) batchResponse[0]).Count);
}
}
}
42 changes: 42 additions & 0 deletions Src/Recombee.ApiClient.Tests/UpdateMoreItemsUnitTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
This file is auto-generated, do not edit
*/


using System;
using System.Collections.Generic;
using System.Linq;
using Xunit;
using Recombee.ApiClient.ApiRequests;
using Recombee.ApiClient.Bindings;

namespace Recombee.ApiClient.Tests
{
public class UpdateMoreItemsUnitTest: RecombeeUnitTest
{

[Fact]
public void TestUpdateMoreItems()
{
UpdateMoreItems req;
UpdateMoreItemsResponse resp;
Object resp2;
// it 'updates more items'
resp = client.Send(new UpdateMoreItems("'int_property' == 42", new Dictionary<string, object>(){{"int_property",77}}));
Assert.Equal(1, resp.ItemIds.Count());
Assert.Equal (1,resp.Count);
}

[Fact]
public async void TestUpdateMoreItemsAsync()
{
UpdateMoreItems req;
UpdateMoreItemsResponse resp;
Object resp2;
// it 'updates more items'
resp = await client.SendAsync(new UpdateMoreItems("'int_property' == 42", new Dictionary<string, object>(){{"int_property",77}}));
Assert.Equal(1, resp.ItemIds.Count());
Assert.Equal (1,resp.Count);
}
}
}
Loading

0 comments on commit 4ee8200

Please sign in to comment.