Skip to content

Commit bfb46d1

Browse files
algolia-botmillotp
andcommitted
fix(specs): allow one sided rule validity (generated)
algolia/api-clients-automation#5060 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Pierre Millot <[email protected]>
1 parent a578e18 commit bfb46d1

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

Sources/Recommend/Models/RecommendTimeRange.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import Foundation
88

99
public struct RecommendTimeRange: Codable, JSONEncodable {
1010
/// When the rule should start to be active, in Unix epoch time.
11-
public var from: Int64
11+
public var from: Int64?
1212
/// When the rule should stop to be active, in Unix epoch time.
13-
public var until: Int64
13+
public var until: Int64?
1414

15-
public init(from: Int64, until: Int64) {
15+
public init(from: Int64? = nil, until: Int64? = nil) {
1616
self.from = from
1717
self.until = until
1818
}
@@ -26,8 +26,8 @@ public struct RecommendTimeRange: Codable, JSONEncodable {
2626

2727
public func encode(to encoder: Encoder) throws {
2828
var container = encoder.container(keyedBy: CodingKeys.self)
29-
try container.encode(self.from, forKey: .from)
30-
try container.encode(self.until, forKey: .until)
29+
try container.encodeIfPresent(self.from, forKey: .from)
30+
try container.encodeIfPresent(self.until, forKey: .until)
3131
}
3232
}
3333

@@ -40,7 +40,7 @@ extension RecommendTimeRange: Equatable {
4040

4141
extension RecommendTimeRange: Hashable {
4242
public func hash(into hasher: inout Hasher) {
43-
hasher.combine(self.from.hashValue)
44-
hasher.combine(self.until.hashValue)
43+
hasher.combine(self.from?.hashValue)
44+
hasher.combine(self.until?.hashValue)
4545
}
4646
}

Sources/Search/Models/SearchTimeRange.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import Foundation
88

99
public struct SearchTimeRange: Codable, JSONEncodable {
1010
/// When the rule should start to be active, in Unix epoch time.
11-
public var from: Int64
11+
public var from: Int64?
1212
/// When the rule should stop to be active, in Unix epoch time.
13-
public var until: Int64
13+
public var until: Int64?
1414

15-
public init(from: Int64, until: Int64) {
15+
public init(from: Int64? = nil, until: Int64? = nil) {
1616
self.from = from
1717
self.until = until
1818
}
@@ -26,8 +26,8 @@ public struct SearchTimeRange: Codable, JSONEncodable {
2626

2727
public func encode(to encoder: Encoder) throws {
2828
var container = encoder.container(keyedBy: CodingKeys.self)
29-
try container.encode(self.from, forKey: .from)
30-
try container.encode(self.until, forKey: .until)
29+
try container.encodeIfPresent(self.from, forKey: .from)
30+
try container.encodeIfPresent(self.until, forKey: .until)
3131
}
3232
}
3333

@@ -40,7 +40,7 @@ extension SearchTimeRange: Equatable {
4040

4141
extension SearchTimeRange: Hashable {
4242
public func hash(into hasher: inout Hasher) {
43-
hasher.combine(self.from.hashValue)
44-
hasher.combine(self.until.hashValue)
43+
hasher.combine(self.from?.hashValue)
44+
hasher.combine(self.until?.hashValue)
4545
}
4646
}

0 commit comments

Comments
 (0)