Skip to content

Commit d3eeae5

Browse files
committed
New evaluation methods in SplitClient
1 parent bec7cc7 commit d3eeae5

File tree

4 files changed

+264
-4
lines changed

4 files changed

+264
-4
lines changed

splitio/example/pubspec.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,28 +150,28 @@ packages:
150150
path: ".."
151151
relative: true
152152
source: path
153-
version: "0.1.6-rc.1"
153+
version: "0.1.6"
154154
splitio_android:
155155
dependency: transitive
156156
description:
157157
path: "../../splitio_android"
158158
relative: true
159159
source: path
160-
version: "0.1.6-rc.1"
160+
version: "0.1.6"
161161
splitio_ios:
162162
dependency: transitive
163163
description:
164164
path: "../../splitio_ios"
165165
relative: true
166166
source: path
167-
version: "0.1.6-rc.1"
167+
version: "0.1.6"
168168
splitio_platform_interface:
169169
dependency: transitive
170170
description:
171171
path: "../../splitio_platform_interface"
172172
relative: true
173173
source: path
174-
version: "1.3.0-rc.1"
174+
version: "1.3.0"
175175
stack_trace:
176176
dependency: transitive
177177
description:

splitio/lib/split_client.dart

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,46 @@ abstract class SplitClient {
4949
Future<Map<String, String>> getTreatments(List<String> featureFlagNames,
5050
[Map<String, dynamic> attributes = const {}]);
5151

52+
/// Convenience method to perform multiple evaluations by flag set. Returns a [Map] in
53+
/// which the keys are feature flag names and the values are treatments.
54+
///
55+
/// A flag set needs to be specified in [flagSet].
56+
///
57+
/// Optionally, a [Map] can be specified with the [attributes] parameter to
58+
/// take into account when evaluating.
59+
Future<Map<String, String>> getTreatmentsByFlagSet(String flagSet,
60+
[Map<String, dynamic> attributes = const {}]);
61+
62+
/// Convenience method to perform multiple evaluations by flag sets. Returns a [Map] in
63+
/// which the keys are feature flag names and the values are treatments.
64+
///
65+
/// A list of flag sets needs to be specified in [flagSets].
66+
///
67+
/// Optionally, a [Map] can be specified with the [attributes] parameter to
68+
/// take into account when evaluating.
69+
Future<Map<String, String>> getTreatmentsByFlagSets(List<String> flagSets,
70+
[Map<String, dynamic> attributes = const {}]);
71+
72+
/// Convenience method to perform multiple evaluations by flag set. Returns a [Map] in
73+
/// which the keys are feature flag names and the values are [SplitResult] objects.
74+
///
75+
/// A flag set needs to be specified in [flagSet].
76+
///
77+
/// Optionally, a [Map] can be specified with the [attributes] parameter to
78+
/// take into account when evaluating.
79+
Future<Map<String, SplitResult>> getTreatmentsWithConfigByFlagSet(String flagSet,
80+
[Map<String, dynamic> attributes = const {}]);
81+
82+
/// Convenience method to perform multiple evaluations by flag sets. Returns a [Map] in
83+
/// which the keys are feature flag names and the values are [SplitResult] objects.
84+
///
85+
/// A list of flag sets needs to be specified in [flagSets].
86+
///
87+
/// Optionally, a [Map] can be specified with the [attributes] parameter to
88+
/// take into account when evaluating.
89+
Future<Map<String, SplitResult>> getTreatmentsWithConfigByFlagSets(List<String> flagSets,
90+
[Map<String, dynamic> attributes = const {}]);
91+
5292
/// Convenience method to perform multiple evaluations. Returns a [Map] in
5393
/// which the keys are feature flag names and the values are [SplitResult] objects.
5494
///
@@ -185,6 +225,42 @@ class DefaultSplitClient implements SplitClient {
185225
attributes: attributes);
186226
}
187227

228+
@override
229+
Future<Map<String, String>> getTreatmentsByFlagSet(String flagSet, [Map<String, dynamic> attributes = const {}]) {
230+
return _platform.getTreatmentsByFlagSet(
231+
matchingKey: _matchingKey,
232+
bucketingKey: _bucketingKey,
233+
flagSet: flagSet,
234+
attributes: attributes);
235+
}
236+
237+
@override
238+
Future<Map<String, String>> getTreatmentsByFlagSets(List<String> flagSets, [Map<String, dynamic> attributes = const {}]) {
239+
return _platform.getTreatmentsByFlagSets(
240+
matchingKey: _matchingKey,
241+
bucketingKey: _bucketingKey,
242+
flagSets: flagSets,
243+
attributes: attributes);
244+
}
245+
246+
@override
247+
Future<Map<String, SplitResult>> getTreatmentsWithConfigByFlagSet(String flagSet, [Map<String, dynamic> attributes = const {}]) {
248+
return _platform.getTreatmentsWithConfigByFlagSet(
249+
matchingKey: _matchingKey,
250+
bucketingKey: _bucketingKey,
251+
flagSet: flagSet,
252+
attributes: attributes);
253+
}
254+
255+
@override
256+
Future<Map<String, SplitResult>> getTreatmentsWithConfigByFlagSets(List<String> flagSets, [Map<String, dynamic> attributes = const {}]) {
257+
return _platform.getTreatmentsWithConfigByFlagSets(
258+
matchingKey: _matchingKey,
259+
bucketingKey: _bucketingKey,
260+
flagSets: flagSets,
261+
attributes: attributes);
262+
}
263+
188264
@override
189265
Future<bool> track(String eventType,
190266
{String? trafficType,

splitio/test/splitio_client_test.dart

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,118 @@ void main() {
133133
'attributes': {'attr1': true}
134134
});
135135
});
136+
137+
test('getTreatmentsByFlagSet without attributes', () async {
138+
SplitClient client = _getClient();
139+
140+
client.getTreatmentsByFlagSet('set_1');
141+
142+
expect(_platform.methodName, 'getTreatmentsByFlagSet');
143+
expect(_platform.methodArguments, {
144+
'flagSet': 'set_1',
145+
'matchingKey': 'matching-key',
146+
'bucketingKey': 'bucketing-key',
147+
'attributes': {}
148+
});
149+
});
150+
151+
test('getTreatmentsByFlagSet with attributes', () async {
152+
SplitClient client = _getClient();
153+
154+
client.getTreatmentsByFlagSet('set_1', {'attr1': true});
155+
156+
expect(_platform.methodName, 'getTreatmentsByFlagSet');
157+
expect(_platform.methodArguments, {
158+
'flagSet': 'set_1',
159+
'matchingKey': 'matching-key',
160+
'bucketingKey': 'bucketing-key',
161+
'attributes': {'attr1': true}
162+
});
163+
});
164+
165+
test('getTreatmentsByFlagSets without attributes', () async {
166+
SplitClient client = _getClient();
167+
168+
client.getTreatmentsByFlagSets(['set_1', 'set_2']);
169+
170+
expect(_platform.methodName, 'getTreatmentsByFlagSets');
171+
expect(_platform.methodArguments, {
172+
'flagSets': ['set_1', 'set_2'],
173+
'matchingKey': 'matching-key',
174+
'bucketingKey': 'bucketing-key',
175+
'attributes': {}
176+
});
177+
});
178+
179+
test('getTreatmentsByFlagSets with attributes', () async {
180+
SplitClient client = _getClient();
181+
182+
client.getTreatmentsByFlagSets(['set_1', 'set_2'], {'attr1': true});
183+
184+
expect(_platform.methodName, 'getTreatmentsByFlagSets');
185+
expect(_platform.methodArguments, {
186+
'flagSets': ['set_1', 'set_2'],
187+
'matchingKey': 'matching-key',
188+
'bucketingKey': 'bucketing-key',
189+
'attributes': {'attr1': true}
190+
});
191+
});
192+
193+
test('getTreatmentsWithConfigByFlagSet without attributes', () async {
194+
SplitClient client = _getClient();
195+
196+
client.getTreatmentsWithConfigByFlagSet('set_1');
197+
198+
expect(_platform.methodName, 'getTreatmentsWithConfigByFlagSet');
199+
expect(_platform.methodArguments, {
200+
'flagSet': 'set_1',
201+
'matchingKey': 'matching-key',
202+
'bucketingKey': 'bucketing-key',
203+
'attributes': {}
204+
});
205+
});
206+
207+
test('getTreatmentsWithConfigByFlagSet with attributes', () async {
208+
SplitClient client = _getClient();
209+
210+
client.getTreatmentsWithConfigByFlagSet('set_1', {'attr1': true});
211+
212+
expect(_platform.methodName, 'getTreatmentsWithConfigByFlagSet');
213+
expect(_platform.methodArguments, {
214+
'flagSet': 'set_1',
215+
'matchingKey': 'matching-key',
216+
'bucketingKey': 'bucketing-key',
217+
'attributes': {'attr1': true}
218+
});
219+
});
220+
221+
test('getTreatmentsWithConfigByFlagSets without attributes', () async {
222+
SplitClient client = _getClient();
223+
224+
client.getTreatmentsWithConfigByFlagSets(['set_1', 'set_2']);
225+
226+
expect(_platform.methodName, 'getTreatmentsWithConfigByFlagSets');
227+
expect(_platform.methodArguments, {
228+
'flagSets': ['set_1', 'set_2'],
229+
'matchingKey': 'matching-key',
230+
'bucketingKey': 'bucketing-key',
231+
'attributes': {}
232+
});
233+
});
234+
235+
test('getTreatmentsWithConfigByFlagSets with attributes', () async {
236+
SplitClient client = _getClient();
237+
238+
client.getTreatmentsWithConfigByFlagSets(['set_1', 'set_2'], {'attr1': true});
239+
240+
expect(_platform.methodName, 'getTreatmentsWithConfigByFlagSets');
241+
expect(_platform.methodArguments, {
242+
'flagSets': ['set_1', 'set_2'],
243+
'matchingKey': 'matching-key',
244+
'bucketingKey': 'bucketing-key',
245+
'attributes': {'attr1': true}
246+
});
247+
});
136248
});
137249

138250
group('track', () {

splitio/test/splitio_platform_stub.dart

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,78 @@ class SplitioPlatformStub
156156
return Future.value({});
157157
}
158158

159+
@override
160+
Future<Map<String, String>> getTreatmentsByFlagSet(
161+
{required String matchingKey,
162+
required String? bucketingKey,
163+
required String flagSet,
164+
Map<String, dynamic> attributes = const {}}) {
165+
methodName = 'getTreatmentsByFlagSet';
166+
167+
methodArguments = {
168+
'matchingKey': matchingKey,
169+
'bucketingKey': bucketingKey,
170+
'flagSet': flagSet,
171+
'attributes': attributes,
172+
};
173+
174+
return Future.value({});
175+
}
176+
177+
@override
178+
Future<Map<String, String>> getTreatmentsByFlagSets(
179+
{required String matchingKey,
180+
required String? bucketingKey,
181+
required List<String> flagSets,
182+
Map<String, dynamic> attributes = const {}}) {
183+
methodName = 'getTreatmentsByFlagSets';
184+
185+
methodArguments = {
186+
'matchingKey': matchingKey,
187+
'bucketingKey': bucketingKey,
188+
'flagSets': flagSets,
189+
'attributes': attributes,
190+
};
191+
192+
return Future.value({});
193+
}
194+
195+
@override
196+
Future<Map<String, SplitResult>> getTreatmentsWithConfigByFlagSet(
197+
{required String matchingKey,
198+
required String? bucketingKey,
199+
required String flagSet,
200+
Map<String, dynamic> attributes = const {}}) {
201+
methodName = 'getTreatmentsWithConfigByFlagSet';
202+
203+
methodArguments = {
204+
'matchingKey': matchingKey,
205+
'bucketingKey': bucketingKey,
206+
'flagSet': flagSet,
207+
'attributes': attributes,
208+
};
209+
210+
return Future.value({});
211+
}
212+
213+
@override
214+
Future<Map<String, SplitResult>> getTreatmentsWithConfigByFlagSets(
215+
{required String matchingKey,
216+
required String? bucketingKey,
217+
required List<String> flagSets,
218+
Map<String, dynamic> attributes = const {}}) {
219+
methodName = 'getTreatmentsWithConfigByFlagSets';
220+
221+
methodArguments = {
222+
'matchingKey': matchingKey,
223+
'bucketingKey': bucketingKey,
224+
'flagSets': flagSets,
225+
'attributes': attributes,
226+
};
227+
228+
return Future.value({});
229+
}
230+
159231
@override
160232
Stream<Impression> impressionsStream() {
161233
methodName = 'impressionsStream';

0 commit comments

Comments
 (0)