Skip to content

Commit db72170

Browse files
feat (audience match types): Condition evaluator, Audience combination and Project Config PRs consolidation. (#351)
* Type changed to NSObject & a test case added * added all type attributes in Optimizely and EventBuilder test cases * attribute filtering in EventBuilder only * missing types added in attribute filtration * Added unit test in decision service and Notification Center to support all type of attributes. One more unit test fixed. For NSNull and Any object other than NSNumber. * null support for attributes & eventTags Notification Center PR. * Nullable attribute and eventTags activate listener and track listener * Generic listener and sendNotifications should have NSDictionary. * feat (audience match types): Update condition evaluator for new audience match types * Updates license * Addresses Review * feat (audience match types): Update audience evaluator and project config for new audience match types * Refact: If no attributes, defaults to empty attributes * Addressed Code Review comments. * 1. Merge branch 'sohail/null-attribute-support' into yasir/audience-match-type-evaluator/ 2. Fix code indentation. * null support for attributes & eventTags Notification Center PR. * Nullable attribute and eventTags activate listener and track listener * Generic listener and sendNotifications should have NSDictionary. * Addressed Code Review comments. * Minor conflicts resolved. * refact(conditions in typed audiences) - convert from str to array * Addressed code review comments. * Addressed code review comments. * Addressed code review comments * feat (audience match types): Update condition evaluator for new audience match types. (#336) * Type changed to NSObject & a test case added * added all type attributes in Optimizely and EventBuilder test cases * attribute filtering in EventBuilder only * missing types added in attribute filtration * Added unit test in decision service and Notification Center to support all type of attributes. One more unit test fixed. For NSNull and Any object other than NSNumber. * null support for attributes & eventTags Notification Center PR. * Nullable attribute and eventTags activate listener and track listener * Generic listener and sendNotifications should have NSDictionary. * feat (audience match types): Update condition evaluator for new audience match types * Updates license * Addresses Review * Addressed Code Review comments. * 1. Merge branch 'sohail/null-attribute-support' into yasir/audience-match-type-evaluator/ 2. Fix code indentation. * Addressed code review comments. * Array issue in swift fixed. * typo corrected. * feat (audience match types): Update audience evaluator and project config for new audience match types (#337) * Type changed to NSObject & a test case added * added all type attributes in Optimizely and EventBuilder test cases * attribute filtering in EventBuilder only * missing types added in attribute filtration * Added unit test in decision service and Notification Center to support all type of attributes. One more unit test fixed. For NSNull and Any object other than NSNumber. * null support for attributes & eventTags Notification Center PR. * Nullable attribute and eventTags activate listener and track listener * Generic listener and sendNotifications should have NSDictionary. * feat (audience match types): Update condition evaluator for new audience match types * Updates license * Addresses Review * feat (audience match types): Update audience evaluator and project config for new audience match types * Refact: If no attributes, defaults to empty attributes * Addressed Code Review comments. * 1. Merge branch 'sohail/null-attribute-support' into yasir/audience-match-type-evaluator/ 2. Fix code indentation. * refact(conditions in typed audiences) - convert from str to array * Addressed code review comments. * Addressed code review comments. * Addressed code review comments * Array issue in swift fixed. * typo corrected. * feat(audience-evaluation) : add support for complex audiences (#343) * Headers updated. * Target Membership Updated for OPTLYAudienceBaseCondition. * Import Headers updated for SDKCore. * TVOS fix for AudienceBaseCondition.
1 parent 2cf848e commit db72170

File tree

52 files changed

+2563
-302
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2563
-302
lines changed

OptimizelySDKCore/OptimizelySDKCore.xcodeproj/project.pbxproj

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,12 +225,20 @@
225225
90855D0120ED254600A97BEC /* OPTLYControlAttributes.h in Headers */ = {isa = PBXBuildFile; fileRef = 90855CFC20ED237F00A97BEC /* OPTLYControlAttributes.h */; settings = {ATTRIBUTES = (Public, ); }; };
226226
90855D0D20ED2E0100A97BEC /* OPTLYControlAttributes.m in Sources */ = {isa = PBXBuildFile; fileRef = 90855D0420ED2B0200A97BEC /* OPTLYControlAttributes.m */; };
227227
90855D0E20ED2E0300A97BEC /* OPTLYControlAttributes.m in Sources */ = {isa = PBXBuildFile; fileRef = 90855D0420ED2B0200A97BEC /* OPTLYControlAttributes.m */; };
228+
C778BD2521DCDAB500AD38AE /* OPTLYTypedAudienceTest.m in Sources */ = {isa = PBXBuildFile; fileRef = C778BD2421DCDAB500AD38AE /* OPTLYTypedAudienceTest.m */; };
229+
C778BD2621DCDAB500AD38AE /* OPTLYTypedAudienceTest.m in Sources */ = {isa = PBXBuildFile; fileRef = C778BD2421DCDAB500AD38AE /* OPTLYTypedAudienceTest.m */; };
228230
C77958C3219BFBC300B4CA89 /* OPTLYNSObject+Validation.h in Headers */ = {isa = PBXBuildFile; fileRef = C77958C0219BFBA000B4CA89 /* OPTLYNSObject+Validation.h */; };
229231
C77958C4219BFBC400B4CA89 /* OPTLYNSObject+Validation.h in Headers */ = {isa = PBXBuildFile; fileRef = C77958C0219BFBA000B4CA89 /* OPTLYNSObject+Validation.h */; };
230232
C77958C5219BFBC700B4CA89 /* OPTLYNSObject+Validation.m in Sources */ = {isa = PBXBuildFile; fileRef = C77958C1219BFBA000B4CA89 /* OPTLYNSObject+Validation.m */; };
231233
C77958C6219BFBC800B4CA89 /* OPTLYNSObject+Validation.m in Sources */ = {isa = PBXBuildFile; fileRef = C77958C1219BFBA000B4CA89 /* OPTLYNSObject+Validation.m */; };
232-
C7809D1921C11675005725FF /* OPTLYValidationTest.m in Sources */ = {isa = PBXBuildFile; fileRef = C7809D1821C11675005725FF /* OPTLYValidationTest.m */; };
233-
C7809D1A21C11675005725FF /* OPTLYValidationTest.m in Sources */ = {isa = PBXBuildFile; fileRef = C7809D1821C11675005725FF /* OPTLYValidationTest.m */; };
234+
C779881321CBC22A002AAEC8 /* OPTLYValidationTest.m in Sources */ = {isa = PBXBuildFile; fileRef = C779881221CBC22A002AAEC8 /* OPTLYValidationTest.m */; };
235+
C779881421CBC22A002AAEC8 /* OPTLYValidationTest.m in Sources */ = {isa = PBXBuildFile; fileRef = C779881221CBC22A002AAEC8 /* OPTLYValidationTest.m */; };
236+
C78F98B7219ADEA600808062 /* OPTLYAudienceBaseCondition.h in Headers */ = {isa = PBXBuildFile; fileRef = C78F98B4219ADE9600808062 /* OPTLYAudienceBaseCondition.h */; settings = {ATTRIBUTES = (Public, ); }; };
237+
C78F98B8219ADEA700808062 /* OPTLYAudienceBaseCondition.h in Headers */ = {isa = PBXBuildFile; fileRef = C78F98B4219ADE9600808062 /* OPTLYAudienceBaseCondition.h */; settings = {ATTRIBUTES = (Public, ); }; };
238+
C78F98B9219ADEAB00808062 /* OPTLYAudienceBaseCondition.m in Sources */ = {isa = PBXBuildFile; fileRef = C78F98B5219ADE9600808062 /* OPTLYAudienceBaseCondition.m */; };
239+
C78F98BA219ADEAB00808062 /* OPTLYAudienceBaseCondition.m in Sources */ = {isa = PBXBuildFile; fileRef = C78F98B5219ADE9600808062 /* OPTLYAudienceBaseCondition.m */; };
240+
C7ACD4FE218C2E4A008EC52E /* typed_audience_datafile.json in Resources */ = {isa = PBXBuildFile; fileRef = C7ACD4FD218C2E4A008EC52E /* typed_audience_datafile.json */; };
241+
C7ACD4FF218C2E51008EC52E /* typed_audience_datafile.json in Resources */ = {isa = PBXBuildFile; fileRef = C7ACD4FD218C2E4A008EC52E /* typed_audience_datafile.json */; };
234242
EA064BC71DD3FC8800DF7537 /* OPTLYQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = EA064BC51DD3FC8800DF7537 /* OPTLYQueue.h */; settings = {ATTRIBUTES = (Public, ); }; };
235243
EA064BC81DD3FC8800DF7537 /* OPTLYQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = EA064BC51DD3FC8800DF7537 /* OPTLYQueue.h */; settings = {ATTRIBUTES = (Public, ); }; };
236244
EA064BC91DD3FC8800DF7537 /* OPTLYQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = EA064BC61DD3FC8800DF7537 /* OPTLYQueue.m */; };
@@ -635,9 +643,13 @@
635643
A52039FD7B704890859320C4 /* Pods-OptimizelySDKCoreiOSTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OptimizelySDKCoreiOSTests.debug.xcconfig"; path = "../Pods/Target Support Files/Pods-OptimizelySDKCoreiOSTests/Pods-OptimizelySDKCoreiOSTests.debug.xcconfig"; sourceTree = "<group>"; };
636644
B333468714C0D4A8633103EF /* Pods-OptimizelySDKCoreiOSTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OptimizelySDKCoreiOSTests.release.xcconfig"; path = "../Pods/Target Support Files/Pods-OptimizelySDKCoreiOSTests/Pods-OptimizelySDKCoreiOSTests.release.xcconfig"; sourceTree = "<group>"; };
637645
BE0C3BD9DC6186DB98A667C2 /* Pods_OptimizelySDKCoreTVOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_OptimizelySDKCoreTVOS.framework; sourceTree = BUILT_PRODUCTS_DIR; };
646+
C778BD2421DCDAB500AD38AE /* OPTLYTypedAudienceTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OPTLYTypedAudienceTest.m; sourceTree = "<group>"; };
638647
C77958C0219BFBA000B4CA89 /* OPTLYNSObject+Validation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "OPTLYNSObject+Validation.h"; sourceTree = "<group>"; };
639648
C77958C1219BFBA000B4CA89 /* OPTLYNSObject+Validation.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "OPTLYNSObject+Validation.m"; sourceTree = "<group>"; };
640-
C7809D1821C11675005725FF /* OPTLYValidationTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OPTLYValidationTest.m; sourceTree = "<group>"; };
649+
C779881221CBC22A002AAEC8 /* OPTLYValidationTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OPTLYValidationTest.m; sourceTree = "<group>"; };
650+
C78F98B4219ADE9600808062 /* OPTLYAudienceBaseCondition.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OPTLYAudienceBaseCondition.h; sourceTree = "<group>"; };
651+
C78F98B5219ADE9600808062 /* OPTLYAudienceBaseCondition.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OPTLYAudienceBaseCondition.m; sourceTree = "<group>"; };
652+
C7ACD4FD218C2E4A008EC52E /* typed_audience_datafile.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = typed_audience_datafile.json; sourceTree = "<group>"; };
641653
E2E7211C032DF7A75264FDDB /* Pods-OptimizelySDKCoreTVOSTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OptimizelySDKCoreTVOSTests.debug.xcconfig"; path = "../Pods/Target Support Files/Pods-OptimizelySDKCoreTVOSTests/Pods-OptimizelySDKCoreTVOSTests.debug.xcconfig"; sourceTree = "<group>"; };
642654
EA064BC51DD3FC8800DF7537 /* OPTLYQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OPTLYQueue.h; sourceTree = "<group>"; };
643655
EA064BC61DD3FC8800DF7537 /* OPTLYQueue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OPTLYQueue.m; sourceTree = "<group>"; };
@@ -1050,6 +1062,8 @@
10501062
EA2FAA531DC6F57100B1D81B /* OPTLYAttribute.m */,
10511063
EA2FAA541DC6F57100B1D81B /* OPTLYAudience.h */,
10521064
EA2FAA551DC6F57100B1D81B /* OPTLYAudience.m */,
1065+
C78F98B4219ADE9600808062 /* OPTLYAudienceBaseCondition.h */,
1066+
C78F98B5219ADE9600808062 /* OPTLYAudienceBaseCondition.m */,
10531067
EA2FAA561DC6F57100B1D81B /* OPTLYBaseCondition.h */,
10541068
EA2FAA571DC6F57100B1D81B /* OPTLYBaseCondition.m */,
10551069
EA2FAA581DC6F57100B1D81B /* OPTLYCondition.h */,
@@ -1183,6 +1197,7 @@
11831197
EA2FAB941DC6FDFA00B1D81B /* TestData */ = {
11841198
isa = PBXGroup;
11851199
children = (
1200+
C7ACD4FD218C2E4A008EC52E /* typed_audience_datafile.json */,
11861201
EA2FAB951DC6FDFA00B1D81B /* BucketerTestsDatafile.json */,
11871202
3E92800D1F26AD4700214C58 /* BucketerTestsDatafile2.json */,
11881203
5E4C07F21DFF645C0042B1F8 /* UnsupportedVersionDatafile.json */,
@@ -1259,6 +1274,7 @@
12591274
EA2FAB861DC6FDFA00B1D81B /* OptimizelyTest.m */,
12601275
3EEC2B0120CB40ED00D096E4 /* OptimizelyV3Test.m */,
12611276
EA2FAB871DC6FDFA00B1D81B /* OPTLYAudienceTest.m */,
1277+
C778BD2421DCDAB500AD38AE /* OPTLYTypedAudienceTest.m */,
12621278
EA2FAB881DC6FDFA00B1D81B /* OPTLYBucketerTest.m */,
12631279
EA2FAB891DC6FDFA00B1D81B /* OPTLYBuilderTest.m */,
12641280
EA2FAB8A1DC6FDFA00B1D81B /* OPTLYConditionTest.m */,
@@ -1276,7 +1292,7 @@
12761292
EA064BCB1DD3FC9F00DF7537 /* OPTLYQueueTest.m */,
12771293
EA2FAB911DC6FDFA00B1D81B /* OPTLYTestHelper.h */,
12781294
EA2FAB921DC6FDFA00B1D81B /* OPTLYTestHelper.m */,
1279-
C7809D1821C11675005725FF /* OPTLYValidationTest.m */,
1295+
C779881221CBC22A002AAEC8 /* OPTLYValidationTest.m */,
12801296
EA2FAB941DC6FDFA00B1D81B /* TestData */,
12811297
);
12821298
path = OptimizelySDKCoreTests;
@@ -1362,6 +1378,7 @@
13621378
EA2FAAA01DC6F57100B1D81B /* OPTLYDatafileKeys.h in Headers */,
13631379
EA2FAAB21DC6F57200B1D81B /* OPTLYEventAudience.h in Headers */,
13641380
EA2FAA881DC6F57100B1D81B /* OPTLYAttribute.h in Headers */,
1381+
C78F98B7219ADEA600808062 /* OPTLYAudienceBaseCondition.h in Headers */,
13651382
EA2FAAE81DC6F57200B1D81B /* OPTLYEventParameterKeys.h in Headers */,
13661383
EA2FAADC1DC6F57200B1D81B /* OPTLYEventLayerState.h in Headers */,
13671384
EA2FAAEE1DC6F57200B1D81B /* OPTLYEventRelatedEvent.h in Headers */,
@@ -1428,6 +1445,7 @@
14281445
EA2FAB131DC6F57200B1D81B /* OPTLYTrafficAllocation.h in Headers */,
14291446
EA2FAA891DC6F57100B1D81B /* OPTLYAttribute.h in Headers */,
14301447
EA2FAA9B1DC6F57100B1D81B /* OPTLYCondition.h in Headers */,
1448+
C78F98B8219ADEA700808062 /* OPTLYAudienceBaseCondition.h in Headers */,
14311449
EA2FAAAD1DC6F57200B1D81B /* OPTLYEvent.h in Headers */,
14321450
EA2FAA8F1DC6F57100B1D81B /* OPTLYAudience.h in Headers */,
14331451
EA2FAB071DC6F57200B1D81B /* OPTLYGroup.h in Headers */,
@@ -1691,6 +1709,7 @@
16911709
EA2FABD81DC6FDFA00B1D81B /* optimizely_7519590183.json in Resources */,
16921710
EA2FABD51DC6FDFA00B1D81B /* test_data_50_experiments.json in Resources */,
16931711
EA2FABCF1DC6FDFA00B1D81B /* test_data_10_experiments.json in Resources */,
1712+
C7ACD4FE218C2E4A008EC52E /* typed_audience_datafile.json in Resources */,
16941713
5E4C07F31DFF645C0042B1F8 /* UnsupportedVersionDatafile.json in Resources */,
16951714
3E99CF7F1FE02C2D00B16B97 /* optimizely_6372300739_v4.json in Resources */,
16961715
3EEC2AF220CB3D9E00D096E4 /* test_data_10_experimentsV3.json in Resources */,
@@ -1716,6 +1735,7 @@
17161735
EA2FABCD1DC6FDFA00B1D81B /* optimizely_6372300739.json in Resources */,
17171736
EA2FABD91DC6FDFA00B1D81B /* optimizely_7519590183.json in Resources */,
17181737
EA2FABD61DC6FDFA00B1D81B /* test_data_50_experiments.json in Resources */,
1738+
C7ACD4FF218C2E51008EC52E /* typed_audience_datafile.json in Resources */,
17191739
EA2FABD01DC6FDFA00B1D81B /* test_data_10_experiments.json in Resources */,
17201740
3E99CF801FE02C2E00B16B97 /* optimizely_6372300739_v4.json in Resources */,
17211741
3EEC2AF320CB3D9E00D096E4 /* test_data_10_experimentsV3.json in Resources */,
@@ -1955,6 +1975,7 @@
19551975
EA2C242F1DE6A2470063ADA0 /* OPTLYProjectConfigBuilder.m in Sources */,
19561976
EA8FD0E11DE9798E00D950AD /* OPTLYNetworkService.m in Sources */,
19571977
EA2FAC171DC6FFC600B1D81B /* OPTLYEventMetric.m in Sources */,
1978+
C78F98B9219ADEAB00808062 /* OPTLYAudienceBaseCondition.m in Sources */,
19581979
EA2FAC181DC6FFC600B1D81B /* OPTLYEventParameterKeys.m in Sources */,
19591980
EA2FAC191DC6FFC600B1D81B /* OPTLYEventRelatedEvent.m in Sources */,
19601981
EA2FAC1B1DC6FFC600B1D81B /* OPTLYEventView.m in Sources */,
@@ -1992,10 +2013,10 @@
19922013
59B9E1E220E35C9E002F732E /* OPTLYProjectConfigSwiftTest.swift in Sources */,
19932014
EA2FAB9C1DC6FDFA00B1D81B /* OptimizelySDKCoreTests.m in Sources */,
19942015
EA2FABA21DC6FDFA00B1D81B /* OptimizelyTest.m in Sources */,
2016+
C778BD2521DCDAB500AD38AE /* OPTLYTypedAudienceTest.m in Sources */,
19952017
59B9E1D120E28DBC002F732E /* OptimizelySwiftTest.swift in Sources */,
19962018
EA2FABC31DC6FDFA00B1D81B /* OPTLYTestHelper.m in Sources */,
19972019
EA2FABBD1DC6FDFA00B1D81B /* OPTLYLoggerTest.m in Sources */,
1998-
C7809D1921C11675005725FF /* OPTLYValidationTest.m in Sources */,
19992020
EA064BCE1DD3FCD700DF7537 /* OPTLYQueueTest.m in Sources */,
20002021
5E4C07FB1DFF66B00042B1F8 /* OPTLYNetworkServiceTest.m in Sources */,
20012022
EA2FABB41DC6FDFA00B1D81B /* OPTLYEventBuilderTest.m in Sources */,
@@ -2004,6 +2025,7 @@
20042025
EA2FABB71DC6FDFA00B1D81B /* OPTLYEventDispatcherTest.m in Sources */,
20052026
EA2FABA51DC6FDFA00B1D81B /* OPTLYAudienceTest.m in Sources */,
20062027
EA2FABB11DC6FDFA00B1D81B /* OPTLYErrorHandlerTest.m in Sources */,
2028+
C779881321CBC22A002AAEC8 /* OPTLYValidationTest.m in Sources */,
20072029
0BDF71FF202D04EF00EB9742 /* OPTLYNotificationCenterTest2.swift in Sources */,
20082030
EA2FABC01DC6FDFA00B1D81B /* OPTLYProjectConfigTest.m in Sources */,
20092031
EA2FABA81DC6FDFA00B1D81B /* OPTLYBucketerTest.m in Sources */,
@@ -2048,6 +2070,7 @@
20482070
EA2FABF21DC6FFA100B1D81B /* OPTLYEventMetric.m in Sources */,
20492071
EA2FABF31DC6FFA100B1D81B /* OPTLYEventParameterKeys.m in Sources */,
20502072
EA2FABF41DC6FFA100B1D81B /* OPTLYEventRelatedEvent.m in Sources */,
2073+
C78F98BA219ADEAB00808062 /* OPTLYAudienceBaseCondition.m in Sources */,
20512074
3E858C881F4227F100D53856 /* OPTLYJSONModel.m in Sources */,
20522075
EA2FABF61DC6FFA100B1D81B /* OPTLYEventView.m in Sources */,
20532076
EA2FABF71DC6FFA100B1D81B /* OPTLYExperiment.m in Sources */,
@@ -2097,13 +2120,14 @@
20972120
3EA818961FFF890E00BEBD41 /* OPTLYNotificationCenterTest.m in Sources */,
20982121
EA2FABB81DC6FDFA00B1D81B /* OPTLYEventDispatcherTest.m in Sources */,
20992122
EA2FABA61DC6FDFA00B1D81B /* OPTLYAudienceTest.m in Sources */,
2100-
C7809D1A21C11675005725FF /* OPTLYValidationTest.m in Sources */,
21012123
EA2FABB21DC6FDFA00B1D81B /* OPTLYErrorHandlerTest.m in Sources */,
21022124
0BDF7200202D04EF00EB9742 /* OPTLYNotificationCenterTest2.swift in Sources */,
2125+
C779881421CBC22A002AAEC8 /* OPTLYValidationTest.m in Sources */,
21032126
EA2FABC11DC6FDFA00B1D81B /* OPTLYProjectConfigTest.m in Sources */,
21042127
EA2FABA91DC6FDFA00B1D81B /* OPTLYBucketerTest.m in Sources */,
21052128
EA9358A21ECD794C00E3F201 /* OPTLYDecisionServiceTest.m in Sources */,
21062129
EA2FABAC1DC6FDFA00B1D81B /* OPTLYBuilderTest.m in Sources */,
2130+
C778BD2621DCDAB500AD38AE /* OPTLYTypedAudienceTest.m in Sources */,
21072131
);
21082132
runOnlyForDeploymentPostprocessing = 0;
21092133
};

OptimizelySDKCore/OptimizelySDKCore/OPTLYAudience.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/****************************************************************************
2-
* Copyright 2016,2018, Optimizely, Inc. and contributors *
2+
* Copyright 2016,2018-2019, Optimizely, Inc. and contributors *
33
* *
44
* Licensed under the Apache License, Version 2.0 (the "License"); *
55
* you may not use this file except in compliance with the License. *
@@ -36,5 +36,6 @@
3636

3737
/// Override OPTLYJSONModel set conditions
3838
- (void)setConditionsWithNSString:(NSString *)string;
39+
- (void)setConditionsWithNSArray:(NSArray *)array;
3940

4041
@end
Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/****************************************************************************
2-
* Copyright 2016, Optimizely, Inc. and contributors *
2+
* Copyright 2016,2018-2019, Optimizely, Inc. and contributors *
33
* *
44
* Licensed under the Apache License, Version 2.0 (the "License"); *
55
* you may not use this file except in compliance with the License. *
@@ -16,6 +16,7 @@
1616

1717
#import "OPTLYAudience.h"
1818
#import "OPTLYDatafileKeys.h"
19+
#import "OPTLYNSObject+Validation.h"
1920

2021
@implementation OPTLYAudience
2122

@@ -27,34 +28,29 @@ + (OPTLYJSONKeyMapper*)keyMapper
2728
}
2829

2930
- (void)setConditionsWithNSString:(NSString *)string {
30-
NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
31-
31+
NSArray *array = [string getValidConditionsArray];
32+
[self setConditionsWithNSArray:array];
33+
}
34+
35+
- (void)setConditionsWithNSArray:(NSArray *)array {
3236
NSError *err = nil;
33-
NSArray *array = [NSJSONSerialization JSONObjectWithData:data
34-
options:NSJSONReadingAllowFragments
35-
error:&err];
36-
if (err != nil) {
37-
NSException *exception = [[NSException alloc] initWithName:err.domain reason:err.localizedFailureReason userInfo:@{@"Error" : err}];
38-
@throw exception;
39-
}
40-
41-
self.conditions = [OPTLYCondition deserializeJSONArray:array error:&err];
42-
37+
self.conditions = [OPTLYCondition deserializeJSONArray:array error:nil];
4338
if (err != nil) {
4439
NSException *exception = [[NSException alloc] initWithName:err.domain reason:err.localizedFailureReason userInfo:@{@"Error" : err}];
4540
@throw exception;
4641
}
4742
}
4843

49-
- (BOOL)evaluateConditionsWithAttributes:(NSDictionary<NSString *, NSObject *> *)attributes {
44+
- (nullable NSNumber *)evaluateConditionsWithAttributes:(NSDictionary<NSString *, NSObject *> *)attributes projectConfig:(nullable OPTLYProjectConfig *)config {
5045
for (NSObject<OPTLYCondition> *condition in self.conditions) {
51-
if ([condition evaluateConditionsWithAttributes:attributes]) {
46+
NSNumber *result = [condition evaluateConditionsWithAttributes:attributes projectConfig:config];
47+
if (result != NULL && [result boolValue] == true) {
5248
// if user satisfies any conditions, return true.
53-
return true;
49+
return [NSNumber numberWithBool:true];
5450
}
5551
}
5652
// if user doesn't satisfy any conditions, return false.
57-
return false;
53+
return [NSNumber numberWithBool:false];
5854
}
5955

6056
@end
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/****************************************************************************
2+
* Copyright 2018-2019, Optimizely, Inc. and contributors *
3+
* *
4+
* Licensed under the Apache License, Version 2.0 (the "License"); *
5+
* you may not use this file except in compliance with the License. *
6+
* You may obtain a copy of the License at *
7+
* *
8+
* http://www.apache.org/licenses/LICENSE-2.0 *
9+
* *
10+
* Unless required by applicable law or agreed to in writing, software *
11+
* distributed under the License is distributed on an "AS IS" BASIS, *
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13+
* See the License for the specific language governing permissions and *
14+
* limitations under the License. *
15+
***************************************************************************/
16+
17+
#ifdef UNIVERSAL
18+
#import "OPTLYJSONModelLib.h"
19+
#else
20+
#import <OptimizelySDKCore/OPTLYJSONModelLib.h>
21+
#endif
22+
#import "OPTLYCondition.h"
23+
24+
@protocol OPTLYAudienceBaseCondition
25+
@end
26+
27+
@interface OPTLYAudienceBaseCondition : NSObject <OPTLYCondition>
28+
29+
@property (nonatomic, strong) NSString *audienceId;
30+
+(BOOL)isBaseConditionJSON:(NSData *)jsonData;
31+
32+
@end
33+

0 commit comments

Comments
 (0)