@@ -75,6 +75,34 @@ class DefaultSplitMethodParser: SplitMethodParser {
7575 splits: argumentParser. getStringListArgument ( argumentName: . splitName, arguments: arguments) ,
7676 attributes: argumentParser. getMapArgument ( argumentName: . attributes, arguments: arguments) as [ String : Any ] ) )
7777 break
78+ case . getTreatmentsByFlagSet:
79+ result ( getTreatmentsByFlagSet (
80+ matchingKey: argumentParser. getStringArgument ( argumentName: . matchingKey, arguments: arguments) ?? " " ,
81+ bucketingKey: argumentParser. getStringArgument ( argumentName: . bucketingKey, arguments: arguments) ,
82+ flagSet: argumentParser. getStringArgument ( argumentName: . flagSet, arguments: arguments) ?? " " ,
83+ attributes: argumentParser. getMapArgument ( argumentName: . attributes, arguments: arguments) as [ String : Any ] ) )
84+ break
85+ case . getTreatmentsByFlagSets:
86+ result ( getTreatmentsByFlagSets (
87+ matchingKey: argumentParser. getStringArgument ( argumentName: . matchingKey, arguments: arguments) ?? " " ,
88+ bucketingKey: argumentParser. getStringArgument ( argumentName: . bucketingKey, arguments: arguments) ,
89+ flagSets: argumentParser. getStringListArgument ( argumentName: . flagSets, arguments: arguments) ,
90+ attributes: argumentParser. getMapArgument ( argumentName: . attributes, arguments: arguments) as [ String : Any ] ) )
91+ break
92+ case . getTreatmentsWithConfigByFlagSet:
93+ result ( getTreatmentsWithConfigByFlagSet (
94+ matchingKey: argumentParser. getStringArgument ( argumentName: . matchingKey, arguments: arguments) ?? " " ,
95+ bucketingKey: argumentParser. getStringArgument ( argumentName: . bucketingKey, arguments: arguments) ,
96+ flagSet: argumentParser. getStringArgument ( argumentName: . flagSet, arguments: arguments) ?? " " ,
97+ attributes: argumentParser. getMapArgument ( argumentName: . attributes, arguments: arguments) as [ String : Any ] ) )
98+ break
99+ case . getTreatmentsWithConfigByFlagSets:
100+ result ( getTreatmentsWithConfigByFlagSets (
101+ matchingKey: argumentParser. getStringArgument ( argumentName: . matchingKey, arguments: arguments) ?? " " ,
102+ bucketingKey: argumentParser. getStringArgument ( argumentName: . bucketingKey, arguments: arguments) ,
103+ flagSets: argumentParser. getStringListArgument ( argumentName: . flagSets, arguments: arguments) ,
104+ attributes: argumentParser. getMapArgument ( argumentName: . attributes, arguments: arguments) as [ String : Any ] ) )
105+ break
78106 case . track:
79107 result ( track ( matchingKey: argumentParser. getStringArgument ( argumentName: . matchingKey, arguments: arguments) ?? " " ,
80108 bucketingKey: argumentParser. getStringArgument ( argumentName: . bucketingKey, arguments: arguments) ,
@@ -215,6 +243,50 @@ class DefaultSplitMethodParser: SplitMethodParser {
215243 }
216244 }
217245
246+ private func getTreatmentsByFlagSet( matchingKey: String , bucketingKey: String ? = nil , flagSet: String , attributes: [ String : Any ] ? = [ : ] ) -> [ String : String ] {
247+ guard let splitWrapper = getSplitWrapper ( ) else {
248+ return [ : ]
249+ }
250+
251+ let treatments = splitWrapper. getTreatmentsByFlagSet ( matchingKey: matchingKey, flagSet: flagSet, bucketingKey: bucketingKey, attributes: attributes)
252+
253+ return treatments
254+ }
255+
256+ private func getTreatmentsByFlagSets( matchingKey: String , bucketingKey: String ? = nil , flagSets: [ String ] , attributes: [ String : Any ] ? = [ : ] ) -> [ String : String ] {
257+ guard let splitWrapper = getSplitWrapper ( ) else {
258+ return [ : ]
259+ }
260+
261+ let treatments = splitWrapper. getTreatmentsByFlagSets ( matchingKey: matchingKey, flagSets: flagSets, bucketingKey: bucketingKey, attributes: attributes)
262+
263+ return treatments
264+ }
265+
266+ private func getTreatmentsWithConfigByFlagSet( matchingKey: String , bucketingKey: String ? = nil , flagSet: String , attributes: [ String : Any ] ? = [ : ] ) -> [ String : [ String : String ? ] ] {
267+ guard let splitWrapper = getSplitWrapper ( ) else {
268+ return [ : ]
269+ }
270+
271+ let treatments = splitWrapper. getTreatmentsWithConfigByFlagSet ( matchingKey: matchingKey, flagSet: flagSet, bucketingKey: bucketingKey, attributes: attributes)
272+
273+ return treatments. mapValues {
274+ [ " treatment " : $0. treatment, " config " : $0. config]
275+ }
276+ }
277+
278+ private func getTreatmentsWithConfigByFlagSets( matchingKey: String , bucketingKey: String ? = nil , flagSets: [ String ] , attributes: [ String : Any ] ? = [ : ] ) -> [ String : [ String : String ? ] ] {
279+ guard let splitWrapper = getSplitWrapper ( ) else {
280+ return [ : ]
281+ }
282+
283+ let treatments = splitWrapper. getTreatmentsWithConfigByFlagSets ( matchingKey: matchingKey, flagSets: flagSets, bucketingKey: bucketingKey, attributes: attributes)
284+
285+ return treatments. mapValues {
286+ [ " treatment " : $0. treatment, " config " : $0. config]
287+ }
288+ }
289+
218290 private func track( matchingKey: String , bucketingKey: String ? = nil , eventType: String , trafficType: String ? = nil , value: Double ? = nil , properties: [ String : Any ? ] ) -> Bool {
219291 guard let splitWrapper = getSplitWrapper ( ) else {
220292 return false
@@ -320,18 +392,4 @@ class DefaultSplitMethodParser: SplitMethodParser {
320392
321393 return splitWrapper
322394 }
323-
324- private func getSplitViewAsMap( splitView: SplitView ? ) -> [ String : Any ? ] {
325- if let splitView = splitView {
326- return [
327- " name " : splitView. name,
328- " trafficType " : splitView. trafficType,
329- " killed " : splitView. killed,
330- " treatments " : splitView. treatments,
331- " changeNumber " : splitView. changeNumber,
332- " configs " : splitView. configs]
333- } else {
334- return [ : ]
335- }
336- }
337395}
0 commit comments