Skip to content

Commit 571120e

Browse files
Merge pull request #16 from mindbox-moscow/release/1.0.0
Release/1.0.0
2 parents b549b72 + 2b59003 commit 571120e

31 files changed

+1159
-260
lines changed

.github/workflows/publish.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ name: publish
22

33
on:
44
pull_request:
5-
types: [closed]
5+
types: [ closed ]
66
branches:
77
- master
88

99
jobs:
1010
publish:
11+
if: github.event.pull_request.merged
1112
timeout-minutes: 4
1213
runs-on: ubuntu-latest
1314
name: ${{ matrix.package }} publishing
@@ -37,13 +38,6 @@ jobs:
3738
run: |
3839
cd ${{ matrix.package }}
3940
echo "VERSION=$(awk '{if ($1 ~ /^version:/) print $2}' pubspec.yaml)" >> $GITHUB_ENV
40-
- uses: sakebook/[email protected]
41-
if: steps.pubspec.outputs.changed == 0
42-
with:
43-
package_directory: ${{ matrix.package }}
44-
credential: ${{ secrets.PUB_CREDENTIALS }}
45-
flutter_package: true
46-
skip_test: true
4741
- name: Create Release
4842
if: steps.pubspec.outputs.changed == 0
4943
id: create_release

mindbox/CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1+
## 1.0.0
2+
3+
* Stable release of 'mindbox' plugin. Features:
4+
* receive and show push notification in both mobile platforms.
5+
* receive push notification data(links) in Flutter.
6+
* execute sync/async operations.
7+
18
## 0.2.0
29

310
* Add execute async operation.
411

5-
612
## 0.1.0
713

814
* Initial release.

mindbox/README.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ This plugin is a wrapper over the native Mindbox([iOS](https://github.com/mindbo
44
[Android](https://github.com/mindbox-moscow/android-sdk)) libraries that allows to
55
receive and handle push notifications.
66

7-
> Flutter Mindbox plugin is in beta.
8-
>
97
## Features
108

119
* Receive and show push notification in both mobile platforms.
1210
* Receive push notification data(links) in Flutter.
11+
* Execute sync/async operations
1312

1413
## Getting started
1514

@@ -83,6 +82,25 @@ Mindbox.instance.getDeviceUUID((uuid) {
8382
```dart
8483
Mindbox.instance.executeAsyncOperation(
8584
operationSystemName: 'operationName',
86-
operationBody: {},
85+
operationBody: {'example': 'body'},
86+
);
87+
```
88+
89+
### Execute sync operation
90+
91+
```dart
92+
Mindbox.instance.executeSyncOperation(
93+
operationSystemName: 'operationName',
94+
operationBody: {'example': 'body'},
95+
onSuccess: (String response) {
96+
jsonDecode(response);
97+
},
98+
onError: (MindboxError error){
99+
if (error is MindboxProtocolError) {
100+
print(error.code);
101+
}
102+
print(error.message);
103+
jsonDecode(error.data);
104+
},
87105
);
88106
```

mindbox/lib/mindbox.dart

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@ import 'package:mindbox_android/mindbox_android.dart';
33
import 'package:mindbox_ios/mindbox_ios.dart';
44
import 'package:mindbox_platform_interface/mindbox_platform_interface.dart';
55
export 'package:mindbox_platform_interface/mindbox_platform_interface.dart'
6-
show MindboxException, Configuration;
6+
show
7+
Configuration,
8+
MindboxError,
9+
MindboxProtocolError,
10+
MindboxNetworkError,
11+
MindboxInternalError,
12+
MindboxValidationError,
13+
MindboxServerError;
714

815
/// Basic Mindbox API
916
class Mindbox {
@@ -37,8 +44,8 @@ class Mindbox {
3744
/// Initializes the SDK for further work
3845
///
3946
/// Read more about parameter [Configuration].
40-
Future<void> init({required Configuration configuration}) async {
41-
await MindboxPlatform.instance.init(configuration: configuration);
47+
void init({required Configuration configuration}) {
48+
MindboxPlatform.instance.init(configuration: configuration);
4249
}
4350

4451
/// Method to obtain device UUID.
@@ -72,4 +79,19 @@ class Mindbox {
7279
operationBody: operationBody,
7380
);
7481
}
82+
83+
/// Method for executing an operation synchronously.
84+
void executeSyncOperation({
85+
required String operationSystemName,
86+
required Map<String, dynamic> operationBody,
87+
required Function(String response) onSuccess,
88+
required Function(MindboxError error) onError,
89+
}) async {
90+
MindboxPlatform.instance.executeSyncOperation(
91+
operationSystemName: operationSystemName,
92+
operationBody: operationBody,
93+
onSuccess: onSuccess,
94+
onError: onError,
95+
);
96+
}
7597
}

mindbox/pubspec.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: mindbox
2-
description: Flutter Mindbox SDK.
3-
version: 0.2.0
2+
description: Flutter Mindbox SDK. Plugin wrapper over of Mindbox iOS/Android SDK.
3+
version: 1.0.0
44
homepage: https://mindbox.cloud/
55
repository: https://github.com/mindbox-moscow/flutter-sdk/tree/master/mindbox
66

@@ -19,9 +19,9 @@ flutter:
1919
dependencies:
2020
flutter:
2121
sdk: flutter
22-
mindbox_android: ^0.2.0
23-
mindbox_ios: ^0.2.0
24-
mindbox_platform_interface: ^0.2.0
22+
mindbox_android: ^1.0.0
23+
mindbox_ios: ^1.0.0
24+
mindbox_platform_interface: ^1.0.0
2525

2626
dev_dependencies:
2727
flutter_test:

mindbox/test/mindbox_test.dart

Lines changed: 5 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,24 @@
11
import 'dart:async';
22

3-
import 'package:flutter/services.dart';
43
import 'package:flutter_test/flutter_test.dart';
54
import 'package:mindbox/mindbox.dart';
65
import 'package:mindbox_ios/mindbox_ios.dart';
76
import 'package:mindbox_platform_interface/mindbox_platform_interface.dart';
87

98
void main() {
10-
const MethodChannel channel = MethodChannel('mindbox.cloud/flutter-sdk');
11-
129
TestWidgetsFlutterBinding.ensureInitialized();
1310

1411
setUp(() {
1512
MindboxIosPlatform.registerPlatform();
16-
channel.setMockMethodCallHandler((MethodCall methodCall) async {
17-
switch (methodCall.method) {
18-
case 'init':
19-
final args = methodCall.arguments;
20-
final String domain = args['domain'];
21-
final String endpointIos = args['endpointIos'];
22-
final String endpointAndroid = args['endpointAndroid'];
23-
if (domain.isEmpty ||
24-
endpointIos.isEmpty ||
25-
endpointAndroid.isEmpty) {
26-
throw MindboxException(message: 'wrong configuration');
27-
}
28-
return Future.value(true);
29-
case 'getDeviceUUID':
30-
return Future.value('dummy-device-uuid');
31-
case 'getToken':
32-
return Future.value('dummy-token');
33-
default:
34-
return '1.2.0';
35-
}
36-
});
13+
channel.setMockMethodCallHandler(mindboxMockMethodCallHandler);
3714
});
3815

3916
tearDown(() {
4017
channel.setMockMethodCallHandler(null);
4118
});
4219

4320
test('getPlatformVersion', () async {
44-
expect(await Mindbox.instance.sdkVersion, '1.2.0');
21+
expect(await Mindbox.instance.sdkVersion, 'dummy-sdk-version');
4522
});
4623

4724
test('init()', () async {
@@ -51,19 +28,7 @@ void main() {
5128
endpointAndroid: 'endpointAndroid',
5229
subscribeCustomerIfCreated: true);
5330

54-
await Mindbox.instance.init(configuration: validConfig);
55-
});
56-
57-
test('When config is invalid, init() calling should throws MindboxException',
58-
() async {
59-
final invalidConfig = Configuration(
60-
domain: '',
61-
endpointIos: '',
62-
endpointAndroid: '',
63-
subscribeCustomerIfCreated: true);
64-
65-
expect(() async => Mindbox.instance.init(configuration: invalidConfig),
66-
throwsA(isA<MindboxException>()));
31+
Mindbox.instance.init(configuration: validConfig);
6732
});
6833

6934
test('When SDK was initialized, getDeviceUUID() should return device uuid',
@@ -78,9 +43,8 @@ void main() {
7843
endpointAndroid: 'endpointAndroid',
7944
subscribeCustomerIfCreated: true);
8045

81-
await Mindbox.instance.init(configuration: validConfig);
46+
Mindbox.instance.init(configuration: validConfig);
8247

83-
expect(completer.isCompleted, isTrue);
8448
expect(await completer.future, equals('dummy-device-uuid'));
8549
});
8650

@@ -105,9 +69,8 @@ void main() {
10569
endpointAndroid: 'endpointAndroid',
10670
subscribeCustomerIfCreated: true);
10771

108-
await Mindbox.instance.init(configuration: validConfig);
72+
Mindbox.instance.init(configuration: validConfig);
10973

110-
expect(completer.isCompleted, isTrue);
11174
expect(await completer.future, equals('dummy-token'));
11275
});
11376

@@ -126,7 +89,6 @@ void main() {
12689

12790
Mindbox.instance.onPushClickReceived((url) => completer.complete(url));
12891

129-
expect(completer.isCompleted, isTrue);
13092
expect(await completer.future, equals('dummy-url'));
13193
});
13294
}

mindbox_android/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.0.0
2+
3+
* Add execute sync operation.
4+
15
## 0.2.0
26

37
* Add execute async operation.

mindbox_android/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,5 @@ android {
4848

4949
dependencies {
5050
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
51-
implementation 'cloud.mindbox:mobile-sdk:1.2.3'
51+
implementation 'cloud.mindbox:mobile-sdk:1.2.7'
5252
}

mindbox_android/android/src/main/kotlin/cloud/mindbox/mindbox_android/MindboxAndroidPlugin.kt

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,8 @@ class MindboxAndroidPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
5858
.subscribeCustomerIfCreated(subscribeIfCreated)
5959
.shouldCreateCustomer(shouldCreateCustomer)
6060
.build()
61-
try {
62-
Mindbox.init(context, config)
63-
result.success("initialized")
64-
} catch (e: Exception) {
65-
result.error("-1", e.message, e.localizedMessage)
66-
}
61+
Mindbox.init(context, config)
62+
result.success("initialized")
6763
} else {
6864
result.error("-1", "Initialization error", "Wrong argument type")
6965
}
@@ -82,6 +78,26 @@ class MindboxAndroidPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
8278
if (call.arguments is List<*>) {
8379
val args = call.arguments as List<*>
8480
Mindbox.executeAsyncOperation(context, args[0] as String, args[1] as String)
81+
result.success("executed")
82+
}
83+
}
84+
"executeSyncOperation" -> {
85+
if (call.arguments is List<*>) {
86+
val args = call.arguments as List<*>
87+
Mindbox.executeSyncOperation(
88+
context,
89+
args[0] as String,
90+
args[1] as String,
91+
{ response ->
92+
result.success(response)
93+
},
94+
{ error ->
95+
result.error(
96+
error.statusCode.toString(),
97+
error.toJson(),
98+
null
99+
)
100+
})
85101
}
86102
}
87103
else -> {

mindbox_android/lib/src/mindbox_android_platform.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,20 @@ class MindboxAndroidPlatform extends MindboxPlatform {
5151
operationBody: operationBody,
5252
);
5353
}
54+
55+
/// Method for executing an operation synchronously.
56+
@override
57+
Future<void> executeSyncOperation({
58+
required String operationSystemName,
59+
required Map<String, dynamic> operationBody,
60+
required Function(String response) onSuccess,
61+
required Function(MindboxError error) onError,
62+
}) async {
63+
_methodHandler.executeSyncOperation(
64+
operationSystemName: operationSystemName,
65+
operationBody: operationBody,
66+
onSuccess: onSuccess,
67+
onError: onError,
68+
);
69+
}
5470
}

0 commit comments

Comments
 (0)