@trycourier/courier-react-native 3.2.1 → 4.0.4
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 +4 -1
- package/android/src/main/java/com/courierreactnative/CourierClientModule.kt +441 -0
- package/android/src/main/java/com/courierreactnative/CourierInboxViewManager.kt +2 -2
- package/android/src/main/java/com/courierreactnative/CourierReactNativePackage.kt +9 -3
- package/android/src/main/java/com/courierreactnative/CourierSharedModule.kt +321 -0
- package/android/src/main/java/com/courierreactnative/CourierSystemModule.kt +91 -0
- package/android/src/main/java/com/courierreactnative/ReactNativeModule.kt +36 -0
- package/android/src/main/java/com/courierreactnative/{Extensions.kt → Utils.kt} +5 -5
- package/courier-react-native.podspec +1 -1
- package/ios/CourierClientModule.swift +450 -0
- package/ios/CourierInboxReactNativeManager.swift +17 -9
- package/ios/CourierReactNativeDelegate.m +18 -35
- package/ios/CourierReactNativeEventEmitter.swift +25 -0
- package/ios/CourierReactNativeModule.m +192 -23
- package/ios/CourierSharedModule.swift +425 -0
- package/ios/CourierSystemModule.swift +147 -0
- package/ios/Utils.swift +103 -115
- package/lib/commonjs/Broadcaster.js +30 -0
- package/lib/commonjs/Broadcaster.js.map +1 -0
- package/lib/commonjs/Modules.js +25 -0
- package/lib/commonjs/Modules.js.map +1 -0
- package/lib/commonjs/client/BrandClient.js +25 -0
- package/lib/commonjs/client/BrandClient.js.map +1 -0
- package/lib/commonjs/client/ClientModule.js +21 -0
- package/lib/commonjs/client/ClientModule.js.map +1 -0
- package/lib/commonjs/client/CourierClient.js +33 -0
- package/lib/commonjs/client/CourierClient.js.map +1 -0
- package/lib/commonjs/client/InboxClient.js +116 -0
- package/lib/commonjs/client/InboxClient.js.map +1 -0
- package/lib/commonjs/client/PreferenceClient.js +73 -0
- package/lib/commonjs/client/PreferenceClient.js.map +1 -0
- package/lib/commonjs/client/TokenClient.js +36 -0
- package/lib/commonjs/client/TokenClient.js.map +1 -0
- package/lib/commonjs/client/TrackingClient.js +25 -0
- package/lib/commonjs/client/TrackingClient.js.map +1 -0
- package/lib/commonjs/index.js +418 -186
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/Android_CourierSheet.js.map +1 -1
- package/lib/commonjs/models/CourierAuthenticationListener.js.map +1 -1
- package/lib/commonjs/models/CourierBrand.js +2 -0
- package/lib/commonjs/models/{CourierUserPreferencesTopic.js.map → CourierBrand.js.map} +1 -1
- package/lib/commonjs/models/CourierButton.js.map +1 -1
- package/lib/commonjs/models/CourierDevice.js +2 -0
- package/lib/commonjs/models/CourierDevice.js.map +1 -0
- package/lib/commonjs/models/CourierFont.js.map +1 -1
- package/lib/commonjs/models/CourierInboxListener.js +2 -2
- package/lib/commonjs/models/CourierInboxListener.js.map +1 -1
- package/lib/commonjs/models/{CourierUserPreferencesTopic.js → CourierInboxMessages.js} +1 -1
- package/lib/commonjs/models/CourierInboxMessages.js.map +1 -0
- package/lib/commonjs/models/CourierInboxTheme.js.map +1 -1
- package/lib/commonjs/models/CourierInfoViewStyle.js.map +1 -1
- package/lib/commonjs/models/CourierPaging.js.map +1 -1
- package/lib/commonjs/models/CourierPreferencesTheme.js.map +1 -1
- package/lib/commonjs/models/CourierPushListener.js +7 -3
- package/lib/commonjs/models/CourierPushListener.js.map +1 -1
- package/lib/commonjs/models/CourierPushProvider.js.map +1 -1
- package/lib/commonjs/models/CourierTrackingEvent.js +16 -0
- package/lib/commonjs/models/CourierTrackingEvent.js.map +1 -0
- package/lib/commonjs/models/CourierUserPreferences.js +54 -0
- package/lib/commonjs/models/CourierUserPreferences.js.map +1 -1
- package/lib/commonjs/models/InboxAction.js.map +1 -1
- package/lib/commonjs/models/InboxMessage.js.map +1 -1
- package/lib/commonjs/models/iOS_CourierCell.js.map +1 -1
- package/lib/commonjs/models/iOS_CourierSheet.js.map +1 -1
- package/lib/commonjs/utils.js +9 -17
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/commonjs/views/CourierInboxView.js +3 -3
- package/lib/commonjs/views/CourierInboxView.js.map +1 -1
- package/lib/commonjs/views/CourierPreferencesView.js.map +1 -1
- package/lib/module/Broadcaster.js +23 -0
- package/lib/module/Broadcaster.js.map +1 -0
- package/lib/module/Modules.js +18 -0
- package/lib/module/Modules.js.map +1 -0
- package/lib/module/client/BrandClient.js +18 -0
- package/lib/module/client/BrandClient.js.map +1 -0
- package/lib/module/client/ClientModule.js +14 -0
- package/lib/module/client/ClientModule.js.map +1 -0
- package/lib/module/client/CourierClient.js +26 -0
- package/lib/module/client/CourierClient.js.map +1 -0
- package/lib/module/client/InboxClient.js +109 -0
- package/lib/module/client/InboxClient.js.map +1 -0
- package/lib/module/client/PreferenceClient.js +66 -0
- package/lib/module/client/PreferenceClient.js.map +1 -0
- package/lib/module/client/TokenClient.js +29 -0
- package/lib/module/client/TokenClient.js.map +1 -0
- package/lib/module/client/TrackingClient.js +18 -0
- package/lib/module/client/TrackingClient.js.map +1 -0
- package/lib/module/index.js +383 -185
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/Android_CourierSheet.js.map +1 -1
- package/lib/module/models/CourierAuthenticationListener.js.map +1 -1
- package/lib/module/models/CourierBrand.js +2 -0
- package/lib/module/models/{CourierUserPreferencesTopic.js.map → CourierBrand.js.map} +1 -1
- package/lib/module/models/CourierButton.js.map +1 -1
- package/lib/module/models/CourierDevice.js +2 -0
- package/lib/module/models/CourierDevice.js.map +1 -0
- package/lib/module/models/CourierFont.js.map +1 -1
- package/lib/module/models/CourierInboxListener.js +1 -1
- package/lib/module/models/CourierInboxListener.js.map +1 -1
- package/lib/module/models/CourierInboxMessages.js +2 -0
- package/lib/module/models/CourierInboxMessages.js.map +1 -0
- package/lib/module/models/CourierInboxTheme.js.map +1 -1
- package/lib/module/models/CourierInfoViewStyle.js.map +1 -1
- package/lib/module/models/CourierPaging.js.map +1 -1
- package/lib/module/models/CourierPreferencesTheme.js.map +1 -1
- package/lib/module/models/CourierPushListener.js +7 -3
- package/lib/module/models/CourierPushListener.js.map +1 -1
- package/lib/module/models/CourierPushProvider.js.map +1 -1
- package/lib/module/models/CourierTrackingEvent.js +9 -0
- package/lib/module/models/CourierTrackingEvent.js.map +1 -0
- package/lib/module/models/CourierUserPreferences.js +53 -1
- package/lib/module/models/CourierUserPreferences.js.map +1 -1
- package/lib/module/models/InboxAction.js.map +1 -1
- package/lib/module/models/InboxMessage.js.map +1 -1
- package/lib/module/models/iOS_CourierCell.js.map +1 -1
- package/lib/module/models/iOS_CourierSheet.js.map +1 -1
- package/lib/module/utils.js +7 -16
- package/lib/module/utils.js.map +1 -1
- package/lib/module/views/CourierInboxView.js +3 -3
- package/lib/module/views/CourierInboxView.js.map +1 -1
- package/lib/module/views/CourierPreferencesView.js.map +1 -1
- package/lib/typescript/src/Broadcaster.d.ts +14 -0
- package/lib/typescript/src/Broadcaster.d.ts.map +1 -0
- package/lib/typescript/src/Modules.d.ts +8 -0
- package/lib/typescript/src/Modules.d.ts.map +1 -0
- package/lib/typescript/src/client/BrandClient.d.ts +15 -0
- package/lib/typescript/src/client/BrandClient.d.ts.map +1 -0
- package/lib/typescript/src/client/ClientModule.d.ts +8 -0
- package/lib/typescript/src/client/ClientModule.d.ts.map +1 -0
- package/lib/typescript/src/client/CourierClient.d.ts +31 -0
- package/lib/typescript/src/client/CourierClient.d.ts.map +1 -0
- package/lib/typescript/src/client/InboxClient.d.ts +94 -0
- package/lib/typescript/src/client/InboxClient.d.ts.map +1 -0
- package/lib/typescript/src/client/PreferenceClient.d.ts +39 -0
- package/lib/typescript/src/client/PreferenceClient.d.ts.map +1 -0
- package/lib/typescript/src/client/TokenClient.d.ts +28 -0
- package/lib/typescript/src/client/TokenClient.d.ts.map +1 -0
- package/lib/typescript/src/client/TrackingClient.d.ts +17 -0
- package/lib/typescript/src/client/TrackingClient.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +300 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/models/Android_CourierSheet.d.ts.map +1 -0
- package/lib/typescript/src/models/CourierAuthenticationListener.d.ts.map +1 -0
- package/lib/typescript/src/models/CourierBrand.d.ts +20 -0
- package/lib/typescript/src/models/CourierBrand.d.ts.map +1 -0
- package/lib/typescript/src/models/CourierButton.d.ts.map +1 -0
- package/lib/typescript/src/models/CourierDevice.d.ts +9 -0
- package/lib/typescript/src/models/CourierDevice.d.ts.map +1 -0
- package/lib/typescript/src/models/CourierFont.d.ts.map +1 -0
- package/lib/typescript/src/models/CourierInboxListener.d.ts.map +1 -0
- package/lib/typescript/src/models/CourierInboxMessages.d.ts +23 -0
- package/lib/typescript/src/models/CourierInboxMessages.d.ts.map +1 -0
- package/lib/typescript/src/models/CourierInboxTheme.d.ts.map +1 -0
- package/lib/typescript/src/models/CourierInfoViewStyle.d.ts.map +1 -0
- package/lib/typescript/src/models/CourierPaging.d.ts.map +1 -0
- package/lib/typescript/src/models/CourierPreferencesTheme.d.ts.map +1 -0
- package/lib/typescript/src/models/CourierPushListener.d.ts +8 -0
- package/lib/typescript/src/models/CourierPushListener.d.ts.map +1 -0
- package/lib/typescript/src/models/CourierPushProvider.d.ts.map +1 -0
- package/lib/typescript/src/models/CourierTrackingEvent.d.ts +8 -0
- package/lib/typescript/src/models/CourierTrackingEvent.d.ts.map +1 -0
- package/lib/typescript/src/models/CourierUserPreferences.d.ts +35 -0
- package/lib/typescript/src/models/CourierUserPreferences.d.ts.map +1 -0
- package/lib/typescript/src/models/InboxAction.d.ts.map +1 -0
- package/lib/typescript/src/models/InboxMessage.d.ts.map +1 -0
- package/lib/typescript/src/models/iOS_CourierCell.d.ts.map +1 -0
- package/lib/typescript/src/models/iOS_CourierSheet.d.ts.map +1 -0
- package/lib/typescript/src/utils.d.ts +14 -0
- package/lib/typescript/src/utils.d.ts.map +1 -0
- package/lib/typescript/src/views/CourierInboxView.d.ts.map +1 -0
- package/lib/typescript/src/views/CourierPreferencesView.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/Broadcaster.tsx +32 -0
- package/src/Modules.tsx +28 -0
- package/src/client/BrandClient.tsx +23 -0
- package/src/client/ClientModule.tsx +21 -0
- package/src/client/CourierClient.tsx +49 -0
- package/src/client/InboxClient.tsx +114 -0
- package/src/client/PreferenceClient.tsx +77 -0
- package/src/client/TokenClient.tsx +34 -0
- package/src/client/TrackingClient.tsx +23 -0
- package/src/index.tsx +398 -205
- package/src/models/CourierBrand.tsx +24 -0
- package/src/models/CourierDevice.tsx +8 -0
- package/src/models/CourierInboxListener.tsx +1 -1
- package/src/models/CourierInboxMessages.tsx +28 -0
- package/src/models/CourierPushListener.tsx +11 -6
- package/src/models/CourierTrackingEvent.tsx +7 -0
- package/src/models/CourierUserPreferences.tsx +70 -3
- package/src/utils.tsx +7 -23
- package/src/views/CourierInboxView.tsx +3 -3
- package/android/src/main/java/com/courierreactnative/CourierReactNativeModule.kt +0 -393
- package/ios/CourierReactNativeModule.swift +0 -524
- package/lib/commonjs/models/CourierUserPreferencesChannel.js +0 -17
- package/lib/commonjs/models/CourierUserPreferencesChannel.js.map +0 -1
- package/lib/commonjs/models/CourierUserPreferencesStatus.js +0 -15
- package/lib/commonjs/models/CourierUserPreferencesStatus.js.map +0 -1
- package/lib/module/models/CourierUserPreferencesChannel.js +0 -10
- package/lib/module/models/CourierUserPreferencesChannel.js.map +0 -1
- package/lib/module/models/CourierUserPreferencesStatus.js +0 -8
- package/lib/module/models/CourierUserPreferencesStatus.js.map +0 -1
- package/lib/module/models/CourierUserPreferencesTopic.js +0 -2
- package/lib/typescript/index.d.ts +0 -199
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/models/Android_CourierSheet.d.ts.map +0 -1
- package/lib/typescript/models/CourierAuthenticationListener.d.ts.map +0 -1
- package/lib/typescript/models/CourierButton.d.ts.map +0 -1
- package/lib/typescript/models/CourierFont.d.ts.map +0 -1
- package/lib/typescript/models/CourierInboxListener.d.ts.map +0 -1
- package/lib/typescript/models/CourierInboxTheme.d.ts.map +0 -1
- package/lib/typescript/models/CourierInfoViewStyle.d.ts.map +0 -1
- package/lib/typescript/models/CourierPaging.d.ts.map +0 -1
- package/lib/typescript/models/CourierPreferencesTheme.d.ts.map +0 -1
- package/lib/typescript/models/CourierPushListener.d.ts +0 -7
- package/lib/typescript/models/CourierPushListener.d.ts.map +0 -1
- package/lib/typescript/models/CourierPushProvider.d.ts.map +0 -1
- package/lib/typescript/models/CourierUserPreferences.d.ts +0 -7
- package/lib/typescript/models/CourierUserPreferences.d.ts.map +0 -1
- package/lib/typescript/models/CourierUserPreferencesChannel.d.ts +0 -9
- package/lib/typescript/models/CourierUserPreferencesChannel.d.ts.map +0 -1
- package/lib/typescript/models/CourierUserPreferencesStatus.d.ts +0 -7
- package/lib/typescript/models/CourierUserPreferencesStatus.d.ts.map +0 -1
- package/lib/typescript/models/CourierUserPreferencesTopic.d.ts +0 -13
- package/lib/typescript/models/CourierUserPreferencesTopic.d.ts.map +0 -1
- package/lib/typescript/models/InboxAction.d.ts.map +0 -1
- package/lib/typescript/models/InboxMessage.d.ts.map +0 -1
- package/lib/typescript/models/iOS_CourierCell.d.ts.map +0 -1
- package/lib/typescript/models/iOS_CourierSheet.d.ts.map +0 -1
- package/lib/typescript/utils.d.ts +0 -21
- package/lib/typescript/utils.d.ts.map +0 -1
- package/lib/typescript/views/CourierInboxView.d.ts.map +0 -1
- package/lib/typescript/views/CourierPreferencesView.d.ts.map +0 -1
- package/src/models/CourierUserPreferencesChannel.tsx +0 -8
- package/src/models/CourierUserPreferencesStatus.tsx +0 -6
- package/src/models/CourierUserPreferencesTopic.tsx +0 -13
- /package/lib/typescript/{models → src/models}/Android_CourierSheet.d.ts +0 -0
- /package/lib/typescript/{models → src/models}/CourierAuthenticationListener.d.ts +0 -0
- /package/lib/typescript/{models → src/models}/CourierButton.d.ts +0 -0
- /package/lib/typescript/{models → src/models}/CourierFont.d.ts +0 -0
- /package/lib/typescript/{models → src/models}/CourierInboxListener.d.ts +0 -0
- /package/lib/typescript/{models → src/models}/CourierInboxTheme.d.ts +0 -0
- /package/lib/typescript/{models → src/models}/CourierInfoViewStyle.d.ts +0 -0
- /package/lib/typescript/{models → src/models}/CourierPaging.d.ts +0 -0
- /package/lib/typescript/{models → src/models}/CourierPreferencesTheme.d.ts +0 -0
- /package/lib/typescript/{models → src/models}/CourierPushProvider.d.ts +0 -0
- /package/lib/typescript/{models → src/models}/InboxAction.d.ts +0 -0
- /package/lib/typescript/{models → src/models}/InboxMessage.d.ts +0 -0
- /package/lib/typescript/{models → src/models}/iOS_CourierCell.d.ts +0 -0
- /package/lib/typescript/{models → src/models}/iOS_CourierSheet.d.ts +0 -0
- /package/lib/typescript/{views → src/views}/CourierInboxView.d.ts +0 -0
- /package/lib/typescript/{views → src/views}/CourierPreferencesView.d.ts +0 -0
package/ios/Utils.swift
CHANGED
|
@@ -23,121 +23,6 @@ extension UNAuthorizationStatus {
|
|
|
23
23
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
internal extension [String: Any?] {
|
|
27
|
-
|
|
28
|
-
func clean() -> NSMutableDictionary {
|
|
29
|
-
|
|
30
|
-
let mutableDictionary = NSMutableDictionary()
|
|
31
|
-
for (key, value) in self {
|
|
32
|
-
if let unwrappedValue = value {
|
|
33
|
-
mutableDictionary[key] = unwrappedValue
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return mutableDictionary
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
internal extension CourierUserPreferences {
|
|
44
|
-
|
|
45
|
-
@objc func toDictionary() -> NSDictionary {
|
|
46
|
-
|
|
47
|
-
let dictionary: [String: Any?] = [
|
|
48
|
-
"items": items.map { $0.toDictionary() },
|
|
49
|
-
"paging": paging.toDictionary(),
|
|
50
|
-
]
|
|
51
|
-
|
|
52
|
-
return dictionary.clean()
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
internal extension CourierUserPreferencesTopic {
|
|
59
|
-
|
|
60
|
-
@objc func toDictionary() -> NSDictionary {
|
|
61
|
-
|
|
62
|
-
let dictionary: [String: Any?] = [
|
|
63
|
-
"defaultStatus": defaultStatus.rawValue,
|
|
64
|
-
"hasCustomRouting": hasCustomRouting,
|
|
65
|
-
"customRouting": customRouting.map { $0.rawValue },
|
|
66
|
-
"status": status,
|
|
67
|
-
"topicId": topicId,
|
|
68
|
-
"topicName": topicName,
|
|
69
|
-
"sectionName": sectionName,
|
|
70
|
-
"sectionId": sectionId,
|
|
71
|
-
]
|
|
72
|
-
|
|
73
|
-
return dictionary.clean()
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
internal extension CourierUserPreferencesPaging {
|
|
80
|
-
|
|
81
|
-
@objc func toDictionary() -> NSDictionary {
|
|
82
|
-
|
|
83
|
-
let dictionary: [String: Any?] = [
|
|
84
|
-
"cursor": cursor,
|
|
85
|
-
"more": more,
|
|
86
|
-
]
|
|
87
|
-
|
|
88
|
-
return dictionary.clean()
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
internal extension InboxMessage {
|
|
95
|
-
|
|
96
|
-
@objc func toDictionary() -> NSDictionary {
|
|
97
|
-
|
|
98
|
-
let dictionary: [String: Any?] = [
|
|
99
|
-
"messageId": messageId,
|
|
100
|
-
"title": title,
|
|
101
|
-
"body": body,
|
|
102
|
-
"preview": preview,
|
|
103
|
-
"created": created,
|
|
104
|
-
"actions": actions?.map { $0.toDictionary() },
|
|
105
|
-
"data": data,
|
|
106
|
-
"read": isRead,
|
|
107
|
-
"opened": isOpened,
|
|
108
|
-
"archived": isArchived,
|
|
109
|
-
"trackingIds": [
|
|
110
|
-
"archiveTrackingId": trackingIds?.archiveTrackingId,
|
|
111
|
-
"openTrackingId": trackingIds?.openTrackingId,
|
|
112
|
-
"clickTrackingId": trackingIds?.clickTrackingId,
|
|
113
|
-
"deliverTrackingId": trackingIds?.deliverTrackingId,
|
|
114
|
-
"unreadTrackingId": trackingIds?.unreadTrackingId,
|
|
115
|
-
"readTrackingId": trackingIds?.readTrackingId,
|
|
116
|
-
]
|
|
117
|
-
]
|
|
118
|
-
|
|
119
|
-
return dictionary.clean()
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
internal extension InboxAction {
|
|
126
|
-
|
|
127
|
-
@objc func toDictionary() -> NSDictionary {
|
|
128
|
-
|
|
129
|
-
let dictionary: [String: Any?] = [
|
|
130
|
-
"content": content,
|
|
131
|
-
"href": href,
|
|
132
|
-
"data": data
|
|
133
|
-
]
|
|
134
|
-
|
|
135
|
-
return dictionary.clean()
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
|
|
141
26
|
internal extension String {
|
|
142
27
|
|
|
143
28
|
func toRowAnimation() -> UITableView.RowAnimation {
|
|
@@ -275,3 +160,106 @@ internal extension NSDictionary {
|
|
|
275
160
|
}
|
|
276
161
|
|
|
277
162
|
}
|
|
163
|
+
|
|
164
|
+
internal extension Encodable {
|
|
165
|
+
|
|
166
|
+
func toJson() throws -> String? {
|
|
167
|
+
let encoder = JSONEncoder()
|
|
168
|
+
encoder.outputFormatting = .prettyPrinted
|
|
169
|
+
let data = try encoder.encode(self)
|
|
170
|
+
return String(data: data, encoding: .utf8) ?? nil
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
internal class Rejections {
|
|
176
|
+
|
|
177
|
+
private static let CLIENT_TAG = "Courier Client Error"
|
|
178
|
+
private static let SHARED_TAG = "Courier SDK Error"
|
|
179
|
+
|
|
180
|
+
static func missingClient(_ reject: @escaping RCTPromiseRejectBlock) {
|
|
181
|
+
reject("Missing Client", Rejections.CLIENT_TAG, nil)
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
static func clientError(_ reject: @escaping RCTPromiseRejectBlock, error: Error) {
|
|
185
|
+
reject(String(describing: error), Rejections.CLIENT_TAG, nil)
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
static func sharedError(_ reject: @escaping RCTPromiseRejectBlock, error: Error) {
|
|
189
|
+
reject(String(describing: error), Rejections.SHARED_TAG, nil)
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
extension [AnyHashable: Any] {
|
|
195
|
+
|
|
196
|
+
func toString() throws -> String {
|
|
197
|
+
let json = try JSONSerialization.data(withJSONObject: self)
|
|
198
|
+
let str = String(data: json, encoding: .utf8)
|
|
199
|
+
return str ?? "Invalid JSON"
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
extension NSDictionary {
|
|
205
|
+
|
|
206
|
+
func toPresentationOptions() -> UNNotificationPresentationOptions {
|
|
207
|
+
|
|
208
|
+
var foregroundPresentationOptions: UNNotificationPresentationOptions = []
|
|
209
|
+
|
|
210
|
+
if let options = self["options"] as? [String] {
|
|
211
|
+
options.forEach { option in
|
|
212
|
+
switch option {
|
|
213
|
+
case "sound": foregroundPresentationOptions.insert(.sound)
|
|
214
|
+
case "badge": foregroundPresentationOptions.insert(.badge)
|
|
215
|
+
case "list": if #available(iOS 14.0, *) { foregroundPresentationOptions.insert(.list) } else { foregroundPresentationOptions.insert(.alert) }
|
|
216
|
+
case "banner": if #available(iOS 14.0, *) { foregroundPresentationOptions.insert(.banner) } else { foregroundPresentationOptions.insert(.alert) }
|
|
217
|
+
default: break
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return foregroundPresentationOptions
|
|
223
|
+
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
internal class LogEvents {
|
|
229
|
+
static let DEBUG_LOG = "courierDebugEvent"
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
internal class PushEvents {
|
|
233
|
+
static let CLICKED_EVENT = "pushNotificationClicked"
|
|
234
|
+
static let DELIVERED_EVENT = "pushNotificationDelivered"
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// MARK: Broadcasting
|
|
238
|
+
|
|
239
|
+
internal extension RCTEventEmitter {
|
|
240
|
+
|
|
241
|
+
func broadcast(name: String, body: Any? = nil) {
|
|
242
|
+
|
|
243
|
+
let events: [String]? = supportedEvents()
|
|
244
|
+
if (events?.contains(name) != true) {
|
|
245
|
+
return
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
sendEvent(
|
|
249
|
+
withName: name,
|
|
250
|
+
body: body
|
|
251
|
+
)
|
|
252
|
+
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
func broadcast(name: String, message: [AnyHashable: Any]? = nil) {
|
|
256
|
+
|
|
257
|
+
do {
|
|
258
|
+
broadcast(name: name, body: try message?.toString())
|
|
259
|
+
} catch {
|
|
260
|
+
Courier.shared.client?.log(String(describing: error))
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
class Broadcaster {
|
|
9
|
+
constructor(module) {
|
|
10
|
+
this.emitter = new _reactNative.NativeEventEmitter(module);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Creates an event listener for the native function
|
|
15
|
+
* @param key Key for the listener
|
|
16
|
+
* @param callback Value returned for the listener callback
|
|
17
|
+
* @returns Subscription
|
|
18
|
+
*/
|
|
19
|
+
addListener(id, callback) {
|
|
20
|
+
if (_reactNative.Platform.OS === 'android') {
|
|
21
|
+
return _reactNative.DeviceEventEmitter.addListener(id, event => callback(event));
|
|
22
|
+
}
|
|
23
|
+
if (_reactNative.Platform.OS === 'ios') {
|
|
24
|
+
return this.emitter.addListener(id, event => callback(event));
|
|
25
|
+
}
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.default = Broadcaster;
|
|
30
|
+
//# sourceMappingURL=Broadcaster.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","Broadcaster","constructor","module","emitter","NativeEventEmitter","addListener","id","callback","Platform","OS","DeviceEventEmitter","event","undefined","exports","default"],"sourceRoot":"../../src","sources":["Broadcaster.tsx"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAEe,MAAMC,WAAW,CAAC;EAI/BC,WAAWA,CAACC,MAAoB,EAAE;IAChC,IAAI,CAACC,OAAO,GAAG,IAAIC,+BAAkB,CAACF,MAAM,CAAC;EAC/C;;EAEA;AACF;AACA;AACA;AACA;AACA;EACEG,WAAWA,CAACC,EAAU,EAAEC,QAA8B,EAAmC;IAEvF,IAAIC,qBAAQ,CAACC,EAAE,KAAK,SAAS,EAAE;MAC7B,OAAOC,+BAAkB,CAACL,WAAW,CAACC,EAAE,EAAGK,KAAU,IAAKJ,QAAQ,CAACI,KAAK,CAAC,CAAC;IAC5E;IAEA,IAAIH,qBAAQ,CAACC,EAAE,KAAK,KAAK,EAAE;MACzB,OAAO,IAAI,CAACN,OAAO,CAACE,WAAW,CAACC,EAAE,EAAGK,KAAU,IAAKJ,QAAQ,CAACI,KAAK,CAAC,CAAC;IACtE;IAEA,OAAOC,SAAS;EAElB;AAEF;AAACC,OAAA,CAAAC,OAAA,GAAAd,WAAA","ignoreList":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Modules = void 0;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
class Modules {
|
|
9
|
+
static LINKING_ERROR = `The package '@trycourier/courier-react-native' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
|
|
10
|
+
ios: "- You have run 'pod install'\n",
|
|
11
|
+
default: ''
|
|
12
|
+
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
|
|
13
|
+
static Client = Modules.getNativeModule(_reactNative.NativeModules.CourierClientModule);
|
|
14
|
+
static Shared = Modules.getNativeModule(_reactNative.NativeModules.CourierSharedModule);
|
|
15
|
+
static System = Modules.getNativeModule(_reactNative.NativeModules.CourierSystemModule);
|
|
16
|
+
static getNativeModule(nativeModule) {
|
|
17
|
+
return nativeModule ? nativeModule : new Proxy({}, {
|
|
18
|
+
get() {
|
|
19
|
+
throw new Error(Modules.LINKING_ERROR);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.Modules = Modules;
|
|
25
|
+
//# sourceMappingURL=Modules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","Modules","LINKING_ERROR","Platform","select","ios","default","Client","getNativeModule","NativeModules","CourierClientModule","Shared","CourierSharedModule","System","CourierSystemModule","nativeModule","Proxy","get","Error","exports"],"sourceRoot":"../../src","sources":["Modules.tsx"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEO,MAAMC,OAAO,CAAC;EAEnB,OAAgBC,aAAa,GAC7B,2FAA2F,GAC3FC,qBAAQ,CAACC,MAAM,CAAC;IAAEC,GAAG,EAAE,gCAAgC;IAAEC,OAAO,EAAE;EAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;EAE/B,OAAgBC,MAAM,GAAGN,OAAO,CAACO,eAAe,CAACC,0BAAa,CAACC,mBAAmB,CAAC;EACnF,OAAgBC,MAAM,GAAGV,OAAO,CAACO,eAAe,CAACC,0BAAa,CAACG,mBAAmB,CAAC;EACnF,OAAgBC,MAAM,GAAGZ,OAAO,CAACO,eAAe,CAACC,0BAAa,CAACK,mBAAmB,CAAC;EAEnF,OAAON,eAAeA,CAAIO,YAA2B,EAAK;IACxD,OAAOA,YAAY,GACfA,YAAY,GACZ,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;MACEC,GAAGA,CAAA,EAAG;QACJ,MAAM,IAAIC,KAAK,CAACjB,OAAO,CAACC,aAAa,CAAC;MACxC;IACF,CACF,CAAM;EACZ;AAEF;AAACiB,OAAA,CAAAlB,OAAA,GAAAA,OAAA","ignoreList":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.BrandClient = void 0;
|
|
7
|
+
var _Modules = require("../Modules");
|
|
8
|
+
class BrandClient {
|
|
9
|
+
constructor(clientId) {
|
|
10
|
+
this.clientId = clientId;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Retrieves brand information for a specific brand ID.
|
|
15
|
+
* @param props - The properties for getting the brand.
|
|
16
|
+
* @param props.brandId - The ID of the brand to retrieve.
|
|
17
|
+
* @returns A promise that resolves with the CourierBrandResponse containing brand information.
|
|
18
|
+
*/
|
|
19
|
+
async getBrand(props) {
|
|
20
|
+
const json = await _Modules.Modules.Client.getBrand(this.clientId, props.brandId);
|
|
21
|
+
return JSON.parse(json);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.BrandClient = BrandClient;
|
|
25
|
+
//# sourceMappingURL=BrandClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_Modules","require","BrandClient","constructor","clientId","getBrand","props","json","Modules","Client","brandId","JSON","parse","exports"],"sourceRoot":"../../../src","sources":["client/BrandClient.tsx"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAGO,MAAMC,WAAW,CAAC;EAIvBC,WAAWA,CAACC,QAAgB,EAAE;IAC5B,IAAI,CAACA,QAAQ,GAAGA,QAAQ;EAC1B;;EAEA;AACF;AACA;AACA;AACA;AACA;EACE,MAAaC,QAAQA,CAACC,KAA0B,EAAiC;IAC/E,MAAMC,IAAI,GAAG,MAAMC,gBAAO,CAACC,MAAM,CAACJ,QAAQ,CAAC,IAAI,CAACD,QAAQ,EAAEE,KAAK,CAACI,OAAO,CAAC;IACxE,OAAOC,IAAI,CAACC,KAAK,CAACL,IAAI,CAAC;EACzB;AAEF;AAACM,OAAA,CAAAX,WAAA,GAAAA,WAAA","ignoreList":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ClientModule = void 0;
|
|
7
|
+
var _Modules = require("../Modules");
|
|
8
|
+
class ClientModule {
|
|
9
|
+
// Constructor to create a low level CourierClient
|
|
10
|
+
constructor(options) {
|
|
11
|
+
this.clientId = this.add(options);
|
|
12
|
+
}
|
|
13
|
+
add(options) {
|
|
14
|
+
return _Modules.Modules.Client.addClient(options);
|
|
15
|
+
}
|
|
16
|
+
remove() {
|
|
17
|
+
return _Modules.Modules.Client.removeClient(this.clientId);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.ClientModule = ClientModule;
|
|
21
|
+
//# sourceMappingURL=ClientModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_Modules","require","ClientModule","constructor","options","clientId","add","Modules","Client","addClient","remove","removeClient","exports"],"sourceRoot":"../../../src","sources":["client/ClientModule.tsx"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAGO,MAAeC,YAAY,CAAC;EAIjC;EACAC,WAAWA,CAACC,OAA6B,EAAE;IACzC,IAAI,CAACC,QAAQ,GAAG,IAAI,CAACC,GAAG,CAACF,OAAO,CAAC;EACnC;EAEQE,GAAGA,CAACF,OAA6B,EAAU;IACjD,OAAOG,gBAAO,CAACC,MAAM,CAACC,SAAS,CAACL,OAAO,CAAC;EAC1C;EAEOM,MAAMA,CAAA,EAAW;IACtB,OAAOH,gBAAO,CAACC,MAAM,CAACG,YAAY,CAAC,IAAI,CAACN,QAAQ,CAAC;EACnD;AAEF;AAACO,OAAA,CAAAV,YAAA,GAAAA,YAAA","ignoreList":[]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.CourierClient = void 0;
|
|
7
|
+
var _ = require("..");
|
|
8
|
+
var _ClientModule = require("./ClientModule");
|
|
9
|
+
var _InboxClient = require("./InboxClient");
|
|
10
|
+
var _PreferenceClient = require("./PreferenceClient");
|
|
11
|
+
var _TokenClient = require("./TokenClient");
|
|
12
|
+
var _TrackingClient = require("./TrackingClient");
|
|
13
|
+
class CourierClient extends _ClientModule.ClientModule {
|
|
14
|
+
constructor(props) {
|
|
15
|
+
const options = {
|
|
16
|
+
userId: props.userId,
|
|
17
|
+
showLogs: props.showLogs ?? __DEV__,
|
|
18
|
+
jwt: props.jwt,
|
|
19
|
+
clientKey: props.clientKey,
|
|
20
|
+
connectionId: props.clientKey,
|
|
21
|
+
tenantId: props.tenantId
|
|
22
|
+
};
|
|
23
|
+
super(options);
|
|
24
|
+
this.options = options;
|
|
25
|
+
this.tokens = new _TokenClient.TokenClient(this.clientId);
|
|
26
|
+
this.brands = new _.BrandClient(this.clientId);
|
|
27
|
+
this.inbox = new _InboxClient.InboxClient(this.clientId);
|
|
28
|
+
this.preferences = new _PreferenceClient.PreferenceClient(this.clientId);
|
|
29
|
+
this.tracking = new _TrackingClient.TrackingClient(this.clientId);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.CourierClient = CourierClient;
|
|
33
|
+
//# sourceMappingURL=CourierClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_","require","_ClientModule","_InboxClient","_PreferenceClient","_TokenClient","_TrackingClient","CourierClient","ClientModule","constructor","props","options","userId","showLogs","__DEV__","jwt","clientKey","connectionId","tenantId","tokens","TokenClient","clientId","brands","BrandClient","inbox","InboxClient","preferences","PreferenceClient","tracking","TrackingClient","exports"],"sourceRoot":"../../../src","sources":["client/CourierClient.tsx"],"mappings":";;;;;;AAAA,IAAAA,CAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,eAAA,GAAAL,OAAA;AAWO,MAAMM,aAAa,SAASC,0BAAY,CAAC;EAS9CC,WAAWA,CAACC,KAAyH,EAAE;IAErI,MAAMC,OAAO,GAAG;MACdC,MAAM,EAAEF,KAAK,CAACE,MAAM;MACpBC,QAAQ,EAAEH,KAAK,CAACG,QAAQ,IAAIC,OAAO;MACnCC,GAAG,EAAEL,KAAK,CAACK,GAAG;MACdC,SAAS,EAAEN,KAAK,CAACM,SAAS;MAC1BC,YAAY,EAAEP,KAAK,CAACM,SAAS;MAC7BE,QAAQ,EAAER,KAAK,CAACQ;IAClB,CAAC;IAED,KAAK,CAACP,OAAO,CAAC;IAEd,IAAI,CAACA,OAAO,GAAGA,OAAO;IAEtB,IAAI,CAACQ,MAAM,GAAG,IAAIC,wBAAW,CAAC,IAAI,CAACC,QAAQ,CAAC;IAC5C,IAAI,CAACC,MAAM,GAAG,IAAIC,aAAW,CAAC,IAAI,CAACF,QAAQ,CAAC;IAC5C,IAAI,CAACG,KAAK,GAAG,IAAIC,wBAAW,CAAC,IAAI,CAACJ,QAAQ,CAAC;IAC3C,IAAI,CAACK,WAAW,GAAG,IAAIC,kCAAgB,CAAC,IAAI,CAACN,QAAQ,CAAC;IACtD,IAAI,CAACO,QAAQ,GAAG,IAAIC,8BAAc,CAAC,IAAI,CAACR,QAAQ,CAAC;EAEnD;AAEF;AAACS,OAAA,CAAAvB,aAAA,GAAAA,aAAA","ignoreList":[]}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.InboxClient = void 0;
|
|
7
|
+
var _Modules = require("../Modules");
|
|
8
|
+
class InboxClient {
|
|
9
|
+
constructor(clientId) {
|
|
10
|
+
this.clientId = clientId;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Retrieves messages from the inbox.
|
|
15
|
+
* @param props - The properties for getting messages.
|
|
16
|
+
* @param props.paginationLimit - Optional. The number of messages to retrieve per page. Defaults to 24.
|
|
17
|
+
* @param props.startCursor - Optional. The cursor to start retrieving messages from.
|
|
18
|
+
* @returns A promise that resolves with the CourierGetInboxMessagesResponse containing the messages.
|
|
19
|
+
*/
|
|
20
|
+
async getMessages(props) {
|
|
21
|
+
const json = await _Modules.Modules.Client.getMessages(this.clientId, props.paginationLimit ?? 24, props.startCursor);
|
|
22
|
+
return JSON.parse(json);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Retrieves archived messages from the inbox.
|
|
27
|
+
* @param props - The properties for getting archived messages.
|
|
28
|
+
* @param props.paginationLimit - Optional. The number of messages to retrieve per page. Defaults to 24.
|
|
29
|
+
* @param props.startCursor - Optional. The cursor to start retrieving messages from.
|
|
30
|
+
* @returns A promise that resolves with the CourierGetInboxMessagesResponse containing the archived messages.
|
|
31
|
+
*/
|
|
32
|
+
async getArchivedMessages(props) {
|
|
33
|
+
const json = await _Modules.Modules.Client.getArchivedMessages(this.clientId, props.paginationLimit ?? 24, props.startCursor);
|
|
34
|
+
return JSON.parse(json);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Retrieves a specific message by its ID.
|
|
39
|
+
* @param props - The properties for getting the message.
|
|
40
|
+
* @param props.messageId - The ID of the message to retrieve.
|
|
41
|
+
* @returns A promise that resolves with the CourierGetInboxMessageResponse containing the message.
|
|
42
|
+
*/
|
|
43
|
+
async getMessageById(props) {
|
|
44
|
+
const json = await _Modules.Modules.Client.getMessageById(this.clientId, props.messageId);
|
|
45
|
+
return JSON.parse(json);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Retrieves the count of unread messages in the inbox.
|
|
50
|
+
* @returns A promise that resolves with the number of unread messages.
|
|
51
|
+
*/
|
|
52
|
+
async getUnreadMessageCount() {
|
|
53
|
+
return await _Modules.Modules.Client.getUnreadMessageCount(this.clientId);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Marks a message as opened.
|
|
58
|
+
* @param props - The properties for opening the message.
|
|
59
|
+
* @param props.messageId - The ID of the message to mark as opened.
|
|
60
|
+
* @returns A promise that resolves with a number indicating the operation result.
|
|
61
|
+
*/
|
|
62
|
+
async open(props) {
|
|
63
|
+
return await _Modules.Modules.Client.openMessage(this.clientId, props.messageId);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Marks a message as read.
|
|
68
|
+
* @param props - The properties for reading the message.
|
|
69
|
+
* @param props.messageId - The ID of the message to mark as read.
|
|
70
|
+
* @returns A promise that resolves with a number indicating the operation result.
|
|
71
|
+
*/
|
|
72
|
+
async read(props) {
|
|
73
|
+
return await _Modules.Modules.Client.readMessage(this.clientId, props.messageId);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Marks a message as unread.
|
|
78
|
+
* @param props - The properties for marking the message as unread.
|
|
79
|
+
* @param props.messageId - The ID of the message to mark as unread.
|
|
80
|
+
* @returns A promise that resolves with a number indicating the operation result.
|
|
81
|
+
*/
|
|
82
|
+
async unread(props) {
|
|
83
|
+
return await _Modules.Modules.Client.unreadMessage(this.clientId, props.messageId);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Records a click event for a message.
|
|
88
|
+
* @param props - The properties for clicking the message.
|
|
89
|
+
* @param props.messageId - The ID of the message that was clicked.
|
|
90
|
+
* @param props.trackingId - The tracking ID associated with the click event.
|
|
91
|
+
* @returns A promise that resolves with a number indicating the operation result.
|
|
92
|
+
*/
|
|
93
|
+
async click(props) {
|
|
94
|
+
return await _Modules.Modules.Client.clickMessage(this.clientId, props.messageId, props.trackingId);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Archives a message.
|
|
99
|
+
* @param props - The properties for archiving the message.
|
|
100
|
+
* @param props.messageId - The ID of the message to archive.
|
|
101
|
+
* @returns A promise that resolves with a number indicating the operation result.
|
|
102
|
+
*/
|
|
103
|
+
async archive(props) {
|
|
104
|
+
return await _Modules.Modules.Client.archiveMessage(this.clientId, props.messageId);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Marks all messages as read.
|
|
109
|
+
* @returns A promise that resolves with a number indicating the operation result.
|
|
110
|
+
*/
|
|
111
|
+
async readAll() {
|
|
112
|
+
return await _Modules.Modules.Client.readAllMessages(this.clientId);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
exports.InboxClient = InboxClient;
|
|
116
|
+
//# sourceMappingURL=InboxClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_Modules","require","InboxClient","constructor","clientId","getMessages","props","json","Modules","Client","paginationLimit","startCursor","JSON","parse","getArchivedMessages","getMessageById","messageId","getUnreadMessageCount","open","openMessage","read","readMessage","unread","unreadMessage","click","clickMessage","trackingId","archive","archiveMessage","readAll","readAllMessages","exports"],"sourceRoot":"../../../src","sources":["client/InboxClient.tsx"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAGO,MAAMC,WAAW,CAAC;EAIvBC,WAAWA,CAACC,QAAgB,EAAE;IAC5B,IAAI,CAACA,QAAQ,GAAGA,QAAQ;EAC1B;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACE,MAAaC,WAAWA,CAACC,KAAyD,EAA4C;IAC5H,MAAMC,IAAI,GAAG,MAAMC,gBAAO,CAACC,MAAM,CAACJ,WAAW,CAAC,IAAI,CAACD,QAAQ,EAAEE,KAAK,CAACI,eAAe,IAAI,EAAE,EAAEJ,KAAK,CAACK,WAAW,CAAC;IAC5G,OAAOC,IAAI,CAACC,KAAK,CAACN,IAAI,CAAC;EACzB;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACE,MAAaO,mBAAmBA,CAACR,KAAyD,EAA4C;IACpI,MAAMC,IAAI,GAAG,MAAMC,gBAAO,CAACC,MAAM,CAACK,mBAAmB,CAAC,IAAI,CAACV,QAAQ,EAAEE,KAAK,CAACI,eAAe,IAAI,EAAE,EAAEJ,KAAK,CAACK,WAAW,CAAC;IACpH,OAAOC,IAAI,CAACC,KAAK,CAACN,IAAI,CAAC;EACzB;;EAEA;AACF;AACA;AACA;AACA;AACA;EACE,MAAaQ,cAAcA,CAACT,KAA4B,EAA2C;IACjG,MAAMC,IAAI,GAAG,MAAMC,gBAAO,CAACC,MAAM,CAACM,cAAc,CAAC,IAAI,CAACX,QAAQ,EAAEE,KAAK,CAACU,SAAS,CAAC;IAChF,OAAOJ,IAAI,CAACC,KAAK,CAACN,IAAI,CAAC;EACzB;;EAEA;AACF;AACA;AACA;EACE,MAAaU,qBAAqBA,CAAA,EAAoB;IACpD,OAAO,MAAMT,gBAAO,CAACC,MAAM,CAACQ,qBAAqB,CAAC,IAAI,CAACb,QAAQ,CAAC;EAClE;;EAEA;AACF;AACA;AACA;AACA;AACA;EACE,MAAac,IAAIA,CAACZ,KAA4B,EAAmB;IAC/D,OAAO,MAAME,gBAAO,CAACC,MAAM,CAACU,WAAW,CAAC,IAAI,CAACf,QAAQ,EAAEE,KAAK,CAACU,SAAS,CAAC;EACzE;;EAEA;AACF;AACA;AACA;AACA;AACA;EACE,MAAaI,IAAIA,CAACd,KAA4B,EAAmB;IAC/D,OAAO,MAAME,gBAAO,CAACC,MAAM,CAACY,WAAW,CAAC,IAAI,CAACjB,QAAQ,EAAEE,KAAK,CAACU,SAAS,CAAC;EACzE;;EAEA;AACF;AACA;AACA;AACA;AACA;EACE,MAAaM,MAAMA,CAAChB,KAA4B,EAAmB;IACjE,OAAO,MAAME,gBAAO,CAACC,MAAM,CAACc,aAAa,CAAC,IAAI,CAACnB,QAAQ,EAAEE,KAAK,CAACU,SAAS,CAAC;EAC3E;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACE,MAAaQ,KAAKA,CAAClB,KAAgD,EAAmB;IACpF,OAAO,MAAME,gBAAO,CAACC,MAAM,CAACgB,YAAY,CAAC,IAAI,CAACrB,QAAQ,EAAEE,KAAK,CAACU,SAAS,EAAEV,KAAK,CAACoB,UAAU,CAAC;EAC5F;;EAEA;AACF;AACA;AACA;AACA;AACA;EACE,MAAaC,OAAOA,CAACrB,KAA4B,EAAmB;IAClE,OAAO,MAAME,gBAAO,CAACC,MAAM,CAACmB,cAAc,CAAC,IAAI,CAACxB,QAAQ,EAAEE,KAAK,CAACU,SAAS,CAAC;EAC5E;;EAEA;AACF;AACA;AACA;EACE,MAAaa,OAAOA,CAAA,EAAoB;IACtC,OAAO,MAAMrB,gBAAO,CAACC,MAAM,CAACqB,eAAe,CAAC,IAAI,CAAC1B,QAAQ,CAAC;EAC5D;AAEF;AAAC2B,OAAA,CAAA7B,WAAA,GAAAA,WAAA","ignoreList":[]}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.PreferenceClient = void 0;
|
|
7
|
+
var _Modules = require("../Modules");
|
|
8
|
+
class PreferenceClient {
|
|
9
|
+
constructor(clientId) {
|
|
10
|
+
this.clientId = clientId;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Retrieves user preferences.
|
|
15
|
+
* @param props - Optional properties for pagination.
|
|
16
|
+
* @param props.paginationCursor - Optional cursor for pagination.
|
|
17
|
+
* @returns A promise that resolves with CourierUserPreferences containing user preference items and paging information.
|
|
18
|
+
*/
|
|
19
|
+
async getUserPreferences(props) {
|
|
20
|
+
const json = await _Modules.Modules.Client.getUserPreferences(this.clientId, props === null || props === void 0 ? void 0 : props.paginationCursor);
|
|
21
|
+
const rawData = JSON.parse(json);
|
|
22
|
+
return {
|
|
23
|
+
items: rawData.items.map(item => ({
|
|
24
|
+
defaultStatus: item.default_status,
|
|
25
|
+
hasCustomRouting: item.has_custom_routing,
|
|
26
|
+
customRouting: item.custom_routing.map(channel => channel),
|
|
27
|
+
status: item.status,
|
|
28
|
+
topicId: item.topic_id,
|
|
29
|
+
topicName: item.topic_name,
|
|
30
|
+
sectionName: item.section_name,
|
|
31
|
+
sectionId: item.section_id
|
|
32
|
+
})),
|
|
33
|
+
paging: rawData.paging
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Retrieves user preference for a specific topic.
|
|
39
|
+
* @param props - Properties for getting the user preference topic.
|
|
40
|
+
* @param props.topicId - The ID of the topic to retrieve preferences for.
|
|
41
|
+
* @returns A promise that resolves with CourierUserPreferencesTopic containing the topic preference details.
|
|
42
|
+
*/
|
|
43
|
+
async getUserPreferenceTopic(props) {
|
|
44
|
+
const json = await _Modules.Modules.Client.getUserPreferenceTopic(this.clientId, props.topicId);
|
|
45
|
+
const rawData = JSON.parse(json);
|
|
46
|
+
const convertedTopic = {
|
|
47
|
+
defaultStatus: rawData.default_status,
|
|
48
|
+
hasCustomRouting: rawData.has_custom_routing,
|
|
49
|
+
customRouting: rawData.custom_routing.map(channel => channel),
|
|
50
|
+
status: rawData.status,
|
|
51
|
+
topicId: rawData.topic_id,
|
|
52
|
+
topicName: rawData.topic_name,
|
|
53
|
+
sectionName: rawData.section_name,
|
|
54
|
+
sectionId: rawData.section_id
|
|
55
|
+
};
|
|
56
|
+
return convertedTopic;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Updates user preference for a specific topic.
|
|
61
|
+
* @param props - Properties for updating the user preference topic.
|
|
62
|
+
* @param props.topicId - The ID of the topic to update preferences for.
|
|
63
|
+
* @param props.status - The new status for the topic preference.
|
|
64
|
+
* @param props.hasCustomRouting - Whether the topic has custom routing.
|
|
65
|
+
* @param props.customRouting - Array of custom routing channels.
|
|
66
|
+
* @returns A promise that resolves when the update is complete.
|
|
67
|
+
*/
|
|
68
|
+
async putUserPreferenceTopic(props) {
|
|
69
|
+
await _Modules.Modules.Client.putUserPreferenceTopic(this.clientId, props.topicId, props.status, props.hasCustomRouting, props.customRouting);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.PreferenceClient = PreferenceClient;
|
|
73
|
+
//# sourceMappingURL=PreferenceClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_Modules","require","PreferenceClient","constructor","clientId","getUserPreferences","props","json","Modules","Client","paginationCursor","rawData","JSON","parse","items","map","item","defaultStatus","default_status","hasCustomRouting","has_custom_routing","customRouting","custom_routing","channel","status","topicId","topic_id","topicName","topic_name","sectionName","section_name","sectionId","section_id","paging","getUserPreferenceTopic","convertedTopic","putUserPreferenceTopic","exports"],"sourceRoot":"../../../src","sources":["client/PreferenceClient.tsx"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAGO,MAAMC,gBAAgB,CAAC;EAI5BC,WAAWA,CAACC,QAAgB,EAAE;IAC5B,IAAI,CAACA,QAAQ,GAAGA,QAAQ;EAC1B;;EAEA;AACF;AACA;AACA;AACA;AACA;EACE,MAAaC,kBAAkBA,CAACC,KAAqC,EAAmC;IAEtG,MAAMC,IAAI,GAAG,MAAMC,gBAAO,CAACC,MAAM,CAACJ,kBAAkB,CAAC,IAAI,CAACD,QAAQ,EAAEE,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEI,gBAAgB,CAAC;IAE5F,MAAMC,OAAO,GAAGC,IAAI,CAACC,KAAK,CAACN,IAAI,CAAC;IAEhC,OAAO;MACLO,KAAK,EAAEH,OAAO,CAACG,KAAK,CAACC,GAAG,CAAEC,IAAS,KAAM;QACvCC,aAAa,EAAED,IAAI,CAACE,cAA8C;QAClEC,gBAAgB,EAAEH,IAAI,CAACI,kBAAkB;QACzCC,aAAa,EAAEL,IAAI,CAACM,cAAc,CAACP,GAAG,CAAEQ,OAAe,IAAKA,OAAwC,CAAC;QACrGC,MAAM,EAAER,IAAI,CAACQ,MAAsC;QACnDC,OAAO,EAAET,IAAI,CAACU,QAAQ;QACtBC,SAAS,EAAEX,IAAI,CAACY,UAAU;QAC1BC,WAAW,EAAEb,IAAI,CAACc,YAAY;QAC9BC,SAAS,EAAEf,IAAI,CAACgB;MAClB,CAAC,CAAC,CAAC;MACHC,MAAM,EAAEtB,OAAO,CAACsB;IAClB,CAAC;EAEH;;EAEA;AACF;AACA;AACA;AACA;AACA;EACE,MAAaC,sBAAsBA,CAAC5B,KAA0B,EAAwC;IACpG,MAAMC,IAAI,GAAG,MAAMC,gBAAO,CAACC,MAAM,CAACyB,sBAAsB,CAAC,IAAI,CAAC9B,QAAQ,EAAEE,KAAK,CAACmB,OAAO,CAAC;IACtF,MAAMd,OAAO,GAAGC,IAAI,CAACC,KAAK,CAACN,IAAI,CAAC;IAEhC,MAAM4B,cAA2C,GAAG;MAClDlB,aAAa,EAAEN,OAAO,CAACO,cAA8C;MACrEC,gBAAgB,EAAER,OAAO,CAACS,kBAAkB;MAC5CC,aAAa,EAAEV,OAAO,CAACW,cAAc,CAACP,GAAG,CAAEQ,OAAe,IAAKA,OAAwC,CAAC;MACxGC,MAAM,EAAEb,OAAO,CAACa,MAAsC;MACtDC,OAAO,EAAEd,OAAO,CAACe,QAAQ;MACzBC,SAAS,EAAEhB,OAAO,CAACiB,UAAU;MAC7BC,WAAW,EAAElB,OAAO,CAACmB,YAAY;MACjCC,SAAS,EAAEpB,OAAO,CAACqB;IACrB,CAAC;IAED,OAAOG,cAAc;EACvB;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,MAAaC,sBAAsBA,CAAC9B,KAA2I,EAAiB;IAC9L,MAAME,gBAAO,CAACC,MAAM,CAAC2B,sBAAsB,CAAC,IAAI,CAAChC,QAAQ,EAAEE,KAAK,CAACmB,OAAO,EAAEnB,KAAK,CAACkB,MAAM,EAAElB,KAAK,CAACa,gBAAgB,EAAEb,KAAK,CAACe,aAAa,CAAC;EACtI;AAEF;AAACgB,OAAA,CAAAnC,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.TokenClient = void 0;
|
|
7
|
+
var _Modules = require("../Modules");
|
|
8
|
+
class TokenClient {
|
|
9
|
+
constructor(clientId) {
|
|
10
|
+
this.clientId = clientId;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Stores a user token for a specific provider.
|
|
15
|
+
* @param props - The properties for storing the user token.
|
|
16
|
+
* @param props.token - The token to be stored.
|
|
17
|
+
* @param props.provider - The provider associated with the token.
|
|
18
|
+
* @param props.device - Optional device information.
|
|
19
|
+
* @returns A promise that resolves when the token is successfully stored.
|
|
20
|
+
*/
|
|
21
|
+
async putUserToken(props) {
|
|
22
|
+
await _Modules.Modules.Client.putUserToken(this.clientId, props.token, props.provider, props.device);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Deletes a user token.
|
|
27
|
+
* @param props - The properties for deleting the user token.
|
|
28
|
+
* @param props.token - The token to be deleted.
|
|
29
|
+
* @returns A promise that resolves when the token is successfully deleted.
|
|
30
|
+
*/
|
|
31
|
+
async deleteUserToken(props) {
|
|
32
|
+
await _Modules.Modules.Client.deleteUserToken(this.clientId, props.token);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.TokenClient = TokenClient;
|
|
36
|
+
//# sourceMappingURL=TokenClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_Modules","require","TokenClient","constructor","clientId","putUserToken","props","Modules","Client","token","provider","device","deleteUserToken","exports"],"sourceRoot":"../../../src","sources":["client/TokenClient.tsx"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAEO,MAAMC,WAAW,CAAC;EAIvBC,WAAWA,CAACC,QAAgB,EAAE;IAC5B,IAAI,CAACA,QAAQ,GAAGA,QAAQ;EAC1B;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACE,MAAaC,YAAYA,CAACC,KAAkE,EAAiB;IAC3G,MAAMC,gBAAO,CAACC,MAAM,CAACH,YAAY,CAAC,IAAI,CAACD,QAAQ,EAAEE,KAAK,CAACG,KAAK,EAAEH,KAAK,CAACI,QAAQ,EAAEJ,KAAK,CAACK,MAAM,CAAC;EAC7F;;EAEA;AACF;AACA;AACA;AACA;AACA;EACE,MAAaC,eAAeA,CAACN,KAAwB,EAAiB;IACpE,MAAMC,gBAAO,CAACC,MAAM,CAACI,eAAe,CAAC,IAAI,CAACR,QAAQ,EAAEE,KAAK,CAACG,KAAK,CAAC;EAClE;AAEF;AAACI,OAAA,CAAAX,WAAA,GAAAA,WAAA","ignoreList":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.TrackingClient = void 0;
|
|
7
|
+
var _Modules = require("../Modules");
|
|
8
|
+
class TrackingClient {
|
|
9
|
+
constructor(clientId) {
|
|
10
|
+
this.clientId = clientId;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Posts a tracking URL with associated event data.
|
|
15
|
+
* @param props - The properties for posting the tracking URL.
|
|
16
|
+
* @param props.url - The tracking URL to be posted.
|
|
17
|
+
* @param props.event - The CourierTrackingEvent associated with the URL.
|
|
18
|
+
* @returns A promise that resolves when the tracking URL is successfully posted.
|
|
19
|
+
*/
|
|
20
|
+
async postTrackingUrl(props) {
|
|
21
|
+
await _Modules.Modules.Client.postTrackingUrl(this.clientId, props.url, props.event);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.TrackingClient = TrackingClient;
|
|
25
|
+
//# sourceMappingURL=TrackingClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_Modules","require","TrackingClient","constructor","clientId","postTrackingUrl","props","Modules","Client","url","event","exports"],"sourceRoot":"../../../src","sources":["client/TrackingClient.tsx"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAEO,MAAMC,cAAc,CAAC;EAI1BC,WAAWA,CAACC,QAAgB,EAAE;IAC5B,IAAI,CAACA,QAAQ,GAAGA,QAAQ;EAC1B;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACE,MAAaC,eAAeA,CAACC,KAAmD,EAAiB;IAC/F,MAAMC,gBAAO,CAACC,MAAM,CAACH,eAAe,CAAC,IAAI,CAACD,QAAQ,EAAEE,KAAK,CAACG,GAAG,EAAEH,KAAK,CAACI,KAAK,CAAC;EAC7E;AAEF;AAACC,OAAA,CAAAT,cAAA,GAAAA,cAAA","ignoreList":[]}
|