@doorstepai/dropoff-sdk 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/doorstepai/dropoffsdk/DoorstepAIModule.kt +42 -32
- package/ios/DoorstepAI.mm +8 -2
- package/ios/DoorstepAI.swift +27 -22
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/DoorstepDropoffSDK.framework/DoorstepDropoffSDK +0 -0
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios.abi.json +215 -57
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios.private.swiftinterface +6 -5
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios.swiftinterface +6 -5
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/DoorstepDropoffSDK.framework/_CodeSignature/CodeResources +8 -8
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/dSYMs/DoorstepDropoffSDK.framework.dSYM/Contents/Resources/DWARF/DoorstepDropoffSDK +0 -0
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/dSYMs/DoorstepDropoffSDK.framework.dSYM/Contents/Resources/Relocations/aarch64/DoorstepDropoffSDK.yml +735 -677
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/DoorstepDropoffSDK +0 -0
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios-simulator.abi.json +215 -57
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +6 -5
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface +6 -5
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/x86_64-apple-ios-simulator.abi.json +215 -57
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +6 -5
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +6 -5
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/_CodeSignature/CodeResources +16 -16
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/DoorstepDropoffSDK.framework.dSYM/Contents/Resources/DWARF/DoorstepDropoffSDK +0 -0
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/DoorstepDropoffSDK.framework.dSYM/Contents/Resources/Relocations/aarch64/DoorstepDropoffSDK.yml +759 -701
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/DoorstepDropoffSDK.framework.dSYM/Contents/Resources/Relocations/x86_64/DoorstepDropoffSDK.yml +759 -700
- package/lib/module/DoorstepAI.js +56 -29
- package/lib/module/DoorstepAI.js.map +1 -1
- package/lib/module/RootDoorstepAI.js.map +1 -1
- package/lib/typescript/src/DoorstepAI.d.ts +6 -5
- package/lib/typescript/src/DoorstepAI.d.ts.map +1 -1
- package/lib/typescript/src/RootDoorstepAI.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/DoorstepAI.tsx +64 -42
- package/src/RootDoorstepAI.tsx +4 -7
package/android/build.gradle
CHANGED
|
@@ -86,7 +86,7 @@ def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
|
86
86
|
dependencies {
|
|
87
87
|
implementation "com.facebook.react:react-android"
|
|
88
88
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
89
|
-
implementation("ai.doorstep.com:doorstepai-dropoff-sdk:1.0.
|
|
89
|
+
implementation("ai.doorstep.com:doorstepai-dropoff-sdk:1.0.1")
|
|
90
90
|
api "org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1"
|
|
91
91
|
}
|
|
92
92
|
|
|
@@ -8,6 +8,7 @@ import com.facebook.react.bridge.ReactMethod
|
|
|
8
8
|
import com.facebook.react.bridge.Promise
|
|
9
9
|
import com.doorstepai.sdks.tracking.DoorstepAI
|
|
10
10
|
import com.doorstepai.sdks.tracking.AddressType
|
|
11
|
+
import com.facebook.react.bridge.ReadableMap
|
|
11
12
|
|
|
12
13
|
class DoorstepAIModule(private val reactContext: ReactApplicationContext) :
|
|
13
14
|
ReactContextBaseJavaModule(reactContext) {
|
|
@@ -32,57 +33,61 @@ class DoorstepAIModule(private val reactContext: ReactApplicationContext) :
|
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
@ReactMethod
|
|
35
|
-
fun startDeliveryByPlaceID(placeID: String, promise: Promise) {
|
|
36
|
+
fun startDeliveryByPlaceID(placeID: String, deliveryId: String, promise: Promise) {
|
|
36
37
|
try {
|
|
37
|
-
DoorstepAI.startDeliveryByPlaceID(placeID) { result ->
|
|
38
|
-
result.onSuccess {
|
|
39
|
-
promise.resolve(
|
|
38
|
+
DoorstepAI.startDeliveryByPlaceID(placeID, deliveryId) { result ->
|
|
39
|
+
result.onSuccess { sessionId ->
|
|
40
|
+
promise.resolve(sessionId)
|
|
40
41
|
}.onFailure { error ->
|
|
41
|
-
promise.reject("DELIVERY_ERROR", error.message ?: "Promise Rejection: Failed to start delivery")
|
|
42
|
+
promise.reject("DELIVERY_ERROR", error.message ?: "Promise Rejection: Failed to start delivery by Place ID")
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
45
|
} catch (e: Exception) {
|
|
45
|
-
promise.reject("DELIVERY_ERROR", e.message ?: "Failed to start delivery")
|
|
46
|
+
promise.reject("DELIVERY_ERROR", e.message ?: "Failed to start delivery by Place ID")
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
@ReactMethod
|
|
50
|
-
fun startDeliveryByPlusCode(plusCode: String, promise: Promise) {
|
|
51
|
+
fun startDeliveryByPlusCode(plusCode: String, deliveryId: String, promise: Promise) {
|
|
51
52
|
try {
|
|
52
|
-
DoorstepAI.startDeliveryByPlusCode(plusCode) { result ->
|
|
53
|
-
result.onSuccess {
|
|
54
|
-
promise.resolve(
|
|
53
|
+
DoorstepAI.startDeliveryByPlusCode(plusCode, deliveryId) { result ->
|
|
54
|
+
result.onSuccess { sessionId ->
|
|
55
|
+
promise.resolve(sessionId)
|
|
55
56
|
}.onFailure { error ->
|
|
56
|
-
promise.reject("DELIVERY_ERROR", error.message ?: "Promise Rejection: Failed to start delivery")
|
|
57
|
+
promise.reject("DELIVERY_ERROR", error.message ?: "Promise Rejection: Failed to start delivery by Plus Code")
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
60
|
} catch (e: Exception) {
|
|
60
|
-
promise.reject("DELIVERY_ERROR", e.message ?: "Failed to start delivery")
|
|
61
|
+
promise.reject("DELIVERY_ERROR", e.message ?: "Failed to start delivery by Plus Code")
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
@ReactMethod
|
|
65
66
|
fun startDeliveryByAddress(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
locality: String,
|
|
69
|
-
administrativeAreaLevel1: String,
|
|
70
|
-
postalCode: String,
|
|
71
|
-
subPremise: String,
|
|
67
|
+
addressMap: ReadableMap,
|
|
68
|
+
deliveryId: String,
|
|
72
69
|
promise: Promise
|
|
73
70
|
) {
|
|
74
71
|
try {
|
|
72
|
+
val streetNumber = addressMap.getString("streetNumber") ?: ""
|
|
73
|
+
val route = addressMap.getString("route") ?: ""
|
|
74
|
+
val subPremise = addressMap.getString("subPremise") ?: ""
|
|
75
|
+
val locality = addressMap.getString("locality") ?: ""
|
|
76
|
+
val administrativeAreaLevel1 = addressMap.getString("administrativeAreaLevel1") ?: ""
|
|
77
|
+
val postalCode = addressMap.getString("postalCode") ?: ""
|
|
78
|
+
|
|
75
79
|
val address = AddressType(
|
|
76
80
|
streetNumber = streetNumber,
|
|
77
81
|
route = route,
|
|
82
|
+
subPremise = subPremise,
|
|
78
83
|
locality = locality,
|
|
79
84
|
administrativeAreaLevel1 = administrativeAreaLevel1,
|
|
80
|
-
postalCode = postalCode
|
|
81
|
-
subPremise = subPremise
|
|
85
|
+
postalCode = postalCode
|
|
82
86
|
)
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
87
|
+
|
|
88
|
+
DoorstepAI.startDeliveryByAddressType(address, deliveryId) { result ->
|
|
89
|
+
result.onSuccess { sessionId ->
|
|
90
|
+
promise.resolve(sessionId)
|
|
86
91
|
}.onFailure { error ->
|
|
87
92
|
promise.reject("DELIVERY_ERROR", error.message ?: "Promise Rejection: Failed to start delivery by address")
|
|
88
93
|
}
|
|
@@ -93,27 +98,27 @@ class DoorstepAIModule(private val reactContext: ReactApplicationContext) :
|
|
|
93
98
|
}
|
|
94
99
|
|
|
95
100
|
@ReactMethod
|
|
96
|
-
fun newEvent(eventName: String, promise: Promise) {
|
|
101
|
+
fun newEvent(eventName: String, deliveryId: String, promise: Promise) {
|
|
97
102
|
try {
|
|
98
|
-
DoorstepAI.newEvent(eventName) { result ->
|
|
99
|
-
result.onSuccess {
|
|
100
|
-
promise.resolve(
|
|
103
|
+
DoorstepAI.newEvent(eventName, deliveryId) { result ->
|
|
104
|
+
result.onSuccess { eventResponse ->
|
|
105
|
+
promise.resolve(eventResponse)
|
|
101
106
|
}.onFailure { error ->
|
|
102
|
-
promise.reject("
|
|
107
|
+
promise.reject("EVENT_CREATION_ERROR", error.message ?: "Promise Rejection: Failed to save event")
|
|
103
108
|
}
|
|
104
109
|
}
|
|
105
110
|
} catch (e: Exception) {
|
|
106
|
-
promise.reject("
|
|
111
|
+
promise.reject("EVENT_CREATION_ERROR", e.message ?: "Failed to save event")
|
|
107
112
|
}
|
|
108
113
|
}
|
|
109
114
|
|
|
110
115
|
@ReactMethod
|
|
111
|
-
fun stopDelivery(promise: Promise) {
|
|
116
|
+
fun stopDelivery(deliveryId: String, promise: Promise) {
|
|
112
117
|
try {
|
|
113
|
-
DoorstepAI.stopDelivery()
|
|
118
|
+
DoorstepAI.stopDelivery(deliveryId)
|
|
114
119
|
promise.resolve(true)
|
|
115
120
|
} catch (e: Exception) {
|
|
116
|
-
promise.reject("
|
|
121
|
+
promise.reject("DELIVERY_STOP_ERROR", e.message ?: "Failed to stop delivery")
|
|
117
122
|
}
|
|
118
123
|
}
|
|
119
124
|
|
|
@@ -122,6 +127,11 @@ class DoorstepAIModule(private val reactContext: ReactApplicationContext) :
|
|
|
122
127
|
DoorstepAI.setAPIKey(key)
|
|
123
128
|
}
|
|
124
129
|
|
|
130
|
+
@ReactMethod
|
|
131
|
+
fun setDevMode(devModeEnabled: Boolean) {
|
|
132
|
+
DoorstepAI.devMode = devModeEnabled
|
|
133
|
+
}
|
|
134
|
+
|
|
125
135
|
companion object {
|
|
126
136
|
const val NAME = "DoorstepAI"
|
|
127
137
|
}
|
package/ios/DoorstepAI.mm
CHANGED
|
@@ -3,19 +3,25 @@
|
|
|
3
3
|
@interface RCT_EXTERN_MODULE(DoorstepAI, NSObject)
|
|
4
4
|
|
|
5
5
|
RCT_EXTERN_METHOD(setApiKey:(NSString *)apiKey)
|
|
6
|
+
RCT_EXTERN_METHOD(setDevMode:(BOOL)devModeEnabled)
|
|
6
7
|
RCT_EXTERN_METHOD(startDeliveryByPlaceID:(NSString *)placeID
|
|
8
|
+
deliveryId:(NSString *)deliveryId
|
|
7
9
|
resolver:(RCTPromiseResolveBlock)resolve
|
|
8
10
|
rejecter:(RCTPromiseRejectBlock)reject)
|
|
9
11
|
RCT_EXTERN_METHOD(startDeliveryByPlusCode:(NSString *)plusCode
|
|
12
|
+
deliveryId:(NSString *)deliveryId
|
|
10
13
|
resolver:(RCTPromiseResolveBlock)resolve
|
|
11
14
|
rejecter:(RCTPromiseRejectBlock)reject)
|
|
12
|
-
RCT_EXTERN_METHOD(startDeliveryByAddress:(
|
|
15
|
+
RCT_EXTERN_METHOD(startDeliveryByAddress:(NSDictionary *)address
|
|
16
|
+
deliveryId:(NSString *)deliveryId
|
|
13
17
|
resolver:(RCTPromiseResolveBlock)resolve
|
|
14
18
|
rejecter:(RCTPromiseRejectBlock)reject)
|
|
15
19
|
RCT_EXTERN_METHOD(newEvent:(NSString *)eventName
|
|
20
|
+
deliveryId:(NSString *)deliveryId
|
|
16
21
|
resolver:(RCTPromiseResolveBlock)resolve
|
|
17
22
|
rejecter:(RCTPromiseRejectBlock)reject)
|
|
18
|
-
RCT_EXTERN_METHOD(stopDelivery:(
|
|
23
|
+
RCT_EXTERN_METHOD(stopDelivery:(NSString *)deliveryId
|
|
24
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
19
25
|
rejecter:(RCTPromiseRejectBlock)reject)
|
|
20
26
|
|
|
21
27
|
@end
|
package/ios/DoorstepAI.swift
CHANGED
|
@@ -10,6 +10,11 @@ class DoorstepAIBridge: NSObject {
|
|
|
10
10
|
return true
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
@objc
|
|
14
|
+
func setDevMode(_ devModeEnabled: Bool) {
|
|
15
|
+
DoorstepAI.devMode = devModeEnabled
|
|
16
|
+
}
|
|
17
|
+
|
|
13
18
|
@objc
|
|
14
19
|
func setApiKey(_ apiKey: String) {
|
|
15
20
|
DoorstepAI.setApiKey(key: apiKey)
|
|
@@ -17,12 +22,13 @@ class DoorstepAIBridge: NSObject {
|
|
|
17
22
|
|
|
18
23
|
@objc
|
|
19
24
|
func startDeliveryByPlaceID(_ placeID: NSString,
|
|
25
|
+
deliveryId: NSString,
|
|
20
26
|
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
21
27
|
rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
22
28
|
// Use Swift's concurrency support to call the async method.
|
|
23
29
|
Task {
|
|
24
30
|
do {
|
|
25
|
-
try await DoorstepAI.startDeliveryByPlaceID(placeID: placeID as String)
|
|
31
|
+
try await DoorstepAI.startDeliveryByPlaceID(placeID: placeID as String, deliveryId: deliveryId as String)
|
|
26
32
|
resolve(nil)
|
|
27
33
|
} catch {
|
|
28
34
|
reject("E_START_DELIVERY", "Failed to start delivery by Place ID: \(error.localizedDescription)", error)
|
|
@@ -32,11 +38,12 @@ class DoorstepAIBridge: NSObject {
|
|
|
32
38
|
|
|
33
39
|
@objc
|
|
34
40
|
func startDeliveryByPlusCode(_ plusCode: NSString,
|
|
41
|
+
deliveryId: NSString,
|
|
35
42
|
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
36
43
|
rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
37
44
|
Task {
|
|
38
45
|
do {
|
|
39
|
-
try await DoorstepAI.startDeliveryByPlusCode(plusCode: plusCode as String)
|
|
46
|
+
try await DoorstepAI.startDeliveryByPlusCode(plusCode: plusCode as String, deliveryId: deliveryId as String)
|
|
40
47
|
resolve(nil)
|
|
41
48
|
} catch {
|
|
42
49
|
reject("E_START_DELIVERY", "Failed to start delivery by Plus Code: \(error.localizedDescription)", error)
|
|
@@ -45,51 +52,48 @@ class DoorstepAIBridge: NSObject {
|
|
|
45
52
|
}
|
|
46
53
|
|
|
47
54
|
@objc
|
|
48
|
-
func startDeliveryByAddress(_
|
|
55
|
+
func startDeliveryByAddress(_ address: [String: Any],
|
|
56
|
+
deliveryId: NSString,
|
|
49
57
|
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
50
58
|
rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
51
|
-
guard let data = (addressJSON as String).data(using: .utf8) else {
|
|
52
|
-
reject("E_INVALID_ADDRESS", "Invalid JSON string format.", nil)
|
|
53
|
-
return
|
|
54
|
-
}
|
|
55
|
-
|
|
56
59
|
Task {
|
|
60
|
+
print("Starting delivery by address: \(address)")
|
|
57
61
|
do {
|
|
58
|
-
guard let
|
|
59
|
-
let
|
|
60
|
-
let
|
|
61
|
-
let
|
|
62
|
-
let
|
|
63
|
-
let
|
|
64
|
-
|
|
65
|
-
reject("E_INVALID_ADDRESS", "Missing or invalid fields in address JSON.", nil)
|
|
62
|
+
guard let streetNumber = address["streetNumber"] as? String,
|
|
63
|
+
let route = address["route"] as? String,
|
|
64
|
+
let subPremise = address["subPremise"] as? String,
|
|
65
|
+
let locality = address["locality"] as? String,
|
|
66
|
+
let administrativeAreaLevel1 = address["administrativeAreaLevel1"] as? String,
|
|
67
|
+
let postalCode = address["postalCode"] as? String else {
|
|
68
|
+
reject("E_INVALID_ADDRESS", "Missing or invalid fields in address dictionary.", nil)
|
|
66
69
|
return
|
|
67
70
|
}
|
|
68
71
|
|
|
69
|
-
let
|
|
72
|
+
let addressStruct = AddressType(streetNumber: streetNumber,
|
|
70
73
|
route: route,
|
|
71
74
|
subPremise: subPremise,
|
|
72
75
|
locality: locality,
|
|
73
76
|
administrativeAreaLevel1: administrativeAreaLevel1,
|
|
74
77
|
postalCode: postalCode)
|
|
75
78
|
|
|
76
|
-
try await DoorstepAI.startDeliveryByAddressType(address:
|
|
79
|
+
try await DoorstepAI.startDeliveryByAddressType(address: addressStruct, deliveryId: deliveryId as String)
|
|
77
80
|
resolve(nil)
|
|
78
81
|
} catch let error as DoorstepAIError {
|
|
79
82
|
reject("E_START_DELIVERY", "Failed to start delivery by address: \(error.localizedDescription)", error)
|
|
80
83
|
} catch {
|
|
81
|
-
reject("
|
|
84
|
+
reject("E_UNKNOWN", "An unexpected error occurred: \(error.localizedDescription)", error)
|
|
82
85
|
}
|
|
83
86
|
}
|
|
84
87
|
}
|
|
85
88
|
|
|
86
89
|
@objc
|
|
87
90
|
func newEvent(_ eventName: NSString,
|
|
91
|
+
deliveryId: NSString,
|
|
88
92
|
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
89
93
|
rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
90
94
|
Task {
|
|
91
95
|
do {
|
|
92
|
-
try await DoorstepAI.newEvent(eventName: eventName as String)
|
|
96
|
+
try await DoorstepAI.newEvent(eventName: eventName as String, deliveryId: deliveryId as String)
|
|
93
97
|
resolve(nil)
|
|
94
98
|
} catch {
|
|
95
99
|
reject("E_NEW_EVENT", "Failed to send event: \(error.localizedDescription)", error)
|
|
@@ -98,11 +102,12 @@ class DoorstepAIBridge: NSObject {
|
|
|
98
102
|
}
|
|
99
103
|
|
|
100
104
|
@objc
|
|
101
|
-
func stopDelivery(_
|
|
105
|
+
func stopDelivery(_ deliveryId: NSString,
|
|
106
|
+
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
102
107
|
rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
103
108
|
Task {
|
|
104
109
|
// stopDelivery does not throw so we simply await its completion
|
|
105
|
-
await DoorstepAI.stopDelivery()
|
|
110
|
+
await DoorstepAI.stopDelivery(deliveryId: deliveryId as String)
|
|
106
111
|
resolve(nil)
|
|
107
112
|
}
|
|
108
113
|
}
|