Skip to content

Commit 326adce

Browse files
wip: included and excluded flags updated to required
1 parent a732fdb commit 326adce

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

Sources/Data Model/Holdout.swift

+19-2
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,32 @@ struct Holdout: Codable, ExperimentCore {
3232
var trafficAllocation: [TrafficAllocation]
3333
var audienceIds: [String]
3434
var audienceConditions: ConditionHolder?
35-
var includedFlags: [String]?
36-
var excludedFlags: [String]?
35+
var includedFlags: [String]
36+
var excludedFlags: [String]
3737

3838
enum CodingKeys: String, CodingKey {
3939
case id, key, status, layerId, variations, trafficAllocation, audienceIds, audienceConditions, includedFlags, excludedFlags
4040
}
4141

4242
// replace with serialized string representation with audience names when ProjectConfig is ready
4343
var audiences: String = ""
44+
45+
46+
init(from decoder: Decoder) throws {
47+
let container = try decoder.container(keyedBy: CodingKeys.self)
48+
49+
id = try container.decode(String.self, forKey: .id)
50+
key = try container.decode(String.self, forKey: .key)
51+
status = try container.decode(Status.self, forKey: .status)
52+
layerId = try container.decode(String.self, forKey: .layerId)
53+
variations = try container.decode([Variation].self, forKey: .variations)
54+
trafficAllocation = try container.decode([TrafficAllocation].self, forKey: .trafficAllocation)
55+
audienceIds = try container.decode([String].self, forKey: .audienceIds)
56+
audienceConditions = try container.decodeIfPresent(ConditionHolder.self, forKey: .audienceConditions)
57+
58+
includedFlags = try container.decodeIfPresent([String].self, forKey: .includedFlags) ?? []
59+
excludedFlags = try container.decodeIfPresent([String].self, forKey: .excludedFlags) ?? []
60+
}
4461
}
4562

4663
extension Holdout: Equatable {

0 commit comments

Comments
 (0)