Skip to content

Commit 18434ae

Browse files
fix(specs): consequence is required when saving rules (generated)
algolia/api-clients-automation#4146 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Clément Vannicatte <[email protected]>
1 parent bdce764 commit 18434ae

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Sources/Search/Models/Rule.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public struct Rule: Codable, JSONEncodable {
1414
/// For more information, see
1515
/// [Conditions](https://www.algolia.com/doc/guides/managing-results/rules/rules-overview/#conditions).
1616
public var conditions: [SearchCondition]?
17-
public var consequence: SearchConsequence?
17+
public var consequence: SearchConsequence
1818
/// Description of the rule's purpose to help you distinguish between different rules.
1919
public var description: String?
2020
/// Whether the rule is active.
@@ -25,7 +25,7 @@ public struct Rule: Codable, JSONEncodable {
2525
public init(
2626
objectID: String,
2727
conditions: [SearchCondition]? = nil,
28-
consequence: SearchConsequence? = nil,
28+
consequence: SearchConsequence,
2929
description: String? = nil,
3030
enabled: Bool? = nil,
3131
validity: [SearchTimeRange]? = nil
@@ -53,7 +53,7 @@ public struct Rule: Codable, JSONEncodable {
5353
var container = encoder.container(keyedBy: CodingKeys.self)
5454
try container.encode(self.objectID, forKey: .objectID)
5555
try container.encodeIfPresent(self.conditions, forKey: .conditions)
56-
try container.encodeIfPresent(self.consequence, forKey: .consequence)
56+
try container.encode(self.consequence, forKey: .consequence)
5757
try container.encodeIfPresent(self.description, forKey: .description)
5858
try container.encodeIfPresent(self.enabled, forKey: .enabled)
5959
try container.encodeIfPresent(self.validity, forKey: .validity)
@@ -75,7 +75,7 @@ extension Rule: Hashable {
7575
public func hash(into hasher: inout Hasher) {
7676
hasher.combine(self.objectID.hashValue)
7777
hasher.combine(self.conditions?.hashValue)
78-
hasher.combine(self.consequence?.hashValue)
78+
hasher.combine(self.consequence.hashValue)
7979
hasher.combine(self.description?.hashValue)
8080
hasher.combine(self.enabled?.hashValue)
8181
hasher.combine(self.validity?.hashValue)

0 commit comments

Comments
 (0)