/
OPTLYProjectConfig.h
178 lines (151 loc) · 7.28 KB
/
OPTLYProjectConfig.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/****************************************************************************
* Copyright 2017-2018, Optimizely, Inc. and contributors *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); *
* you may not use this file except in compliance with the License. *
* You may obtain a copy of the License at *
* *
* http://www.apache.org/licenses/LICENSE-2.0 *
* *
* Unless required by applicable law or agreed to in writing, software *
* distributed under the License is distributed on an "AS IS" BASIS, *
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
* See the License for the specific language governing permissions and *
* limitations under the License. *
***************************************************************************/
#import <Foundation/Foundation.h>
#ifdef UNIVERSAL
#import "OPTLYJSONModelLib.h"
#else
#import <OptimizelySDKCore/OPTLYJSONModelLib.h>
#endif
#import "OPTLYProjectConfigBuilder.h"
NS_ASSUME_NONNULL_BEGIN
extern NSString * const kExpectedDatafileVersion;
NS_ASSUME_NONNULL_END
@class OPTLYAttribute, OPTLYAudience, OPTLYBucketer, OPTLYEvent, OPTLYExperiment, OPTLYGroup, OPTLYUserProfileService, OPTLYVariation, OPTLYVariable, OPTLYFeatureFlag, OPTLYRollout;
@protocol OPTLYAttribute, OPTLYAudience, OPTLYBucketer, OPTLYErrorHandler, OPTLYEvent, OPTLYExperiment, OPTLYGroup, OPTLYLogger, OPTLYVariable, OPTLYVariation, OPTLYFeatureFlag, OPTLYRollout;
/*
This class represents all the data contained in the project datafile
and includes helper methods to efficiently access its data.
*/
@interface OPTLYProjectConfig : OPTLYJSONModel
/// Account Id
@property (nonatomic, strong, nonnull) NSString *accountId;
/// Project Id
@property (nonatomic, strong, nonnull) NSString *projectId;
/// JSON Version
@property (nonatomic, strong, nonnull) NSString *version;
/// Datafile Revision number
@property (nonatomic, strong, nonnull) NSString *revision;
/// Flag for IP anonymization
@property (nonatomic, strong, nonnull) NSNumber<OPTLYOptional> *anonymizeIP;
/// Flag for Bot Filtering
@property (nonatomic, strong, nonnull) NSNumber<OPTLYOptional> *botFiltering;
/// List of Optimizely Experiment objects
@property (nonatomic, strong, nonnull) NSArray<OPTLYExperiment> *experiments;
/// List of Optimizely Event Type objects
@property (nonatomic, strong, nonnull) NSArray<OPTLYEvent> *events;
/// List of audience ids
@property (nonatomic, strong, nonnull) NSArray<OPTLYAudience> *audiences;
/// List of attributes objects
@property (nonatomic, strong, nonnull) NSArray<OPTLYAttribute> *attributes;
/// List of group objects
@property (nonatomic, strong, nonnull) NSArray<OPTLYGroup> *groups;
/// List of live variable objects (DEPRECATED)
@property (nonatomic, strong, nonnull) NSArray<OPTLYVariable, OPTLYOptional> *variables;
/// a comprehensive list of experiments that includes experiments being whitelisted (in Groups)
@property (nonatomic, strong, nullable) NSArray<OPTLYExperiment, Ignore> *allExperiments;
@property (nonatomic, strong, nullable) id<OPTLYLogger, Ignore> logger;
@property (nonatomic, strong, nullable) id<OPTLYErrorHandler, Ignore> errorHandler;
@property (nonatomic, strong, readonly, nullable) id<OPTLYUserProfileService, Ignore> userProfileService;
/// Returns the client type (e.g., objective-c-sdk, ios-sdk, tvos-sdk)
@property (nonatomic, strong, readonly, nonnull) NSString<Ignore> *clientEngine;
/// Returns the client version number
@property (nonatomic, strong, readonly, nonnull) NSString<Ignore> *clientVersion;
/// List of Optimizely Feature Flags objects
@property (nonatomic, strong, nonnull) NSArray<OPTLYFeatureFlag, OPTLYOptional> *featureFlags;
/// List of Optimizely Rollouts objects
@property (nonatomic, strong, nonnull) NSArray<OPTLYRollout, OPTLYOptional> *rollouts;
/**
* Initialize the Project Config from a builder block.
*/
+ (nullable instancetype)init:(nonnull OPTLYProjectConfigBuilderBlock)builderBlock
__attribute((deprecated("Use OPTLYProjectConfig initWithBuilder method instead.")));
/**
* Initialize the Project Config from a OPTLYProjectConfigBuilder object.
* @param builder The OPTLYProjectConfigBuilder object, which has logger, errorHandler, and eventDispatcher to be set.
* @return OPTLYProjectConfig instance.
*/
- (nullable instancetype)initWithBuilder:(nonnull OPTLYProjectConfigBuilder *)builder;
/**
* Initialize the Project Config from a datafile.
*/
- (nullable instancetype)initWithDatafile:(nonnull NSData *)datafile;
/**
* Get an Experiment object for a key.
*/
- (nullable OPTLYExperiment *)getExperimentForKey:(nonnull NSString *)experimentKey;
/**
* Get an Experiment object for an Id.
*/
- (nullable OPTLYExperiment *)getExperimentForId:(nonnull NSString *)experimentId;
/**
* Get an experiment Id for the human readable experiment key
**/
- (nullable NSString *)getExperimentIdForKey:(nonnull NSString *)experimentKey;
/**
* Get a Group object for an Id.
*/
- (nullable OPTLYGroup *)getGroupForGroupId:(nonnull NSString *)groupId;
/**
* Get a Feature Flag object for a key.
*/
- (nullable OPTLYFeatureFlag *)getFeatureFlagForKey:(nonnull NSString *)featureFlagKey;
/**
* Get a Rollout object for an Id.
*/
- (nullable OPTLYRollout *)getRolloutForId:(nonnull NSString *)rolloutId;
/**
* Gets an event id for a corresponding event key
*/
- (nullable NSString *)getEventIdForKey:(nonnull NSString *)eventKey;
/**
* Gets an event for a corresponding event key
*/
- (nullable OPTLYEvent *)getEventForKey:(nonnull NSString *)eventKey;
/**
* Get an attribute for a given key.
*/
- (nullable OPTLYAttribute *)getAttributeForKey:(nonnull NSString *)attributeKey;
/**
* Get an attribute Id for a given key.
**/
- (nullable NSString *)getAttributeIdForKey:(nonnull NSString *)attributeKey;
/**
* Get an audience for a given audience id.
*/
- (nullable OPTLYAudience *)getAudienceForId:(nonnull NSString *)audienceId;
/**
* Get a variable for a given live variable key. (DEPRECATED)
*/
- (nullable OPTLYVariable *)getVariableForVariableKey:(nonnull NSString *)variableKey;
/**
* Get forced variation for a given experiment key and user id.
*/
- (nullable OPTLYVariation *)getForcedVariation:(nonnull NSString *)experimentKey
userId:(nonnull NSString *)userId;
/**
* Set forced variation for a given experiment key and user id according to a given variation key.
*/
- (BOOL)setForcedVariation:(nonnull NSString *)experimentKey
userId:(nonnull NSString *)userId
variationKey:(nonnull NSString *)variationKey;
/**
* Get variation for experiment and user ID with user attributes.
*/
- (nullable OPTLYVariation *)getVariationForExperiment:(nonnull NSString *)experimentKey
userId:(nonnull NSString *)userId
attributes:(nullable NSDictionary<NSString *,NSString *> *)attributes
bucketer:(nullable id<OPTLYBucketer>)bucketer;
@end