Skip to content

Commit 45a71b4

Browse files
authored
Merge pull request #2 from sendsay-ru/refactor/ssec_feature
Refactor/ssec_feature
2 parents f33a8ff + 3005aaa commit 45a71b4

File tree

31 files changed

+290
-173
lines changed

31 files changed

+290
-173
lines changed
-19 KB
Binary file not shown.
-963 KB
Binary file not shown.
-1.85 MB
Binary file not shown.
9.55 KB
Loading

Documentation/setup.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ In your project's `pubspec.yaml` file, add a dependency to the Sendsay Flutter S
2020

2121
```yaml
2222
dependencies:
23-
sendsay: 1.6.0
23+
sendsay: 0.1.0
2424
```
2525
26-
Optionally, you can specify a minimum version (for example, `^1.6.0`) or a version range (for example, `>=1.6.0 < 2.0.0`) instead of a specific version. Refer to [Version constraints](https://cocoapods.org/) in the Dart dependencies documentation for details.
26+
Optionally, you can specify a minimum version (for example, `^0.1.0`) or a version range (for example, `>=1.6.0 < 2.0.0`) instead of a specific version. Refer to [Version constraints](https://cocoapods.org/) in the Dart dependencies documentation for details.
2727

2828
### iOS setup
2929

android/src/main/kotlin/com/sendsay/SendsayPlugin.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,11 +1052,13 @@ private class SendsayMethodHandler(private val context: Context) : MethodCallHan
10521052
requireConfigured()
10531053
val data = args as Map<String, Any?>
10541054
val ssec = SSECEvent.fromMap(data)
1055-
val trackType = TrackingSSECType.valueOf(ssec.type)
1055+
val trackType = TrackingSSECType.find(value = ssec.type, id = null)
10561056
val trackData = ssec.data.toTrackSSECData()
10571057

1058+
result.error(TAG + "( trackSSEC() ) : trackData =>", trackData.toString() + "====" + ssec.data.toString(), null)
1059+
10581060
Sendsay.trackSSECEvent(
1059-
trackType,
1061+
trackType!!,
10601062
trackData
10611063
)
10621064
}

android/src/main/kotlin/com/sendsay/data/SSECEvent.kt

Lines changed: 49 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
package com.sendsay.data
22

3+
import com.google.gson.reflect.TypeToken
4+
import com.sendsay.sdk.models.OrderItem
5+
import com.sendsay.sdk.models.OrderItemAdapter
36
import com.sendsay.sdk.models.TrackSSECData
7+
import com.sendsay.sdk.util.SendsayGson
8+
import io.flutter.Log
49

510
data class SSECEvent(val type: String, val data: Map<String, Any>) {
11+
612
companion object {
13+
val gson = SendsayGson.instance;
14+
val orderItemJavaType = object : TypeToken<List<OrderItem>>(){}.type
15+
716
fun fromMap(map: Map<String, Any?>): SSECEvent {
817
return SSECEvent(
918
type = map["type"] as String? ?: throw IllegalStateException("SSECEvent.type is required!"),
@@ -13,22 +22,46 @@ data class SSECEvent(val type: String, val data: Map<String, Any>) {
1322

1423
fun Map<String, Any>.toTrackSSECData(): TrackSSECData {
1524
return TrackSSECData(
16-
productId = this["productId"] as? String,
17-
productName = this["productName"] as? String,
18-
picture = (this["picture"] as? List<*>)?.map { it as String },
19-
url = this["url"] as? String,
20-
available = (this["available"] as? Number)?.toLong(),
21-
categoryPaths = (this["categoryPaths"] as? List<*>)?.map { it as String },
22-
categoryId = (this["categoryId"] as? Number)?.toLong(),
23-
category = this["category"] as? String,
24-
description = this["description"] as? String,
25-
vendor = this["vendor"] as? String,
26-
model = this["model"] as? String,
27-
type = this["type"] as? String,
28-
price = (this["price"] as? Number)?.toDouble(),
29-
oldPrice = (this["oldPrice"] as? Number)?.toDouble(),
30-
updatePerItem = (this["updatePerItem"] as? Number)?.toInt(),
31-
// дальше по списку полей из decompiled-класса
25+
productId = this["productId"] as? String,
26+
productName = this["productName"] as? String,
27+
picture = (this["picture"] as? List<*>)?.map { it as String },
28+
url = this["url"] as? String,
29+
available = (this["available"] as? Number)?.toLong(),
30+
categoryPaths = (this["categoryPaths"] as? List<*>)?.map { it as String },
31+
categoryId = (this["categoryId"] as? Number)?.toLong(),
32+
category = this["category"] as? String,
33+
description = this["description"] as? String,
34+
vendor = this["vendor"] as? String,
35+
model = this["model"] as? String,
36+
type = this["type"] as? String,
37+
price = (this["price"] as? Number)?.toDouble(),
38+
oldPrice = (this["oldPrice"] as? Number)?.toDouble(),
39+
updatePerItem = (this["updatePerItem"] as? Number)?.toInt(),
40+
update = (this["update"] as? Number)?.toInt(),
41+
transactionId = this["transactionId"] as? String,
42+
transactionDt = this["transactionDt"] as? String,
43+
transactionStatus = (this["transactionStatus"] as? Number)?.toLong(),
44+
transactionDiscount = (this["transactionDiscount"] as? Number)?.toDouble(),
45+
transactionSum = (this["transactionSum"] as? Number)?.toDouble(),
46+
deliveryDt = this["deliveryDt"] as? String,
47+
deliveryPrice = (this["deliveryPrice"] as? Number)?.toDouble(),
48+
paymentDt = this["paymentDt"] as? String,
49+
items =
50+
(this["items"] as? List<Map<String, Any?>>?)?.let { raw ->
51+
val raw = this["items"]
52+
Log.d("DBG", "raw items = $raw (${raw?.javaClass})")
53+
54+
val json = gson.toJson(raw)
55+
Log.d("DBG", "json for items = $json")
56+
gson.fromJson(json, orderItemJavaType)
57+
},
58+
subscriptionAdd =
59+
(this["subscriptionAdd"] as? List<Map<String, Any?>>?)?.let { raw ->
60+
val json = gson.toJson(raw)
61+
gson.fromJson(json, orderItemJavaType)
62+
},
63+
subscriptionDelete = (this["subscriptionDelete"] as? List<Int>),
64+
cp = this["cp"] as? Map<String, Any>?,
3265
)
3366
}
3467
}

example/android/app/src/main/kotlin/com/sendsay/example_flutter/MainActivity.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ class MainActivity : FlutterActivity() {
2929

3030
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
3131
super.configureFlutterEngine(flutterEngine)
32-
// MethodChannel(flutterEngine.dartExecutor.binaryMessenger, "com.sendsay.example_flutter/utils").setMethodCallHandler { call, result ->
3332
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, "com.sendsay/utils").setMethodCallHandler { call, result ->
3433
if (call.method == "getAndroidPushIcon") {
3534
result.success(R.mipmap.ic_notification)

example/ios/Flutter/AppFrameworkInfo.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@
2121
<key>CFBundleVersion</key>
2222
<string>1.0</string>
2323
<key>MinimumOSVersion</key>
24-
<string>12.0</string>
24+
<string>13.0</string>
2525
</dict>
2626
</plist>

example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@
805805
"$(inherited)",
806806
"@executable_path/Frameworks",
807807
);
808-
MARKETING_VERSION = 0.1.0;
808+
MARKETING_VERSION = 0.1.1;
809809
PRODUCT_BUNDLE_IDENTIFIER = "ru.sendsay.SendsaySDK-Flutter-Example";
810810
PRODUCT_NAME = "$(TARGET_NAME)";
811811
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -1237,7 +1237,7 @@
12371237
"$(inherited)",
12381238
"@executable_path/Frameworks",
12391239
);
1240-
MARKETING_VERSION = 0.1.0;
1240+
MARKETING_VERSION = 0.1.1;
12411241
PRODUCT_BUNDLE_IDENTIFIER = "ru.sendsay.SendsaySDK-Flutter-Example";
12421242
PRODUCT_NAME = "$(TARGET_NAME)";
12431243
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -1272,7 +1272,7 @@
12721272
"$(inherited)",
12731273
"@executable_path/Frameworks",
12741274
);
1275-
MARKETING_VERSION = 0.1.0;
1275+
MARKETING_VERSION = 0.1.1;
12761276
PRODUCT_BUNDLE_IDENTIFIER = "ru.sendsay.SendsaySDK-Flutter-Example";
12771277
PRODUCT_NAME = "$(TARGET_NAME)";
12781278
PROVISIONING_PROFILE_SPECIFIER = "";

0 commit comments

Comments
 (0)