Skip to content

Commit

Permalink
deprecates: legacy personalization endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Ant-hem committed Jan 30, 2020
1 parent a2240ad commit 2048442
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 25 deletions.
25 changes: 0 additions & 25 deletions src/Algolia.Search.Test/Serializer/SerializerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -644,31 +644,6 @@ public void TestIndexSettingsWithCustomParameters()
Assert.AreEqual(json, "{\"enableRules\":true,\"newParameter\":10}");
}

[Test]
[Parallelizable]
public void TestPersonalization()
{
var strategyToSave = new SetStrategyRequest
{
EventsScoring = new Dictionary<string, EventScoring>
{
{ "Add to cart", new EventScoring { Score = 50, Type = "conversion" } },
{ "Purchase", new EventScoring { Score = 100, Type = "conversion" } }
},
FacetsScoring = new Dictionary<string, FacetScoring>
{
{ "brand", new FacetScoring { Score = 100 } },
{ "categories", new FacetScoring { Score = 10 } }
}
};

// Here we test the payload, as this settings are at app level all tests could overlap
string json = JsonConvert.SerializeObject(strategyToSave, JsonConfig.AlgoliaJsonSerializerSettings);
string expectedJson =
"{\"eventsScoring\":{\"Add to cart\":{\"type\":\"conversion\",\"score\":50},\"Purchase\":{\"type\":\"conversion\",\"score\":100}},\"facetsScoring\":{\"brand\":{\"score\":100},\"categories\":{\"score\":10}}}";
Assert.True(json.Equals(expectedJson));
}

[Test]
[Parallelizable]
public void TestListIndicesResponses64BitsIntegers()
Expand Down
4 changes: 4 additions & 0 deletions src/Algolia.Search/Clients/ISearchClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -536,13 +536,15 @@ public interface ISearchClient
/// </summary>
/// <param name="requestOptions"></param>
/// <returns></returns>
[Obsolete("Endpoint will be deprecated, please use RecommendationClient instead.")]
GetStrategyResponse GetPersonalizationStrategy(RequestOptions requestOptions = null);

/// <summary>
/// Returns the personalization strategy of the application
/// </summary>
/// <param name="requestOptions"></param>
/// <param name="ct">Optional cancellation token</param>
[Obsolete("Endpoint will be deprecated, please use RecommendationClient instead.")]
Task<GetStrategyResponse> GetPersonalizationStrategyAsync(RequestOptions requestOptions = null,
CancellationToken ct = default);

Expand All @@ -552,6 +554,7 @@ public interface ISearchClient
/// <param name="request">The personalization strategy</param>
/// <param name="requestOptions">Request options for the query</param>
/// <returns></returns>
[Obsolete("Endpoint will be deprecated, please use RecommendationClient instead.")]
SetStrategyResponse
SetPersonalizationStrategy(SetStrategyRequest request, RequestOptions requestOptions = null);

Expand All @@ -562,6 +565,7 @@ public interface ISearchClient
/// <param name="requestOptions">Request options for the query</param>
/// <param name="ct">Request options for the query</param>
/// <returns></returns>
[Obsolete("Endpoint will be deprecated, please use RecommendationClient instead.")]
Task<SetStrategyResponse> SetPersonalizationStrategyAsync(SetStrategyRequest request,
RequestOptions requestOptions = null, CancellationToken ct = default);

Expand Down
4 changes: 4 additions & 0 deletions src/Algolia.Search/Clients/SearchClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -677,10 +677,12 @@ public AssignUserIdResponse
}

/// <inheritdoc />
[Obsolete("Endpoint will be deprecated, please use RecommendationClient instead.")]
public GetStrategyResponse GetPersonalizationStrategy(RequestOptions requestOptions = null) =>
AsyncHelper.RunSync(() => GetPersonalizationStrategyAsync(requestOptions));

/// <inheritdoc />
[Obsolete("Endpoint will be deprecated, please use RecommendationClient instead.")]
public async Task<GetStrategyResponse> GetPersonalizationStrategyAsync(RequestOptions requestOptions = null,
CancellationToken ct = default)
{
Expand All @@ -691,11 +693,13 @@ public AssignUserIdResponse
}

/// <inheritdoc />
[Obsolete("Endpoint will be deprecated, please use RecommendationClient instead.")]
public SetStrategyResponse SetPersonalizationStrategy(SetStrategyRequest request,
RequestOptions requestOptions = null) =>
AsyncHelper.RunSync(() => SetPersonalizationStrategyAsync(request, requestOptions));

/// <inheritdoc />
[Obsolete("Endpoint will be deprecated, please use RecommendationClient instead.")]
public async Task<SetStrategyResponse> SetPersonalizationStrategyAsync(SetStrategyRequest request,
RequestOptions requestOptions = null, CancellationToken ct = default)
{
Expand Down
3 changes: 3 additions & 0 deletions src/Algolia.Search/Models/Personalization/EventScoring.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@
* THE SOFTWARE.
*/

using System;

namespace Algolia.Search.Models.Personalization
{
/// <summary>
///
/// </summary>
[Obsolete("Models are deprecated please use models located in Algolia.Search.Models.Recommendation.")]
public class EventScoring
{
/// <summary>
Expand Down
3 changes: 3 additions & 0 deletions src/Algolia.Search/Models/Personalization/FacetScoring.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@
* THE SOFTWARE.
*/

using System;

namespace Algolia.Search.Models.Personalization
{
/// <summary>
///
/// </summary>
[Obsolete("Models are deprecated please use models located in Algolia.Search.Models.Recommendation.")]
public class FacetScoring
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@
* THE SOFTWARE.
*/

using System;
using System.Collections.Generic;

namespace Algolia.Search.Models.Personalization
{
/// <summary>
/// Get personalization strategy response
/// </summary>
[Obsolete("Models are deprecated please use models located in Algolia.Search.Models.Recommendation.")]
public class GetStrategyResponse
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@
* THE SOFTWARE.
*/

using System;
using System.Collections.Generic;

namespace Algolia.Search.Models.Personalization
{
/// <summary>
/// Set personalization strategy request
/// </summary>
[Obsolete("Models are deprecated please use models located in Algolia.Search.Models.Recommendation.")]
public class SetStrategyRequest
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace Algolia.Search.Models.Personalization
/// <summary>
/// Set strategy response
/// </summary>
[Obsolete("Models are deprecated please use models located in Algolia.Search.Models.Recommendation.")]
public class SetStrategyResponse
{
/// <summary>
Expand Down

0 comments on commit 2048442

Please sign in to comment.