Skip to content

Commit

Permalink
feat(rule): implement multi-condition rules
Browse files Browse the repository at this point in the history
  • Loading branch information
aseure committed Jul 15, 2020
1 parent a32ba59 commit dfe6daa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Algolia.Search.Test/EndToEnd/Index/QueryRulesTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,15 @@ public async Task RulesTest()
Rule ruleToSave2 = new Rule
{
ObjectID = "query_edits",
Condition =
Conditions = new List<Condition>
{
new Condition
{
Anchoring = "is",
Pattern = "mobile phone",
Alternatives = Alternatives.Of(true)
},
},
Consequence = new Consequence
{
Params = new ConsequenceParams
Expand Down
7 changes: 7 additions & 0 deletions src/Algolia.Search/Models/Rules/Rule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* THE SOFTWARE.
*/

using System;
using System.Collections.Generic;

namespace Algolia.Search.Models.Rules
Expand All @@ -38,8 +39,14 @@ public class Rule
/// <summary>
/// Condition of the rule, expressed using the following variables: pattern, anchoring, context.
/// </summary>
[Obsolete("Single condition is deprecated, use Conditions (plural) which accept one or more condition(s).")]
public Condition Condition { get; set; }

/// <summary>
/// Conditions of the rule, which can be used to apply more than a single condition to the Rule.
/// </summary>
public List<Condition> Conditions { get; set; }

/// <summary>
/// Consequence of the rule. At least one of the following object must be used: params, promote, hide, userData
/// </summary>
Expand Down

0 comments on commit dfe6daa

Please sign in to comment.