diff --git a/splitio/example/pubspec.lock b/splitio/example/pubspec.lock index cad1492..bf2b499 100644 --- a/splitio/example/pubspec.lock +++ b/splitio/example/pubspec.lock @@ -150,28 +150,28 @@ packages: path: ".." relative: true source: path - version: "0.1.6-rc.1" + version: "0.1.6" splitio_android: dependency: transitive description: path: "../../splitio_android" relative: true source: path - version: "0.1.6-rc.1" + version: "0.1.6" splitio_ios: dependency: transitive description: path: "../../splitio_ios" relative: true source: path - version: "0.1.6-rc.1" + version: "0.1.6" splitio_platform_interface: dependency: transitive description: path: "../../splitio_platform_interface" relative: true source: path - version: "1.3.0-rc.1" + version: "1.3.0" stack_trace: dependency: transitive description: diff --git a/splitio/lib/split_client.dart b/splitio/lib/split_client.dart index 7252206..cb9b27f 100644 --- a/splitio/lib/split_client.dart +++ b/splitio/lib/split_client.dart @@ -49,6 +49,46 @@ abstract class SplitClient { Future> getTreatments(List featureFlagNames, [Map attributes = const {}]); + /// Convenience method to perform multiple evaluations by flag set. Returns a [Map] in + /// which the keys are feature flag names and the values are treatments. + /// + /// A flag set needs to be specified in [flagSet]. + /// + /// Optionally, a [Map] can be specified with the [attributes] parameter to + /// take into account when evaluating. + Future> getTreatmentsByFlagSet(String flagSet, + [Map attributes = const {}]); + + /// Convenience method to perform multiple evaluations by flag sets. Returns a [Map] in + /// which the keys are feature flag names and the values are treatments. + /// + /// A list of flag sets needs to be specified in [flagSets]. + /// + /// Optionally, a [Map] can be specified with the [attributes] parameter to + /// take into account when evaluating. + Future> getTreatmentsByFlagSets(List flagSets, + [Map attributes = const {}]); + + /// Convenience method to perform multiple evaluations by flag set. Returns a [Map] in + /// which the keys are feature flag names and the values are [SplitResult] objects. + /// + /// A flag set needs to be specified in [flagSet]. + /// + /// Optionally, a [Map] can be specified with the [attributes] parameter to + /// take into account when evaluating. + Future> getTreatmentsWithConfigByFlagSet(String flagSet, + [Map attributes = const {}]); + + /// Convenience method to perform multiple evaluations by flag sets. Returns a [Map] in + /// which the keys are feature flag names and the values are [SplitResult] objects. + /// + /// A list of flag sets needs to be specified in [flagSets]. + /// + /// Optionally, a [Map] can be specified with the [attributes] parameter to + /// take into account when evaluating. + Future> getTreatmentsWithConfigByFlagSets(List flagSets, + [Map attributes = const {}]); + /// Convenience method to perform multiple evaluations. Returns a [Map] in /// which the keys are feature flag names and the values are [SplitResult] objects. /// @@ -185,6 +225,42 @@ class DefaultSplitClient implements SplitClient { attributes: attributes); } + @override + Future> getTreatmentsByFlagSet(String flagSet, [Map attributes = const {}]) { + return _platform.getTreatmentsByFlagSet( + matchingKey: _matchingKey, + bucketingKey: _bucketingKey, + flagSet: flagSet, + attributes: attributes); + } + + @override + Future> getTreatmentsByFlagSets(List flagSets, [Map attributes = const {}]) { + return _platform.getTreatmentsByFlagSets( + matchingKey: _matchingKey, + bucketingKey: _bucketingKey, + flagSets: flagSets, + attributes: attributes); + } + + @override + Future> getTreatmentsWithConfigByFlagSet(String flagSet, [Map attributes = const {}]) { + return _platform.getTreatmentsWithConfigByFlagSet( + matchingKey: _matchingKey, + bucketingKey: _bucketingKey, + flagSet: flagSet, + attributes: attributes); + } + + @override + Future> getTreatmentsWithConfigByFlagSets(List flagSets, [Map attributes = const {}]) { + return _platform.getTreatmentsWithConfigByFlagSets( + matchingKey: _matchingKey, + bucketingKey: _bucketingKey, + flagSets: flagSets, + attributes: attributes); + } + @override Future track(String eventType, {String? trafficType, diff --git a/splitio/pubspec.yaml b/splitio/pubspec.yaml index 8b566fe..0f26e06 100644 --- a/splitio/pubspec.yaml +++ b/splitio/pubspec.yaml @@ -19,9 +19,12 @@ flutter: dependencies: flutter: sdk: flutter - splitio_android: ^0.1.6 - splitio_ios: ^0.1.6 - splitio_platform_interface: ^1.3.0 + splitio_android: #^0.1.6 + path: ../splitio_android + splitio_ios: #^0.1.6 + path: ../splitio_ios + splitio_platform_interface: #^1.3.0 + path: ../splitio_platform_interface dev_dependencies: flutter_test: diff --git a/splitio/test/splitio_client_test.dart b/splitio/test/splitio_client_test.dart index 25e638f..de984a8 100644 --- a/splitio/test/splitio_client_test.dart +++ b/splitio/test/splitio_client_test.dart @@ -133,6 +133,118 @@ void main() { 'attributes': {'attr1': true} }); }); + + test('getTreatmentsByFlagSet without attributes', () async { + SplitClient client = _getClient(); + + client.getTreatmentsByFlagSet('set_1'); + + expect(_platform.methodName, 'getTreatmentsByFlagSet'); + expect(_platform.methodArguments, { + 'flagSet': 'set_1', + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + 'attributes': {} + }); + }); + + test('getTreatmentsByFlagSet with attributes', () async { + SplitClient client = _getClient(); + + client.getTreatmentsByFlagSet('set_1', {'attr1': true}); + + expect(_platform.methodName, 'getTreatmentsByFlagSet'); + expect(_platform.methodArguments, { + 'flagSet': 'set_1', + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + 'attributes': {'attr1': true} + }); + }); + + test('getTreatmentsByFlagSets without attributes', () async { + SplitClient client = _getClient(); + + client.getTreatmentsByFlagSets(['set_1', 'set_2']); + + expect(_platform.methodName, 'getTreatmentsByFlagSets'); + expect(_platform.methodArguments, { + 'flagSets': ['set_1', 'set_2'], + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + 'attributes': {} + }); + }); + + test('getTreatmentsByFlagSets with attributes', () async { + SplitClient client = _getClient(); + + client.getTreatmentsByFlagSets(['set_1', 'set_2'], {'attr1': true}); + + expect(_platform.methodName, 'getTreatmentsByFlagSets'); + expect(_platform.methodArguments, { + 'flagSets': ['set_1', 'set_2'], + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + 'attributes': {'attr1': true} + }); + }); + + test('getTreatmentsWithConfigByFlagSet without attributes', () async { + SplitClient client = _getClient(); + + client.getTreatmentsWithConfigByFlagSet('set_1'); + + expect(_platform.methodName, 'getTreatmentsWithConfigByFlagSet'); + expect(_platform.methodArguments, { + 'flagSet': 'set_1', + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + 'attributes': {} + }); + }); + + test('getTreatmentsWithConfigByFlagSet with attributes', () async { + SplitClient client = _getClient(); + + client.getTreatmentsWithConfigByFlagSet('set_1', {'attr1': true}); + + expect(_platform.methodName, 'getTreatmentsWithConfigByFlagSet'); + expect(_platform.methodArguments, { + 'flagSet': 'set_1', + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + 'attributes': {'attr1': true} + }); + }); + + test('getTreatmentsWithConfigByFlagSets without attributes', () async { + SplitClient client = _getClient(); + + client.getTreatmentsWithConfigByFlagSets(['set_1', 'set_2']); + + expect(_platform.methodName, 'getTreatmentsWithConfigByFlagSets'); + expect(_platform.methodArguments, { + 'flagSets': ['set_1', 'set_2'], + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + 'attributes': {} + }); + }); + + test('getTreatmentsWithConfigByFlagSets with attributes', () async { + SplitClient client = _getClient(); + + client.getTreatmentsWithConfigByFlagSets(['set_1', 'set_2'], {'attr1': true}); + + expect(_platform.methodName, 'getTreatmentsWithConfigByFlagSets'); + expect(_platform.methodArguments, { + 'flagSets': ['set_1', 'set_2'], + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + 'attributes': {'attr1': true} + }); + }); }); group('track', () { diff --git a/splitio/test/splitio_platform_stub.dart b/splitio/test/splitio_platform_stub.dart index 369cc83..a996c97 100644 --- a/splitio/test/splitio_platform_stub.dart +++ b/splitio/test/splitio_platform_stub.dart @@ -156,6 +156,78 @@ class SplitioPlatformStub return Future.value({}); } + @override + Future> getTreatmentsByFlagSet( + {required String matchingKey, + required String? bucketingKey, + required String flagSet, + Map attributes = const {}}) { + methodName = 'getTreatmentsByFlagSet'; + + methodArguments = { + 'matchingKey': matchingKey, + 'bucketingKey': bucketingKey, + 'flagSet': flagSet, + 'attributes': attributes, + }; + + return Future.value({}); + } + + @override + Future> getTreatmentsByFlagSets( + {required String matchingKey, + required String? bucketingKey, + required List flagSets, + Map attributes = const {}}) { + methodName = 'getTreatmentsByFlagSets'; + + methodArguments = { + 'matchingKey': matchingKey, + 'bucketingKey': bucketingKey, + 'flagSets': flagSets, + 'attributes': attributes, + }; + + return Future.value({}); + } + + @override + Future> getTreatmentsWithConfigByFlagSet( + {required String matchingKey, + required String? bucketingKey, + required String flagSet, + Map attributes = const {}}) { + methodName = 'getTreatmentsWithConfigByFlagSet'; + + methodArguments = { + 'matchingKey': matchingKey, + 'bucketingKey': bucketingKey, + 'flagSet': flagSet, + 'attributes': attributes, + }; + + return Future.value({}); + } + + @override + Future> getTreatmentsWithConfigByFlagSets( + {required String matchingKey, + required String? bucketingKey, + required List flagSets, + Map attributes = const {}}) { + methodName = 'getTreatmentsWithConfigByFlagSets'; + + methodArguments = { + 'matchingKey': matchingKey, + 'bucketingKey': bucketingKey, + 'flagSets': flagSets, + 'attributes': attributes, + }; + + return Future.value({}); + } + @override Stream impressionsStream() { methodName = 'impressionsStream'; diff --git a/splitio_android/pubspec.yaml b/splitio_android/pubspec.yaml index 3381173..3975208 100644 --- a/splitio_android/pubspec.yaml +++ b/splitio_android/pubspec.yaml @@ -19,7 +19,8 @@ flutter: dependencies: flutter: sdk: flutter - splitio_platform_interface: ^1.3.0 + splitio_platform_interface: #^1.3.0 + path: ../splitio_platform_interface dev_dependencies: flutter_test: diff --git a/splitio_ios/pubspec.yaml b/splitio_ios/pubspec.yaml index 9539b32..a2c7860 100644 --- a/splitio_ios/pubspec.yaml +++ b/splitio_ios/pubspec.yaml @@ -18,7 +18,8 @@ flutter: dependencies: flutter: sdk: flutter - splitio_platform_interface: ^1.3.0 + splitio_platform_interface: #^1.3.0 + path: ../splitio_platform_interface dev_dependencies: flutter_test: